62% amadiscount

Code Review | AmaDiscount Plugin

WordPress plugin AmaDiscount Plugin scored62%from 54 tests.

About plugin

  • Plugin page: amadiscount
  • Plugin version: 1.0
  • PHP version: 7.4.16
  • WordPress compatibility: 2.7-4.1.3
  • WordPress version: 6.3.1
  • First release: Nov 12, 2015
  • Latest release: Nov 12, 2015
  • Number of updates: 5
  • Update frequency: every 0.2 days
  • Top authors: colinph970 (100%)

Code review

54 tests

User reviews

3 reviews

Install metrics

10+ active /1,101 total downloads

Benchmarks

Plugin footprint 65% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
Install script ran successfully

Server metrics [RAM: ▲0.09MB] [CPU: ▼7.30ms] Passed 4 tests

Server-side resources used by AmaDiscount Plugin
This plugin has minimal impact on server resources
PageMemory (MB)CPU Time (ms)
Home /3.57 ▲0.1144.23 ▲3.42
Dashboard /wp-admin3.41 ▲0.0650.83 ▼12.83
Posts /wp-admin/edit.php3.46 ▲0.1048.80 ▼2.48
Add New Post /wp-admin/post-new.php5.99 ▲0.1092.94 ▼8.78
Media Library /wp-admin/upload.php3.33 ▲0.1035.58 ▼5.12
AmaDiscount Config /wp-admin/admin.php?page=adp_config3.3134.21
AmaDiscount Search /wp-admin/admin.php?page=adp_search3.3436.84

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

Input-output and database impact of this plugin
This plugin installed successfully
Filesystem: 20 new files
Database: 3 new tables, 6 new options
New tables
wp_adp_config
wp_adp_search
wp_adp_result
New WordPress options
widget_theysaidso_widget
db_upgraded
widget_recent-comments
can_compress_scripts
theysaidso_admin_options
widget_recent-posts

Browser metrics Passed 4 tests

An overview of browser requirements for AmaDiscount Plugin
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,844 ▲8313.26 ▼1.101.66 ▼0.1043.37 ▼2.20
Dashboard /wp-admin2,250 ▲435.86 ▲0.90109.62 ▲0.9946.59 ▲7.25
Posts /wp-admin/edit.php2,126 ▲262.05 ▼0.0135.62 ▼4.6034.63 ▼3.18
Add New Post /wp-admin/post-new.php1,564 ▲3323.24 ▼0.04639.68 ▼21.6251.43 ▼3.03
Media Library /wp-admin/upload.php1,429 ▲294.22 ▼0.0396.97 ▼6.7444.12 ▼0.44
AmaDiscount Config /wp-admin/admin.php?page=adp_config9132.0523.7230.21
AmaDiscount Search /wp-admin/admin.php?page=adp_search1,1732.2750.7232.71

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

🔸 Tests weight: 35 | The uninstall procedure must remove all plugin files and extra database tables
You still need to fix the following
  • Zombie tables detected upon uninstall: 3 tables
    • wp_adp_search
    • wp_adp_result
    • wp_adp_config
  • This plugin did not uninstall successfully, leaving 6 options in the database
    • theysaidso_admin_options
    • can_compress_scripts
    • widget_theysaidso_widget
    • db_upgraded
    • widget_recent-comments
    • widget_recent-posts

Smoke tests 25% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | This is a short smoke test looking for server-side errors
These server-side errors were triggered
    • > GET request to /wp-admin/admin.php?page=adp_search
    • > POST request to /wp-admin/admin-ajax.php
    • > Notice in wp-content/plugins/amadiscount/adp_functions.php+209
    Trying to get property 'country_code' of non-object
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=adp_search
    • > POST request to /wp-admin/admin-ajax.php
    • > Warning in wp-content/plugins/amadiscount/adp_functions.php+259
    file_get_contents(http://docs.aws.amazon.com/AWSECommerceService/latest/DG/LocaleUS.html): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden

SRP 50% 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
Almost there! Just fix the following items
  • 4× GET requests to PHP files trigger server-side errors or Error 500 responses:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_enqueue_script() in wp-content/plugins/amadiscount/adp_search.php:2
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_option() in wp-content/plugins/amadiscount/adp_functions.php:15
    • > PHP Warning
      Use of undefined constant adp_TABLE_PREFIX - assumed 'adp_TABLE_PREFIX' (this will throw an Error in a future version of PHP) in wp-content/plugins/amadiscount/adp_config.php on line 38
    • > PHP Fatal error
      Uncaught Error: Call to a member function get_results() on null in wp-content/plugins/amadiscount/adp_config.php:39

User-side errors 0% from 1 test

🔹 Test weight: 20 | This is just a short smoke test looking for browser issues
There are user-side issues you should fix
    • > GET request to /wp-admin/admin.php?page=adp_search
    • > Network (severe)
    wp-content/plugins/amadiscount/images/ui-bg_flat_75_ffffff_40x100.png - Failed to load resource: the server responded with a status of 404 (Not Found)
    • > GET request to /wp-admin/admin.php?page=adp_search
    • > Network (severe)
    wp-content/plugins/amadiscount/images/ui-bg_highlight-soft_75_cccccc_1x100.png - Failed to load resource: the server responded with a status of 404 (Not Found)
    • > GET request to /wp-admin/admin.php?page=adp_search
    • > Network (severe)
    wp-content/plugins/amadiscount/images/ui-bg_glass_75_e6e6e6_1x400.png - Failed to load resource: the server responded with a status of 404 (Not Found)
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=adp_search
    • > Javascript (severe) in unknown
    /wp-admin/admin.php?page=adp_search 257:39 Uncaught TypeError: Cannot read properties of undefined (reading 'cat')
    • > GET request to /wp-admin/admin.php?page=adp_search
    • > Network (severe)
    http://pluginhandy.com/amazondiscount/wp-content/uploads/2015/10/Screen-Shot-2015-10-10-at-12.25.30.png - Failed to load resource: the server responded with a status of 403 (Forbidden)

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 94% from 16 tests

Often overlooked, readme.txt is one of the most important files in your plugin
These attributes need your attention:
  • Tags: You are using too many tags: 12 tag instead of maximum 10
You can take inspiration from this readme.txt

amadiscount/adp_functions.php 85% from 13 tests

The main file in "AmaDiscount Plugin" v. 1.0 serves as a complement to information provided in readme.txt and as the entry point to the plugin
Please make the necessary changes and fix the following:
  • Main file name: It is recommended to name the main PHP file as the plugin slug ("amadiscount.php" instead of "adp_functions.php")
  • Text Domain: The text domain name should consist of only dashes and lowercase characters

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | An overview of files in this plugin; executable files are not allowed
There were no executable files found in this plugin2,330 lines of code in 5 files:
LanguageFilesBlank linesComment linesLines of code
CSS235501,255
PHP3601301,075

PHP code Passed 2 tests

Analyzing cyclomatic complexity and code structure
There were no cyclomatic complexity issued detected
Cyclomatic complexity
Average complexity per logical line of code0.22
Average class complexity0.00
▷ Minimum class complexity0.00
▷ Maximum class complexity0.00
Average method complexity0.00
▷ Minimum method complexity0.00
▷ Maximum method complexity0.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes0
▷ Abstract classes00.00%
▷ Concrete classes00.00%
▷ Final classes00.00%
Methods0
▷ Static methods00.00%
▷ Public methods00.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions20
▷ Named functions20100.00%
▷ Anonymous functions00.00%
Constants2
▷ Global constants2100.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
10 PNG files occupy 0.41MB with 0.19MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
images/canada.png0.69KB0.98KB0.00%
images/adp.png213.42KB63.15KB▼ 70.41%
images/keyword.png2.66KB1.48KB▼ 44.27%
images/search_logo.png168.03KB58.22KB▼ 65.35%
images/price.png4.77KB2.07KB▼ 56.58%