72% media-hygiene

Code Review | Media Hygiene: Remove or Delete Unused Images and More!

WordPress plugin Media Hygiene: Remove or Delete Unused Images and More! scored72%from 54 tests.

About plugin

  • Plugin page: media-hygiene
  • Plugin version: 2.0.0
  • PHP compatiblity: 7.4+
  • PHP version: 7.4.16
  • WordPress compatibility: 5.3-6.4.1
  • WordPress version: 6.3.1
  • First release: Apr 6, 2023
  • Latest release: Nov 20, 2023
  • Number of updates: 36
  • Update frequency: every 6.8 days
  • Top authors: slui (100%)

Code review

54 tests

User reviews

10 reviews

Install metrics

800+ active /4,837 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | All plugins must install correctly, without throwing any errors, warnings, or notices
The plugin installed gracefully, with no errors

Server metrics [RAM: ▲0.57MB] [CPU: ▼2.07ms] Passed 4 tests

Analyzing server-side resources used by Media Hygiene: Remove or Delete Unused Images and More!
This plugin has minimal impact on server resources
PageMemory (MB)CPU Time (ms)
Home /4.19 ▲0.7238.66 ▼1.38
Dashboard /wp-admin3.91 ▲0.5649.12 ▼12.63
Posts /wp-admin/edit.php3.96 ▲0.6051.24 ▲2.32
Add New Post /wp-admin/post-new.php6.45 ▲0.5694.80 ▲10.25
Media Library /wp-admin/upload.php3.77 ▲0.5438.94 ▲3.42
Dashboard /wp-admin/admin.php?page=wmh-media-hygiene3.9543.51
Settings /wp-admin/admin.php?page=wmh-settings3.8338.51
Get Help /wp-admin/admin.php?page=wmh-get-help3.7641.38

Server storage [IO: ▲3.67MB] [DB: ▲0.01MB] Passed 3 tests

Filesystem and database footprint
There were no storage issued detected upon installing this plugin
Filesystem: 86 new files
Database: 7 new tables, 7 new options
New tables
wp_wmh_used_media_post_id
wp_wmh_temp
wp_wmh_save_scan_content
wp_wmh_whitelist_media_post_id
wp_wmh_deleted_media
wp_wmh_unused_media_post_id
wp_wmh_error_log
New WordPress options
widget_recent-comments
theysaidso_admin_options
db_upgraded
wmh_send_data_to_server_permission
can_compress_scripts
widget_recent-posts
widget_theysaidso_widget

Browser metrics Passed 4 tests

Media Hygiene: Remove or Delete Unused Images and More!: an overview of browser usage
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,942 ▲18013.29 ▼1.411.72 ▲0.0228.59 ▼14.43
Dashboard /wp-admin2,350 ▲1705.07 ▼0.57105.62 ▲6.2943.81 ▲6.40
Posts /wp-admin/edit.php2,261 ▲1612.41 ▲0.3852.12 ▲13.3637.77 ▼0.76
Add New Post /wp-admin/post-new.php1,648 ▲10323.46 ▼1.51622.76 ▼50.1835.92 ▼29.31
Media Library /wp-admin/upload.php1,550 ▲1564.74 ▲0.53106.48 ▲8.0245.70 ▲2.81
Dashboard /wp-admin/admin.php?page=wmh-media-hygiene2,2218.68104.5196.44
Settings /wp-admin/admin.php?page=wmh-settings2,0339.19100.1349.05
Get Help /wp-admin/admin.php?page=wmh-get-help1,68212.83326.3460.95

Uninstaller [IO: ▲0.00MB] [DB: ▲0.00MB] 75% from 4 tests

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
The following items require your attention
  • This plugin does not fully uninstall, leaving 6 options in the database
    • theysaidso_admin_options
    • widget_recent-comments
    • widget_recent-posts
    • widget_theysaidso_widget
    • db_upgraded
    • can_compress_scripts

Smoke tests 25% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the server (in the Apache logs)
The smoke test was a success, however most plugin functionality was not tested

SRP 0% from 2 tests

🔹 Tests weight: 20 | SRP (Single-Responsibility Principle) - PHP files must act as libraries and never output text or perform any action when accessed directly in a browser
Please take a closer look at the following
  • 19× PHP files output non-empty strings when accessed directly via GET requests (only 10 are shown):
    • > /wp-content/plugins/media-hygiene/includes/wmh-settings.php
    • > /wp-content/plugins/media-hygiene/templates/admin/wmh-media-hygiene-view.php
    • > /wp-content/plugins/media-hygiene/class/admin/wmh-vc.php
    • > /wp-content/plugins/media-hygiene/class/admin/wmh-elementor.php
    • > /wp-content/plugins/media-hygiene/class/admin/wmh-divi.php
    • > /wp-content/plugins/media-hygiene/templates/admin/wmh-settings-view.php
    • > /wp-content/plugins/media-hygiene/templates/admin/wmh-dashboard-view.php
    • > /wp-content/plugins/media-hygiene/media-hygiene.php
    • > /wp-content/plugins/media-hygiene/class/admin/wmh-enfold.php
    • > /wp-content/plugins/media-hygiene/class/admin/wmh-bricks.php
  • 18× PHP files trigger errors when accessed directly with GET requests (only 10 are shown):
    • > PHP Warning
      Use of undefined constant MH_FILE_PATH - assumed 'MH_FILE_PATH' (this will throw an Error in a future version of PHP) in wp-content/plugins/media-hygiene/templates/admin/wmh-deleted-media-view.php on line 3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/media-hygiene/templates/admin/wmh-plugin-feedback-view.php:3
    • > PHP Notice
      Trying to get property 'prefix' of non-object in wp-content/plugins/media-hygiene/templates/admin/wmh-button-view.php on line 4
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/media-hygiene/templates/admin/wmh-filter-view.php:31
    • > PHP Fatal error
      Uncaught Error: Call to a member function get_row() on null in wp-content/plugins/media-hygiene/templates/admin/wmh-button-view.php:38
    • > PHP Notice
      Trying to get property 'prefix' of non-object in wp-content/plugins/media-hygiene/templates/admin/wmh-new-media-info-view.php on line 4
    • > PHP Fatal error
      Uncaught Error: Class 'wmh_general' not found in wp-content/plugins/media-hygiene/templates/admin/wmh-error-log-view.php:4
    • > PHP Fatal error
      require_once(): Failed opening required 'ABSPATHwp-admin/includes/plugin.php' (include_path='.:/usr/share/php') in wp-content/plugins/media-hygiene/uninstall.php on line 3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_option() in wp-content/plugins/media-hygiene/templates/admin/wmh-new-media-info-view.php:7
    • > PHP Fatal error
      Uncaught Error: Call to undefined function admin_url() in wp-content/plugins/media-hygiene/templates/admin/wmh-header-view.php:4

User-side errors 0% from 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
These are user-side errors you should fix
    • > GET request to /wp-admin/admin.php?page=wmh-get-help
    • > Other (warning) in unknown
    /wp-admin/admin.php?page=wmh-get-help 227 Unrecognized feature: 'web-share'.

Optimizations

Plugin configuration 97% from 29 tests

readme.txt 94% from 16 tests

Often overlooked, readme.txt is one of the most important files in your plugin
Please fix the following attributes:
  • Tags: You are using too many tags: 13 tag instead of maximum 10
The official readme.txt might help

media-hygiene/media-hygiene.php Passed 13 tests

The primary PHP file in "Media Hygiene: Remove or Delete Unused Images and More!" version 2.0.0 is used by WordPress to initiate all plugin functionality
76 characters long description:
A plugin to remove unused media from WordPress and free up space on hosting.

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | This is an overview of file extensions present in this plugin and a short test that no dangerous files are bundled with this plugin
Everything looks great! No dangerous files found in this plugin6,780 lines of code in 45 files:
LanguageFilesBlank linesComment linesLines of code
PHP307165314,962
JavaScript76077920
CSS718242897
SVG1001

PHP code 50% from 2 tests

A brief analysis of cyclomatic complexity and code structure for this plugin
Please fix the following
  • Cyclomatic complexity of methods has to be reduced to less than 100 (currently 103)
Cyclomatic complexity
Average complexity per logical line of code0.36
Average class complexity36.00
▷ Minimum class complexity2.00
▷ Maximum class complexity252.00
Average method complexity6.17
▷ Minimum method complexity1.00
▷ Maximum method complexity103.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes17
▷ Abstract classes00.00%
▷ Concrete classes17100.00%
▷ Final classes00.00%
Methods115
▷ Static methods00.00%
▷ Public methods115100.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions2
▷ Named functions2100.00%
▷ Anonymous functions00.00%
Constants6
▷ Global constants6100.00%
▷ Class constants00.00%
▷ Public constants00.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

PNG files should be compressed to save space and minimize bandwidth usage
12 PNG files occupy 0.15MB with 0.10MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
media/woocommerce.png10.09KB3.62KB▼ 64.14%
media/wpbackery.png16.23KB6.48KB▼ 60.05%
media/divi.png10.95KB4.15KB▼ 62.09%
media/wpml.png10.44KB3.77KB▼ 63.86%
media/acf.png11.28KB3.72KB▼ 67.04%