61% wp-statistics

Code Review | WP Statistics

WordPress plugin WP Statistics scored61%from 54 tests.

About plugin

  • Plugin page: wp-statistics
  • Plugin version: 14.2
  • PHP compatiblity: 5.6+
  • PHP version: 7.4.16
  • WordPress compatibility: 4.4-6.3
  • WordPress version: 6.3.1
  • First release: Mar 20, 2011
  • Latest release: Oct 9, 2023
  • Number of updates: 1,328
  • Update frequency: every 3.5 days
  • Top authors: GregRoss (77.94%)mostafa.s1990 (22.06%)

Code review

54 tests

User reviews

632 reviews

Install metrics

600,000+ active /20,388,912 total downloads

Benchmarks

Plugin footprint 64% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
The plugin installed gracefully, with no errors

Server metrics [RAM: ▲5.80MB] [CPU: ▲26.88ms] 50% from 4 tests

Server-side resources used by WP Statistics
It is recommended to improve the following
  • CPU: Try to keep total CPU usage under 500.00ms (currently 1,168.56ms on /wp-admin/admin.php?page=wps_overview_page)
  • Extra RAM: Extra memory usage must be kept under 5MB (currently 5.80MB on /wp-admin/admin.php?page=wps_break_menu)
PageMemory (MB)CPU Time (ms)
Home /8.63 ▲5.1667.17 ▲28.71
Dashboard /wp-admin9.34 ▲5.9981.82 ▲20.75
Posts /wp-admin/edit.php9.55 ▲6.1984.45 ▲38.95
Add New Post /wp-admin/post-new.php11.95 ▲6.06121.23 ▲19.10
Media Library /wp-admin/upload.php9.23 ▲6.0075.76 ▲39.02
Authors /wp-admin/admin.php?page=wps_authors_page9.2568.43
Add-Ons /wp-admin/admin.php?page=wps_plugins_page9.301,401.42
Search Engines /wp-admin/admin.php?page=wps_searches_page9.2565.89
Post Types /wp-admin/admin.php?page=wps_pages_page9.2665.19
Online /wp-admin/admin.php?page=wps_online_page9.2666.57
Browsers /wp-admin/admin.php?page=wps_browser_page9.2669.50
Search Words /wp-admin/admin.php?page=wps_words_page9.2568.65
Overview /wp-admin/admin.php?page=wps_overview_page9.301,168.56
Platforms /wp-admin/admin.php?page=wps_platform_page9.2678.22
/wp-admin/admin.php?page=wps_break_menu9.1862.09

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

Input-output and database impact of this plugin
This plugin installed successfully
Filesystem: 857 new files
Database: 8 new tables, 10 new options
New tables
wp_statistics_historical
wp_statistics_search
wp_statistics_exclusions
wp_statistics_visitor
wp_statistics_useronline
wp_statistics_visitor_relationships
wp_statistics_visit
wp_statistics_pages
New WordPress options
wp_statistics_check_user_online
wp_statistics_plugin_version
can_compress_scripts
widget_recent-posts
db_upgraded
theysaidso_admin_options
wp_statistics
widget_theysaidso_widget
widget_wp_statistics_widget
widget_recent-comments

Browser metrics Passed 4 tests

This is an overview of browser requirements for WP Statistics
Normal browser usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,544 ▲79814.34 ▼0.081.69 ▲0.0632.27 ▼6.91
Dashboard /wp-admin2,940 ▲7607.11 ▲1.47184.52 ▲97.2875.02 ▲34.61
Posts /wp-admin/edit.php2,228 ▲1282.39 ▲0.4337.83 ▼1.8741.43 ▲6.34
Add New Post /wp-admin/post-new.php6,320 ▲4,78526.51 ▲8.06896.56 ▲219.3239.57 ▼31.74
Media Library /wp-admin/upload.php1,483 ▲864.17 ▼0.0395.38 ▼2.5742.88 ▼7.64
Authors /wp-admin/admin.php?page=wps_authors_page1,4764.23128.4097.04
Add-Ons /wp-admin/admin.php?page=wps_plugins_page1,5972.8241.4596.96
Search Engines /wp-admin/admin.php?page=wps_searches_page1,3123.3253.7879.65
Post Types /wp-admin/admin.php?page=wps_pages_page1,4003.4452.2548.64
Online /wp-admin/admin.php?page=wps_online_page1,0452.8637.7466.89
Browsers /wp-admin/admin.php?page=wps_browser_page1,3263.6360.6346.58
Search Words /wp-admin/admin.php?page=wps_words_page1,1352.8236.7870.16
Overview /wp-admin/admin.php?page=wps_overview_page2,8004.70108.4176.86
Platforms /wp-admin/admin.php?page=wps_platform_page1,3623.5160.9672.23
/wp-admin/admin.php?page=wps_break_menu9381.9728.2540.86

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
It is recommended to fix the following
  • The plugin did not uninstall successfully, leaving 8 tables in the database
    • wp_statistics_visit
    • wp_statistics_visitor
    • wp_statistics_visitor_relationships
    • wp_statistics_search
    • wp_statistics_useronline
    • wp_statistics_exclusions
    • wp_statistics_pages
    • wp_statistics_historical
  • This plugin did not uninstall successfully, leaving 10 options in the database
    • can_compress_scripts
    • widget_wp_statistics_widget
    • wp_statistics_plugin_version
    • db_upgraded
    • widget_recent-comments
    • theysaidso_admin_options
    • widget_theysaidso_widget
    • wp_statistics
    • wp_statistics_check_user_online
    • widget_recent-posts

Smoke tests 25% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
These server-side errors were triggered
    • > GET request to /wp-admin/admin.php?page=wps_break_menu
    • > Warning in wp-includes/class-wp-hook.php+310
    call_user_func_array() expects parameter 1 to be a valid callback, class 'WP_STATISTICS\exclusions_page' does not have a method 'exclusions'

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
Please fix the following
  • 10× PHP files output text when accessed directly:
    • > /wp-content/plugins/wp-statistics/includes/admin/templates/layout/postbox.hide.php
    • > /wp-content/plugins/wp-statistics/includes/vendor/whichbrowser/parser/bin/update-profiles.php
    • > /wp-content/plugins/wp-statistics/includes/vendor/whichbrowser/parser/bin/update-browser-ids.php
    • > /wp-content/plugins/wp-statistics/includes/vendor/whichbrowser/parser/bin/update-chrome.php
    • > /wp-content/plugins/wp-statistics/includes/admin/templates/layout/footer.php
    • > /wp-content/plugins/wp-statistics/includes/admin/templates/optimization.php
    • > /wp-content/plugins/wp-statistics/includes/admin/templates/layout/postbox.toggle.php
    • > /wp-content/plugins/wp-statistics/includes/admin/templates/layout/tabs-settings.php
    • > /wp-content/plugins/wp-statistics/includes/admin/templates/header.php
    • > /wp-content/plugins/wp-statistics/includes/admin/templates/emails/default.php
  • 274× PHP files trigger errors when accessed directly with GET requests (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/wp-statistics/includes/admin/templates/pages/visitors.php:21
    • > PHP Fatal error
      Uncaught Error: Class 'GeoIp2\\Record\\AbstractPlaceRecord' not found in wp-content/plugins/wp-statistics/includes/vendor/geoip2/geoip2/src/Record/Subdivision.php:29
    • > PHP Fatal error
      Uncaught Error: Class 'GeoIp2\\Model\\AbstractModel' not found in wp-content/plugins/wp-statistics/includes/vendor/geoip2/geoip2/src/Model/Domain.php:19
    • > PHP Fatal error
      Uncaught Error: Class 'WP_STATISTICS\\Menus' not found in wp-content/plugins/wp-statistics/includes/admin/pages/class-wp-statistics-admin-page-plugins.php:14
    • > PHP Fatal error
      Uncaught Error: Call to undefined function WP_STATISTICS\\add_action() in wp-content/plugins/wp-statistics/includes/admin/pages/class-wp-statistics-admin-page-overview.php:21
    • > PHP Fatal error
      require(): Failed opening required 'wp-content/plugins/wp-statistics/includes/vendor/geoip2/geoip2/examples/../vendor/autoload.php' (include_path='.:/usr/share/php') in wp-content/plugins/wp-statistics/includes/vendor/geoip2/geoip2/examples/benchmark.php on line 3
    • > PHP Fatal error
      Uncaught Error: Call to undefined function wp_nonce_field() in wp-content/plugins/wp-statistics/includes/admin/templates/settings.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'WhichBrowser\\Data\\DeviceModels' not found in wp-content/plugins/wp-statistics/includes/vendor/whichbrowser/parser/data/indices/models-brew.php:5
    • > PHP Warning
      count(): Parameter must be an array or an object that implements Countable in wp-content/plugins/wp-statistics/includes/vendor/whichbrowser/parser/bin/query.php on line 13
    • > PHP Fatal error
      Uncaught Error: Call to undefined function WP_STATISTICS\\add_action() in wp-content/plugins/wp-statistics/includes/admin/class-wp-statistics-admin-export.php:15

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
There were no browser issues found

Optimizations

Plugin configuration 97% from 29 tests

readme.txt 94% from 16 tests

Perhaps the most important file in your plugin readme.txt gets parsed in order to generate the public listing of your plugin
Please fix the following attributes:
  • Tags: Too many tags (27 tag instead of maximum 10); only the first 5 tags are used in your directory listing
The official readme.txt is a good inspiration

wp-statistics/wp-statistics.php Passed 13 tests

The principal PHP file in "WP Statistics" v. 14.2 is loaded by WordPress automatically on each request
74 characters long description:
This plugin gives you the complete information on your website's visitors.

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short check of programming languages and file extensions; no executable files are allowed
Success! There were no dangerous files found in this plugin119,544 lines of code in 795 files:
LanguageFilesBlank linesComment linesLines of code
PHP3678,9488,43078,319
SVG2781019,657
JavaScript6051869113,641
Sass651,003915,795
C19718589
Markdown51940500
JSON400469
CSS8856414
YAML418080
Bourne Shell120040
m418032
C/C++ Header14128

PHP code 50% from 2 tests

An overview of cyclomatic complexity and code structure
These items need your attention
  • Method cyclomatic complexity should be reduced to less than 100 (currently 107)
Cyclomatic complexity
Average complexity per logical line of code0.43
Average class complexity21.43
▷ Minimum class complexity1.00
▷ Maximum class complexity489.00
Average method complexity4.85
▷ Minimum method complexity1.00
▷ Maximum method complexity107.00
Code structure
Namespaces32
Interfaces6
Traits26
Classes199
▷ Abstract classes63.02%
▷ Concrete classes19396.98%
▷ Final classes10.52%
Methods1,222
▷ Static methods41634.04%
▷ Public methods91374.71%
▷ Protected methods635.16%
▷ Private methods24620.13%
Functions68
▷ Named functions3652.94%
▷ Anonymous functions3247.06%
Constants112
▷ Global constants98.04%
▷ Class constants10391.96%
▷ Public constants103100.00%

Plugin size 50% from 2 tests

Image compression 50% from 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
23 PNG files occupy 0.66MB with 0.20MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/images/search-engine/unknown.png0.78KB0.82KB0.00%
assets/images/pages-visitors-map-preview.png126.18KB70.18KB▼ 44.38%
assets/images/pages-referring-preview.png173.49KB64.24KB▼ 62.97%
assets/images/preview-lock.png0.52KB0.34KB▼ 33.90%
assets/images/search-engine/duckduckgo.png0.67KB0.58KB▼ 14.24%