78% advanced-custom-routes-custom-endpoints-for-wp-rest-api

Code Review | Advanced Custom Routes - Custom Endpoints for WP REST API

WordPress plugin Advanced Custom Routes - Custom Endpoints for WP REST API scored 78% from 54 tests.

About plugin

  • Plugin page: advanced-custom-r...
  • Plugin version: 0.8.0
  • PHP version: 7.4.16
  • WordPress version: 5.9.2
  • First release: Jul 27, 2019
  • Latest release: Jul 28, 2019
  • Number of updates: 4
  • Update frequency: every 1.0 days
  • Top authors: lcarlile (100%)

Code review

54 tests

User reviews

2 reviews

Install metrics

80+ active / 1,386 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
The plugin installed gracefully, with no errors

Server metrics [RAM: ▼2.33MB] [CPU: ▼360.98ms] Passed 4 tests

Server-side resources used by Advanced Custom Routes - Custom Endpoints for WP REST API
Server-side resource usage in normal parameters
PageMemory (MB)CPU Time (ms)
Home /2.04 ▼1.486.75 ▼44.83
Dashboard /wp-admin2.05 ▼1.354.67 ▼29.25
Posts /wp-admin/edit.php2.05 ▼1.584.63 ▼33.12
Add New Post /wp-admin/post-new.php2.05 ▼4.925.95 ▼1,336.71
Media Library /wp-admin/upload.php2.05 ▼1.244.90 ▼21.00
Settings /wp-admin/edit.php?post_type=cd-custom-rest-api&page=wp-rest-endpoints-settings2.066.58
Custom Routes /wp-admin/edit.php?post_type=cd-custom-rest-api2.064.94

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

Input-output and database impact of this plugin
There were no storage issued detected upon installing this plugin
Filesystem: 300 new files
Database: no new tables, no new options

Browser metrics Passed 4 tests

An overview of browser requirements for Advanced Custom Routes - Custom Endpoints for WP REST API
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,840 ▲8616.09 ▲0.106.57 ▲0.142.39 ▲0.14
Dashboard /wp-admin2,934 ▲766.41 ▲0.32119.33 ▼17.56149.76 ▼17.20
Posts /wp-admin/edit.php2,730 ▲363.27 ▲0.0468.62 ▲1.45140.84 ▼3.70
Add New Post /wp-admin/post-new.php1,691 ▼6715.69 ▼5.67427.23 ▼39.78188.46 ▲20.15
Media Library /wp-admin/upload.php1,742 ▲415.70 ▲0.19164.35 ▲23.95190.75 ▼6.99
Settings /wp-admin/edit.php?post_type=cd-custom-rest-api&page=wp-rest-endpoints-settings1,0742.8157.90106.06
Custom Routes /wp-admin/edit.php?post_type=cd-custom-rest-api1,4153.2064.44122.07

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
These items require your attention
  • The plugin did not uninstall gracefully
    • > User notice in wp-includes/functions.php+5768
    wp_register_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the select2_styles handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.)

Smoke tests 50% 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)
Please fix the following server-side errors
  • 3 occurences, only the last one shown
    • > GET request to /wp-admin/edit.php?post_type=cd-custom-rest-api
    • > POST request to /wp-admin/admin-ajax.php
    • > User notice in wp-includes/functions.php+5768
    wp_register_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the select2_styles handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.)
  • 3 occurences, only the last one shown
    • > GET request to /wp-admin/edit.php?post_type=cd-custom-rest-api
    • > POST request to /wp-admin/admin-ajax.php
    • > User notice in wp-includes/functions.php+5768
    wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the select2_styles handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.)
  • 3 occurences, only the last one shown
    • > GET request to /wp-admin/edit.php?post_type=cd-custom-rest-api
    • > POST request to /wp-admin/admin-ajax.php
    • > User notice in wp-includes/functions.php+5768
    wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the select2_scripts handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.)
  • 3 occurences, only the last one shown
    • > GET request to /wp-admin/edit.php?post_type=cd-custom-rest-api
    • > POST request to /wp-admin/admin-ajax.php
    • > User notice in wp-includes/functions.php+5768
    wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the select2_scripts handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.)

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 take a closer look at the following
  • 26× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Call to undefined function maybe_unserialize() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/query-builder/query-builder-options/post-parent/post-parent-exclude.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/response-output/response-output.php:15
    • > PHP Fatal error
      Uncaught Error: Call to undefined function maybe_unserialize() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/query-builder/query-builder-options/post-ids/post-id-include.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function maybe_unserialize() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/query-builder/query-builder-options/categories/category-exclude.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function maybe_unserialize() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/query-builder/query-builder-options/authors/author-include.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/query-builder/query-builder-options.php:15
    • > PHP Fatal error
      Uncaught Error: Call to undefined function maybe_unserialize() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/query-builder/query-builder-options/authors/author-exclude.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/route-endpoint/route-endpoint.php:15
    • > PHP Fatal error
      Uncaught Error: Call to undefined function maybe_unserialize() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/query-builder/query-builder-options/post-types/post-type.php:4
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/advanced-custom-routes-custom-endpoints-for-wp-rest-api/admin/register-custom-post-type.php:48

User-side errors Passed 1 test

🔹 Test weight: 20 | This is just a short smoke test looking for browser issues
No browser errors were detected

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 88% from 16 tests

Perhaps the most important file in your plugin readme.txt gets parsed in order to generate the public listing of your plugin
Attributes that need to be fixed:
  • Requires at least: Invalid plugin version format
  • Tags: Please reduce the number of tags, currently 11 tag instead of maximum 10
The official readme.txt is a good inspiration

advanced-custom-routes-custom-endpoints-for-wp-rest-api/index.php 92% from 13 tests

The primary PHP file in "Advanced Custom Routes - Custom Endpoints for WP REST API" version 0.8.0 is used by WordPress to initiate all plugin functionality
Please make the necessary changes and fix the following:
  • Main file name: Name the main plugin file the same as the plugin slug ("advanced-custom-routes-custom-endpoints-for-wp-rest-api.php" instead of "index.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | This is a short overview of programming languages used in this plugin, detecting executable files
Good job! No executable or dangerous file extensions detected4,169 lines of code in 38 files:
LanguageFilesBlank linesComment linesLines of code
JSON7002,279
PHP264681561,262
JavaScript310865379
CSS21357249

PHP code Passed 2 tests

An overview of cyclomatic complexity and code structure
Great job! No cyclomatic complexity issues were detected in this plugin
Cyclomatic complexity
Average complexity per logical line of code0.39
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%
Functions18
▷ Named functions1688.89%
▷ Anonymous functions211.11%
Constants0
▷ Global constants00.00%
▷ Class constants00.00%
▷ Public constants00.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

All PNG images should be compressed to minimize bandwidth usage for end users
8 PNG files occupy 0.20MB with 0.10MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/icon-256x256.png5.70KB2.94KB▼ 48.42%
assets/screenshot-2.png45.44KB11.94KB▼ 73.73%
assets/banner-1544x500.png17.30KB11.44KB▼ 33.85%
assets/screenshot-4.png21.48KB7.23KB▼ 66.33%
assets/banner-772x250.png12.54KB8.07KB▼ 35.62%