58% woocommerce-paypal-payments

Code Review | WooCommerce PayPal Payments

WordPress plugin WooCommerce PayPal Payments scored58%from 54 tests.

About plugin

  • Plugin page: woocommerce-paypa...
  • Plugin version: 2.4.1
  • PHP compatiblity: 7.2+
  • PHP version: 7.4.16
  • WordPress compatibility: 3.9-6.3
  • WordPress version: 6.3.1
  • First release: Oct 15, 2020
  • Latest release: Nov 14, 2023
  • Number of updates: 49
  • Update frequency: every 23.1 days
  • Top authors: woothemes (59.18%)automattic (42.86%)

Code review

54 tests

User reviews

345 reviews

Install metrics

600,000+ active /9,002,826 total downloads

Benchmarks

Plugin footprint 48% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
This plugin's installer ran successfully

Server metrics [RAM: ▲0.14MB] [CPU: ▼4.31ms] Passed 4 tests

An overview of server-side resources used by WooCommerce PayPal Payments
Server-side resource usage in normal parameters
PageMemory (MB)CPU Time (ms)
Home /3.62 ▲0.1543.64 ▲4.00
Dashboard /wp-admin3.45 ▲0.1449.51 ▼0.72
Posts /wp-admin/edit.php3.56 ▲0.2046.58 ▼3.44
Add New Post /wp-admin/post-new.php6.03 ▲0.1488.43 ▼16.94
Media Library /wp-admin/upload.php3.37 ▲0.1437.91 ▲3.86

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

Input-output and database impact of this plugin
This plugin was installed successfully
Filesystem: 768 new files
Database: no new tables, 7 new options
New WordPress options
can_compress_scripts
theysaidso_admin_options
woocommerce-ppcp-version
widget_recent-posts
widget_recent-comments
widget_theysaidso_widget
db_upgraded

Browser metrics Passed 4 tests

A check of browser resources used by WooCommerce PayPal Payments
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,797 ▲3514.72 ▲0.381.73 ▼0.0342.74 ▼1.41
Dashboard /wp-admin2,199 ▲195.56 ▼0.0585.91 ▼17.2737.57 ▼6.76
Posts /wp-admin/edit.php2,107 ▲71.95 ▲0.0138.28 ▲0.9935.39 ▼2.48
Add New Post /wp-admin/post-new.php1,533 ▲723.30 ▲0.24661.47 ▲13.1650.55 ▼12.40
Media Library /wp-admin/upload.php1,407 ▲164.23 ▲0.08106.57 ▲4.8445.66 ▲3.11

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

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
You still need to fix the following
  • This plugin did not uninstall without warnings or errors
    • > Notice in wp-content/plugins/woocommerce-paypal-payments/woocommerce-paypal-payments.php+24
    Constant PAYPAL_API_URL already defined
  • Uninstaller has failed for this plugin, leaving 768 files (10.54MB) in the plugin directory
    • (new file) lib/packages/Dhii/Collection/ContainerInterface.php
    • (new file) lib/common/Pattern/SingletonDecorator.php
    • (new file) lib/packages/Dhii/Collection/ClearableContainerInterface.php
    • (new file) api/order-functions.php
    • (new file) LICENSE
    • (new file) changelog.txt
    • (new file) lib/packages/Dhii/Collection/ContainerFactoryInterface.php
    • (new file) lib/common/Pattern/SingletonTrait.php
    • (new file) bootstrap.php
    • (new file) lib/packages/Dhii/Collection/CountableListInterface.php
    • ...
  • The uninstall procedure has failed, leaving 8 options in the database
    • widget_recent-posts
    • widget_theysaidso_widget
    • widget_recent-comments
    • theysaidso_admin_options
    • recovery_mode_email_last_sent
    • db_upgraded
    • can_compress_scripts
    • woocommerce-ppcp-version

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
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
Almost there! Just fix the following items
  • 1× GET requests to PHP files return non-empty strings:
    • > /wp-content/plugins/woocommerce-paypal-payments/uninstall.php
  • 193× PHP files trigger server errors when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Interface 'WooCommerce\\PayPalCommerce\\Vendor\\Dhii\\Modular\\Module\\ModuleInterface' not found in wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-status-report/src/StatusReportModule.php:29
    • > PHP Fatal error
      Trait 'WooCommerce\\PayPalCommerce\\Button\\Helper\\ContextTrait' not found in wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-wc-gateway/src/Checkout/DisableGateways.php on line 24
    • > PHP Fatal error
      Uncaught Error: Interface 'WooCommerce\\PayPalCommerce\\Vendor\\Interop\\Container\\ServiceProviderInterface' not found in wp-content/plugins/woocommerce-paypal-payments/lib/packages/Dhii/Container/ServiceProvider.php:14
    • > PHP Fatal error
      require_once(): Failed opening required 'wp-content/plugins/woocommerce-paypal-payments/vendor/dhii/validation-interface/vendor/autoload.php' (include_path='.:/usr/share/php') in wp-content/plugins/woocommerce-paypal-payments/vendor/dhii/validation-interface/tests/bootstrap.php on line 8
    • > PHP Fatal error
      Uncaught Error: Interface 'WpOop\\WordPress\\Plugin\\PluginInterface' not found in wp-content/plugins/woocommerce-paypal-payments/src/Plugin.php:18
    • > PHP Fatal error
      Uncaught Error: Interface 'WooCommerce\\PayPalCommerce\\ApiClient\\Authentication\\Bearer' not found in wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-api-client/src/Authentication/PayPalBearer.php:22
    • > PHP Fatal error
      Uncaught Error: Interface 'WooCommerce\\PayPalCommerce\\Vendor\\Dhii\\Collection\\ContainerInterface' not found in wp-content/plugins/woocommerce-paypal-payments/lib/packages/Dhii/Container/CachingContainer.php:20
    • > PHP Fatal error
      Uncaught Error: Interface 'WooCommerce\\PayPalCommerce\\Vendor\\Dhii\\Collection\\ContainerInterface' not found in wp-content/plugins/woocommerce-paypal-payments/lib/packages/Dhii/Collection/WritableContainerInterface.php:12
    • > PHP Fatal error
      Trait 'WooCommerce\\PayPalCommerce\\ApiClient\\Endpoint\\RequestTrait' not found in wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-api-client/src/Endpoint/BillingPlans.php on line 24
    • > PHP Fatal error
      Uncaught Error: Interface 'WooCommerce\\PayPalCommerce\\Webhooks\\Handler\\RequestHandler' not found in wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-webhooks/src/Handler/PaymentCaptureCompleted.php:23

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)
There were no browser issues found

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 94% from 16 tests

The readme.txt file is an important file in your plugin as it is parsed by WordPress.org to prepare the public listing of your plugin
Attributes that need to be fixed:
  • Tags: You are using too many tags: 12 tag instead of maximum 10
The official readme.txt might help

woocommerce-paypal-payments/woocommerce-paypal-payments.php 85% from 13 tests

The principal PHP file in "WooCommerce PayPal Payments" v. 2.4.1 is loaded by WordPress automatically on each request
You should first fix the following items:
  • Requires at least: Required version does not match the one declared in readme.txt ("5.3" instead of "3.9")
  • Description: If Twitter did it, so should we! Keep the description under 140 characters (currently 311 characters long)

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
There were no executable files found in this plugin50,641 lines of code in 701 files:
LanguageFilesBlank linesComment linesLines of code
PHP5288,03622,23840,232
JavaScript1201,2972966,739
JSON3002,239
Sass91130509
XML6226423
SVG2102363
Markdown325074
YAML12029
Dockerfile113224
CSS9009

PHP code Passed 2 tests

This is a short overview of cyclomatic complexity and code structure for this plugin
There were no cyclomatic complexity issued detected
Cyclomatic complexity
Average complexity per logical line of code0.33
Average class complexity8.62
▷ Minimum class complexity1.00
▷ Maximum class complexity203.00
Average method complexity2.59
▷ Minimum method complexity1.00
▷ Maximum method complexity43.00
Code structure
Namespaces110
Interfaces67
Traits19
Classes358
▷ Abstract classes30.84%
▷ Concrete classes35599.16%
▷ Final classes20.56%
Methods1,907
▷ Static methods854.46%
▷ Public methods1,53380.39%
▷ Protected methods1769.23%
▷ Private methods19810.38%
Functions662
▷ Named functions152.27%
▷ Anonymous functions64797.73%
Constants374
▷ Global constants112.94%
▷ Class constants36397.06%
▷ Public constants34996.14%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Using a strong compression for your PNG files is a great way to speed-up your plugin
5 PNG files occupy 0.29MB with 0.12MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
modules/ppcp-wc-gateway/assets/images/button-Google-Pay.png4.81KB3.10KB▼ 35.55%
modules/ppcp-wc-gateway/assets/images/paypal.png28.27KB13.28KB▼ 53.03%
modules/ppcp-wc-gateway/assets/images/button-Apple-Pay.png7.01KB2.98KB▼ 57.46%
modules/ppcp-onboarding/assets/images/cards-screen-acdc.png166.57KB72.16KB▼ 56.68%
modules/ppcp-onboarding/assets/images/cards-screen-basic.png89.25KB77.75KB▼ 12.88%