83% wordpress-random-image

Code Review | Wordpress Random Image

WordPress plugin Wordpress Random Image scored83%from 54 tests.

About plugin

  • Plugin page: wordpress-random-...
  • Plugin version: 2.0
  • PHP version: 7.4.16
  • WordPress compatibility: 3.0-3.8.1
  • WordPress version: 6.3.1
  • First release: Apr 4, 2012
  • Latest release: Nov 16, 2016
  • Number of updates: 8
  • Update frequency: every 211.0 days
  • Top authors: mervinpraison (100%)

Code review

54 tests

User reviews

7 reviews

Install metrics

600+ active /19,110 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
Install script ran successfully

Server metrics [RAM: ▲0.00MB] [CPU: ▼13.79ms] Passed 4 tests

Analyzing server-side resources used by Wordpress Random Image
This plugin has minimal impact on server resources
PageMemory (MB)CPU Time (ms)
Home /3.48 ▲0.0146.49 ▲5.36
Dashboard /wp-admin3.32 ▼0.0352.29 ▼19.25
Posts /wp-admin/edit.php3.37 ▲0.0148.77 ▼4.08
Add New Post /wp-admin/post-new.php5.90 ▲0.0185.89 ▼32.81
Media Library /wp-admin/upload.php3.25 ▲0.0138.62 ▲0.98

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

Input-output and database impact of this plugin
No storage issues were detected
Filesystem: 6 new files
Database: no new tables, 6 new options
New WordPress options
widget_recent-posts
widget_theysaidso_widget
theysaidso_admin_options
widget_recent-comments
db_upgraded
can_compress_scripts

Browser metrics Passed 4 tests

Wordpress Random Image: an overview of browser usage
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,789 ▲314.25 ▼0.351.62 ▼0.1042.87 ▼1.67
Dashboard /wp-admin2,198 ▲275.57 ▲0.0481.73 ▼4.7040.02 ▼5.15
Posts /wp-admin/edit.php2,100 ▼02.12 ▲0.1137.06 ▲0.8333.92 ▼6.29
Add New Post /wp-admin/post-new.php1,526 ▼223.55 ▲0.44695.73 ▲27.6752.31 ▼6.66
Media Library /wp-admin/upload.php1,397 ▼34.20 ▼0.0397.63 ▼19.8243.20 ▼3.06

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

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
You still need to fix the following
  • This plugin does not fully uninstall, leaving 6 options in the database
    • db_upgraded
    • can_compress_scripts
    • widget_theysaidso_widget
    • widget_recent-comments
    • widget_recent-posts
    • theysaidso_admin_options

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no server-side errors were triggered
Even though everything seems fine, this is not an exhaustive test

SRP 50% from 2 tests

🔹 Tests weight: 20 | The single-responsibility principle applies for WordPress plugins as well - please make sure your PHP files perform no actions when accessed directly
The following issues need your attention
  • 7× PHP files trigger server-side errors or warnings when accessed directly:
    • > PHP Warning
      include(WP_PLUGIN_DIR/wordpress-random-image/random-image-class-id.php): failed to open stream: No such file or directory in wp-content/plugins/wordpress-random-image/random-image.php on line 48
    • > PHP Warning
      include(): Failed opening 'WP_PLUGIN_DIR/wordpress-random-image/random-image-class.php' for inclusion (include_path='.:/usr/share/php') in wp-content/plugins/wordpress-random-image/random-image.php on line 47
    • > PHP Warning
      include(WP_PLUGIN_DIR/wordpress-random-image/random-image-class.php): failed to open stream: No such file or directory in wp-content/plugins/wordpress-random-image/random-image.php on line 47
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_shortcode() in wp-content/plugins/wordpress-random-image/random-image.php:59
    • > PHP Warning
      include(): Failed opening 'WP_PLUGIN_DIR/wordpress-random-image/random-image-class-id.php' for inclusion (include_path='.:/usr/share/php') in wp-content/plugins/wordpress-random-image/random-image.php on line 48
    • > PHP Warning
      Use of undefined constant WP_PLUGIN_DIR - assumed 'WP_PLUGIN_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/wordpress-random-image/random-image.php on line 47
    • > PHP Warning
      Use of undefined constant WP_PLUGIN_DIR - assumed 'WP_PLUGIN_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/wordpress-random-image/random-image.php on line 48

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
Everything seems fine, but this is not an exhaustive test

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 94% from 16 tests

It's important to format your readme.txt file correctly as it is parsed for the public listing of your plugin
Please fix the following attributes:
  • Screenshots: These screenshots require images: #1 (Finding Attachment ID), #2 (Default Wordpress Gallery Option ( Images from this Gallery will get displayed Randomly on using the shortcode [random-image])
The official readme.txt might help

wordpress-random-image/random-image.php 85% from 13 tests

The main PHP script in "Wordpress Random Image" version 2.0 is automatically included on every request by WordPress
You should first fix the following items:
  • Main file name: Even though not officially enforced, the main plugin file should be the same as the plugin slug ("wordpress-random-image.php" instead of "random-image.php")
  • Description: The description should be shorter than 140 characters (currently 154 characters long)

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short glimpse at programming languages used with this plugin and a check that no dangerous files are present
There were no executable files found in this plugin105 lines of code in 3 files:
LanguageFilesBlank linesComment linesLines of code
PHP37355105

PHP code Passed 2 tests

This plugin's cyclomatic complexity and code structure detailed below
All good! No complexity issues found
Cyclomatic complexity
Average complexity per logical line of code0.39
Average class complexity8.00
▷ Minimum class complexity8.00
▷ Maximum class complexity8.00
Average method complexity1.00
▷ Minimum method complexity1.00
▷ Maximum method complexity1.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes1
▷ Abstract classes00.00%
▷ Concrete classes1100.00%
▷ Final classes00.00%
Methods2
▷ Static methods00.00%
▷ Public methods2100.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions4
▷ Named functions4100.00%
▷ Anonymous functions00.00%
Constants5
▷ Global constants5100.00%
▷ Class constants00.00%
▷ Public constants00.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
2 PNG files occupy 0.20MB with 0.13MB in potential savings
Potential savings
Compression of 2 random PNG files using pngquant
FileSize - originalSize - compressedSavings
screenshot-1.png89.44KB26.01KB▼ 70.92%
screenshot-2.png113.46KB50.77KB▼ 55.25%