Media Cleaner - Version 6.4.4

Version Description

(2022/09/01) =

Download this release

Release Info

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

Code changes from version 6.4.3 to 6.4.4

Files changed (5) hide show
  1. classes/core.php +16 -4
  2. classes/rest.php +1 -1
  3. classes/ui.php +12 -7
  4. media-cleaner.php +2 -2
  5. readme.txt +3 -2
classes/core.php CHANGED
@@ -25,8 +25,8 @@ class Meow_WPMC_Core {
25
  public function __construct() {
26
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
27
  add_action( 'init', array( $this, 'init' ) );
28
- add_action( 'delete_attachment', array( $this, 'delete_or_trash_attachment' ), 10, 1 );
29
- add_action( 'trashed_post', array( $this, 'delete_or_trash_attachment' ), 10, 1 );
30
  }
31
 
32
  function plugins_loaded() {
@@ -142,7 +142,7 @@ class Meow_WPMC_Core {
142
  }
143
  }
144
 
145
- function delete_or_trash_attachment( $post_id ) {
146
  global $wpdb;
147
  $table_name = $wpdb->prefix . "mclean_scan";
148
  $wpdb->query( $wpdb->prepare( "DELETE FROM $table_name WHERE postId = %d", $post_id ) );
@@ -1081,6 +1081,11 @@ class Meow_WPMC_Core {
1081
  return true;
1082
  }
1083
 
 
 
 
 
 
1084
  $size = 0;
1085
  $countfiles = 0;
1086
  $check_broken_media = !$this->check_content;
@@ -1157,9 +1162,16 @@ class Meow_WPMC_Core {
1157
  $wpdb->query("TRUNCATE $table_name");
1158
  }
1159
 
 
 
 
 
 
 
 
1160
  function echo_issue( $issue ) {
1161
  if ( $issue == 'NO_CONTENT' ) {
1162
- _e( "Seems not use", 'media-cleaner' );
1163
  }
1164
  else if ( $issue == 'ORPHAN_FILE' ) {
1165
  _e( "Not in Library", 'media-cleaner' );
25
  public function __construct() {
26
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
27
  add_action( 'init', array( $this, 'init' ) );
28
+ add_action( 'delete_attachment', array( $this, 'delete_attachment_related_data' ), 10, 1 );
29
+ add_action( 'trashed_post', array( $this, 'delete_attachment_related_data' ), 10, 1 );
30
  }
31
 
32
  function plugins_loaded() {
142
  }
143
  }
144
 
145
+ function delete_attachment_related_data( $post_id ) {
146
  global $wpdb;
147
  $table_name = $wpdb->prefix . "mclean_scan";
148
  $wpdb->query( $wpdb->prepare( "DELETE FROM $table_name WHERE postId = %d", $post_id ) );
1081
  return true;
1082
  }
1083
 
1084
+ // Remove everything related to this media from the database.
1085
+ if ( !$checkOnly ) {
1086
+ $this->delete_attachment_related_data( $attachmentId );
1087
+ }
1088
+
1089
  $size = 0;
1090
  $countfiles = 0;
1091
  $check_broken_media = !$this->check_content;
1162
  $wpdb->query("TRUNCATE $table_name");
1163
  }
1164
 
1165
+ function get_issue_for_postId( $postId ) {
1166
+ global $wpdb;
1167
+ $table_name = $wpdb->prefix . "mclean_scan";
1168
+ $issue = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE postId = %d", $postId ), OBJECT );
1169
+ return $issue;
1170
+ }
1171
+
1172
  function echo_issue( $issue ) {
1173
  if ( $issue == 'NO_CONTENT' ) {
1174
+ _e( "Not found in content", 'media-cleaner' );
1175
  }
1176
  else if ( $issue == 'ORPHAN_FILE' ) {
1177
  _e( "Not in Library", 'media-cleaner' );
classes/rest.php CHANGED
@@ -490,7 +490,7 @@ class Meow_WPMC_Rest
490
  }
491
  $entry->thumbnail_url = $thumbnail;
492
  $entry->image_url = $image;
493
- $entry->title = get_the_title( $entry->postId );
494
  }
495
  }
496
 
490
  }
491
  $entry->thumbnail_url = $thumbnail;
492
  $entry->image_url = $image;
493
+ $entry->title = html_entity_decode( get_the_title( $entry->postId ) );
494
  }
495
  }
496
 
classes/ui.php CHANGED
@@ -62,7 +62,6 @@ class Meow_WPMC_UI {
62
  }
63
 
64
  function display_metabox( $post ) {
65
-
66
  // Search the references to the ID
67
  $originType = $this->core->reference_exists( null, $post->ID );
68
 
@@ -77,17 +76,23 @@ class Meow_WPMC_UI {
77
  }
78
  }
79
 
80
- // Resolve the readable name for this issue (if exists)
81
  if ( $originType ) {
82
- if ( array_key_exists( $originType, $this->foundTypes ) )
83
  echo $this->foundTypes[ $originType ];
84
- else
 
85
  echo "It seems to be used as: " . $originType;
 
 
86
  }
87
- // Otherwise just display the un-readable name
88
- else {
89
- echo "There is no information about this media in the Cleaner DB. It is either not in use, or the scan hasn't been ran.";
 
 
90
  }
 
 
91
  }
92
 
93
  function media_row_actions( $actions, $post ) {
62
  }
63
 
64
  function display_metabox( $post ) {
 
65
  // Search the references to the ID
66
  $originType = $this->core->reference_exists( null, $post->ID );
67
 
76
  }
77
  }
78
 
 
79
  if ( $originType ) {
80
+ if ( array_key_exists( $originType, $this->foundTypes ) ) {
81
  echo $this->foundTypes[ $originType ];
82
+ }
83
+ else {
84
  echo "It seems to be used as: " . $originType;
85
+ }
86
+ return;
87
  }
88
+
89
+ $issue = $this->core->get_issue_for_postId( $post->ID );
90
+ if ( $issue ) {
91
+ $this->core->echo_issue( $issue->issue );
92
+ return;
93
  }
94
+
95
+ echo "There is no information about this media in the Cleaner DB. It is either not in use, or the scan hasn't been ran.";
96
  }
97
 
98
  function media_row_actions( $actions, $post ) {
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.4.3
7
  Author: Jordy Meow
8
  Author URI: https://jordymeow.com
9
  Text Domain: media-cleaner
@@ -14,7 +14,7 @@ Originally developed for two of my websites:
14
  */
15
 
16
  if ( !defined( 'WPMC_VERSION' ) ) {
17
- define( 'WPMC_VERSION', '6.4.3' );
18
  define( 'WPMC_PREFIX', 'wpmc' );
19
  define( 'WPMC_DOMAIN', 'media-cleaner' );
20
  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.4.4
7
  Author: Jordy Meow
8
  Author URI: https://jordymeow.com
9
  Text Domain: media-cleaner
14
  */
15
 
16
  if ( !defined( 'WPMC_VERSION' ) ) {
17
+ define( 'WPMC_VERSION', '6.4.4' );
18
  define( 'WPMC_PREFIX', 'wpmc' );
19
  define( 'WPMC_DOMAIN', 'media-cleaner' );
20
  define( 'WPMC_ENTRY', __FILE__ );
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://meowapps.com/donation/
5
  Requires at least: 5.0
6
  Tested up to: 6.0.1
7
  Requires PHP: 7.0
8
- Stable tag: 6.4.3
9
 
10
  Clean your WordPress from unused files, broken media entries. Powerful engine and beautiful UI!
11
 
@@ -84,7 +84,8 @@ To make everything perfect, you will also need to clean and optimize your databa
84
 
85
  == Changelog ==
86
 
87
- = 6.4.3 (2022/08/20) =
 
88
  * Add: Auto-retry in the UI.
89
 
90
  = 6.4.2 (2022/08/03) =
5
  Requires at least: 5.0
6
  Tested up to: 6.0.1
7
  Requires PHP: 7.0
8
+ Stable tag: 6.4.4
9
 
10
  Clean your WordPress from unused files, broken media entries. Powerful engine and beautiful UI!
11
 
84
 
85
  == Changelog ==
86
 
87
+ = 6.4.4 (2022/09/01) =
88
+ = Fix: Avoid duplicate issues, even if a file is analyzed twice for some reason.
89
  * Add: Auto-retry in the UI.
90
 
91
  = 6.4.2 (2022/08/03) =