Version Description
- Update: Better and fresh new UI. The way it works was simplified while keeping the same features and giving more room for new ones. This is the biggest update to Media Cleaner ever :)
- Update: Create the DB for Cleaner automatically if needed.
Download this release
Release Info
Developer | TigrouMeow |
Plugin | Media Cleaner |
Version | 6.0.2 |
Comparing to | |
See all releases |
Code changes from version 6.0.1 to 6.0.2
- classes/admin.php +5 -3
- classes/core.php +1 -1
- classes/engine.php +1 -1
- classes/rest.php +4 -21
- classes/ui.php +14 -0
- common/admin.php +2 -2
- media-cleaner.php +2 -2
- readme.txt +19 -15
classes/admin.php
CHANGED
@@ -93,11 +93,12 @@ class Meow_WPMC_Admin extends MeowCommon_Admin {
|
|
93 |
return [
|
94 |
'wpmc_method' => get_option( 'wpmc_method', 'media' ),
|
95 |
'wpmc_content' => get_option( 'wpmc_content', true ),
|
96 |
-
'
|
|
|
97 |
'wpmc_live_content' => get_option( 'wpmc_live_content', false ),
|
98 |
'wpmc_debuglogs' => get_option( 'wpmc_debuglogs', false ),
|
99 |
-
'wpmc_images_only' => get_option( 'wpmc_images_only' ),
|
100 |
-
'wpmc_thumbnails_only' => get_option( 'wpmc_thumbnails_only' ),
|
101 |
'wpmc_dirs_filter' => get_option( 'wpmc_dirs_filter', '' ),
|
102 |
'wpmc_files_filter' => get_option( 'wpmc_files_filter', '' ),
|
103 |
'wpmc_hide_thumbnails' => get_option( 'wpmc_hide_thumbnails' ),
|
@@ -105,6 +106,7 @@ class Meow_WPMC_Admin extends MeowCommon_Admin {
|
|
105 |
'wpmc_medias_buffer' => get_option( 'wpmc_medias_buffer', 100 ),
|
106 |
'wpmc_posts_buffer' => get_option( 'wpmc_posts_buffer', 5 ),
|
107 |
'wpmc_analysis_buffer' => get_option( 'wpmc_analysis_buffer', 100 ),
|
|
|
108 |
'wpmc_delay' => get_option( 'wpmc_delay', 100 ),
|
109 |
'wpmc_shortcodes_disabled' => get_option( 'wpmc_shortcodes_disabled' ),
|
110 |
];
|
93 |
return [
|
94 |
'wpmc_method' => get_option( 'wpmc_method', 'media' ),
|
95 |
'wpmc_content' => get_option( 'wpmc_content', true ),
|
96 |
+
'wpmc_filesystem_content' => get_option( 'wpmc_filesystem_content', false ),
|
97 |
+
'wpmc_media_library' => get_option( 'wpmc_media_library', true ),
|
98 |
'wpmc_live_content' => get_option( 'wpmc_live_content', false ),
|
99 |
'wpmc_debuglogs' => get_option( 'wpmc_debuglogs', false ),
|
100 |
+
'wpmc_images_only' => get_option( 'wpmc_images_only', false ),
|
101 |
+
'wpmc_thumbnails_only' => get_option( 'wpmc_thumbnails_only', false ),
|
102 |
'wpmc_dirs_filter' => get_option( 'wpmc_dirs_filter', '' ),
|
103 |
'wpmc_files_filter' => get_option( 'wpmc_files_filter', '' ),
|
104 |
'wpmc_hide_thumbnails' => get_option( 'wpmc_hide_thumbnails' ),
|
106 |
'wpmc_medias_buffer' => get_option( 'wpmc_medias_buffer', 100 ),
|
107 |
'wpmc_posts_buffer' => get_option( 'wpmc_posts_buffer', 5 ),
|
108 |
'wpmc_analysis_buffer' => get_option( 'wpmc_analysis_buffer', 100 ),
|
109 |
+
'wpmc_file_op_buffer' => get_option( 'wpmc_file_op_buffer', 20 ),
|
110 |
'wpmc_delay' => get_option( 'wpmc_delay', 100 ),
|
111 |
'wpmc_shortcodes_disabled' => get_option( 'wpmc_shortcodes_disabled' ),
|
112 |
];
|
classes/core.php
CHANGED
@@ -55,7 +55,7 @@ class Meow_WPMC_Core {
|
|
55 |
|
56 |
// Only for REST
|
57 |
if ( $this->is_rest ) {
|
58 |
-
new Meow_WPMC_Rest( $this );
|
59 |
}
|
60 |
|
61 |
if ( is_admin() ) {
|
55 |
|
56 |
// Only for REST
|
57 |
if ( $this->is_rest ) {
|
58 |
+
new Meow_WPMC_Rest( $this, $this->admin );
|
59 |
}
|
60 |
|
61 |
if ( is_admin() ) {
|
classes/engine.php
CHANGED
@@ -55,7 +55,7 @@ SQL;
|
|
55 |
$check_content = get_option( 'wpmc_content', true );
|
56 |
}
|
57 |
else if ( $method === 'files' ) {
|
58 |
-
$check_content = get_option( 'wpmc_filesystem_content',
|
59 |
}
|
60 |
|
61 |
if ( $method == 'media' && !$check_content ) {
|
55 |
$check_content = get_option( 'wpmc_content', true );
|
56 |
}
|
57 |
else if ( $method === 'files' ) {
|
58 |
+
$check_content = get_option( 'wpmc_filesystem_content', false );
|
59 |
}
|
60 |
|
61 |
if ( $method == 'media' && !$check_content ) {
|
classes/rest.php
CHANGED
@@ -5,11 +5,12 @@ class Meow_WPMC_Rest
|
|
5 |
private $core = null;
|
6 |
private $namespace = 'media-cleaner/v1';
|
7 |
|
8 |
-
public function __construct( $core ) {
|
9 |
if ( !current_user_can( 'administrator' ) ) {
|
10 |
return;
|
11 |
}
|
12 |
$this->core = $core;
|
|
|
13 |
$this->engine = $core->engine;
|
14 |
add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
|
15 |
}
|
@@ -375,28 +376,10 @@ class Meow_WPMC_Rest
|
|
375 |
function rest_all_settings() {
|
376 |
return new WP_REST_Response( [
|
377 |
'success' => true,
|
378 |
-
'data' => [
|
379 |
-
'wpmc_method' => get_option( 'wpmc_method', 'media' ),
|
380 |
-
'wpmc_content' => get_option( 'wpmc_content', true ),
|
381 |
-
'wpmc_filesystem_content' => get_option( 'wpmc_filesystem_content', true ),
|
382 |
-
'wpmc_media_library' => get_option( 'wpmc_media_library'),
|
383 |
-
'wpmc_live_content' => get_option( 'wpmc_live_content', false ),
|
384 |
-
'wpmc_debuglogs' => get_option( 'wpmc_debuglogs', false ),
|
385 |
-
'wpmc_images_only' => get_option( 'wpmc_images_only' ),
|
386 |
-
'wpmc_thumbnails_only' => get_option( 'wpmc_thumbnails_only' ),
|
387 |
-
'wpmc_dirs_filter' => get_option( 'wpmc_dirs_filter', '' ),
|
388 |
-
'wpmc_files_filter' => get_option( 'wpmc_files_filter', '' ),
|
389 |
-
'wpmc_hide_thumbnails' => get_option( 'wpmc_hide_thumbnails' ),
|
390 |
-
'wpmc_hide_warning' => get_option( 'wpmc_hide_warning' ),
|
391 |
-
'wpmc_medias_buffer' => get_option( 'wpmc_medias_buffer', 100 ),
|
392 |
-
'wpmc_posts_buffer' => get_option( 'wpmc_posts_buffer', 5 ),
|
393 |
-
'wpmc_analysis_buffer' => get_option( 'wpmc_analysis_buffer', 100 ),
|
394 |
-
'wpmc_file_op_buffer' => get_option( 'wpmc_file_op_buffer', 20 ),
|
395 |
-
'wpmc_delay' => get_option( 'wpmc_delay', 100 ),
|
396 |
-
'wpmc_shortcodes_disabled' => get_option( 'wpmc_shortcodes_disabled' ),
|
397 |
'incompatible_plugins' => !class_exists( 'MeowPro_WPMC_Core' ) ? Meow_WPMC_Support::get_issues() : [],
|
398 |
'media_trash' => MEDIA_TRASH,
|
399 |
-
]
|
400 |
], 200 );
|
401 |
}
|
402 |
|
5 |
private $core = null;
|
6 |
private $namespace = 'media-cleaner/v1';
|
7 |
|
8 |
+
public function __construct( $core, $admin ) {
|
9 |
if ( !current_user_can( 'administrator' ) ) {
|
10 |
return;
|
11 |
}
|
12 |
$this->core = $core;
|
13 |
+
$this->admin = $admin;
|
14 |
$this->engine = $core->engine;
|
15 |
add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
|
16 |
}
|
376 |
function rest_all_settings() {
|
377 |
return new WP_REST_Response( [
|
378 |
'success' => true,
|
379 |
+
'data' => array_merge( $this->admin->get_all_options(), [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
'incompatible_plugins' => !class_exists( 'MeowPro_WPMC_Core' ) ? Meow_WPMC_Support::get_issues() : [],
|
381 |
'media_trash' => MEDIA_TRASH,
|
382 |
+
])
|
383 |
], 200 );
|
384 |
}
|
385 |
|
classes/ui.php
CHANGED
@@ -46,6 +46,20 @@ class Meow_WPMC_UI {
|
|
46 |
}
|
47 |
|
48 |
public function cleaner_dashboard() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
echo '<div id="wpmc-dashboard"></div>';
|
50 |
}
|
51 |
|
46 |
}
|
47 |
|
48 |
public function cleaner_dashboard() {
|
49 |
+
|
50 |
+
// Check the DB. If does not exist, let's create it.
|
51 |
+
// TODO: When PHP 7 only, let's clean this and use anonymous functions.
|
52 |
+
global $wpdb;
|
53 |
+
$table_scan = $wpdb->prefix . "mclean_refs";
|
54 |
+
$table_refs = $wpdb->prefix . "mclean_scan";
|
55 |
+
$db_init = !( strtolower( $wpdb->get_var( "SHOW TABLES LIKE '$table_scan'" ) ) != strtolower( $table_scan )
|
56 |
+
|| strtolower( $wpdb->get_var( "SHOW TABLES LIKE '$table_refs'" ) ) != strtolower( $table_refs ) );
|
57 |
+
if ( !$db_init ) {
|
58 |
+
wpmc_create_database();
|
59 |
+
$db_init = !( strtolower( $wpdb->get_var( "SHOW TABLES LIKE '$table_scan'" ) ) != strtolower( $table_scan )
|
60 |
+
|| strtolower( $wpdb->get_var( "SHOW TABLES LIKE '$table_refs'" ) ) != strtolower( $table_refs ) );
|
61 |
+
}
|
62 |
+
|
63 |
echo '<div id="wpmc-dashboard"></div>';
|
64 |
}
|
65 |
|
common/admin.php
CHANGED
@@ -148,11 +148,11 @@ if ( !class_exists( 'MeowCommon_Admin' ) ) {
|
|
148 |
function get_phperrorlogs() {
|
149 |
$errorpath = ini_get( 'error_log' );
|
150 |
$output_lines = array();
|
151 |
-
if ( !empty( $errorpath ) ) {
|
152 |
$file = new SplFileObject( $errorpath, 'r' );
|
153 |
$file->seek( PHP_INT_MAX );
|
154 |
$last_line = $file->key();
|
155 |
-
$iterator = new LimitIterator( $file, $last_line - 500, $last_line );
|
156 |
$lines = iterator_to_array( $iterator );
|
157 |
foreach ( $lines as $line ) {
|
158 |
$newline = '';
|
148 |
function get_phperrorlogs() {
|
149 |
$errorpath = ini_get( 'error_log' );
|
150 |
$output_lines = array();
|
151 |
+
if ( !empty( $errorpath ) && file_exists( $errorpath ) ) {
|
152 |
$file = new SplFileObject( $errorpath, 'r' );
|
153 |
$file->seek( PHP_INT_MAX );
|
154 |
$last_line = $file->key();
|
155 |
+
$iterator = new LimitIterator( $file, $last_line > 500 ? $last_line - 500 : 0, $last_line );
|
156 |
$lines = iterator_to_array( $iterator );
|
157 |
foreach ( $lines as $line ) {
|
158 |
$newline = '';
|
media-cleaner.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Media Cleaner
|
4 |
Plugin URI: https://meowapps.com
|
5 |
Description: Clean your WordPress from unused or broken media entries and files.
|
6 |
-
Version: 6.0.
|
7 |
Author: Jordy Meow
|
8 |
Author URI: https://meowapps.com
|
9 |
Text Domain: media-cleaner
|
@@ -13,7 +13,7 @@ Originally developed for two of my websites:
|
|
13 |
- Haikyo (https://haikyo.org)
|
14 |
*/
|
15 |
|
16 |
-
define( 'WPMC_VERSION', '6.0.
|
17 |
define( 'WPMC_PREFIX', 'wpmc' );
|
18 |
define( 'WPMC_DOMAIN', 'media-cleaner' );
|
19 |
define( 'WPMC_ENTRY', __FILE__ );
|
3 |
Plugin Name: Media Cleaner
|
4 |
Plugin URI: https://meowapps.com
|
5 |
Description: Clean your WordPress from unused or broken media entries and files.
|
6 |
+
Version: 6.0.2
|
7 |
Author: Jordy Meow
|
8 |
Author URI: https://meowapps.com
|
9 |
Text Domain: media-cleaner
|
13 |
- Haikyo (https://haikyo.org)
|
14 |
*/
|
15 |
|
16 |
+
define( 'WPMC_VERSION', '6.0.2' );
|
17 |
define( 'WPMC_PREFIX', 'wpmc' );
|
18 |
define( 'WPMC_DOMAIN', 'media-cleaner' );
|
19 |
define( 'WPMC_ENTRY', __FILE__ );
|
readme.txt
CHANGED
@@ -5,9 +5,9 @@ Donate link: https://commerce.coinbase.com/checkout/d047546a-77a8-41c8-9ea9-4a95
|
|
5 |
Requires at least: 4.8
|
6 |
Tested up to: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 6.0.
|
9 |
|
10 |
-
Clean your WordPress from unused or broken media entries and files.
|
11 |
|
12 |
== Description ==
|
13 |
|
@@ -19,19 +19,19 @@ For compatibility, Pro version and important information, please read this until
|
|
19 |
|
20 |
=== IMPORTANT ===
|
21 |
|
22 |
-
This tool
|
23 |
|
24 |
-
===
|
25 |
|
26 |
-
|
27 |
|
28 |
=== COMPATIBILITY ===
|
29 |
|
30 |
-
|
31 |
|
32 |
=== PRO VERSION ===
|
33 |
|
34 |
-
The Pro version adds Filesystem Analysis, extra support for complex plugins, Live Site option and WP-CLI support.
|
35 |
|
36 |
With the Filesystem Analysis, [Media Cleaner Pro](https://meowapps.com/plugin/media-cleaner/) scans your physical /uploads directory, and match it against the Media Library. It also has extra support for complex plugins, such as:
|
37 |
|
@@ -50,24 +50,24 @@ With the Filesystem Analysis, [Media Cleaner Pro](https://meowapps.com/plugin/me
|
|
50 |
|
51 |
The Live Site option will analyze the online version of your website, which might enhance the accuracy of the Cleaner in edge-cases.
|
52 |
|
53 |
-
Last but not least, [Media Cleaner Pro](https://meowapps.com/plugin/media-cleaner/) has support for WP-CLI. If you have direct access (SSH) to your server, you will be able to run the plugin at a much higher speed or have it
|
54 |
|
55 |
-
===
|
56 |
|
57 |
-
Better to be safe than sorry. This plugin deletes files! Therefore, backup is not only important, it is **
|
58 |
|
59 |
=== SPECIAL THANKS ===
|
60 |
|
61 |
-
- Mike Meinz, an amazing developer from the US who made a thorough debugging of the whole process,
|
62 |
- Satoshi Soma, an excellent Japanese developer.
|
63 |
-
- To all the users who helped me with reproducing issues and testing new plugins and
|
64 |
|
65 |
== Installation ==
|
66 |
|
67 |
1. Upload the plugin to WordPress.
|
68 |
-
2. Activate the plugin through the 'Plugins' menu in WordPress
|
69 |
-
3. Go
|
70 |
-
|
71 |
|
72 |
== Screenshots ==
|
73 |
|
@@ -75,6 +75,10 @@ Better to be safe than sorry. This plugin deletes files! Therefore, backup is no
|
|
75 |
|
76 |
== Changelog ==
|
77 |
|
|
|
|
|
|
|
|
|
78 |
= 6.0.1 =
|
79 |
* Update: Brings back errors management to the bulk actions (skip, skip all).
|
80 |
* Update: Prompt before emptying the trash.
|
5 |
Requires at least: 4.8
|
6 |
Tested up to: 5.5
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 6.0.2
|
9 |
|
10 |
+
Clean your WordPress Website from unused or broken media entries and files.
|
11 |
|
12 |
== Description ==
|
13 |
|
19 |
|
20 |
=== IMPORTANT ===
|
21 |
|
22 |
+
This tool cuts like a knife. Do not use this plugin if you don't have a recent backup, or if you don't understand what it does. This plugin does its best to help you. Learn how to use it and you will get awesome results.
|
23 |
|
24 |
+
=== HOW IT WORKS ===
|
25 |
|
26 |
+
Any files detected as not used will be listed in a specific dashboard. It will be up to you to delete them. Then, they will be moved to the plugin’s internal trash on the plugin. After more testing, you can restore those files from the trash, or you can delete them permanently.
|
27 |
|
28 |
=== COMPATIBILITY ===
|
29 |
|
30 |
+
This plugin works with any kind of media entry, including retina and/or WebP versions. The plugin has been tested on modern WordPress installs (Gutenberg included) as well as many older versions. The plugin has also been tested on various themes along with a community of thousands of users. It does support **WooCommerce**. If you are using complex plugins to handle the content of your website, **the Pro version might be required**. I am constantly increasing compatibility with other plugins.
|
31 |
|
32 |
=== PRO VERSION ===
|
33 |
|
34 |
+
The Pro version adds Filesystem Analysis, extra support for complex plugins, Live Site option and WP-CLI support.
|
35 |
|
36 |
With the Filesystem Analysis, [Media Cleaner Pro](https://meowapps.com/plugin/media-cleaner/) scans your physical /uploads directory, and match it against the Media Library. It also has extra support for complex plugins, such as:
|
37 |
|
50 |
|
51 |
The Live Site option will analyze the online version of your website, which might enhance the accuracy of the Cleaner in edge-cases.
|
52 |
|
53 |
+
Last but not least, [Media Cleaner Pro](https://meowapps.com/plugin/media-cleaner/) has support for WP-CLI. If you have direct access (SSH) to your server, you will be able to run the plugin at a much higher speed or have it run automatically, if you’d like.
|
54 |
|
55 |
+
=== BE CAREFUL: PREPARE A BACKUP ===
|
56 |
|
57 |
+
Better to be safe than sorry. This plugin deletes files! Therefore, backup is not only important, it is **required**. Do not use this plugin if you are not ready. I can't help you if you damage your media library permanently without a backup.
|
58 |
|
59 |
=== SPECIAL THANKS ===
|
60 |
|
61 |
+
- Mike Meinz, an amazing developer from the US who made a thorough debugging of the whole process, loaded a lot of corrections and optimizations and added support for more plugins.
|
62 |
- Satoshi Soma, an excellent Japanese developer.
|
63 |
+
- To all the users who helped me with reproducing issues and testing new plugins and page builders.
|
64 |
|
65 |
== Installation ==
|
66 |
|
67 |
1. Upload the plugin to WordPress.
|
68 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
69 |
+
3. Go to Meow Apps -> Cleaner in the sidebar and check the appropriate options.
|
70 |
+
4. Go to Media -> Cleaner.
|
71 |
|
72 |
== Screenshots ==
|
73 |
|
75 |
|
76 |
== Changelog ==
|
77 |
|
78 |
+
= 6.0.2 =
|
79 |
+
* Update: Better and fresh new UI. The way it works was simplified while keeping the same features and giving more room for new ones. This is the biggest update to Media Cleaner ever :)
|
80 |
+
* Update: Create the DB for Cleaner automatically if needed.
|
81 |
+
|
82 |
= 6.0.1 =
|
83 |
* Update: Brings back errors management to the bulk actions (skip, skip all).
|
84 |
* Update: Prompt before emptying the trash.
|