66% pdf-generator-for-wp

Code Review | PDF Generator for WordPress - Create & Customize PDF for Posts, Pages and WooCommerce Products

WordPress plugin PDF Generator for WordPress - Create & Customize PDF for Posts, Pages and WooCommerce Products scored66%from 54 tests.

About plugin

  • Plugin page: pdf-generator-for-wp
  • Plugin version: 1.2.9
  • PHP compatiblity: 7.2+
  • PHP version: 7.4.16
  • WordPress compatibility: 5.5.0-6.4.1
  • WordPress version: 6.3.1
  • First release: May 26, 2021
  • Latest release: Nov 24, 2023
  • Number of updates: 42
  • Update frequency: every 21.7 days
  • Top authors: wpswings (76.19%)makewebbetter (26.19%)

Code review

54 tests

User reviews

24 reviews

Install metrics

1,000+ active /37,521 total downloads

Benchmarks

Plugin footprint 82% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | The install procedure must perform silently
Install script ran successfully

Server metrics [RAM: ▲0.92MB] [CPU: ▲1.38ms] Passed 4 tests

Analyzing server-side resources used by PDF Generator for WordPress - Create & Customize PDF for Posts, Pages and WooCommerce Products
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /4.05 ▲0.5943.18 ▲2.60
Dashboard /wp-admin4.43 ▲1.1354.04 ▲4.47
Posts /wp-admin/edit.php4.28 ▲0.9233.69 ▼12.23
Add New Post /wp-admin/post-new.php6.98 ▲1.0999.14 ▲12.53
Media Library /wp-admin/upload.php4.30 ▲1.0741.35 ▲10.66
PDF Generator For WP /wp-admin/admin.php?page=pdf_generator_for_wp_menu4.3250.67
Home /wp-admin/admin.php?page=home4.3143.79

Server storage [IO: ▲25.22MB] [DB: ▲0.00MB] 67% from 3 tests

Analyzing filesystem and database footprints of this plugin
Please try to fix the following items
  • Filesystem usage must be lower than 25MB (currently using 25.22MB)
Filesystem: 800 new files
Database: no new tables, 15 new options
New WordPress options
pgfw_save_admin_display_settings
can_compress_scripts
widget_recent-comments
widget_recent-posts
theysaidso_admin_options
pgfw_body_save_settings
pgfw_advanced_save_settings
pgfw_meta_fields_save_settings
db_upgraded
wps_all_plugins_active
...

Browser metrics Passed 4 tests

This is an overview of browser requirements for PDF Generator for WordPress - Create & Customize PDF for Posts, Pages and WooCommerce Products
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,945 ▲18313.42 ▼1.298.91 ▲7.2436.97 ▼7.68
Dashboard /wp-admin2,212 ▲355.57 ▼0.1194.47 ▼5.8662.71 ▲18.25
Posts /wp-admin/edit.php2,142 ▲391.97 ▲0.0039.75 ▼0.5733.46 ▼1.88
Add New Post /wp-admin/post-new.php1,552 ▲2623.77 ▲0.21615.07 ▼87.17121.96 ▲65.68
Media Library /wp-admin/upload.php1,432 ▲324.13 ▼0.1399.85 ▼5.4079.05 ▲32.20
PDF Generator For WP /wp-admin/admin.php?page=pdf_generator_for_wp_menu2,2405.82111.48191.73
Home /wp-admin/admin.php?page=home1,1515.2683.80101.67

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

🔸 Tests weight: 35 | The uninstall procedure must remove all plugin files and extra database tables
Please fix the following items
  • This plugin did not uninstall successfully, leaving 15 options in the database
    • pgfw_footer_setting_submit
    • theysaidso_admin_options
    • widget_theysaidso_widget
    • widget_recent-comments
    • pgfw_header_setting_submit
    • pgfw_general_settings_save
    • pgfw_pdf_upload_save_settings
    • widget_recent-posts
    • pgfw_advanced_save_settings
    • db_upgraded
    • ...

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
These server-side errors were triggered
  • 4 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=home
    • > Warning in wp-includes/functions.php+6935
    Cannot modify header information - headers already sent by (output started at wp-includes/script-loader.php:2838)

SRP 0% from 2 tests

🔹 Tests weight: 20 | SRP (Single-Responsibility Principle) - PHP files must act as libraries and never output text or perform any action when accessed directly in a browser
Almost there! Just fix the following items
  • 3× PHP files perform the task of outputting text when accessed with GET requests:
    • > /wp-content/plugins/pdf-generator-for-wp/common/partials/pdf-generator-for-wp-common-display.php
    • > /wp-content/plugins/pdf-generator-for-wp/public/partials/pdf-generator-for-wp-public-display.php
    • > /wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/sabberworm/php-css-parser/tests/quickdump.php
  • 191× GET requests to PHP files have triggered server-side errors or warnings (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'Dompdf\\Positioner\\AbstractPositioner' not found in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/dompdf/dompdf/src/Positioner/TableCell.php:19
    • > PHP Fatal error
      Uncaught Error: Class 'FontLib\\TrueType\\Header' not found in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/phenx/php-font-lib/src/FontLib/WOFF/Header.php:16
    • > PHP Fatal error
      Uncaught Error: Interface 'Dompdf\\Canvas' not found in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/dompdf/dompdf/src/Adapter/GD.php:24
    • > PHP Fatal error
      Uncaught Error: Class 'Dompdf\\Positioner\\AbstractPositioner' not found in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/dompdf/dompdf/src/Positioner/Absolute.php:16
    • > PHP Notice
      Undefined variable: fontDir in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/dompdf/dompdf/lib/fonts/dompdf_font_family_cache.php on line 64
    • > PHP Notice
      Undefined variable: fontDir in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/dompdf/dompdf/lib/fonts/dompdf_font_family_cache.php on line 9
    • > PHP Notice
      Undefined variable: fontDir in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/dompdf/dompdf/lib/fonts/dompdf_font_family_cache.php on line 41
    • > PHP Notice
      Undefined variable: fontDir in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/dompdf/dompdf/lib/fonts/dompdf_font_family_cache.php on line 11
    • > PHP Fatal error
      Uncaught Error: Class 'Sabberworm\\CSS\\Parsing\\SourceException' not found in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/sabberworm/php-css-parser/lib/Sabberworm/CSS/Parsing/OutputException.php:8
    • > PHP Fatal error
      Uncaught Error: Class 'FontLib\\BinaryStream' not found in wp-content/plugins/pdf-generator-for-wp/package/lib/dompdf/vendor/phenx/php-font-lib/src/FontLib/Table/Type/nameRecord.php:18

User-side errors 0% from 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
Please take a look at the following user-side issues
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=home
    • > Network (severe)
    wp-content/plugins/pdf-generator-for-wp/admin/src/fonts/nunito-sans/NunitoSans-Regular.ttf - Failed to load resource: the server responded with a status of 404 (Not Found)

Optimizations

Plugin configuration 96% from 29 tests

readme.txt Passed 16 tests

Often overlooked, readme.txt is one of the most important files in your plugin
5 plugin tags: pdf generator, pdf creator, wordpress pdf generator, pdf, pdf maker

pdf-generator-for-wp/pdf-generator-for-wp.php 92% from 13 tests

This is the main PHP file of "PDF Generator for WordPress - Create & Customize PDF for Posts, Pages and WooCommerce Products" version 1.2.9, providing information about the plugin in the header fields and serving as the principal entry point to the plugin's functions
It is important to fix the following:
  • Description: Keep the plugin description shorter than 140 characters (currently 464 characters long)

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short review of files and their extensions; it is not recommended to include executable files
Success! There were no dangerous files found in this plugin179,942 lines of code in 544 files:
LanguageFilesBlank linesComment linesLines of code
PHP30310,41721,75490,126
SVG414136,072
HTML681,733024,460
JavaScript274,18914,31914,325
CSS721,5002828,869
XML17631093,490
PO File15336861,211
Markdown62650947
JSON600378
YAML312264

PHP code 50% from 2 tests

This is a very shot review of cyclomatic complexity and code structure
The following items need your attention
  • Method cyclomatic complexity should be reduced to less than 100 (currently 652)
Cyclomatic complexity
Average complexity per logical line of code0.42
Average class complexity36.62
▷ Minimum class complexity1.00
▷ Maximum class complexity797.00
Average method complexity4.45
▷ Minimum method complexity1.00
▷ Maximum method complexity652.00
Code structure
Namespaces35
Interfaces5
Traits0
Classes218
▷ Abstract classes125.50%
▷ Concrete classes20694.50%
▷ Final classes00.00%
Methods2,370
▷ Static methods1466.16%
▷ Public methods2,03885.99%
▷ Protected methods24810.46%
▷ Private methods843.54%
Functions45
▷ Named functions2862.22%
▷ Anonymous functions1737.78%
Constants184
▷ Global constants105.43%
▷ Class constants17494.57%
▷ Public constants174100.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
35 PNG files occupy 1.24MB with 0.41MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
admin/src/images/timer.png1.22KB0.97KB▼ 20.93%
admin/src/images/temp1_screenshot.png133.12KB36.02KB▼ 72.94%
package/lib/datatable/DataTables-1.10.24/images/sort_asc.png0.16KB0.25KB0.00%
admin/src/images/print_icon.png3.84KB3.75KB▼ 2.44%
admin/src/images/temp4_screenshot.png261.24KB79.18KB▼ 69.69%