72% amp-wp

Code Review | AMP WP - Google AMP For WordPress

WordPress plugin AMP WP - Google AMP For WordPress scored72%from 54 tests.

About plugin

  • Plugin page: amp-wp
  • Plugin version: 1.5.15
  • PHP compatiblity: 7.0+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.9.6-6.2.2
  • WordPress version: 6.3.1
  • First release: Sep 17, 2018
  • Latest release: Jul 10, 2023
  • Number of updates: 53
  • Update frequency: every 33.5 days
  • Top authors: pixelative (98.11%)mohsinrafique (3.77%)

Code review

54 tests

User reviews

55 reviews

Install metrics

1,000+ active /66,464 total downloads

Benchmarks

Plugin footprint 82% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
This plugin's installer ran successfully

Server metrics [RAM: ▲1.81MB] [CPU: ▲10.94ms] 75% from 4 tests

Analyzing server-side resources used by AMP WP - Google AMP For WordPress
The following require your attention
  • CPU: Total CPU usage must kept under 500.00ms (currently 527.99ms on /wp-admin/admin.php?page=amp-wp-add-ons)
PageMemory (MB)CPU Time (ms)
Home /5.32 ▲1.8657.13 ▲16.05
Dashboard /wp-admin5.14 ▲1.8072.49 ▲10.73
Posts /wp-admin/edit.php5.21 ▲1.8662.55 ▲16.05
Add New Post /wp-admin/post-new.php7.68 ▲1.8098.54 ▲1.67
Media Library /wp-admin/upload.php5.00 ▲1.7756.52 ▲15.32
Settings /wp-admin/admin.php?page=amp-wp-settings5.10494.58
Help /wp-admin/admin.php?page=amp-wp-help5.05496.28
Welcome /wp-admin/admin.php?page=amp-wp-welcome5.05492.51
System Status /wp-admin/admin.php?page=amp-wp-system-status5.252,520.61
Customize AMP Theme /wp-admin/customize.php?return=%2Fwp-admin%2Fwp-api.php&url=http%3A%2F%2Fwp.com%2Famp&autofocus%5Bpanel%5D=amp-wp-panel9.62198.48
Add-ons /wp-admin/admin.php?page=amp-wp-add-ons5.05527.99

Server storage [IO: ▲2.00MB] [DB: ▲0.04MB] Passed 3 tests

A short overview of filesystem and database impact
No storage issues were detected
Filesystem: 312 new files
Database: no new tables, 9 new options
New WordPress options
theysaidso_admin_options
amp_wp_layout_settings
db_upgraded
amp_wp_general_settings
widget_recent-comments
widget_recent-posts
widget_theysaidso_widget
amp-wp-translation
can_compress_scripts

Browser metrics Passed 4 tests

Checking browser requirements for AMP WP - Google AMP For WordPress
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,901 ▲14013.62 ▼0.575.49 ▲3.7142.33 ▼0.53
Dashboard /wp-admin2,296 ▲1195.90 ▲0.32119.91 ▲32.5344.60 ▲5.27
Posts /wp-admin/edit.php2,207 ▲1072.34 ▲0.3635.77 ▼4.6231.54 ▼3.32
Add New Post /wp-admin/post-new.php6,309 ▲4,78326.53 ▲3.48952.01 ▲243.1045.37 ▼10.07
Media Library /wp-admin/upload.php1,510 ▲1104.40 ▲0.23105.54 ▲2.0662.72 ▲14.43
Settings /wp-admin/admin.php?page=amp-wp-settings5,3583.0573.3476.91
Help /wp-admin/admin.php?page=amp-wp-help9851.8525.7531.81
Welcome /wp-admin/admin.php?page=amp-wp-welcome6,5131.9028.4455.10
System Status /wp-admin/admin.php?page=amp-wp-system-status1,6051.9329.5649.88
Customize AMP Theme /wp-admin/customize.php?return=%2Fwp-admin%2Fwp-api.php&url=http%3A%2F%2Fwp.com%2Famp&autofocus%5Bpanel%5D=amp-wp-panel6,89017.98595.45117.92
Add-ons /wp-admin/admin.php?page=amp-wp-add-ons1,0251.8525.7733.39

Uninstaller [IO: ▲0.00MB] [DB: ▲0.04MB] 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
  • Zombie WordPress options were found after uninstall: 9 options
    • theysaidso_admin_options
    • can_compress_scripts
    • db_upgraded
    • widget_recent-comments
    • widget_theysaidso_widget
    • amp-wp-translation
    • amp_wp_general_settings
    • amp_wp_layout_settings
    • widget_recent-posts

Smoke tests 25% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the server (in the Apache logs)
Smoke test failed, please fix the following
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=amp-wp-settings
    • > Notice in wp-content/plugins/amp-wp/admin/partials/settings/amp-wp-admin-layout.php+106
    Undefined variable: notice_switch

SRP 50% 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
Please fix the following
  • 72× GET requests to PHP files have triggered server-side errors or warnings (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'Amp_WP_Component_Base' not found in wp-content/plugins/amp-wp/includes/components/class-amp-wp-carousel-component.php:9
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_option() in wp-content/plugins/amp-wp/public/partials/tez/single-post/comments.php:19
    • > PHP Fatal error
      Uncaught Error: Call to undefined function amp_wp_get_header() in wp-content/plugins/amp-wp/public/partials/tez/404.php:19
    • > PHP Warning
      Use of undefined constant AMP_WP_DIR_PATH - assumed 'AMP_WP_DIR_PATH' (this will throw an Error in a future version of PHP) in wp-content/plugins/amp-wp/admin/partials/amp-wp-admin-add-ons.php on line 16
    • > PHP Fatal error
      Uncaught Error: Call to undefined function amp_wp_enqueue_block_style() in wp-content/plugins/amp-wp/public/partials/tez/template-parts/listing-1.php:18
    • > PHP Notice
      Undefined variable: gdpr_countries in wp-content/plugins/amp-wp/public/partials/tez/components/gdpr/gdpr.php on line 22
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_filter() in wp-content/plugins/amp-wp/public/partials/tez/amp-wp-ads-manager/ads.php:18
    • > PHP Fatal error
      Uncaught Error: Class 'WP_Scripts' not found in wp-content/plugins/amp-wp/includes/class-amp-wp-scripts.php:9
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/amp-wp/admin/partials/welcome/amp-wp-admin-getting-started.php:15
    • > PHP Fatal error
      Uncaught Error: Call to undefined function amp_wp_enqueue_block_style() in wp-content/plugins/amp-wp/public/partials/tez/components/pagination/pagination.php:17

User-side errors 0% from 1 test

🔹 Test weight: 20 | This is just a short smoke test looking for browser issues
Please fix the following browser errors
    • > GET request to /wp-admin/customize.php?return=%2Fwp-admin%2Fwp-api.php&url=http%3A%2F%2Fwp.com%2Famp&autofocus%5Bpanel%5D=amp-wp-panel
    • > Network (severe)
    amp?customize_changeset_uuid=f65ed55e-c4ca-4a76-b151-5c1532a73d3c&customize_theme=twentytwentyone&customize_messenger_channel=preview-0 - Failed to load resource: the server responded with a status of 404 (Not Found)
    • > GET request to /wp-admin/customize.php?return=%2Fwp-admin%2Fwp-api.php&url=http%3A%2F%2Fwp.com%2Famp&autofocus%5Bpanel%5D=amp-wp-panel
    • > Security (warning) in unknown
    /amp?customize_changeset_uuid=f65ed55e-c4ca-4a76-b151-5c1532a73d3c&customize_theme=twentytwentyone&customize_messenger_channel=preview-0 - An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.

Optimizations

Plugin configuration Passed 29 tests

readme.txt Passed 16 tests

It's important to format your readme.txt file correctly as it is parsed for the public listing of your plugin
8 plugin tags: amp, accelerated mobile pages, amp for wp, mobile theme, amp wp...

amp-wp/amp-wp.php Passed 13 tests

"AMP WP - Google AMP For WordPress" version 1.5.15's primary PHP file adds more information about the plugin and serves as the entry point for WordPress
140 characters long description:
Automagically add Google AMP functionality to your site. Tons of Premium Features for FREE. Enable/Disable Post Types, Categories, and Tags.

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | There should be no dangerous file extensions present in any WordPress plugin
Everything looks great! No dangerous files found in this plugin31,723 lines of code in 279 files:
LanguageFilesBlank linesComment linesLines of code
PHP1302,4857,71515,943
JavaScript121,4284336,527
SVG369204,560
CSS986567293,955
HTML31513738

PHP code 50% from 2 tests

This plugin's cyclomatic complexity and code structure detailed below
Please fix the following
  • Method cyclomatic complexity has to be reduced to less than 100 (currently 121)
Cyclomatic complexity
Average complexity per logical line of code0.49
Average class complexity22.47
▷ Minimum class complexity1.00
▷ Maximum class complexity220.00
Average method complexity4.08
▷ Minimum method complexity1.00
▷ Maximum method complexity121.00
Code structure
Namespaces0
Interfaces1
Traits0
Classes54
▷ Abstract classes11.85%
▷ Concrete classes5398.15%
▷ Final classes00.00%
Methods385
▷ Static methods8522.08%
▷ Public methods33185.97%
▷ Protected methods348.83%
▷ Private methods205.19%
Functions213
▷ Named functions21098.59%
▷ Anonymous functions31.41%
Constants19
▷ Global constants1578.95%
▷ Class constants421.05%
▷ Public constants4100.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.10MB with 0.05MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
admin/images/welcome/configure-structured-data.png3.66KB1.96KB▼ 46.30%
admin/images/welcome/configure-notice-bar.png4.71KB2.11KB▼ 55.21%
admin/images/welcome/customize.png9.72KB3.21KB▼ 67.03%
admin/images/welcome/configure-layout.png7.21KB2.17KB▼ 69.89%
admin/images/pixelative.png2.98KB1.92KB▼ 35.57%