78% prevent-direct-access

Code Review | Prevent Direct Access - Protect WordPress Files

WordPress plugin Prevent Direct Access - Protect WordPress Files scored78%from 54 tests.

About plugin

  • Plugin page: prevent-direct-ac...
  • Plugin version: 2.8.5
  • PHP compatiblity: 5.6.1+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.7-6.3.1
  • WordPress version: 6.3.1
  • First release: Nov 27, 2015
  • Latest release: Sep 12, 2023
  • Number of updates: 133
  • Update frequency: every 21.4 days
  • Top authors: gaupoit (84.96%)duonghung1269 (12.03%)buildwps (4.51%)

Code review

54 tests

User reviews

270 reviews

Install metrics

9,000+ active /146,654 total downloads

Benchmarks

Plugin footprint 82% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | All plugins must install correctly, without throwing any errors, warnings, or notices
The plugin installed gracefully, with no errors

Server metrics [RAM: ▲0.49MB] [CPU: ▲5.69ms] 75% from 4 tests

Server-side resources used by Prevent Direct Access - Protect WordPress Files
Please take the time to fix the following items
  • CPU: You should keep total CPU usage under 500.00ms (currently 867.37ms on /wp-admin/admin.php?page=wp_pda_options)
PageMemory (MB)CPU Time (ms)
Home /3.99 ▲0.4947.61 ▲6.50
Dashboard /wp-admin3.86 ▲0.4767.83 ▲0.11
Posts /wp-admin/edit.php3.89 ▲0.5063.28 ▲15.16
Add New Post /wp-admin/post-new.php6.47 ▲0.54109.61 ▲7.81
Media Library /wp-admin/upload.php3.79 ▲0.5246.43 ▲8.34
Go Pro /wp-admin/admin.php?page=wp_pda_gopro3.7252.68
Settings /wp-admin/admin.php?page=wp_pda_options3.77867.37

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

Input-output and database impact of this plugin
Just a few items left to fix
  • Illegal file modification found: 1 file (0.99KB) outside of "wp-content/plugins/prevent-direct-access/" and "wp-content/uploads/"
    • (modified) .htaccess
Filesystem: 107 new files
Database: 1 new table, 10 new options
New tables
wp_prevent_direct_access_free
New WordPress options
FREE_PDA_SETTINGS
can_compress_scripts
updated_htaccess_success
pda_options
widget_theysaidso_widget
db_upgraded
theysaidso_admin_options
widget_recent-comments
widget_recent-posts
pda_jal_db_version_free

Browser metrics Passed 4 tests

Prevent Direct Access - Protect WordPress Files: an overview of browser usage
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,824 ▲3814.46 ▼0.071.78 ▼0.3447.71 ▲5.71
Dashboard /wp-admin2,230 ▲505.60 ▼0.0183.16 ▼11.6440.86 ▲3.59
Posts /wp-admin/edit.php2,135 ▲352.00 ▲0.0537.37 ▲1.2835.88 ▼1.14
Add New Post /wp-admin/post-new.php1,564 ▲3623.02 ▼0.19649.56 ▼53.9744.18 ▼14.94
Media Library /wp-admin/upload.php1,497 ▲1006.40 ▲1.98134.35 ▲32.8745.86 ▼2.98
Go Pro /wp-admin/admin.php?page=wp_pda_gopro1,3241.8127.4558.13
Settings /wp-admin/admin.php?page=wp_pda_options1,1512.0528.0641.53

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

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
The following items require your attention
  • Zombie WordPress options were found after uninstall: 9 options
    • widget_theysaidso_widget
    • db_upgraded
    • can_compress_scripts
    • widget_recent-comments
    • theysaidso_admin_options
    • updated_htaccess_success
    • widget_recent-posts
    • FREE_PDA_SETTINGS
    • pda_options

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

SRP 0% from 2 tests

🔹 Tests weight: 20 | A shallow check of the single-responsibility principle; PHP files should perform no action - including output of placeholder text - and trigger no errors when accessed directly
Almost there! Just fix the following items
  • 1× PHP files perform the task of outputting text when accessed with GET requests:
    • > /wp-content/plugins/prevent-direct-access/includes/function.php
  • 26× GET requests to PHP files trigger server-side errors or Error 500 responses (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_html__() in wp-content/plugins/prevent-direct-access/includes/views/view-prevent-direct-access-lite-remove-license-and-all-data.php:18
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_attr() in wp-content/plugins/prevent-direct-access/includes/views/view-prevent-direct-access-lite-ptotect-file.php:12
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_attr() in wp-content/plugins/prevent-direct-access/includes/views/view-prevent-direct-access-lite-prevent-right-click.php:12
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_attr() in wp-content/plugins/prevent-direct-access/includes/views/view-prevent-direct-access-lite-prevent-hotlinking.php:12
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_html__() in wp-content/plugins/prevent-direct-access/includes/views/view-prevent-direct-access-lite-no-access-page.php:12
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_get_current_user() in wp-content/plugins/prevent-direct-access/includes/partials/subscribe.php:8
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_html__() in wp-content/plugins/prevent-direct-access/includes/views/view-prevent-direct-access-lite-auto-create-private-link.php:18
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_html__() in wp-content/plugins/prevent-direct-access/includes/views/view-prevent-direct-access-lite-block-access-info-file.php:17
    • > PHP Fatal error
      Uncaught Error: Class 'Pda_Helper' not found in wp-content/plugins/prevent-direct-access/includes/views/view-prevent-direct-access-lite-file-access-permission.php:8
    • > PHP Fatal error
      Uncaught Error: Call to undefined function esc_html__() in wp-content/plugins/prevent-direct-access/includes/views/view-prevent-direct-access-lite-private-url-prefix.php:13

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a smoke test targeting browser errors/issues
Everything seems fine on the user side

Optimizations

Plugin configuration 96% from 29 tests

readme.txt Passed 16 tests

The readme.txt file uses markdown syntax to describe your plugin to the world
5 plugin tags: copy protection, protection, downloads, folder protection, uploads

prevent-direct-access/prevent-direct-access.php 92% from 13 tests

"Prevent Direct Access - Protect WordPress Files" version 2.8.5's main PHP file describes plugin functionality and also serves as the entry point to any WordPress functionality
Please make the necessary changes and fix the following:
  • Description: The description should be shorter than 140 characters (currently 206 characters long)

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | Executable files are considered dangerous and should not be included with any WordPress plugin
There were no executable files found in this plugin16,167 lines of code in 73 files:
LanguageFilesBlank linesComment linesLines of code
CSS121,747488,920
PHP425951,2483,673
SVG1002,671
JavaScript104283489
PO File8119151414

PHP code Passed 2 tests

This is a very shot review of cyclomatic complexity and code structure
No complexity issues detected
Cyclomatic complexity
Average complexity per logical line of code0.30
Average class complexity17.07
▷ Minimum class complexity1.00
▷ Maximum class complexity98.00
Average method complexity2.59
▷ Minimum method complexity1.00
▷ Maximum method complexity15.00
Code structure
Namespaces1
Interfaces0
Traits0
Classes15
▷ Abstract classes00.00%
▷ Concrete classes15100.00%
▷ Final classes00.00%
Methods154
▷ Static methods2012.99%
▷ Public methods14896.10%
▷ Protected methods00.00%
▷ Private methods63.90%
Functions40
▷ Named functions3587.50%
▷ Anonymous functions512.50%
Constants22
▷ Global constants836.36%
▷ Class constants1463.64%
▷ Public constants14100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

It is recommended to compress PNG files in your plugin to minimize bandwidth usage
11 PNG files occupy 0.45MB with 0.25MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
public/assets/avatar/default3.png0.53KB0.17KB▼ 68.32%
public/assets/avatar/deborah-128.png28.56KB9.61KB▼ 66.37%
public/assets/avatar/default2.png5.24KB2.54KB▼ 51.50%
public/assets/pda-gold-affiliate-banner-v5.png142.24KB77.54KB▼ 45.49%
public/assets/pda-gold-affiliate-banner(1200x480).png178.56KB100.18KB▼ 43.90%