Media Cleaner - Version 4.5.0

Version Description

  • Add: Support for WooCommerce Short Description.
  • Add: Support for Divi Background.
  • Add: Support for Custom Fields Pro (ACF gallery).
  • Fix: Better support for CSS background.
  • Fix: Avoid detected file to be re-added if already there.
  • Update: Removed UTF-8 option (became useless).
Download this release

Release Info

Developer TigrouMeow
Plugin Icon 128x128 Media Cleaner
Version 4.5.0
Comparing to
See all releases

Code changes from version 4.4.8 to 4.5.0

Files changed (3) hide show
  1. core.php +46 -5
  2. media-cleaner.php +2 -2
  3. readme.txt +5 -3
core.php CHANGED
@@ -319,6 +319,17 @@ class Meow_WPMC_Core {
319
  }
320
  }
321
 
 
 
 
 
 
 
 
 
 
 
 
322
  if ( get_option( 'wpmc_background', false ) ) {
323
  preg_match_all( "/url\(\'?\"?((https?:\/\/)?[^\\&\#\[\] \"\?]+\.(jpe?g|gif|png|ico|tif?f|bmp))\'?\"?\)/", $html, $res );
324
  //error_log( print_r( $res, 1 ) );
@@ -391,14 +402,19 @@ class Meow_WPMC_Core {
391
  }
392
 
393
  global $wpdb;
 
 
394
  $posts = $wpdb->get_col( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p
395
  WHERE p.post_status != 'inherit'
396
  AND p.post_status != 'trash'
397
  AND p.post_type != 'attachment'
 
 
398
  AND p.post_type != 'shop_order'
399
  AND p.post_type != 'shop_order_refund'
400
  AND p.post_type != 'nav_menu_item'
401
  AND p.post_type != 'revision'
 
402
  LIMIT %d, %d", $limit, $limitsize
403
  )
404
  );
@@ -416,7 +432,7 @@ class Meow_WPMC_Core {
416
  $found['wpmc_theme_urls'] = $theme_urls;
417
  }
418
 
419
- // Analyze Widgets (only on start)
420
  if ( get_option( 'wpmc_widgets', false ) && empty( $limit ) ) {
421
  $widgets_ids = array();
422
  $widgets_urls = array();
@@ -427,6 +443,25 @@ class Meow_WPMC_Core {
427
  $found['wpmc_widgets_urls'] = $widgets_urls;
428
  }
429
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  // Prepare likes for SQL
431
  $like = "";
432
  foreach ( $this->metakeys as $metakey )
@@ -438,7 +473,6 @@ class Meow_WPMC_Core {
438
  $html = get_post_field( 'post_content', $post );
439
 
440
  if ( $check_postmeta ) {
441
- global $wpdb;
442
 
443
  // Detect values in the general (known, based on %like%) Meta Keys
444
  $metas = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta
@@ -510,7 +544,7 @@ class Meow_WPMC_Core {
510
  else if ( $field['type'] == 'image' && $format == 'url' ) {
511
  array_push( $postmeta_images_acf_urls, $this->wpmc_clean_url( $field['value'] ) );
512
  }
513
- else if ( $field['type'] == 'gallery' ) {
514
  foreach ( $field['value'] as $media ) {
515
  array_push( $postmeta_images_acf_ids, $media['id'] );
516
  }
@@ -545,13 +579,20 @@ class Meow_WPMC_Core {
545
  if ( $shortcode_support )
546
  $html = do_shortcode( $html );
547
 
548
- // Check for images urls in posts
 
549
  $posts_images_urls = get_transient( "wpmc_posts_images_urls" );
550
  if ( empty( $posts_images_urls ) )
551
  $posts_images_urls = array();
552
-
553
  $new_urls = $this->get_urls_from_html( $html );
554
  $posts_images_urls = array_merge( $posts_images_urls, $new_urls );
 
 
 
 
 
 
 
555
  set_transient( "wpmc_posts_images_urls", $posts_images_urls, $this->transient_life );
556
  $found['wpmc_posts_images_urls'] = $posts_images_urls;
557
 
319
  }
320
  }
321
 
322
+ // Background Image in Divi (Elegant Themes)
323
+ if ( function_exists( '_et_core_find_latest' ) ) {
324
+ preg_match_all( "/background_image=\"((https?:\/\/)?[^\\&\#\[\] \"\?]+\.(jpe?g|gif|png|ico|tif?f|bmp))\"/", $html, $res );
325
+ if ( !empty( $res ) && isset( $res[1] ) && count( $res[1] ) > 0 ) {
326
+ foreach ( $res[1] as $url ) {
327
+ if ( !preg_match('/(elegantthemesimages\.com)|(elegantthemes\.com)/', $url ) )
328
+ array_push( $results, $this->wpmc_clean_url( $url ) );
329
+ }
330
+ }
331
+ }
332
+
333
  if ( get_option( 'wpmc_background', false ) ) {
334
  preg_match_all( "/url\(\'?\"?((https?:\/\/)?[^\\&\#\[\] \"\?]+\.(jpe?g|gif|png|ico|tif?f|bmp))\'?\"?\)/", $html, $res );
335
  //error_log( print_r( $res, 1 ) );
402
  }
403
 
404
  global $wpdb;
405
+ // Maybe we could avoid to check more post_types.
406
+ // SELECT post_type, COUNT(*) FROM `wp_posts` GROUP BY post_type
407
  $posts = $wpdb->get_col( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p
408
  WHERE p.post_status != 'inherit'
409
  AND p.post_status != 'trash'
410
  AND p.post_type != 'attachment'
411
+ AND p.post_type NOT LIKE '%acf-%'
412
+ AND p.post_type NOT LIKE '%edd_%'
413
  AND p.post_type != 'shop_order'
414
  AND p.post_type != 'shop_order_refund'
415
  AND p.post_type != 'nav_menu_item'
416
  AND p.post_type != 'revision'
417
+ AND p.post_type != 'auto-draft'
418
  LIMIT %d, %d", $limit, $limitsize
419
  )
420
  );
432
  $found['wpmc_theme_urls'] = $theme_urls;
433
  }
434
 
435
+ // Only on Start: Analyze Widgets
436
  if ( get_option( 'wpmc_widgets', false ) && empty( $limit ) ) {
437
  $widgets_ids = array();
438
  $widgets_urls = array();
443
  $found['wpmc_widgets_urls'] = $widgets_urls;
444
  }
445
 
446
+ // Only on Start: Analyze WooCommerce Categories Images
447
+ if ( class_exists( 'WooCommerce' ) && empty( $limit ) ) {
448
+ $metas = $wpdb->get_col( "SELECT meta_value
449
+ FROM $wpdb->termmeta
450
+ WHERE meta_key LIKE '%thumbnail_id%'"
451
+ );
452
+ print_r( $metas, 1 );
453
+ if ( count( $metas ) > 0 ) {
454
+ $postmeta_images_ids = get_transient( "wpmc_postmeta_images_ids" );
455
+ if ( empty( $postmeta_images_ids ) )
456
+ $postmeta_images_ids = array();
457
+ foreach ( $metas as $meta )
458
+ if ( is_numeric( $meta ) && $meta > 0 )
459
+ array_push( $postmeta_images_ids, $meta );
460
+ set_transient( "wpmc_postmeta_images_ids", $postmeta_images_ids, $this->transient_life );
461
+ $found['wpmc_postmeta_images_ids'] = $postmeta_images_ids;
462
+ }
463
+ }
464
+
465
  // Prepare likes for SQL
466
  $like = "";
467
  foreach ( $this->metakeys as $metakey )
473
  $html = get_post_field( 'post_content', $post );
474
 
475
  if ( $check_postmeta ) {
 
476
 
477
  // Detect values in the general (known, based on %like%) Meta Keys
478
  $metas = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta
544
  else if ( $field['type'] == 'image' && $format == 'url' ) {
545
  array_push( $postmeta_images_acf_urls, $this->wpmc_clean_url( $field['value'] ) );
546
  }
547
+ else if ( $field['type'] == 'gallery' && !empty( $field['value'] ) ) {
548
  foreach ( $field['value'] as $media ) {
549
  array_push( $postmeta_images_acf_ids, $media['id'] );
550
  }
579
  if ( $shortcode_support )
580
  $html = do_shortcode( $html );
581
 
582
+ // Check for images urls in posts (and in the excerpt if WooCommerce is used, as
583
+ // WooCommerce stores the Product Short Description in there.
584
  $posts_images_urls = get_transient( "wpmc_posts_images_urls" );
585
  if ( empty( $posts_images_urls ) )
586
  $posts_images_urls = array();
 
587
  $new_urls = $this->get_urls_from_html( $html );
588
  $posts_images_urls = array_merge( $posts_images_urls, $new_urls );
589
+ if ( class_exists( 'WooCommerce' ) ) {
590
+ $excerpt = get_post_field( 'post_excerpt', $post );
591
+ $new_urls = $this->get_urls_from_html( $excerpt );
592
+ $posts_images_urls = array_merge( $posts_images_urls, $new_urls );
593
+ set_transient( "wpmc_posts_images_urls", $posts_images_urls, $this->transient_life );
594
+ $found['wpmc_posts_images_urls'] = $posts_images_urls;
595
+ }
596
  set_transient( "wpmc_posts_images_urls", $posts_images_urls, $this->transient_life );
597
  $found['wpmc_posts_images_urls'] = $posts_images_urls;
598
 
media-cleaner.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Media Cleaner
4
  Plugin URI: http://meowapps.com
5
  Description: Clean your Media Library, many options, trash system.
6
- Version: 4.4.8
7
  Author: Jordy Meow
8
  Author URI: http://meowapps.com
9
  Text Domain: media-cleaner
@@ -27,7 +27,7 @@ if ( class_exists( 'Meow_WPMC_Core' ) ) {
27
  if ( is_admin() ) {
28
 
29
  global $wpmc_version;
30
- $wpmc_version = '4.4.8';
31
 
32
  // Admin
33
  require( 'wpmc_admin.php' );
3
  Plugin Name: Media Cleaner
4
  Plugin URI: http://meowapps.com
5
  Description: Clean your Media Library, many options, trash system.
6
+ Version: 4.5.0
7
  Author: Jordy Meow
8
  Author URI: http://meowapps.com
9
  Text Domain: media-cleaner
27
  if ( is_admin() ) {
28
 
29
  global $wpmc_version;
30
+ $wpmc_version = '4.5.0';
31
 
32
  // Admin
33
  require( 'wpmc_admin.php' );
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: TigrouMeow
3
  Tags: management, admin, file, files, images, image, media, library, upload, clean, cleaning
4
  Requires at least: 4.2
5
  Tested up to: 4.9
6
- Stable tag: 4.4.8
7
 
8
  Clean your Media Library and Uploads directory. It has an internal trash and recovery features. Please read the description.
9
 
@@ -15,7 +15,7 @@ A tutorial is available on the official website, here: [Media Cleaner](https://m
15
 
16
  **This tool is a knife. I do my best to make this knife a perfect one. However, this is still a knife, and in the hands of somebody who doesn't know how to use it, it might end badly. Don't use it if you don't have any backup, or if you don't know what it does. For backup, you can use such a plugin as [UpdraftPlus](https://updraftplus.com/?afref=460).**
17
 
18
- **COMPATIBILITY**. I am adding support for page builders and specific plugins little by little. Currently, I have been working with ACF, Divi (Elegant Themes), Fusion Builder (Avada), WooCommerce, Visual Composer (WPBakery), Beaver Builder, and Gutenberg.
19
 
20
  **SPECIAL PLUGIN**. Such a plugin is difficult to create and to maintain. If you understand WordPress, you probably know why. This plugin does its best to help you. Learn how to use it and you will get awesome results.
21
 
@@ -52,7 +52,9 @@ It re-creates the Media Cleaner table in the database. You will need to re-run t
52
 
53
  == Changelog ==
54
 
55
- = 4.4.8 =
 
 
56
  * Add: Support for Custom Fields Pro (ACF gallery).
57
  * Fix: Better support for CSS background.
58
  * Fix: Avoid detected file to be re-added if already there.
3
  Tags: management, admin, file, files, images, image, media, library, upload, clean, cleaning
4
  Requires at least: 4.2
5
  Tested up to: 4.9
6
+ Stable tag: 4.5.0
7
 
8
  Clean your Media Library and Uploads directory. It has an internal trash and recovery features. Please read the description.
9
 
15
 
16
  **This tool is a knife. I do my best to make this knife a perfect one. However, this is still a knife, and in the hands of somebody who doesn't know how to use it, it might end badly. Don't use it if you don't have any backup, or if you don't know what it does. For backup, you can use such a plugin as [UpdraftPlus](https://updraftplus.com/?afref=460).**
17
 
18
+ **COMPATIBILITY**. I am adding support for page builders and specific plugins little by little. Currently, I have been working with ACF, Divi, Fusion Builder (Avada), WooCommerce, Visual Composer (WPBakery), Elementor, Beaver Builder, and Gutenberg.
19
 
20
  **SPECIAL PLUGIN**. Such a plugin is difficult to create and to maintain. If you understand WordPress, you probably know why. This plugin does its best to help you. Learn how to use it and you will get awesome results.
21
 
52
 
53
  == Changelog ==
54
 
55
+ = 4.5.0 =
56
+ * Add: Support for WooCommerce Short Description.
57
+ * Add: Support for Divi Background.
58
  * Add: Support for Custom Fields Pro (ACF gallery).
59
  * Fix: Better support for CSS background.
60
  * Fix: Avoid detected file to be re-added if already there.