73% wp-conditional-post-restrictions

Code Review | Restrict Posts based on Conditions - Conditional Post Restrictions

WordPress plugin Restrict Posts based on Conditions - Conditional Post Restrictions scored73%from 54 tests.

About plugin

  • Plugin page: wp-conditional-po...
  • Plugin version: 1.2.2
  • PHP version: 7.4.16
  • WordPress compatibility: 3.6-6.2
  • WordPress version: 6.3.1
  • First release: Oct 9, 2020
  • Latest release: Jul 5, 2023
  • Number of updates: 14
  • Update frequency: every 71.4 days
  • Top authors: JoseVega (100%)

Code review

54 tests

User reviews

2 reviews

Install metrics

70+ active /2,695 total downloads

Benchmarks

Plugin footprint 64% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
This plugin's installer ran successfully

Server metrics [RAM: ▲5.57MB] [CPU: ▲23.18ms] 50% from 4 tests

Analyzing server-side resources used by Restrict Posts based on Conditions - Conditional Post Restrictions
The following require your attention
  • CPU: Total CPU usage should be kept under 500.00ms (currently 1,645.55ms on /wp-admin/options-general.php?page=vpr_settings)
  • Extra RAM: Try to keep extra memory usage under 5MB (currently 5.57MB on /wp-admin/options-general.php?page=vpr_settings)
PageMemory (MB)CPU Time (ms)
Home /9.26 ▲5.7973.43 ▲12.80
Dashboard /wp-admin9.28 ▲5.9790.10 ▲33.98
Posts /wp-admin/edit.php9.28 ▲5.9292.46 ▲37.31
Add New Post /wp-admin/post-new.php10.49 ▲4.60132.50 ▲8.64
Media Library /wp-admin/upload.php9.28 ▲6.0477.77 ▲37.40
Freemius Debug [v.2.5.10] /wp-admin/admin.php?page=freemius9.2888.68
Posts restrictions /wp-admin/options-general.php?page=vpr_settings9.281,645.55

Server storage [IO: ▲3.77MB] [DB: ▲0.00MB] Passed 3 tests

How much does this plugin use your filesystem and database?
No storage issues were detected
Filesystem: 284 new files
Database: no new tables, 10 new options
New WordPress options
wpcpr_welcome_redirect
widget_recent-posts
widget_theysaidso_widget
theysaidso_admin_options
db_upgraded
fs_active_plugins
fs_debug_mode
widget_recent-comments
fs_accounts
can_compress_scripts

Browser metrics Passed 4 tests

Restrict Posts based on Conditions - Conditional Post Restrictions: an overview of browser usage
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,810 ▲2414.37 ▲0.131.71 ▼0.4330.48 ▼16.01
Dashboard /wp-admin2,219 ▲425.61 ▼0.1099.66 ▼12.4046.77 ▼9.31
Posts /wp-admin/edit.php2,122 ▲192.06 ▲0.0245.33 ▲2.2441.74 ▼0.89
Add New Post /wp-admin/post-new.php1,827 ▲30120.28 ▲2.75688.79 ▼91.1155.44 ▼7.73
Media Library /wp-admin/upload.php1,421 ▲244.15 ▼0.03108.19 ▼5.6749.26 ▲0.82
Freemius Debug [v.2.5.10] /wp-admin/admin.php?page=freemius1,0891.9531.4833.31
Posts restrictions /wp-admin/options-general.php?page=vpr_settings1,0441.9027.7361.00

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

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
You still need to fix the following
  • Uninstall procedure had uncaught errors
    • > Notice in wp-content/plugins/wp-conditional-post-restrictions/vendor/freemius/includes/class-freemius.php+8486
    Undefined property: stdClass::$plugins
  • This plugin did not uninstall successfully, leaving 10 options in the database
    • wpcpr_welcome_redirect
    • fs_debug_mode
    • theysaidso_admin_options
    • db_upgraded
    • fs_active_plugins
    • widget_theysaidso_widget
    • widget_recent-posts
    • can_compress_scripts
    • fs_accounts
    • widget_recent-comments

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no server-side errors were triggered
Even though everything seems fine, this is not 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
  • 21× GET requests to PHP files trigger server-side errors or Error 500 responses (only 10 are shown):
    • > PHP Warning
      Use of undefined constant WPCPR_DIST_DIR - assumed 'WPCPR_DIST_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/wp-conditional-post-restrictions/inc/freemius-init.php on line 11
    • > PHP Fatal error
      require_once(): Failed opening required 'WPCPR_DIST_DIR/vendor/freemius/start.php' (include_path='.:/usr/share/php') in wp-content/plugins/wp-conditional-post-restrictions/inc/freemius-init.php on line 11
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_path() in wp-content/plugins/wp-conditional-post-restrictions/modules/core/wpcr/conditions.php:9
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_create_nonce() in wp-content/plugins/wp-conditional-post-restrictions/vendor/vg-plugin-sdk/views/page-template.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/wp-conditional-post-restrictions/backend/settings-page.php:3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_filter() in wp-content/plugins/wp-conditional-post-restrictions/backend/teasers.php:3
    • > PHP Fatal error
      Uncaught Error: Class 'Vegacorp_Condition' not found in wp-content/plugins/wp-conditional-post-restrictions/modules/core/inc/conditions/user/user-role.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'Vegacorp_Condition' not found in wp-content/plugins/wp-conditional-post-restrictions/modules/core/inc/conditions/posts/is-the-post-author.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'Vegacorp_Condition' not found in wp-content/plugins/wp-conditional-post-restrictions/modules/core/inc/conditions/posts/referer.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function get_header() in wp-content/plugins/wp-conditional-post-restrictions/modules/core/views/frontend/custom-restricted-object-content.php:2

User-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
There were no browser issues found

Optimizations

Plugin configuration Passed 29 tests

readme.txt Passed 16 tests

The readme.txt file uses markdown syntax to describe your plugin to the world
5 plugin tags: registration form, access-control, restrict access, restrict posts, restrict pages

wp-conditional-post-restrictions/wp-conditional-post-restrictions.php Passed 13 tests

The main PHP script in "Restrict Posts based on Conditions - Conditional Post Restrictions" version 1.2.2 is automatically included on every request by WordPress
45 characters long description:
Restricts posts based on different conditions

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | This is an overview of file extensions present in this plugin and a short test that no dangerous files are bundled with this plugin
Success! There were no dangerous files found in this plugin46,496 lines of code in 239 files:
LanguageFilesBlank linesComment linesLines of code
PHP1529,07217,84836,185
JavaScript662,6537299,788
CSS19690512
XML10010
SVG1001

PHP code 50% from 2 tests

A short review of cyclomatic complexity and code structure
Please tend to the following items
  • Cyclomatic complexity of classes should be reduced to less than 1000 (currently 3,073)
Cyclomatic complexity
Average complexity per logical line of code0.60
Average class complexity65.66
▷ Minimum class complexity1.00
▷ Maximum class complexity3,073.00
Average method complexity4.29
▷ Minimum method complexity1.00
▷ Maximum method complexity94.00
Code structure
Namespaces0
Interfaces0
Traits8
Classes66
▷ Abstract classes34.55%
▷ Concrete classes6395.45%
▷ Final classes00.00%
Methods1,485
▷ Static methods20113.54%
▷ Public methods1,09073.40%
▷ Protected methods201.35%
▷ Private methods37525.25%
Functions112
▷ Named functions112100.00%
▷ Anonymous functions00.00%
Constants152
▷ Global constants10569.08%
▷ Class constants4730.92%
▷ Public constants47100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Using a strong compression for your PNG files is a great way to speed-up your plugin
2 PNG files occupy 0.02MB with 0.01MB in potential savings
Potential savings
Compression of 2 random PNG files using pngquant
FileSize - originalSize - compressedSavings
vendor/freemius/assets/img/theme-icon.png10.97KB5.78KB▼ 47.37%
vendor/freemius/assets/img/plugin-icon.png9.16KB5.26KB▼ 42.58%