58% amazon-link

Code Review | Amazon Link

WordPress plugin Amazon Link scored 58% from 54 tests.

About plugin

  • Plugin page: amazon-link
  • Plugin version: 3.2.10
  • PHP version: 7.4.16
  • WordPress compatibility: 3.3-5.1
  • WordPress version: 5.8.1
  • First release: Sep 20, 2010
  • Latest release: Mar 6, 2019
  • Number of updates: 198
  • Update frequency: every 16.5 days
  • Top authors: paulstuttard (100%)

Code review

54 tests

User reviews

52 reviews

Install metrics

4,000+ active / 219,187 total downloads

Benchmarks

Plugin footprint 47% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
This plugin's installer ran successfully

Server metrics [RAM: ▲0.63MB] [CPU: ▼168.80ms] 75% from 4 tests

A check of server-side resources used by Amazon Link
Please fix the following
  • CPU: You should keep total CPU usage under 500.00ms (currently 2,093.96ms on /wp-admin/admin.php?page=amazon-link-settings)
PageMemory (MB)CPU Time (ms)
Home /3.15 ▲0.4336.76 ▲13.76
Dashboard /wp-admin3.92 ▲0.8750.46 ▲5.53
Posts /wp-admin/edit.php3.97 ▲0.8648.18 ▲5.15
Add New Post /wp-admin/post-new.php5.86 ▲0.4381.05 ▼687.25
Media Library /wp-admin/upload.php3.79 ▲0.7934.87 ▲1.38
Settings /wp-admin/admin.php?page=amazon-link-settings3.862,093.96
Templates /wp-admin/admin.php?page=amazon-link-templates4.0044.43
Setup /wp-admin/admin.php?page=amazon-link-quickstart3.92289.72
Associate IDs /wp-admin/admin.php?page=amazon-link-channels3.8333.26

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

How much does this plugin use your filesystem and database?
The plugin installed successfully
Filesystem: 71 new files
Database: no new tables, 3 new options
New WordPress options
AmazonLinkTemplates
AmazonLinkOptions
AmazonLinkChannels

Browser metrics Passed 4 tests

Checking browser requirements for Amazon Link
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,748 ▲15215.88 ▲0.2210.15 ▲0.4745.48 ▼1.59
Dashboard /wp-admin3,001 ▲675.93 ▼0.24147.22 ▼17.76120.97 ▲11.21
Posts /wp-admin/edit.php2,783 ▲442.60 ▼0.1063.85 ▼10.8795.21 ▲6.95
Add New Post /wp-admin/post-new.php2,459 ▲77624.77 ▲5.98414.48 ▲0.70122.19 ▲12.02
Media Library /wp-admin/upload.php1,794 ▼135.01 ▼0.04195.89 ▲13.80135.32 ▲19.13
Settings /wp-admin/admin.php?page=amazon-link-settings4,0392.9280.51163.47
Templates /wp-admin/admin.php?page=amazon-link-templates8,4585.67286.96172.90
Setup /wp-admin/admin.php?page=amazon-link-quickstart2,8462.8275.01124.27
Associate IDs /wp-admin/admin.php?page=amazon-link-channels2,3592.7771.68123.34

Uninstaller [IO: ▲0.58MB] [DB: ▲0.01MB] 25% from 4 tests

🔸 Tests weight: 35 | The uninstall procedure must remove all plugin files and extra database tables
It is recommended to fix the following
  • Uninstall procedure validation failed for this plugin
    • > Compile error in wp-content/plugins/amazon-link/amazon.php+1771
    Cannot redeclare amazon_get_link() (previously declared in wp-content/plugins/amazon-link/amazon.php:1771)
  • Incomplete uninstall procedure, leaving 71 files (0.58MB) in the plugin directory
    • (new file) extras/amazon-link-references.php
    • (new file) extras/amazon-link-spoof-locale.php
    • (new file) extras/amazon-link-cache.php
    • (new file) amazon.php
    • (new file) amazon.js
    • (new file) extras/amazon-link-convert.php
    • (new file) Amazon.css
    • (new file) extras/amazon-link-images.php
    • (new file) extras/amazon-link-editorial.php
    • (new file) extras/amazon-link-redirect.php
    • ...
  • The uninstall procedure has failed, leaving 4 options in the database
    • AmazonLinkChannels
    • recovery_mode_email_last_sent
    • AmazonLinkTemplates
    • AmazonLinkOptions

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
Good news, no errors were detected

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
Please fix the following
  • 34× GET requests to PHP files have triggered server-side errors or warnings (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'WP_Query' not found in wp-content/plugins/amazon-link/include/showRecommendations.php:110
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/amazon-link/include/showRecommendations.php on line 104
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_filter() in wp-content/plugins/amazon-link/extras/amazon-link-spoof-locale.php:77
    • > PHP Fatal error
      Uncaught Error: Using $this when not in object context in wp-content/plugins/amazon-link/include/showDefaultTemplates.php:8
    • > PHP Notice
      Undefined variable: region in wp-content/plugins/amazon-link/include/awsRequest.php on line 36
    • > PHP Fatal error
      Uncaught Error: Call to undefined function is_admin() in wp-content/plugins/amazon-link/amazon.php:1759
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_plugin_data() in wp-content/plugins/amazon-link/include/showInfo.php:2
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/amazon-link/include/showRecommendations.php on line 104
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/amazon-link/extras/amazon-link-convert.php:269
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_option() in wp-content/plugins/amazon-link/include/upgradeSettings.php:4

User-side errors 0% from 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
Please take a look at the following user-side issues
  • 6 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Network (severe)
    http://wms-eu.amazon-adsystem.com/20070822/GB/js/swfobject_1_5.js - Failed to load resource: the server responded with a status of 404 (Not Found)
  • 4 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Javascript (warning) in unknown
    http://wms-eu.amazon-adsystem.com/20070822/GB/js/AmazonWidgets.js 465 A parser-blocking, cross site (i.e. different eTLD+1) script, http://ws-eu.amazon-adsystem.com/widgets/q?MarketPlace=GB&Operation=MyFavorites&ServiceVersion=20070822&WS=1&ID=LStrings, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Javascript (warning) in unknown
    http://wms-eu.amazon-adsystem.com/20070822/GB/js/AmazonWidgets.js 466 A parser-blocking, cross site (i.e. different eTLD+1) script, http://wms-eu.amazon-adsystem.com/panda/20070822/GB/js/8001_1.js, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Javascript (warning) in unknown
    http://wms-eu.amazon-adsystem.com/panda/20070822/GB/js/8001_1.js 2086 A parser-blocking, cross site (i.e. different eTLD+1) script, http://wms-eu.amazon-adsystem.com/js/popup.js, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.
  • 3 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Javascript (warning) in unknown
    http://wms-eu.amazon-adsystem.com/panda/20070822/GB/js/8001_1.js 2095 A parser-blocking, cross site (i.e. different eTLD+1) script, http://wms-eu.amazon-adsystem.com/js/nifty.js, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Javascript (warning) in unknown
    http://wms-eu.amazon-adsystem.com/panda/20070822/GB/js/8001_1.js 2104 A parser-blocking, cross site (i.e. different eTLD+1) script, http://wms-eu.amazon-adsystem.com/js/colors.js, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Network (severe)
    http://www.assoc-amazon.co.uk/e/ir?t=&l=as2&o=2&a=0893817449 - Failed to load resource: net::ERR_CONNECTION_REFUSED
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Network (severe)
    http://unknown%20string/e/ir?o=2&t=amawid-21&l=wey - Failed to load resource: net::ERR_NAME_NOT_RESOLVED
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Network (severe)
    http://wms-eu.amazon-adsystem.com/GB/img/star44_tpng.png - Failed to load resource: the server responded with a status of 404 (Not Found)
    • > GET request to /wp-admin/admin.php?page=amazon-link-templates
    • > Network (severe)
    http://wms-eu.amazon-adsystem.com/GB/img/star47_tpng.png - Failed to load resource: the server responded with a status of 404 (Not Found)

Optimizations

Plugin configuration 93% from 29 tests

readme.txt 94% from 16 tests

Often overlooked, readme.txt is one of the most important files in your plugin
Attributes that need to be fixed:
  • Tags: Please reduce the number of tags, currently 12 tag instead of maximum 10
You can look at the official readme.txt

amazon-link/amazon.php 92% from 13 tests

Analyzing the main PHP file in "Amazon Link" version 3.2.10
The following require your attention:
  • Main file name: Please rename the main PHP file in this plugin to the plugin slug ("amazon-link.php" instead of "amazon.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short check of programming languages and file extensions; no executable files are allowed
Success! There were no dangerous files found in this plugin6,523 lines of code in 42 files:
LanguageFilesBlank linesComment linesLines of code
PHP361,3671,5745,897
JavaScript47725414
CSS2431212

PHP code Passed 2 tests

This is a very shot review of cyclomatic complexity and code structure
All good! No complexity issues found
Cyclomatic complexity
Average complexity per logical line of code0.42
Average class complexity74.00
▷ Minimum class complexity4.00
▷ Maximum class complexity231.00
Average method complexity4.87
▷ Minimum method complexity1.00
▷ Maximum method complexity96.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes7
▷ Abstract classes00.00%
▷ Concrete classes7100.00%
▷ Final classes00.00%
Methods132
▷ Static methods00.00%
▷ Public methods132100.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions52
▷ Named functions52100.00%
▷ Anonymous functions00.00%
Constants8
▷ Global constants112.50%
▷ Class constants787.50%
▷ Public constants7100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

PNG files should be compressed to save space and minimize bandwidth usage
14 PNG files occupy 0.02MB with 0.01MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
images/star_3_5.png1.40KB0.61KB▼ 56.53%
images/star_0.png1.27KB0.44KB▼ 65.10%
images/star_4.png1.38KB0.58KB▼ 58.00%
images/star_2_5.png1.41KB0.63KB▼ 55.45%
images/star_0_5.png0.58KB0.44KB▼ 25.00%