46% gift-voucher

Code Review | Gift Cards (Gift Vouchers and Packages) (WooCommerce Supported)

WordPress plugin Gift Cards (Gift Vouchers and Packages) (WooCommerce Supported) scored46%from 54 tests.

About plugin

  • Plugin page: gift-voucher
  • Plugin version: 4.3.6
  • PHP compatiblity: 5.6+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.0-6.2
  • WordPress version: 6.3.1
  • First release: Mar 30, 2018
  • Latest release: Jul 7, 2023
  • Number of updates: 290
  • Update frequency: every 6.6 days
  • Top authors: codemenschen (74.14%)telberia (26.21%)

Code review

54 tests

User reviews

104 reviews

Install metrics

2,000+ active /85,662 total downloads

Benchmarks

Plugin footprint 65% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
This plugin's installer ran successfully

Server metrics [RAM: ▲1.92MB] [CPU: ▲2.35ms] Passed 4 tests

Analyzing server-side resources used by Gift Cards (Gift Vouchers and Packages) (WooCommerce Supported)
Server-side resource usage in normal parameters
PageMemory (MB)CPU Time (ms)
Home /5.38 ▲1.9154.76 ▲16.34
Dashboard /wp-admin5.25 ▲1.9458.94 ▲1.51
Posts /wp-admin/edit.php5.28 ▲1.9364.03 ▲12.24
Add New Post /wp-admin/post-new.php7.89 ▲2.0190.71 ▼20.70
Media Library /wp-admin/upload.php5.14 ▲1.9153.43 ▲17.68
All Gift Items /wp-admin/edit.php?post_type=wpgv_voucher_product5.2053.42
Settings /wp-admin/admin.php?page=voucher-setting5.4761.12
View Voucher Details /wp-admin/admin.php?page=view-voucher-details5.1046.27
All Gift Cards /wp-admin/edit.php?post_type=voucher_template5.2047.94
Gift Cards Categories /wp-admin/edit-tags.php?taxonomy=category_voucher_template&post_type=voucher_template5.0947.99
Add New Template /wp-admin/admin.php?page=new-voucher-template5.1350.72
Item Categories /wp-admin/edit-tags.php?taxonomy=wpgv_voucher_category&post_type=wpgv_voucher_product5.2349.83
Voucher Templates /wp-admin/admin.php?page=voucher-templates5.0646.11
Gift Voucher Orders /wp-admin/admin.php?page=vouchers-lists5.0645.63

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

A short overview of filesystem and database impact
This plugin installed successfully
Filesystem: 802 new files
Database: 4 new tables, 8 new options
New tables
wp_giftvouchers_template
wp_giftvouchers_setting
wp_giftvouchers_list
wp_giftvouchers_activity
New WordPress options
can_compress_scripts
widget_recent-comments
theysaidso_admin_options
wpgv_demoimageurl
widget_theysaidso_widget
widget_recent-posts
db_upgraded
jal_db_version

Browser metrics Passed 4 tests

A check of browser resources used by Gift Cards (Gift Vouchers and Packages) (WooCommerce Supported)
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,889 ▲12814.39 ▲0.041.78 ▲0.1538.87 ▲1.25
Dashboard /wp-admin2,280 ▲1065.77 ▲0.1888.23 ▼15.6143.37 ▼4.13
Posts /wp-admin/edit.php2,188 ▲852.45 ▲0.4335.74 ▼2.2033.91 ▲2.74
Add New Post /wp-admin/post-new.php1,605 ▲7923.58 ▲0.68669.26 ▲54.6036.73 ▼10.76
Media Library /wp-admin/upload.php1,489 ▲924.41 ▲0.22106.97 ▲0.9247.83 ▲3.79
All Gift Items /wp-admin/edit.php?post_type=wpgv_voucher_product1,1632.2437.8027.84
Settings /wp-admin/admin.php?page=voucher-setting5,44713.94377.8593.00
View Voucher Details /wp-admin/admin.php?page=view-voucher-details1,0801.9731.0233.64
All Gift Cards /wp-admin/edit.php?post_type=voucher_template1,1662.2335.8128.12
Gift Cards Categories /wp-admin/edit-tags.php?taxonomy=category_voucher_template&post_type=voucher_template1,3642.1831.8937.43
Add New Template /wp-admin/admin.php?page=new-voucher-template1,2173.4048.1036.25
Item Categories /wp-admin/edit-tags.php?taxonomy=wpgv_voucher_category&post_type=wpgv_voucher_product1,5423.5742.2629.16
Voucher Templates /wp-admin/admin.php?page=voucher-templates1,1541.9530.6128.06
Gift Voucher Orders /wp-admin/admin.php?page=vouchers-lists1,1212.0228.7525.71

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
These items require your attention
  • Zombie tables detected upon uninstall: 4 tables
    • wp_giftvouchers_list
    • wp_giftvouchers_setting
    • wp_giftvouchers_activity
    • wp_giftvouchers_template
  • This plugin does not fully uninstall, leaving 8 options in the database
    • can_compress_scripts
    • jal_db_version
    • theysaidso_admin_options
    • widget_recent-posts
    • wpgv_demoimageurl
    • widget_recent-comments
    • db_upgraded
    • widget_theysaidso_widget

Smoke tests 0% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | This is a short smoke test looking for server-side errors
Smoke test failed, please fix the following
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+17
    Undefined index: voucher_id
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+59
    Trying to get property 'order_type' of non-object
  • 3 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+88
    Trying to get property 'item_id' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+40
    Trying to get property 'id' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+52
    Trying to get property 'couponcode' of non-object
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+53
    Trying to get property 'voucheradd_time' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+54
    Trying to get property 'status' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+55
    Trying to get property 'voucherpdf_link' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+89
    Trying to access array offset on value of type bool
  • 3 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+111
    Trying to get property 'buying_for' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+110
    Trying to get property 'from_name' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+112
    Trying to get property 'to_name' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+114
    Trying to get property 'amount' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+115
    Trying to get property 'message' of non-object
  • 3 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+141
    Trying to get property 'shipping_type' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+144
    Trying to get property 'firstname' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+144
    Trying to get property 'lastname' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+145
    Trying to get property 'email' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+146
    Trying to get property 'address' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+147
    Trying to get property 'postcode' of non-object
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+148
    Trying to get property 'shipping_method' of non-object
  • 3 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+153
    Trying to get property 'pay_method' of non-object
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Notice in wp-content/plugins/gift-voucher/include/view_voucher_details.php+159
    Trying to get property 'expiry' of non-object

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 fix the following
  • 16× PHP files perform the action of outputting non-empty strings when accessed directly (only 10 are shown):
    • > /wp-content/plugins/gift-voucher/vendor/setasign/fpdf/tutorial/tuto3.php
    • > /wp-content/plugins/gift-voucher/vendor/stripe/stripe-php/update_certs.php
    • > /wp-content/plugins/gift-voucher/vendor/sofort/examples/example.ideal.banks.php
    • > /wp-content/plugins/gift-voucher/vendor/setasign/fpdf/tutorial/tuto1.php
    • > /wp-content/plugins/gift-voucher/vendor/setasign/fpdf/tutorial/tuto5.php
    • > /wp-content/plugins/gift-voucher/vendor/setasign/fpdf/tutorial/tuto2.php
    • > /wp-content/plugins/gift-voucher/vendor/sofort/examples/example.ideal.php
    • > /wp-content/plugins/gift-voucher/vendor/stripe/stripe-php/build.php
    • > /wp-content/plugins/gift-voucher/vendor/setasign/fpdf/tutorial/tuto4.php
    • > /wp-content/plugins/gift-voucher/vendor/sofort/examples/example.paycode.details.php
  • 369× PHP files trigger errors when accessed directly with GET requests (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'PayPal\\Common\\PayPalModel' not found in wp-content/plugins/gift-voucher/vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/PayoutBatchHeader.php:24
    • > PHP Fatal error
      Uncaught Error: Class 'Stripe\\ApiResource' not found in wp-content/plugins/gift-voucher/vendor/stripe/stripe-php/lib/Source.php:44
    • > PHP Warning
      count(): Parameter must be an array or an object that implements Countable in wp-content/plugins/gift-voucher/vendor/sofort/examples/example.transaction.php on line 74
    • > PHP Fatal error
      Uncaught Error: Interface 'PayPalHttp\\Serializer' not found in wp-content/plugins/gift-voucher/vendor/paypal/paypalhttp/lib/PayPalHttp/Serializer/Form.php:8
    • > PHP Fatal error
      Uncaught Error: Class 'PayPal\\Common\\PayPalModel' not found in wp-content/plugins/gift-voucher/vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Payee.php:17
    • > PHP Fatal error
      Uncaught Error: Class 'Stripe\\ApiResource' not found in wp-content/plugins/gift-voucher/vendor/stripe/stripe-php/lib/Recipient.php:25
    • > PHP Fatal error
      require(): Failed opening required 'wp-content/plugins/gift-voucher/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/../../vendor/autoload.php' (include_path='.:/usr/share/php') in wp-content/plugins/gift-voucher/vendor/paypal/paypal-checkout-sdk/samples/AuthorizeIntentExamples/AuthorizeOrder.php on line 5
    • > PHP Fatal error
      Uncaught Error: Class 'PayPal\\Common\\PayPalModel' not found in wp-content/plugins/gift-voucher/vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/CarrierAccountToken.php:17
    • > PHP Fatal error
      Uncaught Error: Class 'Stripe\\ApiResource' not found in wp-content/plugins/gift-voucher/vendor/stripe/stripe-php/lib/AlipayAccount.php:13
    • > PHP Fatal error
      Uncaught Error: Interface 'PayPal\\Handler\\IPayPalHandler' not found in wp-content/plugins/gift-voucher/vendor/paypal/rest-api-sdk-php/lib/PayPal/Handler/RestHandler.php:20

User-side errors 0% from 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the browser (console and network errors and warnings)
These are user-side errors you should fix
    • > GET request to /wp-admin/admin.php?page=view-voucher-details
    • > Network (severe)
    wp-content/plugins/gift-voucher/assets/img/pdf.png%20width= - Failed to load resource: the server responded with a status of 404 (Not Found)

Optimizations

Plugin configuration 97% from 29 tests

readme.txt 94% 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 need to be fixed:
  • Screenshots: Add descriptions for screenshots #13, #14 in gift-voucher/assets to your readme.txt
The official readme.txt is a good inspiration

gift-voucher/gift-voucher.php Passed 13 tests

The primary PHP file in "Gift Cards (Gift Vouchers and Packages) (WooCommerce Supported)" version 4.3.6 is used by WordPress to initiate all plugin functionality
101 characters long description:
Let your customers buy gift cards/certificates for your services & products directly on your website.

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
These items require your attention
  • Even if your plugin relies on executable files (for example a companion app), never distribute executable files with your plugin
    • .crt - Security Certificate in Firefox, IE, Chrome, Safari
      • wp-content/plugins/gift-voucher/vendor/stripe/stripe-php/data/ca-certificates.crt
82,101 lines of code in 656 files:
LanguageFilesBlank linesComment linesLines of code
PHP51741,57078,37742,509
JavaScript104,2984,80818,286
PO File125,0016,9309,238
HTML597203,240
CSS9467173,061
SVG8102,814
Markdown1660901,534
JSON14001,171
XML8110224
YAML20022
Ruby1002

PHP code Passed 2 tests

A brief analysis of cyclomatic complexity and code structure for this plugin
Although this was not an exhaustive test, there were no cyclomatic complexity issues detected
Cyclomatic complexity
Average complexity per logical line of code0.20
Average class complexity6.43
▷ Minimum class complexity1.00
▷ Maximum class complexity339.00
Average method complexity1.68
▷ Minimum method complexity1.00
▷ Maximum method complexity29.00
Code structure
Namespaces39
Interfaces13
Traits9
Classes432
▷ Abstract classes204.63%
▷ Concrete classes41295.37%
▷ Final classes10.24%
Methods3,599
▷ Static methods2898.03%
▷ Public methods3,37693.80%
▷ Protected methods1293.58%
▷ Private methods942.61%
Functions103
▷ Named functions9188.35%
▷ Anonymous functions1211.65%
Constants646
▷ Global constants182.79%
▷ Class constants62897.21%
▷ Public constants628100.00%

Plugin size 50% from 2 tests

Image compression 50% from 2 tests

Using a strong compression for your PNG files is a great way to speed-up your plugin
29 PNG files occupy 1.34MB with 0.27MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/img/style2.png11.22KB11.32KB0.00%
assets/img/icon-mail-envelope.png3.56KB2.09KB▼ 41.48%
assets/img/delivery-truck.png0.69KB0.70KB0.00%
assets/img/info-icon.png3.03KB3.14KB0.00%
assets/img/templates/png/template-voucher-lanscape-4.png53.32KB22.36KB▼ 58.06%