52% word-count-and-social-shares

Code Review | Word Count and Social Shares

WordPress plugin Word Count and Social Shares scored52%from 54 tests.

About plugin

  • Plugin page: word-count-and-so...
  • Plugin version: 1.0
  • PHP version: 7.4.16
  • WordPress compatibility: 3.0-3.5.1
  • WordPress version: 6.3.1
  • First release: Apr 3, 2013
  • Latest release: May 18, 2015
  • Number of updates: 21
  • Update frequency: every 36.9 days
  • Top authors: Dejan SEO (100%)

Code review

54 tests

User reviews

2 reviews

Install metrics

10+ active /3,777 total downloads

Benchmarks

Plugin footprint 47% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | It is important to correctly install your plugin, without throwing errors or notices
The plugin installed gracefully, with no errors

Server metrics [RAM: ▼0.81MB] [CPU: ▼37.05ms] Passed 4 tests

A check of server-side resources used by Word Count and Social Shares
Server-side resource usage in normal parameters
PageMemory (MB)CPU Time (ms)
Home /3.62 ▲0.1641.27 ▼2.59
Dashboard /wp-admin3.14 ▼0.2123.67 ▼40.07
Posts /wp-admin/edit.php3.14 ▼0.2225.91 ▼25.15
Add New Post /wp-admin/post-new.php3.14 ▼2.7525.20 ▼75.41
Media Library /wp-admin/upload.php3.14 ▼0.0925.27 ▼7.55
Full Time report /wp-admin/admin.php?page=social_shares_full_time3.1426.04
Word Count and Social Shares /wp-admin/admin.php?page=social_shares3.1428.12
Options /wp-admin/admin.php?page=social_shares_config3.1424.39
Download .CSV /wp-admin/admin.php?page=social_shares_csv3.1428.83

Server storage [IO: ▲0.34MB] [DB: ▲0.00MB] 67% from 3 tests

How much does this plugin use your filesystem and database?
It is recommended to fix the following issues
  • Illegal file modification found: 1 file (0.08KB) outside of "wp-content/plugins/word-count-and-social-shares/" and "wp-content/uploads/"
    • (new file) wp-admin/cache/7505d64a54e061b7acd54ccd58b49dc43500b635.cache
Filesystem: 24 new files
Database: 1 new table, 7 new options
New tables
wp_social_shares_report
New WordPress options
widget_recent-posts
widget_recent-comments
theysaidso_admin_options
can_compress_scripts
widget_theysaidso_widget
db_upgraded
social_shares_plugin_version

Browser metrics Passed 4 tests

Word Count and Social Shares: an overview of browser usage
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,855 ▲10913.63 ▼0.661.73 ▲0.0543.12 ▼2.42
Dashboard /wp-admin2,249 ▲585.29 ▼0.59105.70 ▼0.8578.30 ▲34.56
Posts /wp-admin/edit.php2,147 ▲582.41 ▲0.4140.75 ▼0.1635.54 ▼0.24
Add New Post /wp-admin/post-new.php1,717 ▲18922.43 ▲4.32623.68 ▲20.6336.17 ▼11.87
Media Library /wp-admin/upload.php1,437 ▲524.59 ▲0.3897.35 ▲4.0477.69 ▲37.35
Full Time report /wp-admin/admin.php?page=social_shares_full_time1,7977.1258.6875.61
Word Count and Social Shares /wp-admin/admin.php?page=social_shares1,2805.0951.0843.59
Options /wp-admin/admin.php?page=social_shares_config8532.1429.0529.87
Download .CSV /wp-admin/admin.php?page=social_shares_csv8252.3327.5026.86

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

🔸 Tests weight: 35 | The uninstall procedure must remove all plugin files and extra database tables
It is recommended to fix the following
  • This plugin did not uninstall without warnings or errors
    • > User deprecated in wp-includes/functions.php+5737
    Function has_cap was called with an argument that is deprecated since version 2.0.0! Usage of user levels is deprecated. Use capabilities instead.
  • The uninstall procedure failed, leaving 1 table in the database
    • wp_social_shares_report
  • This plugin does not fully uninstall, leaving 7 options in the database
    • theysaidso_admin_options
    • can_compress_scripts
    • widget_recent-comments
    • social_shares_plugin_version
    • widget_theysaidso_widget
    • widget_recent-posts
    • db_upgraded

Smoke tests 25% from 4 tests

Server-side errors 0% from 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the server (in the Apache logs)
Smoke test failed, please fix the following
  • 44 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=social_shares_csv
    • > User deprecated in wp-includes/functions.php+5737
    Function has_cap was called with an argument that is deprecated since version 2.0.0! Usage of user levels is deprecated. Use capabilities instead.
  • 7 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=social_shares_full_time
    • > Warning in wp-content/plugins/word-count-and-social-shares/includes/posts.class.inc+210
    Use of undefined constant word_count - assumed 'word_count' (this will throw an Error in a future version of PHP)
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=social_shares
    • > Warning in wp-content/plugins/word-count-and-social-shares/includes/posts.class.inc+285
    Use of undefined constant average_words - assumed 'average_words' (this will throw an Error in a future version of PHP)
  • 4 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=social_shares_csv
    • > Notice in wp-content/plugins/word-count-and-social-shares/index.php+368
    Undefined index: act
  • 22 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=social_shares
    • > Notice in wp-content/plugins/word-count-and-social-shares/templates/home_tpl.php+131
    Undefined variable: data
  • 28 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=social_shares
    • > Notice in wp-content/plugins/word-count-and-social-shares/templates/home_tpl.php+131
    Trying to access array offset on value of type null
  • 2 occurences, only the last one shown
    • > GET request to /wp-admin/admin.php?page=social_shares
    • > Notice in wp-content/plugins/word-count-and-social-shares/index.php+62
    Undefined index: date_from
    • > GET request to /wp-admin/admin.php?page=social_shares
    • > Warning in wp-content/plugins/word-count-and-social-shares/includes/posts.class.inc+273
    Division by zero
    • > GET request to /wp-admin/admin.php?page=social_shares_config
    • > Warning in wp-content/plugins/word-count-and-social-shares/index.php+395
    Use of undefined constant save - assumed 'save' (this will throw an Error in a future version of PHP)
    • > GET request to /wp-admin/admin.php?page=social_shares_csv
    • > Notice in wp-content/plugins/word-count-and-social-shares/index.php+363
    Undefined variable: FILE_LIST

SRP 0% 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
  • 1× PHP files output non-empty strings when accessed directly via GET requests:
    • > /wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php
  • 15× PHP files trigger server errors when accessed directly (only 10 are shown):
    • > PHP Notice
      Undefined variable: file in wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php on line 18
    • > PHP Fatal error
      Uncaught Error: Call to undefined function plugins_url() in wp-content/plugins/word-count-and-social-shares/templates/home_fulltime_tpl.php:25
    • > PHP Notice
      Undefined variable: file in wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php on line 19
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php on line 18
    • > PHP Notice
      Undefined variable: file in wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php on line 16
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php on line 16
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php on line 17
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php on line 19
    • > PHP Notice
      Trying to access array offset on value of type null in wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php on line 16
    • > PHP Notice
      Undefined variable: file in wp-content/plugins/word-count-and-social-shares/templates/csv_table_tpl.php on line 16

User-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for browser errors
Everything seems fine, but this is not an exhaustive test

Optimizations

Plugin configuration 93% from 29 tests

readme.txt Passed 16 tests

You should put a lot of thought into formatting readme.txt as it is used by WordPress.org to prepare the public listing of your plugin
6 plugin tags: linkedin, social shares, google, twitter, facebook...

word-count-and-social-shares/index.php 85% from 13 tests

The main PHP file in "Word Count and Social Shares" ver. 1.0 adds more information about the plugin and also serves as the entry point for this plugin
It is important to fix the following:
  • Description: The description should be shorter than 140 characters (currently 166 characters long)
  • Main file name: Even though not officially enforced, the main plugin file should be the same as the plugin slug ("word-count-and-social-shares.php" instead of "index.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short review of files and their extensions; it is not recommended to include executable files
There were no executable files found in this plugin1,534 lines of code in 12 files:
LanguageFilesBlank linesComment linesLines of code
PHP83561411,201
Pascal124109158
JavaScript2026137
CSS11038

PHP code Passed 2 tests

An overview of cyclomatic complexity and code structure
Although this was not an exhaustive test, there were no cyclomatic complexity issues detected
Cyclomatic complexity
Average complexity per logical line of code0.14
Average class complexity0.00
▷ Minimum class complexity0.00
▷ Maximum class complexity0.00
Average method complexity0.00
▷ Minimum method complexity0.00
▷ Maximum method complexity0.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes0
▷ Abstract classes00.00%
▷ Concrete classes00.00%
▷ Final classes00.00%
Methods0
▷ Static methods00.00%
▷ Public methods00.00%
▷ Protected methods00.00%
▷ Private methods00.00%
Functions16
▷ Named functions16100.00%
▷ Anonymous functions00.00%
Constants0
▷ Global constants00.00%
▷ Class constants00.00%
▷ Public constants00.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
8 PNG files occupy 0.16MB with 0.05MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
screenshot-2.png59.70KB22.49KB▼ 62.33%
templates/images/share.png0.88KB1.06KB0.00%
templates/images/filetype_pdf.png5.79KB3.22KB▼ 44.46%
screenshot-3.png33.92KB14.76KB▼ 56.47%
templates/images/settings.png2.86KB2.75KB▼ 3.92%