Media Cleaner - Version 4.4.8

Version Description

  • 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.4.8
Comparing to
See all releases

Code changes from version 4.4.7 to 4.4.8

Files changed (4) hide show
  1. core.php +35 -21
  2. media-cleaner.php +2 -2
  3. readme.txt +7 -1
  4. wpmc_admin.php +10 -22
core.php CHANGED
@@ -58,7 +58,7 @@ class Meow_WPMC_Core {
58
  return;
59
  }
60
  $this->log( "Media Edit > Checking Media #{$post->ID}" );
61
- $success = $this->wpmc_check_media( $post->ID );
62
  $this->log( "Success $success\n" );
63
  if ( $success ) {
64
  if ( $this->last_analysis == "CONTENT" ) {
@@ -320,8 +320,8 @@ class Meow_WPMC_Core {
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 ) );
325
  if ( !empty( $res ) && isset( $res[1] ) && count( $res[1] ) > 0 ) {
326
  foreach ( $res[1] as $url ) {
327
  array_push( $results, $this->wpmc_clean_url( $url ) );
@@ -374,7 +374,7 @@ class Meow_WPMC_Core {
374
 
375
  function wp_ajax_wpmc_prepare_do() {
376
  $limit = isset( $_POST['limit'] ) ? $_POST['limit'] : 0;
377
- $limitsize = get_option( 'wpmc_posts_buffer', 10 );
378
  if ( empty( $limit ) )
379
  $this->wpmc_reset_issues();
380
  $check_postmeta = get_option( 'wpmc_postmeta', false );
@@ -493,16 +493,28 @@ class Meow_WPMC_Core {
493
  $fields = get_field_objects( $post );
494
  if ( is_array( $fields ) ) {
495
  foreach ( $fields as $field ) {
496
- if ( $field['type'] == 'image' && $field['save_format'] == 'object' ) {
 
 
 
 
 
 
 
497
  array_push( $postmeta_images_acf_ids, $field['value']['id'] );
498
  array_push( $postmeta_images_acf_urls, $this->wpmc_clean_url( $field['value']['url'] ) );
499
  }
500
- if ( $field['type'] == 'image' && $field['save_format'] == 'id' ) {
501
  array_push( $postmeta_images_acf_ids, $field['value'] );
502
  }
503
- if ( $field['type'] == 'image' && $field['save_format'] == 'url' ) {
504
  array_push( $postmeta_images_acf_urls, $this->wpmc_clean_url( $field['value'] ) );
505
  }
 
 
 
 
 
506
  }
507
  set_transient( "wpmc_postmeta_images_acf_ids", $postmeta_images_acf_ids, $this->transient_life );
508
  $found['wpmc_postmeta_images_acf_ids'] = $postmeta_images_acf_ids;
@@ -728,7 +740,7 @@ class Meow_WPMC_Core {
728
  $method = 'media';
729
  $path = isset( $_POST['path'] ) ? $_POST['path'] : null;
730
  $limit = isset( $_POST['limit'] ) ? $_POST['limit'] : 0;
731
- $limitsize = get_option( 'wpmc_medias_buffer', 500 );
732
 
733
  if ( $method == 'files' ) {
734
  $output = apply_filters( 'wpmc_list_uploaded_files', array(
@@ -1096,7 +1108,7 @@ class Meow_WPMC_Core {
1096
  return $file;
1097
  }
1098
 
1099
- function wpmc_check_media( $attachmentId ) {
1100
 
1101
  $this->last_analysis = "N/A";
1102
 
@@ -1165,17 +1177,19 @@ class Meow_WPMC_Core {
1165
  $issue = 'ORPHAN_MEDIA';
1166
  }
1167
 
1168
- $table_name = $wpdb->prefix . "wpmcleaner";
1169
- $wpdb->insert( $table_name,
1170
- array(
1171
- 'time' => current_time('mysql'),
1172
- 'type' => 1,
1173
- 'size' => $size,
1174
- 'path' => $mainfile . ( $countfiles > 0 ? ( " (+ " . $countfiles . " files)" ) : "" ),
1175
- 'postId' => $attachmentId,
1176
- 'issue' => $issue
1177
- )
1178
- );
 
 
1179
  return false;
1180
  }
1181
 
@@ -1220,7 +1234,7 @@ class Meow_WPMC_Core {
1220
  echo "<script type='text/javascript'>\n";
1221
  echo 'var wpmc_cfg = {
1222
  delay: ' . get_option( 'wpmc_delay', 100 ) . ',
1223
- analysisBuffer: ' . get_option( 'wpmc_analysis_buffer', 5 ) . ',
1224
  isPro: ' . ( $this->admin->is_registered() ? '1' : '0') . ',
1225
  scanFiles: ' . ( ( get_option( 'wpmc_method', 'media' ) == 'files' && $this->admin->is_registered() ) ? '1' : '0' ) . ',
1226
  scanMedia: ' . ( get_option( 'wpmc_method', 'media' ) == 'media' ? '1' : '0' ) . ' };';
58
  return;
59
  }
60
  $this->log( "Media Edit > Checking Media #{$post->ID}" );
61
+ $success = $this->wpmc_check_media( $post->ID, true );
62
  $this->log( "Success $success\n" );
63
  if ( $success ) {
64
  if ( $this->last_analysis == "CONTENT" ) {
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 ) );
325
  if ( !empty( $res ) && isset( $res[1] ) && count( $res[1] ) > 0 ) {
326
  foreach ( $res[1] as $url ) {
327
  array_push( $results, $this->wpmc_clean_url( $url ) );
374
 
375
  function wp_ajax_wpmc_prepare_do() {
376
  $limit = isset( $_POST['limit'] ) ? $_POST['limit'] : 0;
377
+ $limitsize = get_option( 'wpmc_posts_buffer', 5 );
378
  if ( empty( $limit ) )
379
  $this->wpmc_reset_issues();
380
  $check_postmeta = get_option( 'wpmc_postmeta', false );
493
  $fields = get_field_objects( $post );
494
  if ( is_array( $fields ) ) {
495
  foreach ( $fields as $field ) {
496
+
497
+ $format = "";
498
+ if ( isset( $field['return_format'] ) )
499
+ $format = $field['return_format'];
500
+ else if ( isset( $field['save_format'] ) )
501
+ $format = $field['save_format'];
502
+
503
+ if ( $field['type'] == 'image' && ( $format == 'array' || $format == 'object' ) ) {
504
  array_push( $postmeta_images_acf_ids, $field['value']['id'] );
505
  array_push( $postmeta_images_acf_urls, $this->wpmc_clean_url( $field['value']['url'] ) );
506
  }
507
+ else if ( $field['type'] == 'image' && $format == 'id' ) {
508
  array_push( $postmeta_images_acf_ids, $field['value'] );
509
  }
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
+ }
517
+ }
518
  }
519
  set_transient( "wpmc_postmeta_images_acf_ids", $postmeta_images_acf_ids, $this->transient_life );
520
  $found['wpmc_postmeta_images_acf_ids'] = $postmeta_images_acf_ids;
740
  $method = 'media';
741
  $path = isset( $_POST['path'] ) ? $_POST['path'] : null;
742
  $limit = isset( $_POST['limit'] ) ? $_POST['limit'] : 0;
743
+ $limitsize = get_option( 'wpmc_medias_buffer', 50 );
744
 
745
  if ( $method == 'files' ) {
746
  $output = apply_filters( 'wpmc_list_uploaded_files', array(
1108
  return $file;
1109
  }
1110
 
1111
+ function wpmc_check_media( $attachmentId, $checkOnly = false ) {
1112
 
1113
  $this->last_analysis = "N/A";
1114
 
1177
  $issue = 'ORPHAN_MEDIA';
1178
  }
1179
 
1180
+ if ( !$checkOnly ) {
1181
+ $table_name = $wpdb->prefix . "wpmcleaner";
1182
+ $wpdb->insert( $table_name,
1183
+ array(
1184
+ 'time' => current_time('mysql'),
1185
+ 'type' => 1,
1186
+ 'size' => $size,
1187
+ 'path' => $mainfile . ( $countfiles > 0 ? ( " (+ " . $countfiles . " files)" ) : "" ),
1188
+ 'postId' => $attachmentId,
1189
+ 'issue' => $issue
1190
+ )
1191
+ );
1192
+ }
1193
  return false;
1194
  }
1195
 
1234
  echo "<script type='text/javascript'>\n";
1235
  echo 'var wpmc_cfg = {
1236
  delay: ' . get_option( 'wpmc_delay', 100 ) . ',
1237
+ analysisBuffer: ' . get_option( 'wpmc_analysis_buffer', 10 ) . ',
1238
  isPro: ' . ( $this->admin->is_registered() ? '1' : '0') . ',
1239
  scanFiles: ' . ( ( get_option( 'wpmc_method', 'media' ) == 'files' && $this->admin->is_registered() ) ? '1' : '0' ) . ',
1240
  scanMedia: ' . ( get_option( 'wpmc_method', 'media' ) == 'media' ? '1' : '0' ) . ' };';
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.7
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.7';
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.4.8
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.4.8';
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.7
7
 
8
  Clean your Media Library and Uploads directory. It has an internal trash and recovery features. Please read the description.
9
 
@@ -52,6 +52,12 @@ It re-creates the Media Cleaner table in the database. You will need to re-run t
52
 
53
  == Changelog ==
54
 
 
 
 
 
 
 
55
  = 4.4.7 =
56
  * Fix: Divi Single Image wasn't always properly detected.
57
  * Add: Option for CSS background.
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
 
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.
59
+ * Update: Removed UTF-8 option (became useless).
60
+
61
  = 4.4.7 =
62
  * Fix: Divi Single Image wasn't always properly detected.
63
  * Add: Option for CSS background.
wpmc_admin.php CHANGED
@@ -12,17 +12,17 @@ class Meow_WPMC_Admin extends MeowApps_Admin {
12
 
13
  function admin_notices() {
14
 
15
- $mediasBuffer = get_option( 'wpmc_medias_buffer', 500 );
16
- $postsBuffer = get_option( 'wpmc_posts_buffer', 10 );
17
- $analysisBuffer = get_option( 'wpmc_analysis_buffer', 5 );
18
  $delay = get_option( 'wpmc_delay', 100 );
19
 
20
  if ( !is_numeric( $mediasBuffer ) || $mediasBuffer < 1 )
21
- update_option( 'wpmc_medias_buffer', 500 );
22
  if ( !is_numeric( $postsBuffer ) || $postsBuffer < 1 )
23
- update_option( 'wpmc_posts_buffer', 10 );
24
  if ( !is_numeric( $analysisBuffer ) || $analysisBuffer < 1 )
25
- update_option( 'wpmc_analysis_buffer', 5 );
26
  if ( !is_numeric( $delay ) )
27
  update_option( 'wpmc_delay', 100 );
28
 
@@ -69,9 +69,6 @@ class Meow_WPMC_Admin extends MeowApps_Admin {
69
  add_settings_field( 'wpmc_background', "Background CSS<br />(Pro)",
70
  array( $this, 'admin_background_callback' ),
71
  'wpmc_settings-menu', 'wpmc_settings' );
72
- add_settings_field( 'wpmc_utf8', "UTF-8",
73
- array( $this, 'admin_utf8_callback' ),
74
- 'wpmc_settings-menu', 'wpmc_settings' );
75
  add_settings_field( 'wpmc_debuglogs', "Logs",
76
  array( $this, 'admin_debuglogs_callback' ),
77
  'wpmc_settings-menu', 'wpmc_settings', array( "Enable" ) );
@@ -109,7 +106,6 @@ class Meow_WPMC_Admin extends MeowApps_Admin {
109
  register_setting( 'wpmc_settings', 'wpmc_widgets' );
110
  register_setting( 'wpmc_settings', 'wpmc_media_library' );
111
  register_setting( 'wpmc_settings', 'wpmc_postmeta' );
112
- register_setting( 'wpmc_settings', 'wpmc_utf8' );
113
  register_setting( 'wpmc_settings', 'wpmc_debuglogs' );
114
 
115
  register_setting( 'wpmc_ui_settings', 'wpmc_hide_thumbnails' );
@@ -122,21 +118,21 @@ class Meow_WPMC_Admin extends MeowApps_Admin {
122
  }
123
 
124
  function admin_medias_buffer_callback( $args ) {
125
- $value = get_option( 'wpmc_medias_buffer', 500 );
126
  $html = '<input type="number" style="width: 100%;" id="wpmc_medias_buffer" name="wpmc_medias_buffer" value="' . $value . '" />';
127
  $html .= '<br /><span class="description">The number of medias to read in one time during the preparation phase. This is fast, so the value should be between 50 and 1000.</label>';
128
  echo $html;
129
  }
130
 
131
  function admin_posts_buffer_callback( $args ) {
132
- $value = get_option( 'wpmc_posts_buffer', 10 );
133
  $html = '<input type="number" style="width: 100%;" id="wpmc_posts_buffer" name="wpmc_posts_buffer" value="' . $value . '" />';
134
  $html .= '<br /><span class="description">The number of posts to read in one time during the preparation phase. This takes a bit of time in case galleries are being used. Recommended value is between 5 and 20.</label>';
135
  echo $html;
136
  }
137
 
138
  function admin_analysis_buffer_callback( $args ) {
139
- $value = get_option( 'wpmc_analysis_buffer', 5 );
140
  $html = '<input type="number" style="width: 100%;" id="wpmc_analysis_buffer" name="wpmc_analysis_buffer" value="' . $value . '" />';
141
  $html .= '<br /><span class="description">The number of medias or files to analyse in one time. It is the main part of the process and it depends on the scanning options. Recommended value is 5 but can be more on a powerful server, or 1 if your server is not powerful or your WordPress very bloated.</label>';
142
  echo $html;
@@ -145,7 +141,7 @@ class Meow_WPMC_Admin extends MeowApps_Admin {
145
  function admin_delay_callback( $args ) {
146
  $value = get_option( 'wpmc_delay', 100 );
147
  $html = '<input type="number" style="width: 100%;" id="wpmc_delay" name="wpmc_delay" value="' . $value . '" />';
148
- $html .= '<br /><span class="description">This is a delay Media Cleaner will wait between each request. The process is intensive so this gives the server time to relax a little (hosting services sometimes require this). Recommended value is actually 0, 100 (ms) is for safety, some servers require 2000 or 5000 (2 or 5 seconds).</label>';
149
  echo $html;
150
  }
151
 
@@ -273,14 +269,6 @@ class Meow_WPMC_Admin extends MeowApps_Admin {
273
  echo $html;
274
  }
275
 
276
- function admin_utf8_callback( $args ) {
277
- $value = get_option( 'wpmc_utf8', null );
278
- $html = '<input type="checkbox" id="wpmc_utf8" name="wpmc_utf8" value="1" ' .
279
- checked( 1, get_option( 'wpmc_utf8' ), false ) . '/>';
280
- $html .= __( '<label>Do not skip UTF-8 filenames</label><br /><small>PHP does not always work well with UTF-8 on all systems. If the scanning suddenly stops, this might be the cause.</small>', 'media-cleaner' );
281
- echo $html;
282
- }
283
-
284
  function admin_debuglogs_callback( $args ) {
285
  $clearlogs = isset ( $_GET[ 'clearlogs' ] ) ? $_GET[ 'clearlogs' ] : 0;
286
  if ( $clearlogs && file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
12
 
13
  function admin_notices() {
14
 
15
+ $mediasBuffer = get_option( 'wpmc_medias_buffer', 50 );
16
+ $postsBuffer = get_option( 'wpmc_posts_buffer', 5 );
17
+ $analysisBuffer = get_option( 'wpmc_analysis_buffer', 10 );
18
  $delay = get_option( 'wpmc_delay', 100 );
19
 
20
  if ( !is_numeric( $mediasBuffer ) || $mediasBuffer < 1 )
21
+ update_option( 'wpmc_medias_buffer', 50 );
22
  if ( !is_numeric( $postsBuffer ) || $postsBuffer < 1 )
23
+ update_option( 'wpmc_posts_buffer', 5 );
24
  if ( !is_numeric( $analysisBuffer ) || $analysisBuffer < 1 )
25
+ update_option( 'wpmc_analysis_buffer', 10 );
26
  if ( !is_numeric( $delay ) )
27
  update_option( 'wpmc_delay', 100 );
28
 
69
  add_settings_field( 'wpmc_background', "Background CSS<br />(Pro)",
70
  array( $this, 'admin_background_callback' ),
71
  'wpmc_settings-menu', 'wpmc_settings' );
 
 
 
72
  add_settings_field( 'wpmc_debuglogs', "Logs",
73
  array( $this, 'admin_debuglogs_callback' ),
74
  'wpmc_settings-menu', 'wpmc_settings', array( "Enable" ) );
106
  register_setting( 'wpmc_settings', 'wpmc_widgets' );
107
  register_setting( 'wpmc_settings', 'wpmc_media_library' );
108
  register_setting( 'wpmc_settings', 'wpmc_postmeta' );
 
109
  register_setting( 'wpmc_settings', 'wpmc_debuglogs' );
110
 
111
  register_setting( 'wpmc_ui_settings', 'wpmc_hide_thumbnails' );
118
  }
119
 
120
  function admin_medias_buffer_callback( $args ) {
121
+ $value = get_option( 'wpmc_medias_buffer', 50 );
122
  $html = '<input type="number" style="width: 100%;" id="wpmc_medias_buffer" name="wpmc_medias_buffer" value="' . $value . '" />';
123
  $html .= '<br /><span class="description">The number of medias to read in one time during the preparation phase. This is fast, so the value should be between 50 and 1000.</label>';
124
  echo $html;
125
  }
126
 
127
  function admin_posts_buffer_callback( $args ) {
128
+ $value = get_option( 'wpmc_posts_buffer', 5 );
129
  $html = '<input type="number" style="width: 100%;" id="wpmc_posts_buffer" name="wpmc_posts_buffer" value="' . $value . '" />';
130
  $html .= '<br /><span class="description">The number of posts to read in one time during the preparation phase. This takes a bit of time in case galleries are being used. Recommended value is between 5 and 20.</label>';
131
  echo $html;
132
  }
133
 
134
  function admin_analysis_buffer_callback( $args ) {
135
+ $value = get_option( 'wpmc_analysis_buffer', 10 );
136
  $html = '<input type="number" style="width: 100%;" id="wpmc_analysis_buffer" name="wpmc_analysis_buffer" value="' . $value . '" />';
137
  $html .= '<br /><span class="description">The number of medias or files to analyse in one time. It is the main part of the process and it depends on the scanning options. Recommended value is 5 but can be more on a powerful server, or 1 if your server is not powerful or your WordPress very bloated.</label>';
138
  echo $html;
141
  function admin_delay_callback( $args ) {
142
  $value = get_option( 'wpmc_delay', 100 );
143
  $html = '<input type="number" style="width: 100%;" id="wpmc_delay" name="wpmc_delay" value="' . $value . '" />';
144
+ $html .= '<br /><span class="description">This is a delay Media Cleaner will wait between each request. The process is intensive so this gives the server time to relax a little (hosting services sometimes require this). Recommended value is actually 0, 100 (ms) is for safety, some servers require 2000 or 500 (2 or 5 seconds).</label>';
145
  echo $html;
146
  }
147
 
269
  echo $html;
270
  }
271
 
 
 
 
 
 
 
 
 
272
  function admin_debuglogs_callback( $args ) {
273
  $clearlogs = isset ( $_GET[ 'clearlogs' ] ) ? $_GET[ 'clearlogs' ] : 0;
274
  if ( $clearlogs && file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {