68% ip2location-country-blocker

Code Review | IP2Location Country Blocker

WordPress plugin IP2Location Country Blocker scored68%from 54 tests.

About plugin

  • Plugin page: ip2location-count...
  • Plugin version: 2.33.2
  • PHP version: 7.4.16
  • WordPress compatibility: 4.6-6.4
  • WordPress version: 6.3.1
  • First release: Nov 26, 2013
  • Latest release: Nov 10, 2023
  • Number of updates: 405
  • Update frequency: every 9.0 days
  • Top authors: ip2location (100%)

Code review

54 tests

User reviews

109 reviews

Install metrics

20,000+ active /842,571 total downloads

Benchmarks

Plugin footprint 65% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | It is important to correctly install your plugin, without throwing errors or notices
This plugin's installer ran successfully

Server metrics [RAM: ▲0.69MB] [CPU: ▼7.76ms] Passed 4 tests

An overview of server-side resources used by IP2Location Country Blocker
This plugin does not affect your website's performance
PageMemory (MB)CPU Time (ms)
Home /4.19 ▲0.7237.14 ▼4.19
Dashboard /wp-admin4.04 ▲0.6950.06 ▼11.50
Posts /wp-admin/edit.php4.09 ▲0.7349.72 ▲2.83
Add New Post /wp-admin/post-new.php6.57 ▲0.6984.21 ▼18.16
Media Library /wp-admin/upload.php3.90 ▲0.6737.73 ▲4.29
Settings /wp-admin/admin.php?page=ip2location-country-blocker-settings3.8733.65
Statistics /wp-admin/admin.php?page=ip2location-country-blocker-statistics3.8733.96
IP Lookup /wp-admin/admin.php?page=ip2location-country-blocker-ip-lookup3.8733.45
Backend /wp-admin/admin.php?page=ip2location-country-blocker-backend3.8732.60
Frontend /wp-admin/admin.php?page=ip2location-country-blocker3.8733.63

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

How much does this plugin use your filesystem and database?
The plugin installed successfully
Filesystem: 65 new files
Database: 3 new tables, 45 new options
New tables
wp_ip2location_country_blocker_backend_rate_limit_log
wp_ip2location_country_blocker_frontend_rate_limit_log
wp_ip2location_country_blocker_log
New WordPress options
ip2location_country_blocker_px_lookup_mode
ip2location_country_blocker_frontend_whitelist_logged_user
ip2location_country_blocker_detect_forwarder_ip
ip2location_country_blocker_backend_block_mode
ip2location_country_blocker_frontend_skip_bots
ip2location_country_blocker_debug_log_enabled
db_upgraded
ip2location_country_blocker_px_database
ip2location_country_blocker_frontend_redirect_url
ip2location_country_blocker_backend_skip_bots
...

Browser metrics Passed 4 tests

A check of browser resources used by IP2Location Country Blocker
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,869 ▲10714.34 ▼0.371.72 ▼0.0936.31 ▼7.22
Dashboard /wp-admin2,275 ▲955.66 ▲0.0293.18 ▼6.1540.61 ▼2.10
Posts /wp-admin/edit.php2,177 ▲772.01 ▲0.0740.42 ▲3.7038.70 ▲3.96
Add New Post /wp-admin/post-new.php1,567 ▲3223.32 ▼1.81643.76 ▼4.6050.09 ▼14.94
Media Library /wp-admin/upload.php1,477 ▲774.28 ▲0.0399.50 ▼4.9040.36 ▼3.42
Settings /wp-admin/admin.php?page=ip2location-country-blocker-settings1,5392.2335.2037.70
Statistics /wp-admin/admin.php?page=ip2location-country-blocker-statistics1,5462.3629.2930.85
IP Lookup /wp-admin/admin.php?page=ip2location-country-blocker-ip-lookup1,5362.2328.2130.91
Backend /wp-admin/admin.php?page=ip2location-country-blocker-backend1,5462.3126.6733.88
Frontend /wp-admin/admin.php?page=ip2location-country-blocker1,5522.3126.8332.30

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

🔸 Tests weight: 35 | It is important to correctly uninstall your plugin, without leaving any traces
It is recommended to fix the following
  • Zombie tables were found after uninstall: 2 tables
    • wp_ip2location_country_blocker_frontend_rate_limit_log
    • wp_ip2location_country_blocker_backend_rate_limit_log
  • This plugin does not fully uninstall, leaving 6 options in the database
    • widget_theysaidso_widget
    • widget_recent-comments
    • theysaidso_admin_options
    • widget_recent-posts
    • db_upgraded
    • can_compress_scripts

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
The smoke test was a success, however most plugin functionality was not tested

SRP 0% from 2 tests

🔹 Tests weight: 20 | It is important to ensure that your PHP files perform no action when accessed directly, respecting the single-responsibility principle
Please fix the following items
  • 2× PHP files output non-empty strings when accessed directly via GET requests:
    • > /wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2location-php/tests/bootstrap.php
    • > /wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2proxy-php/tests/bootstrap.php
  • 11× PHP files trigger server errors when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2location-php/tests/WebServiceTest.php:10
    • > PHP Warning
      require(vendor/autoload.php): failed to open stream: No such file or directory in wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2proxy-php/examples/example.php on line 3
    • > PHP Warning
      require(vendor/autoload.php): failed to open stream: No such file or directory in wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2location-php/examples/example.php on line 3
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2proxy-php/tests/WebServiceTest.php:9
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2proxy-php/tests/DatabaseTest.php:9
    • > PHP Fatal error
      require(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/share/php') in wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2location-php/examples/example.php on line 3
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2location-php/tests/IpToolsTest.php:10
    • > PHP Fatal error
      Uncaught Error: Class 'PHPUnit\\Framework\\TestCase' not found in wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2location-php/tests/CountryTest.php:9
    • > PHP Fatal error
      require(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/share/php') in wp-content/plugins/ip2location-country-blocker/vendor/ip2location/ip2proxy-php/examples/example.php on line 3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_upload_dir() in wp-content/plugins/ip2location-country-blocker/ip2location-country-blocker.php:11

User-side errors Passed 1 test

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

Optimizations

Plugin configuration 90% from 29 tests

readme.txt 88% from 16 tests

Often overlooked, readme.txt is one of the most important files in your plugin
Attributes that need to be fixed:
  • Tags: Please reduce the number of tags, currently 11 tag instead of maximum 10
  • Screenshots: Screenshot #6 (**Statistic Page** - View blocked traffics and countries.) image required
The official readme.txt might help

ip2location-country-blocker/ip2location-country-blocker.php 92% from 13 tests

The main PHP script in "IP2Location Country Blocker" version 2.33.2 is automatically included on every request by WordPress
Please make the necessary changes and fix the following:
  • Text Domain: The text domain name should consist of only dashes and lowercase characters

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | Executable files are not allowed as they can serve as attack vectors
Good job! No executable or dangerous file extensions detected6,948 lines of code in 47 files:
LanguageFilesBlank linesComment linesLines of code
PHP281,4932,0376,097
JavaScript88612392
JSON300190
Markdown2770189
CSS415866
XML20014

PHP code Passed 2 tests

An short overview of logical lines of code, cyclomatic complexity, and other code metrics
Everything seems fine, there were no complexity issues found
Cyclomatic complexity
Average complexity per logical line of code0.46
Average class complexity58.53
▷ Minimum class complexity1.00
▷ Maximum class complexity532.00
Average method complexity5.51
▷ Minimum method complexity1.00
▷ Maximum method complexity98.00
Code structure
Namespaces10
Interfaces0
Traits0
Classes17
▷ Abstract classes00.00%
▷ Concrete classes17100.00%
▷ Final classes00.00%
Methods219
▷ Static methods2611.87%
▷ Public methods11753.42%
▷ Protected methods20.91%
▷ Private methods10045.66%
Functions4
▷ Named functions125.00%
▷ Anonymous functions375.00%
Constants104
▷ Global constants32.88%
▷ Class constants10197.12%
▷ Public constants7776.24%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
10 PNG files occupy 0.06MB with 0.03MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/img/step-1.png4.04KB1.52KB▼ 62.47%
assets/css/chosen-sprite@2x.png0.72KB0.83KB0.00%
assets/img/step-end.png31.47KB10.52KB▼ 66.57%
assets/img/logo.png3.47KB1.73KB▼ 50.07%
assets/img/step-1-selected.png3.01KB1.35KB▼ 55.06%