83% wp-2fa

Code Review | WP 2FA - Two-factor authentication for WordPress

WordPress plugin WP 2FA - Two-factor authentication for WordPress scored83%from 54 tests.

About plugin

  • Plugin page: wp-2fa
  • Plugin version: 2.5.0
  • PHP compatiblity: 7.2+
  • PHP version: 7.4.16
  • WordPress compatibility: 5.0-6.3.1
  • WordPress version: 6.3.1
  • First release: Mar 20, 2020
  • Latest release: Sep 30, 2023
  • Number of updates: 90
  • Update frequency: every 14.3 days
  • Top authors: WPWhiteSecurity (100%)

Code review

54 tests

User reviews

109 reviews

Install metrics

40,000+ active /497,087 total downloads

Benchmarks

Plugin footprint 82% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
This plugin's installer ran successfully

Server metrics [RAM: ▲2.08MB] [CPU: ▲8.78ms] Passed 4 tests

A check of server-side resources used by WP 2FA - Two-factor authentication for WordPress
This plugin does not affect your website's performance
PageMemory (MB)CPU Time (ms)
Home /4.89 ▲1.4446.49 ▲4.54
Dashboard /wp-admin5.64 ▲2.3461.19 ▲7.78
Posts /wp-admin/edit.php5.66 ▲2.3163.91 ▲11.53
Add New Post /wp-admin/post-new.php8.13 ▲2.24111.48 ▲11.27
Media Library /wp-admin/upload.php5.56 ▲2.3355.07 ▲19.32
/wp-admin/index.php?page=wp-2fa-setup5.4443.69
Settings /wp-admin/admin.php?page=wp-2fa-settings5.5046.51
Premium Features ➤ /wp-admin/admin.php?page=wp-2fa-premium-features5.4744.70
2FA Policies /wp-admin/admin.php?page=wp-2fa-policies5.6950.96
Help & Contact Us /wp-admin/admin.php?page=wp-2fa-help-contact-us5.4746.22

Server storage [IO: ▲2.54MB] [DB: ▲0.01MB] 67% from 3 tests

Input-output and database impact of this plugin
It is recommended to fix the following issues
  • Illegal file modification detected: 1 file (4.42KB) outside of "wp-content/plugins/wp-2fa/" and "wp-content/uploads/"
    • (modified) wp-config.php
Filesystem: 294 new files
Database: no new tables, 10 new options
New WordPress options
db_upgraded
wp_2fa_settings_hash
wp_2fa_policy
can_compress_scripts
wp_2fa_plugin_version
widget_recent-comments
widget_recent-posts
theysaidso_admin_options
wp_2fa_default_settings_applied
widget_theysaidso_widget

Browser metrics Passed 4 tests

A check of browser resources used by WP 2FA - Two-factor authentication for WordPress
This plugin has a minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,915 ▲15813.27 ▼1.541.60 ▼0.3241.32 ▲2.11
Dashboard /wp-admin2,321 ▲1334.85 ▼0.03100.47 ▼9.3844.15 ▼4.04
Posts /wp-admin/edit.php2,204 ▲1122.05 ▼0.0141.18 ▼0.1437.38 ▲2.05
Add New Post /wp-admin/post-new.php1,563 ▲2923.02 ▼0.19586.13 ▼48.8759.22 ▼0.28
Media Library /wp-admin/upload.php1,504 ▲1194.28 ▲0.0998.54 ▼2.1147.08 ▲1.33
/wp-admin/index.php?page=wp-2fa-setup2331.8725.0124.52
Settings /wp-admin/admin.php?page=wp-2fa-settings1,1232.2537.8532.21
Premium Features ➤ /wp-admin/admin.php?page=wp-2fa-premium-features1,4612.4130.0058.22
2FA Policies /wp-admin/admin.php?page=wp-2fa-policies1,7712.6050.8039.22
Help & Contact Us /wp-admin/admin.php?page=wp-2fa-help-contact-us1,5369.63280.2660.77

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

🔸 Tests weight: 35 | All plugins must uninstall correctly, removing their source code and extra database tables they might have created
Please fix the following items
  • Zombie WordPress options detected upon uninstall: 10 options
    • wp_2fa_policy
    • db_upgraded
    • theysaidso_admin_options
    • widget_recent-posts
    • wp_2fa_settings_hash
    • can_compress_scripts
    • wp_2fa_plugin_version
    • widget_theysaidso_widget
    • wp_2fa_default_settings_applied
    • widget_recent-comments

Smoke tests 75% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | This is a shallow check for server-side errors
Even though everything seems fine, this is not an exhaustive test

SRP 50% 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
  • 112× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Interface 'WP2FA_Vendor\\BaconQrCode\\Renderer\\Path\\OperationInterface' not found in wp-content/plugins/wp-2fa/vendor/bacon/bacon-qr-code/src/Renderer/Path/Curve.php:6
    • > PHP Parse error
      syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE) in wp-content/plugins/wp-2fa/vendor/khanamiryan/qrcode-detector-decoder/lib/Common/Reedsolomon/ReedSolomonDecoder.php on line 44
    • > PHP Fatal error
      Uncaught Error: Class 'WP2FA_Vendor\\Zxing\\Binarizer' not found in wp-content/plugins/wp-2fa/vendor/khanamiryan/qrcode-detector-decoder/lib/Common/GlobalHistogramBinarizer.php:33
    • > PHP Fatal error
      Uncaught Error: Interface 'WP2FA_Vendor\\DASPRiD\\Enum\\Exception\\ExceptionInterface' not found in wp-content/plugins/wp-2fa/vendor/dasprid/enum/src/Exception/IllegalArgumentException.php:7
    • > PHP Parse error
      syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE) in wp-content/plugins/wp-2fa/vendor/khanamiryan/qrcode-detector-decoder/lib/LuminanceSource.php on line 31
    • > PHP Fatal error
      Uncaught Error: Interface 'WP2FA_Vendor\\Zxing\\Reader' not found in wp-content/plugins/wp-2fa/vendor/khanamiryan/qrcode-detector-decoder/lib/Qrcode/QRCodeReader.php:34
    • > PHP Fatal error
      Uncaught Error: Interface 'WP2FA_Vendor\\DASPRiD\\Enum\\Exception\\ExceptionInterface' not found in wp-content/plugins/wp-2fa/vendor/dasprid/enum/src/Exception/ExpectationException.php:7
    • > PHP Fatal error
      Uncaught Error: Class 'WP2FA_Vendor\\Endroid\\QrCode\\Writer\\AbstractWriter' not found in wp-content/plugins/wp-2fa/vendor/endroid/qr-code/src/Writer/BinaryWriter.php:13
    • > PHP Parse error
      syntax error, unexpected ')', expecting '|' or variable (T_VARIABLE) in wp-content/plugins/wp-2fa/vendor/khanamiryan/qrcode-detector-decoder/lib/BinaryBitmap.php on line 124
    • > PHP Fatal error
      Uncaught Error: Class 'WP2FA_Vendor\\MyCLabs\\Enum\\Enum' not found in wp-content/plugins/wp-2fa/vendor/endroid/qr-code/src/ErrorCorrectionLevel.php:23

User-side errors Passed 1 test

🔹 Test weight: 20 | A shallow check that no browser errors were triggered
Everything seems fine on the user side

Optimizations

Plugin configuration 93% from 29 tests

readme.txt Passed 16 tests

The readme.txt file is important because it is parsed by WordPress.org for the public listing of your plugin
6 plugin tags: two-step authentication, two-factor authentication, 2fa, 2-factor authentication, multi-step authentication...

wp-2fa/wp-2fa.php 85% from 13 tests

"WP 2FA - Two-factor authentication for WordPress" version 2.5.0's main PHP file describes plugin functionality and also serves as the entry point to any WordPress functionality
The following require your attention:
  • Description: Keep the plugin description shorter than 140 characters (currently 171 characters long)
  • Requires PHP: The required version number must match the one declared in readme.txt ("7.2.0" instead of "7.2")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short check of programming languages and file extensions; no executable files are allowed
Everything looks great! No dangerous files found in this plugin24,872 lines of code in 247 files:
LanguageFilesBlank linesComment linesLines of code
PHP2352,72812,54823,713
JSON100644
JavaScript57964413
SVG22195
CSS4007

PHP code Passed 2 tests

An short overview of logical lines of code, cyclomatic complexity, and other code metrics
This plugin has no cyclomatic complexity problems
Cyclomatic complexity
Average complexity per logical line of code0.40
Average class complexity16.76
▷ Minimum class complexity1.00
▷ Maximum class complexity202.00
Average method complexity3.52
▷ Minimum method complexity1.00
▷ Maximum method complexity73.00
Code structure
Namespaces47
Interfaces19
Traits1
Classes211
▷ Abstract classes94.27%
▷ Concrete classes20295.73%
▷ Final classes10551.98%
Methods1,500
▷ Static methods64543.00%
▷ Public methods1,21881.20%
▷ Protected methods271.80%
▷ Private methods25517.00%
Functions54
▷ Named functions2648.15%
▷ Anonymous functions2851.85%
Constants193
▷ Global constants157.77%
▷ Class constants17892.23%
▷ Public constants9553.37%

Plugin size Passed 2 tests

Image compression Passed 2 tests

PNG files should be compressed to save space and minimize bandwidth usage
15 PNG files occupy 0.23MB with 0.11MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
FileSize - originalSize - compressedSavings
dist/images/wp-2fa-white-icon20x28.png0.79KB1.16KB0.00%
dist/images/password-policy-manager.png8.19KB3.95KB▼ 51.79%
dist/images/wp-white-security.png8.80KB4.31KB▼ 51.05%
dist/images/wp-2fa-square.png28.64KB13.47KB▼ 52.97%
dist/images/okta-logo.png9.00KB1.93KB▼ 78.60%