10% wp-pdf-templates

Code Review | WordPress PDF Templates

WordPress plugin WordPress PDF Templates scored10%from 54 tests.

About plugin

  • Plugin page: wp-pdf-templates
  • Plugin version: 1.4.3
  • PHP version: 7.4.16
  • WordPress compatibility: 4.0-4.4.2
  • WordPress version: 6.3.1
  • First release: Jun 24, 2014
  • Latest release: Jun 5, 2017
  • Number of updates: 53
  • Update frequency: every 20.3 days
  • Top authors: Zuige (96.23%)ottok (3.77%)onnimonni (3.77%)

Code review

54 tests

User reviews

21 reviews

Install metrics

700+ active /18,017 total downloads

Benchmarks

Plugin footprint 40% from 16 tests

Installer 0% from 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
These installer errors require your attention
  • Install procedure validation failed for this plugin
    • > Warning in wp-content/plugins/wp-pdf-templates/wp-pdf-templates.php+172
    copy(wp-content/plugins/wp-pdf-templatesvendor/dompdf/dompdf/lib/fonts/dompdf_font_family_cache.dist.php): failed to open stream: No such file or directory

Server metrics [RAM: ▲0.05MB] [CPU: ▼3.37ms] Passed 4 tests

Server-side resources used by WordPress PDF Templates
This plugin does not affect your website's performance
PageMemory (MB)CPU Time (ms)
Home /3.53 ▲0.0741.71 ▲0.36
Dashboard /wp-admin3.35 ▲0.0549.63 ▼0.48
Posts /wp-admin/edit.php3.42 ▲0.0654.13 ▲3.04
Add New Post /wp-admin/post-new.php5.94 ▲0.0587.25 ▼14.28
Media Library /wp-admin/upload.php3.28 ▲0.0537.65 ▲0.94

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

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

Browser metrics Passed 4 tests

This is an overview of browser requirements for WordPress PDF Templates
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,789 ▲2814.34 ▼0.011.85 ▲0.0542.84 ▼6.96
Dashboard /wp-admin2,192 ▲125.62 ▼0.0593.71 ▲2.4641.60 ▲1.89
Posts /wp-admin/edit.php2,100 ▼02.02 ▲0.0640.92 ▲0.5136.75 ▼3.74
Add New Post /wp-admin/post-new.php1,526 ▼223.03 ▲0.22646.50 ▲10.0351.01 ▲0.48
Media Library /wp-admin/upload.php1,403 ▼04.25 ▲0.09102.48 ▲2.2144.43 ▼0.34

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

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
The following items require your attention
  • The plugin did not uninstall gracefully
    • > Warning in wp-content/plugins/wp-pdf-templates/uninstall.php+27
    rmdir(wp-content/uploads/dompdf-fonts): Directory not empty
  • Zombie WordPress options were found after uninstall: 6 options
    • theysaidso_admin_options
    • widget_theysaidso_widget
    • db_upgraded
    • widget_recent-posts
    • widget_recent-comments
    • can_compress_scripts

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no server-side errors were triggered
Good news, no errors were detected

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
Please fix the following
  • 2× PHP files output text when accessed directly:
    • > /wp-content/plugins/wp-pdf-templates/load_font.php
    • > /wp-content/plugins/wp-pdf-templates/dompdf/load_font.php
  • 377× PHP files trigger errors when accessed directly with GET requests (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'Composer\\Installers\\BaseInstaller' not found in wp-content/plugins/wp-pdf-templates/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'FontLib\\Header' not found in wp-content/plugins/wp-pdf-templates/vendor/phenx/php-font-lib/src/FontLib/EOT/Header.php:21
    • > PHP Fatal error
      Uncaught Error: Class 'Composer\\Installers\\BaseInstaller' not found in wp-content/plugins/wp-pdf-templates/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php:4
    • > PHP Warning
      Use of undefined constant DOMPDF_DIR - assumed 'DOMPDF_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/wp-pdf-templates/dompdf/lib/fonts/dompdf_font_family_cache.dist.php on line 27
    • > PHP Warning
      Use of undefined constant DOMPDF_DIR - assumed 'DOMPDF_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/wp-pdf-templates/dompdf/lib/fonts/dompdf_font_family_cache.dist.php on line 54
    • > PHP Fatal error
      Uncaught Error: Class 'Dompdf\\Positioner\\AbstractPositioner' not found in wp-content/plugins/wp-pdf-templates/vendor/dompdf/dompdf/src/Positioner/ListBullet.php:19
    • > PHP Warning
      Use of undefined constant DOMPDF_LIB_DIR - assumed 'DOMPDF_LIB_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/wp-pdf-templates/dompdf/include/stylesheet.cls.php on line 15
    • > PHP Notice
      Undefined variable: rootDir in wp-content/plugins/wp-pdf-templates/vendor/dompdf/dompdf/lib/fonts/dompdf_font_family_cache.dist.php on line 70
    • > PHP Warning
      Use of undefined constant DOMPDF_DIR - assumed 'DOMPDF_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/wp-pdf-templates/dompdf/lib/fonts/dompdf_font_family_cache.dist.php on line 7
    • > PHP Fatal error
      Uncaught Error: Class 'Frame_Reflower' not found in wp-content/plugins/wp-pdf-templates/dompdf/include/text_frame_reflower.cls.php:16

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
Everything seems fine, but this is not an exhaustive test

Optimizations

Plugin configuration Passed 29 tests

readme.txt Passed 16 tests

The readme.txt file is undoubtedly the most important file in your plugin, preparing it for public listing on WordPress.org
5 plugin tags: seravo, dompdf, templates, print, pdf

wp-pdf-templates/wp-pdf-templates.php Passed 13 tests

The primary PHP file in "WordPress PDF Templates" version 1.4.3 is used by WordPress to initiate all plugin functionality
124 characters long description:
This plugin utilises the DOMPDF Library to provide a URL endpoint e.g. /my-post/pdf/ that generates a downloadable PDF file.

Code Analysis 97% from 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 plugin52,464 lines of code in 394 files:
LanguageFilesBlank linesComment linesLines of code
PHP36714,21623,05250,921
Markdown91650563
JSON900479
CSS18842378
XML33057
YAML312048
HTML20018

PHP code 50% from 2 tests

An overview of cyclomatic complexity and code structure
It is recommended to fix the following
  • Method cyclomatic complexity has to be reduced to less than 100 (currently 653)
Cyclomatic complexity
Average complexity per logical line of code0.42
Average class complexity29.29
▷ Minimum class complexity1.00
▷ Maximum class complexity766.00
Average method complexity4.50
▷ Minimum method complexity1.00
▷ Maximum method complexity653.00
Code structure
Namespaces26
Interfaces3
Traits0
Classes350
▷ Abstract classes144.00%
▷ Concrete classes33696.00%
▷ Final classes00.00%
Methods2,954
▷ Static methods1404.74%
▷ Public methods2,48684.16%
▷ Protected methods35912.15%
▷ Private methods1093.69%
Functions79
▷ Named functions6683.54%
▷ Anonymous functions1316.46%
Constants330
▷ Global constants154.55%
▷ Class constants31595.45%
▷ Public constants315100.00%

Plugin size 50% from 2 tests

Image compression 50% from 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
7 PNG files occupy 1.27MB with 0.62MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/icon-128x128.png8.83KB5.46KB▼ 38.12%
dompdf/lib/res/broken_image.png0.60KB0.47KB▼ 22.33%
assets/banner-1544x500.png18.62KB7.36KB▼ 60.46%
assets/banner-772x250.png13.73KB6.67KB▼ 51.40%
assets/screenshot-1.png1,237.33KB358.07KB▼ 71.06%