52% accept-payments-wp

Code Review | Braintree Payments For Wordpress - Accept Payments WP

WordPress plugin Braintree Payments For Wordpress - Accept Payments WP scored52%from 54 tests.

About plugin

  • Plugin page: accept-payments-wp
  • Plugin version: 1.2.1
  • PHP version: 7.4.16
  • WordPress compatibility: 4.7-5.0.3
  • WordPress version: 6.3.1
  • First release: Jan 24, 2019
  • Latest release: Jan 31, 2019
  • Number of updates: 16
  • Update frequency: every 0.5 days
  • Top authors: LukasPaskauskas (100%)

Code review

54 tests

User reviews

1 review

Install metrics

10+ active /1,040 total downloads

Benchmarks

Plugin footprint 65% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | All plugins must install correctly, without throwing any errors, warnings, or notices
The plugin installed successfully, without throwing any errors or notices

Server metrics [RAM: ▲0.32MB] [CPU: ▼4.24ms] Passed 4 tests

Analyzing server-side resources used by Braintree Payments For Wordpress - Accept Payments WP
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /3.77 ▲0.3047.91 ▲8.60
Dashboard /wp-admin3.67 ▲0.3651.18 ▲2.89
Posts /wp-admin/edit.php3.72 ▲0.3646.75 ▼7.63
Add New Post /wp-admin/post-new.php6.21 ▲0.3286.57 ▼13.16
Media Library /wp-admin/upload.php3.53 ▲0.2939.90 ▲0.95
Add New Payment Form /wp-admin/post-new.php?post_type=accept_payments_wp3.5747.08
24/7 Support And Feature Request /wp-admin/edit.php?post_type=accept_payments_wp&page=accept_payments_wp_support3.5035.02
Settings /wp-admin/edit.php?post_type=accept_payments_wp&page=accept_payments_wp_settings3.5036.20
Payment Forms /wp-admin/edit.php?post_type=accept_payments_wp3.5741.53

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

Filesystem and database footprint
The plugin installed successfully
Filesystem: 334 new files
Database: no new tables, 6 new options
New WordPress options
can_compress_scripts
db_upgraded
widget_recent-comments
theysaidso_admin_options
widget_recent-posts
widget_theysaidso_widget

Browser metrics Passed 4 tests

A check of browser resources used by Braintree Payments For Wordpress - Accept Payments WP
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,833 ▲7214.35 ▲0.001.58 ▼0.3641.71 ▼3.12
Dashboard /wp-admin2,236 ▲565.63 ▼0.0591.71 ▲3.5643.15 ▼1.40
Posts /wp-admin/edit.php2,144 ▲442.00 ▼0.0335.08 ▼4.2932.48 ▼5.17
Add New Post /wp-admin/post-new.php1,561 ▲3323.45 ▲0.12683.99 ▲16.2161.70 ▲2.57
Media Library /wp-admin/upload.php1,444 ▲474.22 ▲0.0599.42 ▼5.2846.30 ▼5.67
Add New Payment Form /wp-admin/post-new.php?post_type=accept_payments_wp1,5862.6257.5167.51
24/7 Support And Feature Request /wp-admin/edit.php?post_type=accept_payments_wp&page=accept_payments_wp_support8331.9925.3440.37
Settings /wp-admin/edit.php?post_type=accept_payments_wp&page=accept_payments_wp_settings1,0182.0525.5828.46
Payment Forms /wp-admin/edit.php?post_type=accept_payments_wp1,1301.9730.6433.66

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

🔸 Tests weight: 35 | It is important to correctly uninstall your plugin, without leaving any traces
The following items require your attention
  • Uninstall procedure validation failed for this plugin
    • > Warning in wp-includes/class-wp-hook.php+310
    call_user_func_array() expects parameter 1 to be a valid callback, function 'deactivate_wp_plugin' not found or invalid function name
  • The uninstall procedure has failed, leaving 6 options in the database
    • widget_recent-comments
    • can_compress_scripts
    • widget_theysaidso_widget
    • db_upgraded
    • theysaidso_admin_options
    • widget_recent-posts

Smoke tests 25% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | This is a short smoke test looking for server-side errors
Almost there, just fix the following server-side errors
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/post-new.php?post_type=accept_payments_wp
    • > Warning in wp-content/plugins/accept-payments-wp/includes/core/AcceptPaymentsWPMetaBoxes.php+22
    Illegal string offset 'price'
  • 4 occurences, only the last one shown
    • > GET request to /wp-admin/post-new.php?post_type=accept_payments_wp
    • > Warning in wp-content/plugins/accept-payments-wp/includes/core/AcceptPaymentsWPMetaBoxes.php+101
    Cannot assign an empty string to a string offset
    • > GET request to /wp-admin/post-new.php?post_type=accept_payments_wp
    • > Warning in wp-content/plugins/accept-payments-wp/includes/core/AcceptPaymentsWPMetaBoxes.php+88
    Illegal string offset 'description'
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/post-new.php?post_type=accept_payments_wp
    • > Warning in wp-content/plugins/accept-payments-wp/includes/core/AcceptPaymentsWPMetaBoxes.php+51
    Illegal string offset 'success_page_url'
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/post-new.php?post_type=accept_payments_wp
    • > Warning in wp-content/plugins/accept-payments-wp/includes/core/AcceptPaymentsWPMetaBoxes.php+60
    Illegal string offset 'failure_page_url'
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/post-new.php?post_type=accept_payments_wp
    • > Warning in wp-content/plugins/accept-payments-wp/includes/core/AcceptPaymentsWPMetaBoxes.php+41
    Illegal string offset 'button_text'
    • > GET request to /wp-admin/post-new.php?post_type=accept_payments_wp
    • > Warning in wp-content/plugins/accept-payments-wp/includes/core/AcceptPaymentsWPMetaBoxes.php+31
    Illegal string offset 'item_description'

SRP 0% 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
  • 1× PHP files perform the action of outputting non-empty strings when accessed directly:
    • > /wp-content/plugins/accept-payments-wp/templates/admin/support.php
  • 206× GET requests to PHP files have triggered server-side errors or warnings (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Http' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/tests/integration/HttpClientApi.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Base' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/lib/Braintree/Result/Error.php:36
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Http' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/tests/integration/HttpClientApi.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Exception' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/lib/Braintree/Exception/InvalidSignature.php:6
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Http' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/tests/integration/HttpClientApi.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Http' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/tests/integration/HttpClientApi.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Exception' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/lib/Braintree/Exception/TestOperationPerformedInProduction.php:12
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Http' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/tests/integration/HttpClientApi.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Instance' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/lib/Braintree/Transaction/MasterpassCardDetails.php:36
    • > PHP Fatal error
      Uncaught Error: Class 'Braintree\\Exception' not found in wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/lib/Braintree/Exception/Connection.php:13

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 issues were found

Optimizations

Plugin configuration 93% from 29 tests

readme.txt 88% from 16 tests

It's important to format your readme.txt file correctly as it is parsed for the public listing of your plugin
These attributes need to be fixed:
  • Tags: You are using too many tags: 12 tag instead of maximum 10
  • Requires php: Version not formatted correctly
The official readme.txt is a good inspiration

accept-payments-wp/accept-payments-wp.php Passed 13 tests

Analyzing the main PHP file in "Braintree Payments For Wordpress - Accept Payments WP" version 1.2.1
58 characters long description:
Easily accept Braintree Payments on your Wordpress website

Code Analysis 5% from 3 tests

File types 0% from 1 test

🔸 Test weight: 35 | An overview of files in this plugin; executable files are not allowed
It is important to fix the following items
  • Do not distribute dangerous files with your plugin
    • .crt - Security Certificate in Firefox, IE, Chrome, Safari
      • wp-content/plugins/accept-payments-wp/vendor/braintree/braintree_php/lib/ssl/api_braintreegateway_com.ca.crt
36,599 lines of code in 322 files:
LanguageFilesBlank linesComment linesLines of code
PHP3035,3185,57435,652
Markdown62160590
CSS31610102
JSON20087
Ruby117064
JavaScript214456
XML12022
Dockerfile1419
Bourne Shell1308
make1208
SVG1001

PHP code Passed 2 tests

A short review of cyclomatic complexity and code structure
This plugin has no cyclomatic complexity problems
Cyclomatic complexity
Average complexity per logical line of code0.08
Average class complexity4.51
▷ Minimum class complexity1.00
▷ Maximum class complexity163.00
Average method complexity1.43
▷ Minimum method complexity1.00
▷ Maximum method complexity33.00
Code structure
Namespaces26
Interfaces0
Traits0
Classes294
▷ Abstract classes20.68%
▷ Concrete classes29299.32%
▷ Final classes10.34%
Methods2,391
▷ Static methods49020.49%
▷ Public methods2,16490.51%
▷ Protected methods1004.18%
▷ Private methods1275.31%
Functions20
▷ Named functions315.00%
▷ Anonymous functions1785.00%
Constants871
▷ Global constants60.69%
▷ Class constants86599.31%
▷ Public constants865100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
2 compressed PNG files occupy 0.00MB
Potential savings
Compression of 2 random PNG files using pngquant
FileSize - originalSize - compressedSavings
vendor/braintree/braintree_php/tests/fixtures/bt_logo.png2.39KB2.26KB▼ 5.32%
assets/images/icon-coin.png0.64KB0.56KB▼ 13.03%