94% add-device-type-to-body-class

Code Review | Add Device Type to Body Class

WordPress plugin Add Device Type to Body Class scored 94% from 54 tests.

About plugin

  • Plugin page: add-device-type-t...
  • Plugin version: 1.0
  • PHP compatiblity: 5.0+
  • PHP version: 7.4.16
  • WordPress compatibility: 3.2-5.8
  • WordPress version: 5.8.1
  • First release: Jan 21, 2019
  • Latest release: Jul 18, 2021
  • Number of updates: 9
  • Update frequency: every 101.1 days
  • Top authors: aftabmuni (100%)

Code review

54 tests

User reviews

1 review

Install metrics

50+ active / 636 total downloads

Benchmarks

Plugin footprint Passed 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.00MB] [CPU: ▼147.21ms] Passed 4 tests

A check of server-side resources used by Add Device Type to Body Class
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /3.11 ▲0.3940.86 ▲20.58
Dashboard /wp-admin3.06 ▲0.0142.98 ▼2.81
Posts /wp-admin/edit.php3.12 ▲0.0144.80 ▼2.67
Add New Post /wp-admin/post-new.php5.43 ▼0.0092.06 ▼577.13
Media Library /wp-admin/upload.php3.01 ▼0.0031.46 ▼6.23

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

Filesystem and database footprint
No storage issues were detected
Filesystem: 3 new files
Database: no new tables, no new options

Browser metrics Passed 4 tests

This is an overview of browser requirements for Add Device Type to Body Class
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,703 ▲10715.91 ▲0.2510.02 ▲0.6351.04 ▲6.19
Dashboard /wp-admin2,967 ▲335.92 ▼0.01135.42 ▼11.74112.12 ▼1.56
Posts /wp-admin/edit.php2,739 ▼02.72 ▼0.0060.89 ▼6.3692.74 ▲1.88
Add New Post /wp-admin/post-new.php1,872 ▼419.16 ▲0.00367.45 ▼40.89102.43 ▼11.19
Media Library /wp-admin/upload.php1,810 ▲35.05 ▲0.02140.77 ▼13.13113.49 ▼18.76

Uninstaller [IO: ▲0.00MB] [DB: ▲0.00MB] Passed 4 tests

🔸 Tests weight: 35 | It is important to correctly uninstall your plugin, without leaving any traces
Uninstall script ran successfully

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
Even though no errors were found, this is by no means an exhaustive test

SRP 50% 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
Please fix the following
  • 1× PHP files trigger server-side errors or warnings when accessed directly:
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugin_dir_path() in wp-content/plugins/add-device-type-to-body-class/add-device-type-to-body-class.php:23

User-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the browser (console and network errors and warnings)
Everything seems fine on the user side

Optimizations

Plugin configuration 96% from 29 tests

readme.txt Passed 16 tests

It's important to format your readme.txt file correctly as it is parsed for the public listing of your plugin
5 plugin tags: add mobile to body class, tablet, device specific css, desktop, add device type to wordpress

add-device-type-to-body-class/add-device-type-to-body-class.php 92% from 13 tests

The main PHP file in "Add Device Type to Body Class" ver. 1.0 adds more information about the plugin and also serves as the entry point for this plugin
The following require your attention:
  • Description: Keep the plugin description shorter than 140 characters (currently 152 characters long)

Code Analysis Passed 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 plugin705 lines of code in 2 files:
LanguageFilesBlank linesComment linesLines of code
PHP2163665705

PHP code Passed 2 tests

An overview of cyclomatic complexity and code structure
Great job! No cyclomatic complexity issues were detected in this plugin
Cyclomatic complexity
Average complexity per logical line of code0.95
Average class complexity134.00
▷ Minimum class complexity134.00
▷ Maximum class complexity134.00
Average method complexity4.69
▷ Minimum method complexity1.00
▷ Maximum method complexity77.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes1
▷ Abstract classes00.00%
▷ Concrete classes1100.00%
▷ Final classes00.00%
Methods36
▷ Static methods925.00%
▷ Public methods3391.67%
▷ Protected methods25.56%
▷ Private methods12.78%
Functions4
▷ Named functions4100.00%
▷ Anonymous functions00.00%
Constants12
▷ Global constants325.00%
▷ Class constants975.00%
▷ Public constants9100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

All PNG images should be compressed to minimize bandwidth usage for end users
No PNG files were detected