Version Description
- Add: Support for WooCommerce Gallery.
- Add: Support for Visual Composer (Single Image and Gallery).
Download this release
Release Info
Developer | TigrouMeow |
Plugin | Media Cleaner |
Version | 4.1.0 |
Comparing to | |
See all releases |
Code changes from version 4.0.7 to 4.1.0
- common/admin.php +9 -9
- core.php +80 -17
- media-cleaner.js +7 -5
- media-cleaner.php +2 -2
- readme.txt +8 -4
- wpmc_admin.php +1 -1
- wpmc_checkers.php +50 -16
common/admin.php
CHANGED
@@ -5,7 +5,7 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
5 |
class MeowApps_Admin {
|
6 |
|
7 |
public static $loaded = false;
|
8 |
-
public static $admin_version = "1.
|
9 |
|
10 |
public $prefix; // prefix used for actions, filters (mfrh)
|
11 |
public $mainfile; // plugin main file (media-file-renamer.php)
|
@@ -161,6 +161,8 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
161 |
|
162 |
$plugin_file = $plugin . '/' . $plugin . '.php';
|
163 |
if ( is_plugin_active( $plugin_file ) ) {
|
|
|
|
|
164 |
if ( $pro )
|
165 |
return "<small><span style='float: right;'><span class='dashicons dashicons-heart' style='color: rgba(255, 63, 0, 1); font-size: 30px !important; margin-right: 10px;'></span></span></small>";
|
166 |
else
|
@@ -237,26 +239,24 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
237 |
<h3 class=""><span class="dashicons dashicons-camera"></span> UI Plugins </h3>
|
238 |
<ul class="">
|
239 |
<li><b>WP/LR Sync</b> <?php echo $this->check_install( 'wplr-sync' ) ?><br />
|
240 |
-
|
241 |
<li><b>Meow Lightbox</b> <?php echo $this->check_install( 'meow-lightbox' ) ?><br />
|
242 |
-
|
243 |
<li><b>Meow Gallery</b> <?php echo $this->check_install( 'meow-gallery' ) ?><br />
|
244 |
-
|
245 |
-
<li><b>Audio Story for Images</b> <?php echo $this->check_install( 'audio-story-images' ) ?><br />
|
246 |
-
Add audio to your images.</li>
|
247 |
</ul>
|
248 |
</div>
|
249 |
<div class="meow-box meow-col meow-span_1_of_2">
|
250 |
<h3 class=""><span class="dashicons dashicons-admin-tools"></span> System Plugins</h3>
|
251 |
<ul class="">
|
252 |
<li><b>Media File Renamer</b> <?php echo $this->check_install( 'media-file-renamer' ) ?><br />
|
253 |
-
|
254 |
<li><b>Media Cleaner</b> <?php echo $this->check_install( 'media-cleaner' ) ?><br />
|
255 |
Detect the files which are not in use.</li>
|
256 |
<li><b>WP Retina 2x</b> <?php echo $this->check_install( 'wp-retina-2x' ) ?><br />
|
257 |
The famous plugin that adds Retina support.</li>
|
258 |
-
<li><b>WP Category Permalink</b> <?php echo $this->check_install( 'wp-category-permalink' ) ?><br />
|
259 |
-
Allows you to select a main category (or taxonomy) for nicer permalinks.</li>
|
260 |
</ul>
|
261 |
</div>
|
262 |
</div>
|
5 |
class MeowApps_Admin {
|
6 |
|
7 |
public static $loaded = false;
|
8 |
+
public static $admin_version = "1.3";
|
9 |
|
10 |
public $prefix; // prefix used for actions, filters (mfrh)
|
11 |
public $mainfile; // plugin main file (media-file-renamer.php)
|
161 |
|
162 |
$plugin_file = $plugin . '/' . $plugin . '.php';
|
163 |
if ( is_plugin_active( $plugin_file ) ) {
|
164 |
+
if ( $plugin == 'wplr-sync' )
|
165 |
+
$pro = true;
|
166 |
if ( $pro )
|
167 |
return "<small><span style='float: right;'><span class='dashicons dashicons-heart' style='color: rgba(255, 63, 0, 1); font-size: 30px !important; margin-right: 10px;'></span></span></small>";
|
168 |
else
|
239 |
<h3 class=""><span class="dashicons dashicons-camera"></span> UI Plugins </h3>
|
240 |
<ul class="">
|
241 |
<li><b>WP/LR Sync</b> <?php echo $this->check_install( 'wplr-sync' ) ?><br />
|
242 |
+
Synchronize photos (folders, collections, keywords) from Lightroom to WordPress.</li>
|
243 |
<li><b>Meow Lightbox</b> <?php echo $this->check_install( 'meow-lightbox' ) ?><br />
|
244 |
+
Light but powerful lightbox that can also display photo information (EXIF).</li>
|
245 |
<li><b>Meow Gallery</b> <?php echo $this->check_install( 'meow-gallery' ) ?><br />
|
246 |
+
Gallery (using the built-in WP gallery) that makes your website look better.</li>
|
247 |
+
<!-- <li><b>Audio Story for Images</b> <?php echo $this->check_install( 'audio-story-images' ) ?><br />
|
248 |
+
Add audio (music, explanation, ambiance) to your images.</li> -->
|
249 |
</ul>
|
250 |
</div>
|
251 |
<div class="meow-box meow-col meow-span_1_of_2">
|
252 |
<h3 class=""><span class="dashicons dashicons-admin-tools"></span> System Plugins</h3>
|
253 |
<ul class="">
|
254 |
<li><b>Media File Renamer</b> <?php echo $this->check_install( 'media-file-renamer' ) ?><br />
|
255 |
+
For nicer filenames and better SEO.</li>
|
256 |
<li><b>Media Cleaner</b> <?php echo $this->check_install( 'media-cleaner' ) ?><br />
|
257 |
Detect the files which are not in use.</li>
|
258 |
<li><b>WP Retina 2x</b> <?php echo $this->check_install( 'wp-retina-2x' ) ?><br />
|
259 |
The famous plugin that adds Retina support.</li>
|
|
|
|
|
260 |
</ul>
|
261 |
</div>
|
262 |
</div>
|
core.php
CHANGED
@@ -196,34 +196,93 @@ class Meow_WPMC_Core {
|
|
196 |
$limitsize = get_option( 'wpmc_posts_buffer', 10 );
|
197 |
if ( empty( $limit ) )
|
198 |
$this->wpmc_reset_issues();
|
199 |
-
|
|
|
|
|
|
|
200 |
echo json_encode( array(
|
201 |
'results' => array(),
|
202 |
'success' => true,
|
203 |
'finished' => true,
|
204 |
-
'message' => __( "Galleries
|
205 |
) );
|
206 |
die();
|
207 |
}
|
208 |
-
|
209 |
-
if ( empty( $galleries_images ) )
|
210 |
-
$galleries_images = array();
|
211 |
global $wpdb;
|
212 |
$posts = $wpdb->get_col( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p
|
213 |
WHERE p.post_status != 'inherit'
|
214 |
AND p.post_type != 'attachment'
|
|
|
215 |
LIMIT %d, %d", $limit, $limitsize
|
216 |
)
|
217 |
);
|
218 |
foreach ( $posts as $post ) {
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
|
|
224 |
}
|
225 |
}
|
226 |
-
set_transient( "wpmc_galleries_images", $galleries_images, 60 * 60 * 2 );
|
227 |
$finished = count( $posts ) < $limitsize;
|
228 |
echo json_encode(
|
229 |
array(
|
@@ -595,19 +654,19 @@ class Meow_WPMC_Core {
|
|
595 |
|
596 |
// ANALYSIS
|
597 |
$this->last_analysis = "NONE";
|
598 |
-
if ( $this->wpmc_check_is_ignore( $mainfile ) ) {
|
599 |
$this->last_analysis = "IGNORED";
|
600 |
return true;
|
601 |
}
|
602 |
-
if ( $this->checkers->has_background_or_header( $mainfile ) ) {
|
603 |
$this->last_analysis = "BACKGROUND_OR_HEADER";
|
604 |
return true;
|
605 |
}
|
606 |
-
if ( $this->checkers->has_content( $mainfile ) ) {
|
607 |
$this->last_analysis = "CONTENT";
|
608 |
return true;
|
609 |
}
|
610 |
-
if ( $this->checkers->check_in_gallery( $mainfile ) ) {
|
611 |
$this->last_analysis = "GALLERY";
|
612 |
return true;
|
613 |
}
|
@@ -634,11 +693,11 @@ class Meow_WPMC_Core {
|
|
634 |
error_log("checking MEDIA-IMAGE {$filepath}");
|
635 |
|
636 |
// ANALYSIS
|
637 |
-
if ( $this->checkers->check_in_gallery( $filepath ) ) {
|
638 |
$this->last_analysis = "GALLERY";
|
639 |
return true;
|
640 |
}
|
641 |
-
if ( $this->checkers->has_background_or_header( $filepath ) ) {
|
642 |
$this->last_analysis = "BACKGROUND_OR_HEADER";
|
643 |
return true;
|
644 |
}
|
@@ -678,7 +737,11 @@ class Meow_WPMC_Core {
|
|
678 |
else {
|
679 |
$wpdb->query( "DELETE FROM $table_name WHERE ignored = 0 AND deleted = 0" );
|
680 |
}
|
|
|
|
|
|
|
681 |
delete_transient( "wpmc_galleries_images" );
|
|
|
682 |
delete_transient( 'wpmc_posts_with_shortcode' );
|
683 |
}
|
684 |
|
@@ -869,7 +932,7 @@ class Meow_WPMC_Core {
|
|
869 |
}
|
870 |
|
871 |
if ( !MEDIA_TRASH ) {
|
872 |
-
_e( "<div class='notice notice-warning'><p>The trash for the Media Library is disabled. Any media removed by the plugin will be <b>permanently deleted</b>. To enable it, modify your wp-config.php file and add this line:<br /><b>define( 'MEDIA_TRASH', true );</b></p></div>" );
|
873 |
}
|
874 |
|
875 |
if ( !$this->admin->is_registered() ) {
|
196 |
$limitsize = get_option( 'wpmc_posts_buffer', 10 );
|
197 |
if ( empty( $limit ) )
|
198 |
$this->wpmc_reset_issues();
|
199 |
+
|
200 |
+
$check_posts = get_option( 'wpmc_posts', false );
|
201 |
+
$check_galleries = get_option( 'wpmc_galleries', false );
|
202 |
+
if ( !$check_galleries && !$check_posts ) {
|
203 |
echo json_encode( array(
|
204 |
'results' => array(),
|
205 |
'success' => true,
|
206 |
'finished' => true,
|
207 |
+
'message' => __( "Galleries and Posts analysis is off. Done.", 'media-cleaner' )
|
208 |
) );
|
209 |
die();
|
210 |
}
|
211 |
+
|
|
|
|
|
212 |
global $wpdb;
|
213 |
$posts = $wpdb->get_col( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p
|
214 |
WHERE p.post_status != 'inherit'
|
215 |
AND p.post_type != 'attachment'
|
216 |
+
AND p.post_type != 'revision'
|
217 |
LIMIT %d, %d", $limit, $limitsize
|
218 |
)
|
219 |
);
|
220 |
foreach ( $posts as $post ) {
|
221 |
+
|
222 |
+
if ( $check_posts ) {
|
223 |
+
// TODO: Not yet creating this.
|
224 |
+
$posts_images = get_transient( "wpmc_posts_images" );
|
225 |
+
set_transient( "wpmc_posts_images", $posts_images, 60 * 60 * 2 );
|
226 |
+
|
227 |
+
// Single Image in Visual Composer (WPBakery)
|
228 |
+
if ( class_exists( 'Vc_Manager' ) ) {
|
229 |
+
$posts_images_vc = get_transient( "wpmc_posts_images_visualcomposer" );
|
230 |
+
if ( empty( $posts_images_vc ) )
|
231 |
+
$posts_images_vc = array();
|
232 |
+
$html = get_post_field( 'post_content', $post );
|
233 |
+
preg_match_all( "/image=\"([0-9]+)\"/", $html, $res );
|
234 |
+
if ( !empty( $res ) && isset( $res[1] ) ) {
|
235 |
+
$posts_images_vc = array_merge( $posts_images_vc, $res[1] );
|
236 |
+
}
|
237 |
+
set_transient( "wpmc_posts_images_visualcomposer", $posts_images_vc, 60 * 60 * 2 );
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
if ( $check_galleries ) {
|
242 |
+
|
243 |
+
// Galleries in Visual Composer (WPBakery)
|
244 |
+
if ( class_exists( 'Vc_Manager' ) ) {
|
245 |
+
$galleries_images_vc = get_transient( "wpmc_galleries_images_visualcomposer" );
|
246 |
+
if ( empty( $galleries_images_vc ) )
|
247 |
+
$galleries_images_vc = array();
|
248 |
+
$html = get_post_field( 'post_content', $post );
|
249 |
+
preg_match_all( "/images=\"([0-9,]+)/", $html, $res );
|
250 |
+
if ( !empty( $res ) && isset( $res[1] ) ) {
|
251 |
+
foreach ( $res[1] as $r ) {
|
252 |
+
$ids = explode( ',', $r );
|
253 |
+
$galleries_images_vc = array_merge( $galleries_images_vc, $ids );
|
254 |
+
}
|
255 |
+
}
|
256 |
+
set_transient( "wpmc_galleries_images_visualcomposer", $galleries_images_vc, 60 * 60 * 2 );
|
257 |
+
}
|
258 |
+
|
259 |
+
// WooCommerce
|
260 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
261 |
+
$galleries_images_wc = get_transient( "wpmc_galleries_images_woocommerce" );
|
262 |
+
if ( empty( $galleries_images_wc ) )
|
263 |
+
$galleries_images_wc = array();
|
264 |
+
$res = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $post
|
265 |
+
AND meta_key = '_product_image_gallery'" );
|
266 |
+
foreach ( $res as $values ) {
|
267 |
+
$ids = explode( ',', $values );
|
268 |
+
$galleries_images_wc = array_merge( $galleries_images_wc, $ids );
|
269 |
+
}
|
270 |
+
set_transient( "wpmc_galleries_images_woocommerce", $galleries_images_wc, 60 * 60 * 2 );
|
271 |
+
}
|
272 |
+
|
273 |
+
// Standard WP Gallery
|
274 |
+
$galleries_images = get_transient( "wpmc_galleries_images" );
|
275 |
+
if ( empty( $galleries_images ) )
|
276 |
+
$galleries_images = array();
|
277 |
+
$galleries = get_post_galleries_images( $post );
|
278 |
+
foreach ( $galleries as $gallery ) {
|
279 |
+
foreach ( $gallery as $image ) {
|
280 |
+
array_push( $galleries_images, $image );
|
281 |
+
}
|
282 |
}
|
283 |
+
set_transient( "wpmc_galleries_images", $galleries_images, 60 * 60 * 2 );
|
284 |
}
|
285 |
}
|
|
|
286 |
$finished = count( $posts ) < $limitsize;
|
287 |
echo json_encode(
|
288 |
array(
|
654 |
|
655 |
// ANALYSIS
|
656 |
$this->last_analysis = "NONE";
|
657 |
+
if ( $this->wpmc_check_is_ignore( $mainfile, $attachmentId ) ) {
|
658 |
$this->last_analysis = "IGNORED";
|
659 |
return true;
|
660 |
}
|
661 |
+
if ( $this->checkers->has_background_or_header( $mainfile, $attachmentId ) ) {
|
662 |
$this->last_analysis = "BACKGROUND_OR_HEADER";
|
663 |
return true;
|
664 |
}
|
665 |
+
if ( $this->checkers->has_content( $mainfile, $attachmentId ) ) {
|
666 |
$this->last_analysis = "CONTENT";
|
667 |
return true;
|
668 |
}
|
669 |
+
if ( $this->checkers->check_in_gallery( $mainfile, $attachmentId ) ) {
|
670 |
$this->last_analysis = "GALLERY";
|
671 |
return true;
|
672 |
}
|
693 |
error_log("checking MEDIA-IMAGE {$filepath}");
|
694 |
|
695 |
// ANALYSIS
|
696 |
+
if ( $this->checkers->check_in_gallery( $filepath, $attachmentId ) ) {
|
697 |
$this->last_analysis = "GALLERY";
|
698 |
return true;
|
699 |
}
|
700 |
+
if ( $this->checkers->has_background_or_header( $filepath, $attachmentId ) ) {
|
701 |
$this->last_analysis = "BACKGROUND_OR_HEADER";
|
702 |
return true;
|
703 |
}
|
737 |
else {
|
738 |
$wpdb->query( "DELETE FROM $table_name WHERE ignored = 0 AND deleted = 0" );
|
739 |
}
|
740 |
+
delete_transient( "wpmc_posts_images_visualcomposer" );
|
741 |
+
delete_transient( "wpmc_galleries_images_visualcomposer" );
|
742 |
+
delete_transient( "wpmc_galleries_images_woocommerce" );
|
743 |
delete_transient( "wpmc_galleries_images" );
|
744 |
+
delete_transient( "wpmc_posts_images" );
|
745 |
delete_transient( 'wpmc_posts_with_shortcode' );
|
746 |
}
|
747 |
|
932 |
}
|
933 |
|
934 |
if ( !MEDIA_TRASH ) {
|
935 |
+
_e( "<div class='notice notice-warning'><p>The trash for the Media Library is disabled. Any media removed by the plugin will be <b>permanently deleted</b>. To enable it, modify your wp-config.php file and add this line (preferably at the top):<br /><b>define( 'MEDIA_TRASH', true );</b></p></div>" );
|
936 |
}
|
937 |
|
938 |
if ( !$this->admin->is_registered() ) {
|
media-cleaner.js
CHANGED
@@ -101,12 +101,13 @@ function wpmc_delete_all(isTrash) {
|
|
101 |
});
|
102 |
}
|
103 |
|
104 |
-
function wpmc_update_progress(current, totalcount) {
|
105 |
-
|
|
|
106 |
}
|
107 |
|
108 |
function wpmc_delete_do(items, totalcount) {
|
109 |
-
wpmc_update_progress(totalcount - items.length, totalcount);
|
110 |
if (items.length > 0) {
|
111 |
newItems = wpmc_pop_array(items, 5);
|
112 |
data = { action: 'wpmc_delete_do', data: newItems };
|
@@ -342,8 +343,9 @@ function wpmc_scan_do() {
|
|
342 |
reply = { success: false, message: "The reply from the server is broken. The reply will be displayed in your Javascript console. You should also check your PHP Error Logs." };
|
343 |
console.debug( "Media File Cleaner got this reply from the server: " + response);
|
344 |
}
|
345 |
-
if (
|
346 |
-
|
|
|
347 |
}
|
348 |
if (reply.result) {
|
349 |
wpmc.issues += expectedSuccess - reply.result.success;
|
101 |
});
|
102 |
}
|
103 |
|
104 |
+
function wpmc_update_progress(current, totalcount, isDeleting = false) {
|
105 |
+
var action = isDeleting ? "Deleting" : "Analyzing";
|
106 |
+
jQuery('#wpmc_progression').html('<span class="dashicons dashicons-controls-play"></span> ' + action + ' ' + current + "/" + totalcount + " (" + Math.round(current / totalcount * 100) + "%)");
|
107 |
}
|
108 |
|
109 |
function wpmc_delete_do(items, totalcount) {
|
110 |
+
wpmc_update_progress(totalcount - items.length, totalcount, true);
|
111 |
if (items.length > 0) {
|
112 |
newItems = wpmc_pop_array(items, 5);
|
113 |
data = { action: 'wpmc_delete_do', data: newItems };
|
343 |
reply = { success: false, message: "The reply from the server is broken. The reply will be displayed in your Javascript console. You should also check your PHP Error Logs." };
|
344 |
console.debug( "Media File Cleaner got this reply from the server: " + response);
|
345 |
}
|
346 |
+
if (!reply.success) {
|
347 |
+
wpmc_update_to_error(reply.message);
|
348 |
+
console.debug("Media Cleaner got an error from server.", reply.message);
|
349 |
}
|
350 |
if (reply.result) {
|
351 |
wpmc.issues += expectedSuccess - reply.result.success;
|
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.0
|
7 |
Author: Jordy Meow
|
8 |
Author URI: http://meowapps.com
|
9 |
Text Domain: media-cleaner
|
@@ -19,7 +19,7 @@ Originally developed for two of my websites:
|
|
19 |
if ( is_admin() ) {
|
20 |
|
21 |
global $wpmc_version;
|
22 |
-
$wpmc_version = '4.0
|
23 |
|
24 |
// Admin
|
25 |
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.1.0
|
7 |
Author: Jordy Meow
|
8 |
Author URI: http://meowapps.com
|
9 |
Text Domain: media-cleaner
|
19 |
if ( is_admin() ) {
|
20 |
|
21 |
global $wpmc_version;
|
22 |
+
$wpmc_version = '4.1.0';
|
23 |
|
24 |
// Admin
|
25 |
require( 'wpmc_admin.php' );
|
readme.txt
CHANGED
@@ -3,17 +3,17 @@ 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.8
|
6 |
-
Stable tag: 4.0
|
7 |
|
8 |
-
Clean your Media Library and Uploads directory. It has an internal trash and recovery features.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
Clean your Media Library from the media which aren't used in any of your posts, gallery and so on. It features an internal trash, moving the files in there temporarily for you to make sure the files aren't actually in used; once checked, you can trash them permanently. **Before using this plugin, make sure you have a proper backup of your files and database. This is the most important step on the usage of this plugin as you can't trust any file deletion tools.** The Pro version of this plugin brings also scanning to the /uploads folder and will detect which files aren't registered in the Media Library, not used in your content and so on. Retina images are also detected and supported, shortcodes, HTML in sidebars and of course your posts, pages and all post types.
|
13 |
|
14 |
-
**This tool is a knife. I
|
15 |
|
16 |
-
**
|
17 |
|
18 |
**UNIQUE PLUGIN**. Such a plugin is difficult to create and to maintain. If you understand WordPress, you probably know why. This plugin tries its best to help you. Get used to it and you will get awesome results. This is the only plugin to propose those functions and even a dashboard to cleanup your WordPress install from unused files.
|
19 |
|
@@ -50,6 +50,10 @@ It re-creates the Media Cleaner table in the database. You will need to re-run t
|
|
50 |
|
51 |
== Changelog ==
|
52 |
|
|
|
|
|
|
|
|
|
53 |
= 4.0.7 =
|
54 |
* Update: Bulk analyze/prepare galleries, avoid the first request to time out.
|
55 |
* Add: Many option to make the processing faster or slower depending on the server.
|
3 |
Tags: management, admin, file, files, images, image, media, library, upload, clean, cleaning
|
4 |
Requires at least: 4.2
|
5 |
Tested up to: 4.8
|
6 |
+
Stable tag: 4.1.0
|
7 |
|
8 |
+
Clean your Media Library and Uploads directory. It has an internal trash and recovery features. Please read the description.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
Clean your Media Library from the media which aren't used in any of your posts, gallery and so on. It features an internal trash, moving the files in there temporarily for you to make sure the files aren't actually in used; once checked, you can trash them permanently. **Before using this plugin, make sure you have a proper backup of your files and database. This is the most important step on the usage of this plugin as you can't trust any file deletion tools.** The Pro version of this plugin brings also scanning to the /uploads folder and will detect which files aren't registered in the Media Library, not used in your content and so on. Retina images are also detected and supported, shortcodes, HTML in sidebars and of course your posts, pages and all post types.
|
13 |
|
14 |
+
**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.**
|
15 |
|
16 |
+
**PAGE BUILDER**. I am adding support for page builders little by little. Each page builder requires a particular code in the Media Cleaner. As for now, Visual Composer by WPBakery is supported.
|
17 |
|
18 |
**UNIQUE PLUGIN**. Such a plugin is difficult to create and to maintain. If you understand WordPress, you probably know why. This plugin tries its best to help you. Get used to it and you will get awesome results. This is the only plugin to propose those functions and even a dashboard to cleanup your WordPress install from unused files.
|
19 |
|
50 |
|
51 |
== Changelog ==
|
52 |
|
53 |
+
= 4.1.0 =
|
54 |
+
* Add: Support for WooCommerce Gallery.
|
55 |
+
* Add: Support for Visual Composer (Single Image and Gallery).
|
56 |
+
|
57 |
= 4.0.7 =
|
58 |
* Update: Bulk analyze/prepare galleries, avoid the first request to time out.
|
59 |
* Add: Many option to make the processing faster or slower depending on the server.
|
wpmc_admin.php
CHANGED
@@ -280,7 +280,7 @@ class Meow_WPMC_Admin extends MeowApps_Admin {
|
|
280 |
$value = get_option( 'wpmc_galleries', null );
|
281 |
$html = '<input type="checkbox" id="wpmc_galleries" name="wpmc_galleries" value="1" ' .
|
282 |
checked( 1, get_option( 'wpmc_galleries' ), false ) . '/>';
|
283 |
-
$html .= '<label>Analyze</label><br /><small>Checks if the file is used in a WP Gallery (
|
284 |
echo $html;
|
285 |
}
|
286 |
|
280 |
$value = get_option( 'wpmc_galleries', null );
|
281 |
$html = '<input type="checkbox" id="wpmc_galleries" name="wpmc_galleries" value="1" ' .
|
282 |
checked( 1, get_option( 'wpmc_galleries' ), false ) . '/>';
|
283 |
+
$html .= '<label>Analyze</label><br /><small>Checks if the file is used in a <b>WP Gallery</b> (in any post type) or in a <b>WooCommerce Gallery</b>.</small>';
|
284 |
echo $html;
|
285 |
}
|
286 |
|
wpmc_checkers.php
CHANGED
@@ -37,11 +37,32 @@ class Meow_WPMC_Checkers {
|
|
37 |
return false;
|
38 |
}
|
39 |
|
40 |
-
function check_in_gallery( $file ) {
|
41 |
|
42 |
if ( !get_option( 'wpmc_galleries', false ) )
|
43 |
return false;
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
$file = $this->core->wpmc_clean_uploaded_filename( $file );
|
46 |
$uploads = wp_upload_dir();
|
47 |
$parsedURL = parse_url( $uploads['baseurl'] );
|
@@ -110,6 +131,34 @@ class Meow_WPMC_Checkers {
|
|
110 |
|
111 |
// Check in Posts Content
|
112 |
if ( get_option( 'wpmc_posts', true ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
$file = $this->core->wpmc_clean_uploaded_filename( $file );
|
114 |
$uploads = wp_upload_dir();
|
115 |
$parsedURL = parse_url( $uploads['baseurl'] );
|
@@ -138,21 +187,6 @@ class Meow_WPMC_Checkers {
|
|
138 |
error_log( "File {$file} found in post_content, $mediaCount time(s)" );
|
139 |
if ( $mediaCount > 0 )
|
140 |
return true;
|
141 |
-
|
142 |
-
if ( !empty( $mediaId ) ) {
|
143 |
-
$sql = $wpdb->prepare( "SELECT ID
|
144 |
-
FROM $wpdb->posts
|
145 |
-
WHERE post_type <> 'revision'
|
146 |
-
AND post_type <> 'attachment'
|
147 |
-
AND post_content LIKE %s", "%wp-image-$mediaId%" );
|
148 |
-
$foundIds = $wpdb->get_col( $sql );
|
149 |
-
$this->core->last_analysis_ids = $foundIds;
|
150 |
-
$mediaCount = count( $foundIds );
|
151 |
-
if ( $this->core->debug && $mediaCount > 0 )
|
152 |
-
error_log( "Media {$mediaId} found in post_content, $mediaCount time(s)" );
|
153 |
-
if ( $mediaCount > 0 )
|
154 |
-
return true;
|
155 |
-
}
|
156 |
}
|
157 |
|
158 |
// Shortcode analysis
|
37 |
return false;
|
38 |
}
|
39 |
|
40 |
+
function check_in_gallery( $file, $attachment_id = 0 ) {
|
41 |
|
42 |
if ( !get_option( 'wpmc_galleries', false ) )
|
43 |
return false;
|
44 |
|
45 |
+
// Galleries in Visual Composer (WPBakery)
|
46 |
+
if ( class_exists( 'Vc_Manager' ) ) {
|
47 |
+
$galleries_images_vc = get_transient( "wpmc_galleries_images_visualcomposer" );
|
48 |
+
if ( in_array( $attachment_id, $galleries_images_vc ) ) {
|
49 |
+
if ( $this->core->debug )
|
50 |
+
error_log( "Media {$attachment_id} found in a Visual Composer gallery" );
|
51 |
+
return true;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
// Check in WooCommerce Galleries
|
56 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
57 |
+
$galleries_images_wc = get_transient( "wpmc_galleries_images_woocommerce" );
|
58 |
+
if ( in_array( $attachment_id, $galleries_images_wc ) ) {
|
59 |
+
if ( $this->core->debug )
|
60 |
+
error_log( "Media {$attachment_id} found in a WooCommerce gallery" );
|
61 |
+
return true;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
// Check in standard WP Galleries
|
66 |
$file = $this->core->wpmc_clean_uploaded_filename( $file );
|
67 |
$uploads = wp_upload_dir();
|
68 |
$parsedURL = parse_url( $uploads['baseurl'] );
|
131 |
|
132 |
// Check in Posts Content
|
133 |
if ( get_option( 'wpmc_posts', true ) ) {
|
134 |
+
|
135 |
+
// Galleries in Visual Composer (WPBakery)
|
136 |
+
if ( class_exists( 'Vc_Manager' ) ) {
|
137 |
+
$posts_images_vc = get_transient( "wpmc_posts_images_visualcomposer" );
|
138 |
+
if ( in_array( $mediaId, $posts_images_vc ) ) {
|
139 |
+
if ( $this->core->debug )
|
140 |
+
error_log( "Media {$mediaId} found in post_content (Visual Composer)" );
|
141 |
+
return true;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
// Search through the CSS class
|
146 |
+
if ( !empty( $mediaId ) ) {
|
147 |
+
$sql = $wpdb->prepare( "SELECT ID
|
148 |
+
FROM $wpdb->posts
|
149 |
+
WHERE post_type <> 'revision'
|
150 |
+
AND post_type <> 'attachment'
|
151 |
+
AND post_content LIKE %s", "%wp-image-$mediaId%" );
|
152 |
+
$foundIds = $wpdb->get_col( $sql );
|
153 |
+
$this->core->last_analysis_ids = $foundIds;
|
154 |
+
$mediaCount = count( $foundIds );
|
155 |
+
if ( $this->core->debug && $mediaCount > 0 )
|
156 |
+
error_log( "Media {$mediaId} found in post_content, $mediaCount time(s)" );
|
157 |
+
if ( $mediaCount > 0 )
|
158 |
+
return true;
|
159 |
+
}
|
160 |
+
|
161 |
+
// Search through the filename
|
162 |
$file = $this->core->wpmc_clean_uploaded_filename( $file );
|
163 |
$uploads = wp_upload_dir();
|
164 |
$parsedURL = parse_url( $uploads['baseurl'] );
|
187 |
error_log( "File {$file} found in post_content, $mediaCount time(s)" );
|
188 |
if ( $mediaCount > 0 )
|
189 |
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
}
|
191 |
|
192 |
// Shortcode analysis
|