77% restrict-payment-methods-for-woocommerce

Code Review | Restrict Payment Methods For WooCommerce

WordPress plugin Restrict Payment Methods For WooCommerce scored77%from 54 tests.

About plugin

  • Plugin page: restrict-payment-...
  • Plugin version: 1.0
  • PHP version: 7.4.16
  • WordPress version: 6.3.1
  • First release: Sep 26, 2021
  • Latest release: Nov 22, 2022
  • Number of updates: 5
  • Update frequency: every 86.4 days
  • Top authors: gravitymaster97 (100%)

Code review

54 tests

User reviews

1 review

Install metrics

10+ active /479 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.11MB] [CPU: ▼2.71ms] Passed 4 tests

Analyzing server-side resources used by Restrict Payment Methods For WooCommerce
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /3.57 ▲0.1144.84 ▲1.35
Dashboard /wp-admin3.41 ▲0.1151.79 ▲1.99
Posts /wp-admin/edit.php3.52 ▲0.1748.69 ▼3.42
Add New Post /wp-admin/post-new.php6.01 ▲0.1398.50 ▼10.75
Media Library /wp-admin/upload.php3.33 ▲0.1038.86 ▲3.31
Add New /wp-admin/post-new.php?post_type=payment_gateway3.3446.23
Payment Gateway Rules /wp-admin/edit.php?post_type=payment_gateway3.3847.94

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

A short overview of filesystem and database impact
This plugin was installed successfully
Filesystem: 16 new files
Database: no new tables, 7 new options
New WordPress options
theysaidso_admin_options
db_upgraded
recovery_mode_email_last_sent
widget_theysaidso_widget
widget_recent-posts
widget_recent-comments
can_compress_scripts

Browser metrics Passed 4 tests

Restrict Payment Methods For WooCommerce: an overview of browser usage
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,874 ▲12813.55 ▼1.102.09 ▲0.3644.80 ▲4.79
Dashboard /wp-admin2,270 ▲695.38 ▲0.48103.64 ▼10.3639.18 ▼10.07
Posts /wp-admin/edit.php2,154 ▲572.48 ▲0.4443.81 ▲8.1235.01 ▼1.69
Add New Post /wp-admin/post-new.php1,569 ▲1523.29 ▲0.56624.46 ▼49.1037.89 ▼18.90
Media Library /wp-admin/upload.php1,452 ▲494.70 ▲0.47102.61 ▼37.0543.15 ▼7.37
Add New /wp-admin/post-new.php?post_type=payment_gateway1,2821.7111.6340.66
Payment Gateway Rules /wp-admin/edit.php?post_type=payment_gateway1,1212.3936.8729.61

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

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
The following items require your attention
  • Zombie WordPress options were found after uninstall: 7 options
    • can_compress_scripts
    • widget_recent-comments
    • recovery_mode_email_last_sent
    • theysaidso_admin_options
    • widget_recent-posts
    • db_upgraded
    • widget_theysaidso_widget

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
    • > GET request to /wp-admin/post-new.php?post_type=payment_gateway
    • > Error in wp-content/plugins/restrict-payment-methods-for-woocommerce/includes/GMWRPM_Admin.php+238
    Uncaught Error: Class 'WC_Shipping_Zone' not found in wp-content/plugins/restrict-payment-methods-for-woocommerce/includes/GMWRPM_Admin.php:238
    Stack trace:
    #0 wp-content/plugins/restrict-payment-methods-for-woocommerce/includes/GMWRPM_Admin.php(173): GMWRPM_Admin->GMWRPM_shipping()
    #1 wp-content/plugins/restrict-payment-methods-for-woocommerce/includes/GMWRPM_Admin.php(91): GMWRPM_Admin->GMWRPM_comman_html()
    #2 wp-admin/includes/template.php(1443): GMWRPM_Admin->GMWRPM_metabox_rule()
    #3 wp-admin/edit-form-advanced.php(688): do_meta_boxes()
    #4 wp-admin/post-new.php(75): require('/var/www/wordpr...')
    #5 {main}
    thrown

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
  • 1× GET requests to PHP files trigger server-side errors or Error 500 responses:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_option() in wp-content/plugins/restrict-payment-methods-for-woocommerce/includes/GMWRPM_Radio_Button.php:2

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
No browser errors were detected

Optimizations

Plugin configuration 87% from 29 tests

readme.txt 88% from 16 tests

Don't ignore readme.txt as it is the file that instructs WordPress.org on how to present your plugin to the world
These attributes need to be fixed: You can take inspiration from this readme.txt

restrict-payment-methods-for-woocommerce/gm-woocommerce-restrict-payment-methods.php 85% from 13 tests

The entry point to "Restrict Payment Methods For WooCommerce" version 1.0 is a PHP file that has certain tags in its header comment area
The following require your attention:
  • Main file name: Please rename the main PHP file in this plugin to the plugin slug ("restrict-payment-methods-for-woocommerce.php" instead of "gm-woocommerce-restrict-payment-methods.php")
  • Text Domain: You no longer need to specify the text domain since WordPress 4.6; it must be the same as the plugin slug

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | There should be no dangerous file extensions present in any WordPress plugin
Good job! No executable or dangerous file extensions detected593 lines of code in 11 files:
LanguageFilesBlank linesComment linesLines of code
PHP611971498
JavaScript318291
CSS2004

PHP code Passed 2 tests

This is a short overview of cyclomatic complexity and code structure for this plugin
All good! No complexity issues found
Cyclomatic complexity
Average complexity per logical line of code0.65
Average class complexity21.50
▷ Minimum class complexity1.00
▷ Maximum class complexity41.00
Average method complexity4.57
▷ Minimum method complexity1.00
▷ Maximum method complexity35.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes4
▷ Abstract classes00.00%
▷ Concrete classes4100.00%
▷ Final classes00.00%
Methods23
▷ Static methods00.00%
▷ Public methods23100.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions1
▷ Named functions1100.00%
▷ Anonymous functions00.00%
Constants4
▷ Global constants4100.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
2 PNG files occupy 0.04MB with 0.01MB in potential savings
Potential savings
Compression of 2 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/js/select2/select2.png0.51KB0.99KB0.00%
assets/img/close_btn.png36.22KB17.59KB▼ 51.42%