FAQ

Remember to always check your PHP Error Logs. They contain the most important information related to issues your might encounter.

Common Questions

– js_composer: yes, it was used some time ago by Visual Editor, but not anymore
– wplr-tmp: yes, totally
– wpseo-redirects: if you are using redirections in Yoast SEO, you should not delete this
On WordPress, the fact an image is attached to something (in fact, it can only be attached to one and only one post type) doesn’t mean that it is actually being used. Media Cleaner, by default, doesn’t use this information. If you wish to mark the images are used if they are attached, please check the appropriate option in the settings.
When you analyze your Media Library, it’s the media entries which appear as issues. A media entry is not only one image: it is an original image + many thumbnails (and each of them corresponds to an image size, set in your WordPress). If you don’t know about this, I strongly recommend you to read my Article about Image Sizes and my Tutorial about Perfect Images.
The plugin has been already extremely optimized. Unfortunately, it now depends mainly on your WordPress install and your server. With PHP, for each page load (and therefore for each asynchronous requests, in the case of the plugin), WordPress loads itself every time. All the plugins are also being loaded and might even run a task. Media Cleaner cannot do anything about this fact. You can make it faster by checking out a few options, but you best chance is to enhance the system. I am trying to keep an article about accelerating WordPress here. Also, WP Cron might be a solution for you.
Yes, and… no 🙂 Media Cleaner does actually work, but the features are not available on the site master. Thus, it needs to be run independently on each site in order to be part of the technical environment of that specific site. As you might know by now, Media Cleaner actually really go through every small parts of your sites, and even triggers the other plugins and page builders in order to dig into their content. That is only possible this way. The only alternative is to use WP Cron.
It would be way too dangerous. A bad update, the page builder disabled temporary or another mishap and the WordPress install will be basically destroyed. So it’s better not. Also, having this running in the background would slow down the site every time a visitor would load the page (which is really isn’t good), might also crash. WordPress was not really made for running background tasks (it can only react to specific actions) so it’s better to avoid it with such a plugin as Media Cleaner.

That said, if you really want to run a scan in the background every once in a while, you can do it using WP-CLI, and manually create a task (cron tab) on your server. You can ask your developer or system administrator to do this.

Access Control (Roles)

By default, only the administror has access to the Cleaner Dashboard, and any user with the manage_options role (typically, the administrator) has access to the settings.

You can override the access to the Dashboard by adding a filter on wpmc_allow_usage. The following snippet will allow editors to access it.

add_filter( 'wpmc_allow_usage', function( $allow ) {
  return current_user_can( 'editor' ) || $allow;
} );

If you are interested in overring who can access the settings, you can add a filter on wpmc_allow_setup, it works exactly the same way.

Handling Issues for Developers

If you would like to handle special cases and additional detections of file usage, here are a few code snippets that you could use or adapt to your specific needs. You can add those snippets directly using the Code Snippets plugin (or add them into your functions.php file directly).

Images in category’s descriptions

add_action( 'wpmc_scan_once', 'wpmc_scan_once_post_categories', 10, 0 );

function wpmc_scan_once_post_categories() {
	global $wpdb;
	global $wpmc;
	$descs = $wpdb->get_col( "SELECT description FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'category'" );
	foreach ( $descs as $desc ) {
		$urls = $wpmc->get_urls_from_html( $desc );
		$wpmc->add_reference_url( $urls, 'CONTENT (URL)' );
	}
}

Overriding the Cleaner’s decisions

If you are a developer, you can have the last word on Media Cleaner’s decisions. For example, you might want to always set as used a Media which belongs to the administrator, or always set as non-used some filenames with contains the suffix tmp in it.

There are two hooks for this, and for both, you only need to return your final decision on the fact this media or file is being used.

Media Library Method

You need to hook into the wpmc_check_media filter. This hook will call you with those three arguments :

  • $in_use: The Media Cleaner decision.
  • $media_id: The Media ID.
  • $is_broken: If the physical file doesn’t exist.

Let’s say my user ID is 10, and I would like Media Cleaner to suppose that all my images are indeed in use. I could add the following custom snippet.

​add_filter( 'wpmc_check_media', function( $in_use, $media_id, $is_broken ) {
  $post = get_post( $media_id );
  if ( $post->post_author === 1 ) {
    return true;
  }
  return $in_use;
}, 10, 3 );

Filesystem Method

You need to hook into the wpmc_check_file filter. This hook will call you with those two arguments :

  • $in_use: The Media Cleaner decision.
  • $file: The filepath.

Now here is the example of a code snippet that will mark all the .doc files as in-use.

add_filter( 'wpmc_check_file', function( $in_use, $file ) {
  $ext = pathinfo( $file, PATHINFO_EXTENSION );
  if ( $ext === 'doc' ) {
    return true;
  }
  return $in_use;
}, 10, 2);