83% product-preview-for-woocommerce

Code Review | Product Preview for WooCommerce

WordPress plugin Product Preview for WooCommerce scored83%from 54 tests.

About plugin

  • Plugin page: product-preview-f...
  • Plugin version: 3.5.7.9
  • PHP version: 7.4.16
  • WordPress compatibility: 5.0-6.3.1
  • WordPress version: 6.3.1
  • First release: Aug 15, 2016
  • Latest release: Sep 21, 2023
  • Number of updates: 62
  • Update frequency: every 41.9 days
  • Top authors: RazyRx (58.06%)dholovnia (43.55%)

Code review

54 tests

User reviews

3 reviews

Install metrics

100+ active /11,157 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
Install script ran successfully

Server metrics [RAM: ▲1.36MB] [CPU: ▲6.21ms] Passed 4 tests

This is a short check of server-side resources used by Product Preview for WooCommerce
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /4.84 ▲1.3845.34 ▲4.02
Dashboard /wp-admin4.67 ▲1.3361.52 ▼0.35
Posts /wp-admin/edit.php4.79 ▲1.4360.62 ▲13.63
Add New Post /wp-admin/post-new.php7.25 ▲1.37105.42 ▲7.53
Media Library /wp-admin/upload.php4.60 ▲1.3754.05 ▲19.13

Server storage [IO: ▲1.99MB] [DB: ▲0.01MB] Passed 3 tests

Analyzing filesystem and database footprints of this plugin
There were no storage issued detected upon installing this plugin
Filesystem: 87 new files
Database: no new tables, 8 new options
New WordPress options
db_upgraded
widget_recent-posts
br-product_preview-options
widget_recent-comments
widget_theysaidso_widget
berocket_admin_notices_rate_stars
can_compress_scripts
theysaidso_admin_options

Browser metrics Passed 4 tests

Checking browser requirements for Product Preview for WooCommerce
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,825 ▲7914.35 ▼0.031.67 ▲0.0640.72 ▲1.31
Dashboard /wp-admin2,228 ▲485.67 ▲0.0181.46 ▼5.1599.94 ▲60.04
Posts /wp-admin/edit.php2,136 ▲392.06 ▲0.0736.39 ▲1.2938.07 ▲1.64
Add New Post /wp-admin/post-new.php1,577 ▲5123.22 ▲0.21681.39 ▲18.9950.32 ▼5.74
Media Library /wp-admin/upload.php1,430 ▲274.24 ▲0.06100.75 ▲3.5977.32 ▲32.74

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
These items require your attention
  • This plugin does not fully uninstall, leaving 8 options in the database
    • widget_recent-comments
    • widget_theysaidso_widget
    • widget_recent-posts
    • berocket_key_activated_plugins
    • can_compress_scripts
    • theysaidso_admin_options
    • berocket_admin_notices_rate_stars
    • db_upgraded

Smoke tests 75% 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)
Everything seems fine, however this is by no means an exhaustive test

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 fix the following items
  • 22× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_path() in wp-content/plugins/product-preview-for-woocommerce/main.php:3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function do_action() in wp-content/plugins/product-preview-for-woocommerce/berocket/includes/settings_fields.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/product-preview-for-woocommerce/berocket/includes/error_notices.php:5
    • > PHP Fatal error
      Uncaught Error: Using $this when not in object context in wp-content/plugins/product-preview-for-woocommerce/berocket/templates/premium.php:2
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/product-preview-for-woocommerce/berocket/sale/sale.php:4
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/product-preview-for-woocommerce/berocket/includes/admin_notices.php:797
    • > PHP Notice
      Undefined variable: title in wp-content/plugins/product-preview-for-woocommerce/berocket/templates/widget.php on line 1
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/product-preview-for-woocommerce/templates/style_section.php:3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_plugin_data() in wp-content/plugins/product-preview-for-woocommerce/berocket/templates/settings.php:2
    • > PHP Fatal error
      Uncaught Error: Class 'WP_Widget' not found in wp-content/plugins/product-preview-for-woocommerce/berocket/includes/widget.php:8

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a smoke test targeting browser errors/issues
There were no browser issues found

Optimizations

Plugin configuration 90% 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
Attributes that require attention:
  • Tags: Too many tags (18 tag instead of maximum 10); only the first 5 tags are used in your directory listing
  • Screenshots: These screenshots have no corresponding images in /assets: #1 (General settings), #2 (Style settings), #3 (Text settings)
The official readme.txt is a good inspiration

product-preview-for-woocommerce/product-preview.php 92% from 13 tests

The main PHP file in "Product Preview for WooCommerce" ver. 3.5.7.9 adds more information about the plugin and also serves as the entry point for this plugin
The following require your attention:
  • Main file name: Even though not officially enforced, the main plugin file should be the same as the plugin slug ("product-preview-for-woocommerce.php" instead of "product-preview.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | An overview of files in this plugin; executable files are not allowed
Good job! No executable or dangerous file extensions detected20,795 lines of code in 60 files:
LanguageFilesBlank linesComment linesLines of code
CSS142,516769,663
PHP364321,6278,793
JavaScript643581,873
PO File2194216430
XML20036

PHP code Passed 2 tests

An short overview of logical lines of code, cyclomatic complexity, and other code metrics
No cyclomatic complexity issues were detected for this plugin
Cyclomatic complexity
Average complexity per logical line of code0.50
Average class complexity51.20
▷ Minimum class complexity1.00
▷ Maximum class complexity240.00
Average method complexity4.64
▷ Minimum method complexity1.00
▷ Maximum method complexity98.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes25
▷ Abstract classes00.00%
▷ Concrete classes25100.00%
▷ Final classes00.00%
Methods345
▷ Static methods13539.13%
▷ Public methods345100.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions33
▷ Named functions33100.00%
▷ Anonymous functions00.00%
Constants8
▷ Global constants8100.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
6 PNG files occupy 0.01MB with 0.00MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
berocket/libraries/templates/default.png3.87KB2.63KB▼ 31.94%
berocket/includes/ico.png1.90KB1.41KB▼ 25.89%
berocket/assets/images/submenu-icon-a.png0.54KB0.48KB▼ 10.20%
berocket/libraries/addons/default.png3.87KB2.63KB▼ 31.94%
berocket/assets/css/mail.png2.59KB1.92KB▼ 26.02%