78% php-browser-detection

Code Review | PHP Browser Detection

WordPress plugin PHP Browser Detection scored78%from 54 tests.

About plugin

  • Plugin page: php-browser-detec...
  • Plugin version: 3.1.8
  • PHP version: 7.4.16
  • WordPress version: 6.3.1
  • First release: Jan 29, 2010
  • Latest release: Sep 8, 2015
  • Number of updates: 64
  • Update frequency: every 32.0 days
  • Top authors: mindshare (84.38%)MartyThornley (17.19%)

Code review

54 tests

User reviews

16 reviews

Install metrics

1,000+ active /44,870 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
The plugin installed successfully, without throwing any errors or notices

Server metrics [RAM: ▲0.41MB] [CPU: ▲0.64ms] Passed 4 tests

Server-side resources used by PHP Browser Detection
Normal server usage
PageMemory (MB)CPU Time (ms)
Home /5.07 ▲1.6153.71 ▲11.12
Dashboard /wp-admin5.09 ▲1.7955.94 ▲8.84
Posts /wp-admin/edit.php3.36 ▲0.0049.84 ▼1.16
Add New Post /wp-admin/post-new.php5.89 ▲0.0084.62 ▼7.73
Media Library /wp-admin/upload.php3.23 ▲0.0038.37 ▲2.60

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

Input-output and database impact of this plugin
The plugin installed successfully
Filesystem: 16 new files
Database: no new tables, 6 new options
New WordPress options
widget_recent-comments
theysaidso_admin_options
widget_theysaidso_widget
widget_recent-posts
db_upgraded
can_compress_scripts

Browser metrics Passed 4 tests

This is an overview of browser requirements for PHP Browser Detection
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,814 ▲5314.26 ▼0.092.35 ▲0.4342.98 ▲1.24
Dashboard /wp-admin2,195 ▲155.61 ▲0.0182.96 ▼7.9941.61 ▼2.06
Posts /wp-admin/edit.php2,100 ▼02.01 ▲0.0135.65 ▼1.0733.34 ▼2.25
Add New Post /wp-admin/post-new.php1,526 ▼023.62 ▲0.26679.72 ▼3.0864.11 ▲4.34
Media Library /wp-admin/upload.php1,400 ▲64.19 ▼0.0299.07 ▼12.8350.38 ▲7.34

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

🔸 Tests weight: 35 | It is important to correctly uninstall your plugin, without leaving any traces
You still need to fix the following
  • Zombie WordPress options were found after uninstall: 6 options
    • theysaidso_admin_options
    • db_upgraded
    • widget_recent-comments
    • widget_recent-posts
    • widget_theysaidso_widget
    • can_compress_scripts

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for server-side errors
Good news, no errors were detected

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
  • 1× PHP files perform the action of outputting non-empty strings when accessed directly:
    • > /wp-content/plugins/php-browser-detection/inc/tests.php
  • 3× PHP files trigger server errors when accessed directly:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function is_admin() in wp-content/plugins/php-browser-detection/inc/admin.php:19
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_path() in wp-content/plugins/php-browser-detection/php-browser-detection.php:39
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_shortcode() in wp-content/plugins/php-browser-detection/inc/shortcodes.php:30

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a smoke test targeting browser errors/issues
No browser errors were detected

Optimizations

Plugin configuration 97% from 29 tests

readme.txt 94% from 16 tests

The readme.txt file is important because it is parsed by WordPress.org for the public listing of your plugin
Attributes that need to be fixed:
  • Plugin Name: "Plugin Name" should be replaced with the name of your plugin on the first line ( === php-browser-detection === )
The official readme.txt is a good inspiration

php-browser-detection/php-browser-detection.php Passed 13 tests

This is the main PHP file of "PHP Browser Detection" version 3.1.8, providing information about the plugin in the header fields and serving as the principal entry point to the plugin's functions
74 characters long description:
Use PHP to detect browsers for conditional CSS or to detect mobile phones.

Code Analysis Passed 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 plugin41,878 lines of code in 9 files:
LanguageFilesBlank linesComment linesLines of code
INI19,66183630,469
PHP729968111,405
Markdown1204

PHP code Passed 2 tests

A short review of cyclomatic complexity and code structure
There were no cyclomatic complexity issued detected
Cyclomatic complexity
Average complexity per logical line of code0.41
Average class complexity67.00
▷ Minimum class complexity1.00
▷ Maximum class complexity133.00
Average method complexity6.50
▷ Minimum method complexity1.00
▷ Maximum method complexity23.00
Code structure
Namespaces1
Interfaces0
Traits0
Classes2
▷ Abstract classes00.00%
▷ Concrete classes2100.00%
▷ Final classes00.00%
Methods24
▷ Static methods00.00%
▷ Public methods937.50%
▷ Protected methods1562.50%
▷ Private methods00.00%
Functions33
▷ Named functions33100.00%
▷ Anonymous functions00.00%
Constants14
▷ Global constants17.14%
▷ Class constants1392.86%
▷ Public constants13100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

PNG files should be compressed to save space and minimize bandwidth usage
PNG images were not found in this plugin