62% megaoptim-image-optimizer

Code Review | MegaOptim Image Optimizer

WordPress plugin MegaOptim Image Optimizer scored 62% from 54 tests.

About plugin

  • Plugin page: megaoptim-image-o...
  • Plugin version: 1.4.21
  • PHP compatiblity: 5.3+
  • PHP version: 7.4.16
  • WordPress compatibility: 3.6-6.3
  • WordPress version: 6.3.1
  • First release: Oct 5, 2018
  • Latest release: Jul 22, 2023
  • Number of updates: 103
  • Update frequency: every 17.0 days
  • Top authors: megaoptim (83.5%)DarkoG (17.48%)

Code review

54 tests

User reviews

32 reviews

Install metrics

200+ active / 9,153 total downloads

Benchmarks

Plugin footprint 65% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
Install script ran successfully

Server metrics [RAM: ▲0.19MB] [CPU: ▼3.65ms] Passed 4 tests

Server-side resources used by MegaOptim Image Optimizer
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /3.64 ▲0.1840.66 ▲0.32
Dashboard /wp-admin3.50 ▲0.1946.74 ▲2.02
Posts /wp-admin/edit.php3.55 ▲0.1944.31 ▼3.22
Add New Post /wp-admin/post-new.php6.10 ▲0.2183.53 ▼13.72
Media Library /wp-admin/upload.php3.42 ▲0.1937.94 ▲4.98
MegaOptim /wp-admin/options-general.php?page=megaoptim_settings3.5035.93
Bulk MegaOptim /wp-admin/upload.php?page=megaoptim_bulk_optimizer3.4835.68

Server storage [IO: ▲2.10MB] [DB: ▲0.00MB] Passed 3 tests

Analyzing filesystem and database footprints of this plugin
There were no storage issued detected upon installing this plugin
Filesystem: 228 new files
Database: 1 new table, 8 new options
New tables
wp_megaoptim_opt
New WordPress options
can_compress_scripts
db_upgraded
widget_recent-comments
theysaidso_admin_options
widget_recent-posts
megaoptim_settings_data
megaoptim_db_version
widget_theysaidso_widget

Browser metrics Passed 4 tests

MegaOptim Image Optimizer: an overview of browser usage
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,183 ▲44813.71 ▼0.681.78 ▼0.0243.42 ▼7.27
Dashboard /wp-admin2,589 ▲3984.95 ▲0.08109.48 ▲11.1755.24 ▲14.32
Posts /wp-admin/edit.php2,475 ▲3862.17 ▲0.2139.44 ▲2.2541.93 ▲6.48
Add New Post /wp-admin/post-new.php1,894 ▲36118.44 ▼4.66639.46 ▲17.5749.25 ▼11.12
Media Library /wp-admin/upload.php1,801 ▲4164.18 ▼0.01106.79 ▲6.4448.15 ▲5.97
MegaOptim /wp-admin/options-general.php?page=megaoptim_settings1,3502.3328.1743.67
Bulk MegaOptim /wp-admin/upload.php?page=megaoptim_bulk_optimizer1,3182.0026.2428.86

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

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
Please fix the following items
  • This plugin does not fully uninstall, leaving 1 table in the database
    • wp_megaoptim_opt
  • This plugin does not fully uninstall, leaving 8 options in the database
    • db_upgraded
    • megaoptim_settings_data
    • widget_recent-comments
    • megaoptim_db_version
    • can_compress_scripts
    • widget_recent-posts
    • widget_theysaidso_widget
    • theysaidso_admin_options

Smoke tests 25% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for server-side errors
Even though everything seems fine, this is not an exhaustive test

SRP 0% from 2 tests

🔹 Tests weight: 20 | It is important to ensure that your PHP files perform no action when accessed directly, respecting the single-responsibility principle
Almost there! Just fix the following items
  • 52× PHP files perform the task of outputting text when accessed with GET requests (only 10 are shown):
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/classes/Exceptions/MGO_Exception.php
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/classes/MGO_Ajax.php
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/views/modals/default.php
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/compat/mediapress/hooks/attachments.php
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/hooks/general.php
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/compat/nextgen-gallery/helpers.php
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/hooks/attachments.php
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/hooks/internal.php
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/compat/hosting/general/hooks.php
    • > /wp-content/plugins/megaoptim-image-optimizer/includes/compat/cloudflare/classes/MGO_CloudFlare.php
  • 35× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'MegaOptim\\Client\\Http\\BaseClient' not found in wp-content/plugins/megaoptim-image-optimizer/includes/libraries/megaoptim-php/src/Http/CurlClient.php:27
    • > PHP Fatal error
      Uncaught Error: Class 'MGO_BaseObject' not found in wp-content/plugins/megaoptim-image-optimizer/includes/classes/Adapters/MGO_Library.php:27
    • > PHP Fatal error
      Uncaught Error: Class 'Route' not found in wp-content/plugins/megaoptim-image-optimizer/assets/resources/jqueryfiletree/dist/connectors/PHP-Laravel/5/app/Http/routes.php:4
    • > PHP Fatal error
      Uncaught Error: Class 'WP_Background_Process' not found in wp-content/plugins/megaoptim-image-optimizer/includes/classes/Jobs/MGO_Background_Process.php:9
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/megaoptim-image-optimizer/includes/views/settings/key.php:2
    • > PHP Fatal error
      Uncaught Error: Call to undefined function admin_url() in wp-content/plugins/megaoptim-image-optimizer/includes/views/parts/header.php:6
    • > PHP Fatal error
      Uncaught Error: Class 'MGO_Library' not found in wp-content/plugins/megaoptim-image-optimizer/includes/classes/Adapters/MGO_FileLibrary.php:21
    • > PHP Fatal error
      Uncaught Error: Call to undefined function __() in wp-content/plugins/megaoptim-image-optimizer/includes/views/parts/footer.php:8
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/megaoptim-image-optimizer/includes/views/misc/instructions.php:5
    • > PHP Warning
      Use of undefined constant WP_MEGAOPTIM_INC_PATH - assumed 'WP_MEGAOPTIM_INC_PATH' (this will throw an Error in a future version of PHP) in wp-content/plugins/megaoptim-image-optimizer/includes/constants.php on line 7

User-side errors 0% from 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
Please fix the following user-side errors
    • > GET request to /wp-admin/upload.php?page=megaoptim_bulk_optimizer
    • > Javascript (severe) in unknown
    /wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=hoverIntent,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.3.1 3:1808 Uncaught TypeError: Cannot set properties of undefined (setting 'wrap')
    • > GET request to /wp-admin/upload.php?page=megaoptim_bulk_optimizer
    • > Javascript (severe) in unknown
    /wp-includes/js/dist/i18n.min.js?ver=7701b0c3857f914212ef 1:9103 Uncaught TypeError: Cannot read properties of undefined (reading 'hooks')
    • > GET request to /wp-admin/upload.php?page=megaoptim_bulk_optimizer
    • > Javascript (severe) in unknown
    /wp-admin/upload.php?page=megaoptim_bulk_optimizer 381:0 Uncaught ReferenceError: wp is not defined
    • > GET request to /wp-admin/upload.php?page=megaoptim_bulk_optimizer
    • > Javascript (severe) in unknown
    /wp-admin/js/common.min.js?ver=6.3.1 1:61 Uncaught ReferenceError: wp is not defined

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 94% from 16 tests

The readme.txt file is important because it is parsed by WordPress.org for the public listing of your plugin
Please fix the following attributes: You can look at the official readme.txt

megaoptim-image-optimizer/megaoptim.php 85% from 13 tests

This is the main PHP file of "MegaOptim Image Optimizer" version 1.4.21, providing information about the plugin in the header fields and serving as the principal entry point to the plugin's functions
Please make the necessary changes and fix the following:
  • Main file name: Even though not officially enforced, the main plugin file should be the same as the plugin slug ("megaoptim-image-optimizer.php" instead of "megaoptim.php")
  • Description: Please don't use more than 140 characters for the plugin description (currently 213 characters long)

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | This is an overview of programming languages used in this plugin; dangerous file extensions are not allowed
No dangerous file extensions were detected18,818 lines of code in 151 files:
LanguageFilesBlank linesComment linesLines of code
PHP1071,9195,7029,269
CSS7190563,618
SVG1002,671
JavaScript122814821,899
Markdown3970317
HTML13525269
LESS2195156
CoffeeScript12530147
JSON400119
Perl2332295
Go15049
JSP13838
C#210134
ASP.NET12029
Ruby172628
ASP121527
Python11519
Blade22017
Razor12017

PHP code Passed 2 tests

This is a short overview of cyclomatic complexity and code structure for this plugin
Great job! No cyclomatic complexity issues were detected in this plugin
Cyclomatic complexity
Average complexity per logical line of code0.39
Average class complexity19.21
▷ Minimum class complexity1.00
▷ Maximum class complexity202.00
Average method complexity3.28
▷ Minimum method complexity1.00
▷ Maximum method complexity33.00
Code structure
Namespaces8
Interfaces2
Traits0
Classes55
▷ Abstract classes814.55%
▷ Concrete classes4785.45%
▷ Final classes510.64%
Methods480
▷ Static methods6413.33%
▷ Public methods42889.17%
▷ Protected methods357.29%
▷ Private methods173.54%
Functions135
▷ Named functions13398.52%
▷ Anonymous functions21.48%
Constants94
▷ Global constants3537.23%
▷ Class constants5962.77%
▷ Public constants59100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

PNG files should be compressed to save space and minimize bandwidth usage
46 compressed PNG files occupy 0.13MB
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/resources/jqueryfiletree/dist/images/directory-lock.png0.65KB0.77KB0.00%
assets/resources/jqueryfiletree/dist/images/psd.png0.84KB0.88KB0.00%
assets/resources/jqueryfiletree/dist/images/file-lock.png0.60KB0.58KB▼ 2.77%
assets/resources/jquery-ui/images/ui-bg_glass_80_d7ebf9_1x400.png0.34KB0.16KB▼ 53.76%
assets/resources/jqueryfiletree/dist/images/music.png0.38KB0.61KB0.00%