67% woo-payment-gateway

Code Review | Payment Plugins Braintree For WooCommerce

WordPress plugin Payment Plugins Braintree For WooCommerce scored67%from 54 tests.

About plugin

  • Plugin page: woo-payment-gateway
  • Plugin version: 3.2.48
  • PHP compatiblity: 5.6+
  • PHP version: 7.4.16
  • WordPress compatibility: 3.0.0-6.3
  • WordPress version: 6.3.1
  • First release: Aug 11, 2015
  • Latest release: Sep 23, 2023
  • Number of updates: 836
  • Update frequency: every 3.6 days
  • Top authors: mr.clayton (100%)

Code review

54 tests

User reviews

145 reviews

Install metrics

5,000+ active /307,368 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | It is important to correctly install your plugin, without throwing errors or notices
Install script ran successfully

Server metrics [RAM: ▲0.04MB] [CPU: ▼0.08ms] Passed 4 tests

This is a short check of server-side resources used by Payment Plugins Braintree For WooCommerce
This plugin does not affect your website's performance
PageMemory (MB)CPU Time (ms)
Home /3.51 ▲0.0443.28 ▲4.97
Dashboard /wp-admin3.34 ▲0.0450.06 ▲2.17
Posts /wp-admin/edit.php3.46 ▲0.1046.54 ▼5.12
Add New Post /wp-admin/post-new.php5.92 ▲0.0485.71 ▲1.92
Media Library /wp-admin/upload.php3.27 ▲0.0434.37 ▲0.71

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

How much does this plugin use your filesystem and database?
This plugin installed successfully
Filesystem: 650 new files
Database: no new tables, 8 new options
New WordPress options
woocommerce_queue_flush_rewrite_rules
db_upgraded
widget_recent-posts
widget_theysaidso_widget
braintree_wc_version
theysaidso_admin_options
can_compress_scripts
widget_recent-comments

Browser metrics Passed 4 tests

Payment Plugins Braintree For WooCommerce: an overview of browser usage
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,812 ▲6613.57 ▼0.984.75 ▲3.1043.26 ▲2.90
Dashboard /wp-admin2,218 ▲334.88 ▼0.97112.54 ▲8.6344.05 ▲0.44
Posts /wp-admin/edit.php2,100 ▲112.06 ▲0.0437.67 ▲0.9232.04 ▼2.15
Add New Post /wp-admin/post-new.php1,540 ▲2623.30 ▲5.42661.19 ▲9.3255.72 ▲10.10
Media Library /wp-admin/upload.php1,400 ▲214.19 ▼0.0194.50 ▼10.3445.44 ▲0.37

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
Please fix the following items
  • This plugin did not uninstall successfully, leaving 8 options in the database
    • braintree_wc_version
    • widget_recent-comments
    • woocommerce_queue_flush_rewrite_rules
    • widget_recent-posts
    • widget_theysaidso_widget
    • theysaidso_admin_options
    • db_upgraded
    • can_compress_scripts

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the server (in the Apache logs)
Good news, no errors were detected

SRP 0% from 2 tests

🔹 Tests weight: 20 | The single-responsibility principle: PHP files have to remain inert when accessed directly, throwing no errors and performing no actions
Please take a closer look at the following
  • 15× PHP files perform the task of outputting text when accessed with GET requests (only 10 are shown):
    • > /wp-content/plugins/woo-payment-gateway/templates/cart/paypal.php
    • > /wp-content/plugins/woo-payment-gateway/templates/mini-cart/googlepay.php
    • > /wp-content/plugins/woo-payment-gateway/templates/loaders/simple-dots.php
    • > /wp-content/plugins/woo-payment-gateway/templates/loaders/stairs-loader.php
    • > /wp-content/plugins/woo-payment-gateway/templates/checkout/applepay.php
    • > /wp-content/plugins/woo-payment-gateway/templates/checkout/checkout-banner.php
    • > /wp-content/plugins/woo-payment-gateway/templates/product/paypal.php
    • > /wp-content/plugins/woo-payment-gateway/templates/mini-cart/paypal.php
    • > /wp-content/plugins/woo-payment-gateway/templates/loaders/ping-pong.php
    • > /wp-content/plugins/woo-payment-gateway/templates/card-icons.php
  • 197× GET requests to PHP files trigger server-side errors or Error 500 responses (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_html() in wp-content/plugins/woo-payment-gateway/templates/custom-forms/simple-form.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Base' not found in wp-content/plugins/woo-payment-gateway/vendor/braintree/braintree_php/lib/Braintree/MerchantAccount.php:8
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wc_braintree_get_template() in wp-content/plugins/woo-payment-gateway/templates/product/applepay.php:11
    • > PHP Fatal error
      Uncaught Error: Class 'PaymentPlugins\\WooCommerce\\Blocks\\Braintree\\Payments\\Gateways\\AbstractGateway' not found in wp-content/plugins/woo-payment-gateway/packages/blocks/src/Payments/Gateways/ApplePayGateway.php:7
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Base' not found in wp-content/plugins/woo-payment-gateway/vendor/braintree/braintree_php/lib/Braintree/MerchantAccount/IndividualDetails.php:12
    • > PHP Fatal error
      Uncaught Error: Class 'WC_Braintree_Rest_Controller' not found in wp-content/plugins/woo-payment-gateway/includes/deprecated/api/class-wcs-braintree-controller.php:10
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Base' not found in wp-content/plugins/woo-payment-gateway/vendor/braintree/braintree_php/lib/Braintree/GooglePayCard.php:13
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_html() in wp-content/plugins/woo-payment-gateway/templates/custom-forms/bootstrap-form.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Exception' not found in wp-content/plugins/woo-payment-gateway/vendor/braintree/braintree_php/lib/Braintree/Exception/InvalidChallenge.php:12
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Base' not found in wp-content/plugins/woo-payment-gateway/vendor/braintree/braintree_php/lib/Braintree/OAuthResult.php:8

User-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the browser (console and network errors and warnings)
No browser errors were detected

Optimizations

Plugin configuration 87% from 29 tests

readme.txt 88% from 16 tests

You should put a lot of thought into formatting readme.txt as it is used by WordPress.org to prepare the public listing of your plugin
Attributes that require attention:
  • Tags: Please reduce the number of tags, currently 20 tag instead of maximum 10
  • Donate link: Please fix this invalid URI: ""
Please take inspiration from this readme.txt

woo-payment-gateway/braintree-payments.php 85% from 13 tests

Analyzing the main PHP file in "Payment Plugins Braintree For WooCommerce" version 3.2.48
The following require your attention:
  • Main file name: Please rename the main PHP file in this plugin to the plugin slug ("woo-payment-gateway.php" instead of "braintree-payments.php")
  • Requires at least: The required version number must match the one declared in readme.txt ("3.0.1" instead of "3.0.0")

Code Analysis 5% from 3 tests

File types 0% from 1 test

🔸 Test weight: 35 | This is an overview of programming languages used in this plugin; dangerous file extensions are not allowed
It is important to fix the following items
  • Do not include executable or dangerous files in your plugin
    • .crt - Security Certificate in Firefox, IE, Chrome, Safari
      • wp-content/plugins/woo-payment-gateway/vendor/braintree/braintree_php/lib/ssl/api_braintreegateway_com.ca.crt
49,527 lines of code in 623 files:
LanguageFilesBlank linesComment linesLines of code
PHP4344,94913,72533,532
JavaScript1088287668,709
CSS19785705,254
SVG471213801
Markdown22340759
Sass10490298
XML2914116
JSON10058

PHP code Passed 2 tests

Cyclomatic complexity and code structure are the fingerprint of this plugin
There are no cyclomatic complexity problems detected for this plugin
Cyclomatic complexity
Average complexity per logical line of code0.28
Average class complexity7.83
▷ Minimum class complexity1.00
▷ Maximum class complexity313.00
Average method complexity1.96
▷ Minimum method complexity1.00
▷ Maximum method complexity39.00
Code structure
Namespaces25
Interfaces1
Traits2
Classes317
▷ Abstract classes92.84%
▷ Concrete classes30897.16%
▷ Final classes00.00%
Methods2,214
▷ Static methods63228.55%
▷ Public methods1,88685.19%
▷ Protected methods1004.52%
▷ Private methods22810.30%
Functions380
▷ Named functions33588.16%
▷ Anonymous functions4511.84%
Constants905
▷ Global constants30.33%
▷ Class constants90299.67%
▷ Public constants902100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

It is recommended to compress PNG files in your plugin to minimize bandwidth usage
2 PNG files occupy 0.01MB with 0.00MB in potential savings
Potential savings
Compression of 2 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/img/applepay/applepay_button_plain.png3.81KB1.98KB▼ 48.04%
assets/img/applepay/applepay_button_buy.png5.67KB2.67KB▼ 52.83%