84% woocommerce-discounts-plus

Code Review | Discounts Manager for Products

WordPress plugin Discounts Manager for Products scored84%from 54 tests.

About plugin

  • Plugin page: woocommerce-disco...
  • Plugin version: 3.5.0
  • PHP compatiblity: 7.0+
  • PHP version: 7.4.16
  • WordPress compatibility: 3.5-6.2
  • WordPress version: 6.3.1
  • First release: Nov 29, 2014
  • Latest release: May 19, 2023
  • Number of updates: 144
  • Update frequency: every 21.5 days
  • Top authors: fahadmahmood (100%)

Code review

54 tests

User reviews

23 reviews

Install metrics

200+ active /46,022 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
The plugin installed successfully, without throwing any errors or notices

Server metrics [RAM: ▲0.01MB] [CPU: ▼5.76ms] Passed 4 tests

A check of server-side resources used by Discounts Manager for Products
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /3.60 ▲0.1436.11 ▼5.98
Dashboard /wp-admin3.31 ▲0.0144.01 ▼7.82
Posts /wp-admin/edit.php3.36 ▲0.0147.41 ▲0.44
Add New Post /wp-admin/post-new.php5.89 ▲0.0190.46 ▼7.67
Media Library /wp-admin/upload.php3.24 ▲0.0132.23 ▼1.57

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

A short overview of filesystem and database impact
There were no storage issued detected upon installing this plugin
Filesystem: 42 new files
Database: no new tables, 6 new options
New WordPress options
db_upgraded
widget_recent-comments
widget_recent-posts
widget_theysaidso_widget
can_compress_scripts
theysaidso_admin_options

Browser metrics Passed 4 tests

Checking browser requirements for Discounts Manager for Products
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,800 ▲5413.20 ▼1.221.60 ▼0.2937.49 ▼4.75
Dashboard /wp-admin2,203 ▲185.91 ▲1.05105.07 ▲1.6536.48 ▼5.18
Posts /wp-admin/edit.php2,092 ▲32.04 ▼0.0239.78 ▲3.4235.40 ▲3.12
Add New Post /wp-admin/post-new.php1,514 ▼2117.62 ▼5.63581.90 ▼93.6052.96 ▼3.94
Media Library /wp-admin/upload.php1,388 ▲34.22 ▲0.0292.99 ▼5.0639.88 ▼4.98

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
Please fix the following items
  • This plugin does not fully uninstall, leaving 6 options in the database
    • widget_theysaidso_widget
    • widget_recent-comments
    • widget_recent-posts
    • theysaidso_admin_options
    • db_upgraded
    • can_compress_scripts

Smoke tests 75% 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)
Good news, no errors were detected

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
Please fix the following items
  • 9× PHP files trigger server errors when accessed directly:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_nonce_field() in wp-content/plugins/woocommerce-discounts-plus/inc/templates/wcdp_error_message.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_nonce_field() in wp-content/plugins/woocommerce-discounts-plus/inc/templates/wcdp_category.php:6
    • > PHP Fatal error
      Uncaught Error: Call to a member function init_form_fields() on null in wp-content/plugins/woocommerce-discounts-plus/inc/templates/wcdp_general_settings.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'wdp_core_factory' not found in wp-content/plugins/woocommerce-discounts-plus/inc/classes/Woo_Discounts_Plus_Plugin.php:7
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/woocommerce-discounts-plus/inc/templates/wcdp_product_criteria.php:9
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/woocommerce-discounts-plus/inc/templates/wdp_woo_tab.php:30
    • > PHP Fatal error
      Uncaught Error: Call to undefined function current_user_can() in wp-content/plugins/woocommerce-discounts-plus/inc/settings.php:14
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_nonce_field() in wp-content/plugins/woocommerce-discounts-plus/inc/templates/wcdp_global_criteria.php:6
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_nonce_field() in wp-content/plugins/woocommerce-discounts-plus/inc/templates/wcdp_cart_criteria.php:6

User-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
Everything seems fine on the user side

Optimizations

Plugin configuration 93% from 29 tests

readme.txt Passed 16 tests

The readme.txt file is important because it is parsed by WordPress.org for the public listing of your plugin
7 plugin tags: cart discount, woocommerce discount, discounts, criteria, order discount...

woocommerce-discounts-plus/index.php 85% from 13 tests

"Discounts Manager for Products" version 3.5.0's primary PHP file adds more information about the plugin and serves as the entry point for WordPress
The following require your attention:
  • Text Domain: You no longer need to specify the text domain since WordPress 4.6; it must be the same as the plugin slug
  • Main file name: Even though not officially enforced, the main plugin file should be the same as the plugin slug ("woocommerce-discounts-plus.php" instead of "index.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | Executable files are not allowed as they can serve as attack vectors
No dangerous file extensions were detected5,184 lines of code in 23 files:
LanguageFilesBlank linesComment linesLines of code
PHP131,6047553,242
PO File35106881,310
CSS4719423
JavaScript39012209

PHP code Passed 2 tests

This is a very shot review of cyclomatic complexity and code structure
No complexity issues detected
Cyclomatic complexity
Average complexity per logical line of code0.51
Average class complexity194.50
▷ Minimum class complexity1.00
▷ Maximum class complexity388.00
Average method complexity8.90
▷ Minimum method complexity1.00
▷ Maximum method complexity45.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes2
▷ Abstract classes150.00%
▷ Concrete classes150.00%
▷ Final classes00.00%
Methods50
▷ Static methods00.00%
▷ Public methods4284.00%
▷ Protected methods816.00%
▷ Private methods00.00%
Functions42
▷ Named functions42100.00%
▷ Anonymous functions00.00%
Constants0
▷ Global constants00.00%
▷ Class constants00.00%
▷ Public constants00.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Using a strong compression for your PNG files is a great way to speed-up your plugin
9 PNG files occupy 0.17MB with 0.10MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
images/flat-percent.png2.68KB1.25KB▼ 53.21%
images/character-with-case.png22.93KB6.70KB▼ 70.79%
images/email+invoice.png3.87KB2.70KB▼ 30.23%
images/still-anim-sprite.png27.16KB8.07KB▼ 70.29%
images/still-sprite.png31.38KB10.49KB▼ 66.57%