88% loco-translate

Code Review | Loco Translate

WordPress plugin Loco Translate scored 88% from 54 tests.

About plugin

  • Plugin page: loco-translate
  • Plugin version: 2.6.1
  • PHP compatiblity: 5.6.20+
  • PHP version: 7.4.16
  • WordPress compatibility: 5.2-5.9.2
  • WordPress version: 5.9.2
  • First release: Jul 23, 2013
  • Latest release: Mar 16, 2022
  • Number of updates: 679
  • Update frequency: every 4.7 days
  • Top authors: timwhitlock (100%)

Code review

54 tests

User reviews

383 reviews

Install metrics

1,000,000+ active / 17,874,618 total downloads

Benchmarks

Plugin footprint Passed 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | All plugins must install correctly, without throwing any errors, warnings, or notices
The plugin installed successfully, without throwing any errors or notices

Server metrics [RAM: ▲0.11MB] [CPU: ▼289.03ms] 75% from 4 tests

A check of server-side resources used by Loco Translate
Please have a look at the following items
  • CPU: Try to keep total CPU usage under 500.00ms (currently 624.25ms on /wp-admin/admin.php?page=loco)
PageMemory (MB)CPU Time (ms)
Home /3.65 ▲0.1361.23 ▲8.70
Dashboard /wp-admin3.56 ▲0.1542.96 ▲5.89
Posts /wp-admin/edit.php3.78 ▲0.1443.33 ▲1.56
Add New Post /wp-admin/post-new.php7.02 ▲0.0595.94 ▼1,158.01
Media Library /wp-admin/upload.php3.44 ▲0.1426.23 ▼5.56
Home /wp-admin/admin.php?page=loco4.90624.25
Themes /wp-admin/admin.php?page=loco-theme4.5137.30
Plugins /wp-admin/admin.php?page=loco-plugin4.4334.84
Settings /wp-admin/admin.php?page=loco-config3.9129.96
Languages /wp-admin/admin.php?page=loco-lang4.7942.55
WordPress /wp-admin/admin.php?page=loco-core3.7625.46

Server storage [IO: ▲1.39MB] [DB: ▲0.05MB] Passed 3 tests

Input-output and database impact of this plugin
The plugin installed successfully
Filesystem: 294 new files
Database: no new tables, no new options

Browser metrics Passed 4 tests

This is an overview of browser requirements for Loco Translate
This plugin renders optimally with no browser resource issues detected
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,817 ▲7316.22 ▲0.226.36 ▲0.482.08 ▲0.11
Dashboard /wp-admin2,946 ▲886.15 ▲0.07117.64 ▼20.80153.79 ▼8.64
Posts /wp-admin/edit.php2,746 ▲523.25 ▲0.0262.79 ▼1.36133.94 ▼5.25
Add New Post /wp-admin/post-new.php1,695 ▲3416.06 ▼0.53420.86 ▲0.12150.66 ▼6.09
Media Library /wp-admin/upload.php1,746 ▲485.51 ▲0.03144.87 ▲3.60185.23 ▲1.00
Home /wp-admin/admin.php?page=loco1,0713.0729.69107.18
Themes /wp-admin/admin.php?page=loco-theme1,0533.0936.1082.15
Plugins /wp-admin/admin.php?page=loco-plugin1,0283.0827.3887.58
Settings /wp-admin/admin.php?page=loco-config1,4473.1026.39107.26
Languages /wp-admin/admin.php?page=loco-lang1,0103.0927.15119.63
WordPress /wp-admin/admin.php?page=loco-core1,1463.0827.75138.10

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

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
Uninstaller ran successfully

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | This is a short smoke test looking 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
The following issues need your attention
  • 7× PHP files output text when accessed directly:
    • > /wp-content/plugins/loco-translate/tpl/admin/help/tab-home.php
    • > /wp-content/plugins/loco-translate/tpl/admin/help/tab-list-locales.php
    • > /wp-content/plugins/loco-translate/tpl/admin/help/tab-locale-view.php
    • > /wp-content/plugins/loco-translate/tpl/admin/help/tab-bundle-view.php
    • > /wp-content/plugins/loco-translate/tpl/admin/help/tab-file-view.php
    • > /wp-content/plugins/loco-translate/tpl/admin/help/tab-list-bundles.php
    • > /wp-content/plugins/loco-translate/tpl/debug/dump.php
  • 186× GET requests to PHP files have triggered server-side errors or warnings (only 10 are shown):
    • > PHP Notice
      Undefined variable: params in wp-content/plugins/loco-translate/tpl/debug/dump.php on line 9
    • > PHP Fatal error
      Uncaught Error: Using $this when not in object context in wp-content/plugins/loco-translate/tpl/admin/file/edit-po.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'Loco_error_Exception' not found in wp-content/plugins/loco-translate/src/error/Notice.php:6
    • > PHP Fatal error
      Uncaught Error: Using $this when not in object context in wp-content/plugins/loco-translate/tpl/admin/bundle/setup/author.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'Loco_admin_bundle_BaseController' not found in wp-content/plugins/loco-translate/src/admin/init/InitPotController.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'Loco_admin_list_BaseController' not found in wp-content/plugins/loco-translate/src/admin/list/PluginsController.php:6
    • > PHP Fatal error
      Uncaught Error: Using $this when not in object context in wp-content/plugins/loco-translate/tpl/admin/errors/no-backups.php:5
    • > PHP Fatal error
      Uncaught Error: Class 'WP_UnitTestCase' not found in wp-content/plugins/loco-translate/src/test/WordPressTestCase.php:5
    • > PHP Fatal error
      Uncaught Error: Using $this when not in object context in wp-content/plugins/loco-translate/tpl/admin/bundle/debug.php:5
    • > PHP Fatal error
      Uncaught Error: Call to undefined function loco_require_lib() in wp-content/plugins/loco-translate/src/gettext/Metadata.php:3

User-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
Everything seems fine, but this is not an exhaustive test

Optimizations

Plugin configuration 93% from 29 tests

readme.txt 94% from 16 tests

Don't ignore readme.txt as it is the file that instructs WordPress.org on how to present your plugin to the world
These attributes need your attention:
  • Tags: There are too many tags (12 tag instead of maximum 10)
You can take inspiration from this readme.txt

loco-translate/loco.php 92% from 13 tests

The primary PHP file in "Loco Translate" version 2.6.1 is used by WordPress to initiate all plugin functionality
Please make the necessary changes and fix the following:
  • Main file name: The principal plugin file should be the same as the plugin slug ("loco-translate.php" instead of "loco.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short glimpse at programming languages used with this plugin and a check that no dangerous files are present
Good job! No executable or dangerous file extensions detected21,661 lines of code in 271 files:
LanguageFilesBlank linesComment linesLines of code
PHP2383,5387,78515,862
JavaScript13905,642
SVG100113
XML10024
CSS170017
Markdown1203

PHP code Passed 2 tests

A brief analysis of cyclomatic complexity and code structure for this plugin
Although this was not an exhaustive test, there were no cyclomatic complexity issues detected
Cyclomatic complexity
Average complexity per logical line of code0.41
Average class complexity15.61
▷ Minimum class complexity1.00
▷ Maximum class complexity90.00
Average method complexity3.13
▷ Minimum method complexity1.00
▷ Maximum method complexity46.00
Code structure
Namespaces0
Interfaces3
Traits0
Classes180
▷ Abstract classes3318.33%
▷ Concrete classes14781.67%
▷ Final classes00.00%
Methods1,280
▷ Static methods14911.64%
▷ Public methods1,10486.25%
▷ Protected methods503.91%
▷ Private methods1269.84%
Functions40
▷ Named functions40100.00%
▷ Anonymous functions00.00%
Constants19
▷ Global constants1157.89%
▷ Class constants842.11%
▷ Public constants8100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

It is recommended to compress PNG files in your plugin to minimize bandwidth usage
6 compressed PNG files occupy 0.03MB
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
pub/img/api/deepl.png1.39KB1.83KB0.00%
pub/img/flags.png22.53KB23.96KB0.00%
pub/img/api/microsoft.png1.60KB2.06KB0.00%
pub/img/wg/splity.png0.09KB0.09KB0.00%
pub/img/api/google.png2.22KB1.97KB▼ 11.59%