Media Cleaner - Version 5.4.9

Version Description

  • Fix: ACF File field wasn't being detected properly in some cases.
  • Fix: Support for WPBakery Masonry Grid and probably for many more cases than just this one.
  • Add: Ask for confirmation before deleting all the files at once.
  • Info: This plugin is a lot of work. Please help by giving it a nice review, here: https://wordpress.org/support/plugin/media-cleaner/reviews/?rate=5#new-post. Thank you :)
Download this release

Release Info

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

Code changes from version 5.4.6 to 5.4.9

Files changed (6) hide show
  1. common/admin.php +1 -1
  2. core.php +18 -2
  3. engine.php +12 -16
  4. media-cleaner.php +2 -2
  5. readme.txt +11 -2
  6. scripts/dashboard.js +25 -3
common/admin.php CHANGED
@@ -7,7 +7,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
7
  public static $logo = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxIiB2aWV3Qm94PSIwIDAgMTY1IDE2NSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8c3R5bGU+CiAgICAuc3Qye2ZpbGw6IzgwNDYyNX0uc3Qze2ZpbGw6I2ZkYTk2MH0KICA8L3N0eWxlPgogIDxwYXRoIGQ9Ik03MiA3YTc2IDc2IDAgMCAxIDg0IDkxQTc1IDc1IDAgMSAxIDcyIDd6IiBmaWxsPSIjNGE2YjhjIi8+CiAgPHBhdGggZD0iTTQ4IDQ4YzIgNSAyIDEwIDUgMTQgNSA4IDEzIDE3IDIyIDIwbDEtMTBjMS0yIDMtMyA1LTNoMTNjMiAwIDQgMSA1IDNsMyA5IDQtMTBjMi0zIDYtMiA5LTJoMTFjMyAyIDMgNSAzIDhsMiAzN2MwIDMtMSA3LTQgOGgtMTJjLTIgMC0zLTItNS00LTEgMS0yIDMtNCAzLTUgMS05IDEtMTMtMS0zIDItNSAyLTkgMnMtOSAxLTEwLTNjLTItNC0xLTggMC0xMi04LTMtMTUtNy0yMi0xMi03LTctMTUtMTQtMjAtMjMtMy00LTUtOC01LTEzIDEtNCAzLTEwIDYtMTMgNC0zIDEyLTIgMTUgMnoiIGZpbGw9IiMxMDEwMTAiLz4KICA8cGF0aCBjbGFzcz0ic3QyIiBkPSJNNDMgNTFsNCAxMS02IDVoLTZjLTMtNS0zLTExIDAtMTYgMi0yIDYtMyA4IDB6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTQ3IDYybDMgNmMwIDMgMCA0LTIgNnMtNCAyLTcgMmwtNi05aDZsNi01eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik01MCA2OGw4IDljLTMgMy01IDYtOSA4bC04LTljMyAwIDUgMCA3LTJzMy0zIDItNnoiLz4KICA8cGF0aCBkPSJNODIgNzRoMTJsNSAxOCAzIDExIDgtMjloMTNsMiA0MmgtOGwtMS0yLTEtMzEtMTAgMzItNyAxLTktMzMtMSAyOS0xIDRoLThsMy00MnoiIGZpbGw9IiNmZmYiLz4KICA8cGF0aCBjbGFzcz0ic3QzIiBkPSJNNTggNzdsNSA1Yy0xIDQtMiA4LTcgOGwtNy01YzQtMiA2LTUgOS04eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik02MyA4Mmw5IDUtNiA5LTEwLTZjNSAwIDYtNCA3LTh6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTcyIDg3bDMgMS0xIDExLTgtMyA2LTEweiIvPgo8L3N2Zz4K';
8
 
9
  public static $loaded = false;
10
- public static $admin_version = "2.0";
11
 
12
  public $prefix; // prefix used for actions, filters (mfrh)
13
  public $mainfile; // plugin main file (media-file-renamer.php)
7
  public static $logo = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxIiB2aWV3Qm94PSIwIDAgMTY1IDE2NSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8c3R5bGU+CiAgICAuc3Qye2ZpbGw6IzgwNDYyNX0uc3Qze2ZpbGw6I2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sYXNzPSJzdDIiIGQ9Ik02MyA4Mmw5IDUtNiA5LTEwLTZjNSAwIDYtNCA3LTh6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTcyIDg3bDMgMS0xIDExLTgtMyA2LTEweiIvPgo8L3N2Zz4K';
8
 
9
  public static $loaded = false;
10
+ public static $admin_version = "2.2";
11
 
12
  public $prefix; // prefix used for actions, filters (mfrh)
13
  public $mainfile; // plugin main file (media-file-renamer.php)
core.php CHANGED
@@ -283,11 +283,24 @@ class Meow_WPMC_Core {
283
  else if ( in_array( $key, $lookFor ) ) {
284
  if ( empty( $value ) )
285
  continue;
286
- else if ( is_numeric( $value ) )
 
287
  array_push( $ids, $value );
 
288
  else {
289
- if ( $this->is_url( $value ) )
 
290
  array_push( $urls, $this->clean_url( $value ) );
 
 
 
 
 
 
 
 
 
 
291
  }
292
  }
293
  }
@@ -757,6 +770,9 @@ class Meow_WPMC_Core {
757
 
758
  // From a url to the shortened and cleaned url (for example '2013/02/file.png')
759
  function clean_url( $url ) {
 
 
 
760
  $dirIndex = strpos( $url, $this->contentDir );
761
  if ( empty( $url ) || $dirIndex == false )
762
  return null;
283
  else if ( in_array( $key, $lookFor ) ) {
284
  if ( empty( $value ) )
285
  continue;
286
+ else if ( is_numeric( $value ) ) {
287
+ // It this an ID?
288
  array_push( $ids, $value );
289
+ }
290
  else {
291
+ if ( $this->is_url( $value ) ) {
292
+ // Is this an URL?
293
  array_push( $urls, $this->clean_url( $value ) );
294
+ }
295
+ else {
296
+ // Is this an array of IDs, encoded as a string? (like "20,13")
297
+ $pieces = explode( ',', $value );
298
+ foreach ( $pieces as $pval ) {
299
+ if ( is_numeric( $pval ) ) {
300
+ array_push( $ids, $pval );
301
+ }
302
+ }
303
+ }
304
  }
305
  }
306
  }
770
 
771
  // From a url to the shortened and cleaned url (for example '2013/02/file.png')
772
  function clean_url( $url ) {
773
+ // if ( is_array( $url ) ) {
774
+ // error_log( print_r( $url, 1 ) );
775
+ // }
776
  $dirIndex = strpos( $url, $this->contentDir );
777
  if ( empty( $url ) || $dirIndex == false )
778
  return null;
engine.php CHANGED
@@ -19,16 +19,16 @@ class Meow_WPMC_Engine {
19
  $method = get_option( 'wpmc_method', 'media' );
20
  $check_library = get_option(' wpmc_media_library', true );
21
  $check_content = get_option( 'wpmc_content', true );
22
- $check_postmeta = get_option( 'wpmc_postmeta', false );
23
- $check_posts = get_option( 'wpmc_posts', false );
24
- $check_widgets = get_option( 'wpmc_widgets', false );
25
 
26
- if ( $method == 'media' && $check_posts && !$check_content && !$check_postmeta && !$check_widgets ) {
27
- $message = __( "Posts, Meta and Widgets analysis are all off. Done.", 'media-cleaner' );
28
  return true;
29
  }
30
- if ( $method == 'files' && $check_library && !$check_content && !$check_posts && !$check_postmeta && !$check_widgets ) {
31
- $message = __( "Posts, Meta and Widgets analysis are all off. Done.", 'media-cleaner' );
32
  return true;
33
  }
34
 
@@ -61,7 +61,7 @@ class Meow_WPMC_Engine {
61
  // Only at the beginning
62
  if ( empty( $limit ) ) {
63
  $this->core->log( "Parsed references:" );
64
- if ( get_option( 'wpmc_widgets', false ) ) {
65
 
66
  global $wp_registered_widgets;
67
  $syswidgets = $wp_registered_widgets;
@@ -75,7 +75,7 @@ class Meow_WPMC_Engine {
75
  }
76
 
77
  do_action( 'wpmc_scan_widgets' );
78
- }
79
  do_action( 'wpmc_scan_once' );
80
  }
81
 
@@ -83,14 +83,10 @@ class Meow_WPMC_Engine {
83
 
84
  foreach ( $posts as $post ) {
85
  $this->core->timeout_check();
86
-
87
- // Check Meta
88
- if ( $check_content || $check_postmeta )
89
- do_action( 'wpmc_scan_postmeta', $post );
90
 
91
- // Check Posts
92
- if ( $check_content || $check_posts ) {
93
- // Get HTML for this post
94
  $html = get_post_field( 'post_content', $post );
95
  do_action( 'wpmc_scan_post', $html, $post );
96
  }
19
  $method = get_option( 'wpmc_method', 'media' );
20
  $check_library = get_option(' wpmc_media_library', true );
21
  $check_content = get_option( 'wpmc_content', true );
22
+ //$check_postmeta = get_option( 'wpmc_postmeta', false );
23
+ //$check_posts = get_option( 'wpmc_posts', false );
24
+ //$check_widgets = get_option( 'wpmc_widgets', true );
25
 
26
+ if ( $method == 'media' && !$check_content ) {
27
+ $message = __( "Posts, content analysis is off. Done.", 'media-cleaner' );
28
  return true;
29
  }
30
+ if ( $method == 'files' && $check_library && !$check_content ) {
31
+ $message = __( "Posts, library check and content analysis are off. Done.", 'media-cleaner' );
32
  return true;
33
  }
34
 
61
  // Only at the beginning
62
  if ( empty( $limit ) ) {
63
  $this->core->log( "Parsed references:" );
64
+ //if ( get_option( 'wpmc_widgets', false ) ) {
65
 
66
  global $wp_registered_widgets;
67
  $syswidgets = $wp_registered_widgets;
75
  }
76
 
77
  do_action( 'wpmc_scan_widgets' );
78
+ //}
79
  do_action( 'wpmc_scan_once' );
80
  }
81
 
83
 
84
  foreach ( $posts as $post ) {
85
  $this->core->timeout_check();
 
 
 
 
86
 
87
+ // Check content
88
+ if ( $check_content ) {
89
+ do_action( 'wpmc_scan_postmeta', $post );
90
  $html = get_post_field( 'post_content', $post );
91
  do_action( 'wpmc_scan_post', $html, $post );
92
  }
media-cleaner.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Media Cleaner
4
  Plugin URI: https://meowapps.com
5
  Description: Clean your Media Library, many options, trash system.
6
- Version: 5.4.6
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: media-cleaner
@@ -25,7 +25,7 @@ if ( is_admin() ) {
25
 
26
  global $wpmc_version;
27
  global $wpmc;
28
- $wpmc_version = '5.4.6';
29
 
30
  require __DIR__ . '/admin.php';
31
  require __DIR__ . '/core.php';
3
  Plugin Name: Media Cleaner
4
  Plugin URI: https://meowapps.com
5
  Description: Clean your Media Library, many options, trash system.
6
+ Version: 5.4.9
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: media-cleaner
25
 
26
  global $wpmc_version;
27
  global $wpmc;
28
+ $wpmc_version = '5.4.9';
29
 
30
  require __DIR__ . '/admin.php';
31
  require __DIR__ . '/core.php';
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://commerce.coinbase.com/checkout/d047546a-77a8-41c8-9ea9-4a95
5
  Requires at least: 4.8
6
  Tested up to: 5.2
7
  Requires PHP: 7.0
8
- Stable tag: 5.4.6
9
 
10
  Clean your WordPress from unused or broken media and files. It has its own trash system and recovery features. Please read the description.
11
 
@@ -71,9 +71,18 @@ Better to be safe than sorry. This plugin deletes files! Therefore, backup is no
71
 
72
  == Changelog ==
73
 
 
 
 
 
 
 
 
 
 
 
74
  = 5.4.6 =
75
  * Add: Option to disable the analysis of shortcodes.
76
- * Info: This plugin is a lot of work. Please help by giving it a nice review, here: https://wordpress.org/support/plugin/media-cleaner/reviews/?rate=5#new-post. Thank you :)
77
 
78
  = 5.4.4 =
79
  * Add: Support for Brizy Builder.
5
  Requires at least: 4.8
6
  Tested up to: 5.2
7
  Requires PHP: 7.0
8
+ Stable tag: 5.4.9
9
 
10
  Clean your WordPress from unused or broken media and files. It has its own trash system and recovery features. Please read the description.
11
 
71
 
72
  == Changelog ==
73
 
74
+ = 5.4.9 =
75
+ * Fix: ACF File field wasn't being detected properly in some cases.
76
+ * Fix: Support for WPBakery Masonry Grid and probably for many more cases than just this one.
77
+ * Add: Ask for confirmation before deleting all the files at once.
78
+ * Info: This plugin is a lot of work. Please help by giving it a nice review, here: https://wordpress.org/support/plugin/media-cleaner/reviews/?rate=5#new-post. Thank you :)
79
+
80
+ = 5.4.8 =
81
+ * Fix: Widgets were not scanned.
82
+ * Add: Support for Divi modules.
83
+
84
  = 5.4.6 =
85
  * Add: Option to disable the analysis of shortcodes.
 
86
 
87
  = 5.4.4 =
88
  * Add: Support for Brizy Builder.
scripts/dashboard.js CHANGED
@@ -639,8 +639,8 @@ function wpmc_open_dialog(content) {
639
  var filter = $this.data('filter') || '';
640
  if (filter && filter != wrap.find('.search-box input[name="s"]').val()) {
641
  var dialog = wpmc_open_dialog({
642
- title: 'Continue?',
643
- body: 'You have modified the search terms and did not click on "Search".<br>The <b>current</b> results will be deleted. Do you want to continue?',
644
  append: $('<div class="prompt">')
645
  .append(
646
  // Cancel Button
@@ -659,7 +659,29 @@ function wpmc_open_dialog(content) {
659
  });
660
  return;
661
  }
662
- wpmc_delete_all(false, filter);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
  });
664
 
665
  // Ignore Button
639
  var filter = $this.data('filter') || '';
640
  if (filter && filter != wrap.find('.search-box input[name="s"]').val()) {
641
  var dialog = wpmc_open_dialog({
642
+ title: 'Warning',
643
+ body: 'You have modified the search terms and did not click on "Search". <br>The <b>current</b> results will be deleted. Do you want to continue?',
644
  append: $('<div class="prompt">')
645
  .append(
646
  // Cancel Button
659
  });
660
  return;
661
  }
662
+ else {
663
+ var dialog = wpmc_open_dialog({
664
+ title: 'Delete all',
665
+ body: '<b>All the issues will be deleted</b>. If everything is working fine, they will actually be moved to the trash, but you should have a backup ready as well. Do you want to continue?',
666
+ append: $('<div class="prompt">')
667
+ .append(
668
+ // Cancel Button
669
+ $('<a class="button cancel" href="#">Cancel</a>').on('click', function (ev) {
670
+ ev.preventDefault();
671
+ dialog.dialog('close');
672
+ })
673
+ ).append(
674
+ // Continue Button
675
+ $('<a class="button button-primary continue" href="#">Continue</a>').on('click', function (ev) {
676
+ ev.preventDefault();
677
+ dialog.dialog('close');
678
+ wpmc_delete_all(false, filter);
679
+ })
680
+ )
681
+ });
682
+ return;
683
+ }
684
+ //wpmc_delete_all(false, filter);
685
  });
686
 
687
  // Ignore Button