diff --git a/changelog.txt b/changelog.txt index 9552271..849c0d6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,231 @@ == Changelog == += 1.6.11 = + +_Release date: 2026-11-04_ + +**Fixed** + +* The 2FA verification screen is no longer hijacked on membership sites that redirect the WordPress login away from wp-login.php (confirmed live on Restrict Content Pro 4.0.9 with "Hijack Login URL" enabled and the login at a custom account page such as /mi-cuenta/). RCP implements the hijack twice: through the login_url filter (already handled since 1.6.4) and — new finding — through a `login_form_login` redirect that bounces every default-action wp-login.php request to the membership page, dropping the 2FA query arguments. Stage requests now carry a dedicated `action=robotstxt-2fa-verify` (declared to WordPress via a registered `login_form_` hook, preserved on submission through a hidden field), so they run core's login branch without firing `login_form_login`, out of reach of that redirect pattern in any plugin. Verified end to end on the reported replica: password at the membership page → verification screen renders → valid code → user lands back on the membership page, logged in. +* Users logging in from front-end forms (membership/account pages) now return to the page they logged in from after completing 2FA instead of landing in wp-admin: when the request carries no core `redirect_to`, the challenge falls back to the raw HTTP referer, validated to be same-host and not an admin or login URL (foreign and admin referers are ignored). + +**Compatibility** + +* WordPress: 7.0 - 7.2 +* PHP: 8.3 - 8.6 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors +* PHPStan: level max (10), no baseline — 0 errors +* PHPCompatibility: 8.3-8.6 — 0 issues +* PHPUnit: 9.6.38 — 125 tests, 236 assertions (PHP 8.6.0RC3 and 8.3.36) +* Live end-to-end on the reported site replica (WordPress 7.1.4 + Restrict Content Pro 4.0.9): full login → 2FA → return-to-page cycle, MariaDB 11.8.9 + += 1.6.10 = + +_Release date: 2026-11-03_ + +**Fixed** + +* The 2FA verification stage now stays on the login URL the visitor actually used. When wp-login.php executes through an alias or renamed slug (a `/login` rewrite, a "hidden login" setup that does not filter `site_url`), the post-password redirect previously always targeted the literal `/wp-login.php` — on sites where that URL is blocked or renamed away at server level, users were stranded on a 403/404 page right after a correct password. The stage base URL now preserves the executing login surface (path only; host and scheme still come from the site's canonical URL; traversal sequences rejected), while logins submitted from custom pages calling `wp_signon()` keep landing on the real wp-login.php as before (the 1.6.4 Restrict Content Pro guarantee). Full root-cause analysis in `docs/report-login-surface-urls.md`. + +**Compatibility** + +* WordPress: 7.0 - 7.2 +* PHP: 8.3 - 8.6 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors +* PHPStan: level max (10), no baseline — 0 errors +* PHPCompatibility: 8.3-8.6 — 0 issues +* PHPUnit: 9.6.38 — 119 tests, 229 assertions (PHP 8.6.0RC3 and 8.3.36) +* Live surface probes: WordPress 7.2-beta4 (single site) and WordPress 7.0 (multisite) on PHP 8.6.0RC3, MariaDB 11.8.9 + += 1.6.9 = + +_Release date: 2026-11-03_ + +**Changed** + +* Compatibility floors raised: minimum WordPress moved from 5.6 to 7.0 and minimum PHP from 8.0 to 8.3, matching the support policy (latest stable WordPress plus the two previous majors). The full-range compatibility review (WordPress 4.7-7.2 walked down with wp-compat; PHP 5.6-8.6 scanned with PHPCompatibility) confirmed the plugin uses no WordPress symbols newer than 6.0 and no PHP syntax newer than 8.0, so the real code floors are lower — the declared floors are the supported ones. WordPress 7.2 (beta 4, single-site) and WordPress 7.0 (multisite) were live-tested; PHP 8.6 (RC 3) was live-tested and PHP 8.3-8.6 scanned clean. +* The admin menu icon is now a brand SVG (shield with keyhole, base64 data URI) instead of `dashicons-shield`, on both single-site and network admin menus. WordPress core natively renders base64 SVG menu icons (centered at 20px), so the icon works identically on WordPress 7.0, 7.1 and 7.2, stays crisp on high-density screens, and is future-proof against the admin-wide move from Dashicons to SVG icons tracked in WordPress core (PR #12270 / Trac ticket #65089). Dashicons continue to work everywhere else. +* Composer tooling updated: wp-compat 3.0.1, PHPStan 2.3.5, wordpress-stubs 7.1.2, PHPUnit 9.6.38, maxmind-db/reader 1.14.0; `composer audit` reports no known vulnerabilities. + +**Fixed** + +* PHP 8.6 deprecation removed: the REST controller declared a class constant named `namespace` (case-insensitively), which PHP 8.6 deprecates and PHP 9 will reject as a fatal error. Renamed to `REST_NAMESPACE` with no functional change (the constant was private). +* Static-analysis hardening to pass PHPStan at the new maximum level (10) without a baseline: `$wpdb`, `$wp_filter` and `$post` globals are now properly typed; the uninstall routine deletes user meta through the `$wpdb->delete()` WordPress API instead of hand-built SQL; role names from `get_editable_roles()` are validated before translation; `AUTH_SALT` and `COOKIEPATH` are validated as strings before use in the trusted-device cookie; the trusted-device map discards corrupted non-string keys; `get_users()` results are instance-checked before use; a misplaced translators comment on an `_n()` call was fixed (WPCS error). + +**Compatibility** + +* WordPress: 7.0 - 7.2 +* PHP: 8.3 - 8.6 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors, 1 accepted advisory warning (urlencode mirrors WordPress core's wp_login_url()) +* PHPStan: 2.3.5 level max (10), no baseline — 0 errors +* PHPCompatibility: 9.3.5, testVersion 8.3-8.6 — 0 issues +* PHPUnit: 9.6.38 — 110 tests, 220 assertions (PHP 8.6.0RC3 and PHP 8.3.36) +* Live smoke tests: WordPress 7.2-beta4 (single site) and WordPress 7.0 (multisite) on PHP 8.6.0RC3, MariaDB 11.8.9 + += 1.6.8 = + +_Release date: 2026-09-21_ + +**Added** + +* Administrator visibility when email delivery fails: failed verification-code deliveries record a marker and administrators see a persistent, self-clearing notice ("2FA: email delivery is failing…") in wp-admin and the network admin, since forced-email users cannot sign in while delivery is broken. The notice disappears automatically once a code is delivered successfully. + +**Fixed** + +* "We could not determine which account you are trying to access" during verification: the pending-stage token was stored in a transient, which external object caches (Redis/Memcached) can evict at any time, killing live verification sessions. Tokens now live in a persistent option map (capped, pruned, consumed on success, cleaned on uninstall) and the error message now says the session expired and asks the user to sign in again. + +**Compatibility** + +* WordPress: 5.6 – 7.1 +* PHP: 8.0 – 8.5 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors +* PHPStan: level 9 — 0 errors +* PHPCompatibility: 8.0–8.5 — 0 issues +* PHPUnit: 9.6.36 — 110 tests, 220 assertions + += 1.6.7 = + +_Release date: 2026-09-17_ + +**Fixed** + +* The forced-setup wizard felt like a broken redirect loop: the wizard redirect bounced users to the profile with no explanation (it now carries a flag that renders a clear "activate at least one verification method, then save" warning), and saving with an expired form nonce silently did nothing (it now raises a visible "form session expired" error so users know to try again). + +**Compatibility** + +* WordPress: 5.6 – 7.1 +* PHP: 8.0 – 8.5 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors +* PHPStan: level 9 — 0 errors +* PHPCompatibility: 8.0–8.5 — 0 issues +* PHPUnit: 9.6.36 — 98 tests, 197 assertions + += 1.6.6 = + +_Release date: 2026-09-17_ + +**Added** + +* Forced-enrollment warning on the profile 2FA section: when a user's role enforces 2FA but they have no verification method configured yet, the 2FA section of their profile (wp-admin and the frontend shortcode) opens with a warning notice asking them to activate at least one method. While a grace period is active, the notice appends the remaining days. + +**Compatibility** + +* WordPress: 5.6 – 7.1 +* PHP: 8.0 – 8.5 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors +* PHPStan: level 9 — 0 errors +* PHPCompatibility: 8.0–8.5 — 0 issues +* PHPUnit: 9.6.36 — 93 tests, 189 assertions + += 1.6.5 = + +_Release date: 2026-09-17_ + +**Fixed** + +* Fatal error on the login screen with newer WordPress versions: the `login_message` filter can deliver null when no message is set (observed on WordPress 7.x with PHP 8.4, TypeError on a plain visit to wp-login.php). The message callback now accepts `string|null` and coalesces null to an empty string. +* Hardened all externally-fed filter callbacks against null payloads: the four `authenticate` callbacks now accept `string|null` credentials (custom REST/SSO endpoints are known to apply the filter with null), and the `wp_redirect` filter callback coalesces a null location. Verified safe as-is: shortcode callback, Settings API sanitizer, activation hooks, and admin-hook parameters. + +**Compatibility** + +* WordPress: 5.6 – 7.1 +* PHP: 8.0 – 8.5 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors +* PHPStan: level 9 — 0 errors +* PHPCompatibility: 8.0–8.5 — 0 issues +* PHPUnit: 9.6.36 — 87 tests, 180 assertions + += 1.6.4 = + +_Release date: 2026-09-11_ + +**Fixed** + +* Compatibility with Restrict Content Pro's "Hijack Login URL" option: RCP's `login_url` filter made every `wp_login_url()` call return a membership page, so the 2FA verification redirect landed on a restricted page where the verification form cannot render, and the visitor was bounced to the registration page. Verification-stage URLs are now built from the canonical `wp-login.php`, mirroring WordPress core's URL construction before the filterable output. The "Back to login" link keeps the site-configured login URL. + +**Compatibility** + +* WordPress: 5.6 – 7.1 +* PHP: 8.0 – 8.5 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors +* PHPStan: level 9 — 0 errors +* PHPCompatibility: 8.0–8.5 — 0 issues +* PHPUnit: 9.6.36 — 78 tests, 171 assertions + += 1.6.3 = + +_Release date: 2026-08-24_ + +**Changed** + +* Manager detection now uses the ecosystem presence constant (`ROBOTSTXT_MANAGER_NOTICED`, defined by Manager 1.6.2+) with a fallback to the plugin-list scan for older Manager versions, so a stale plugin list can no longer produce false "Manager missing" notices. + +**Fixed** + +* Compatibility with the ALTCHA Spam Protection plugin: when "Protect login" was enabled, submitting the 2FA verification code failed with "[ALTCHA] Sorry, your request could not be processed.". The ALTCHA interceptor is now disabled while the verification screen is shown; the first login step keeps its ALTCHA check. + +**Compatibility** + +* WordPress: 5.6 – 7.1 +* PHP: 8.0 – 8.5 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors +* PHPStan: level 9 — 0 errors +* PHPCompatibility: 8.0–8.5 — 0 issues +* PHPUnit: 9.6.36 — 73 tests, 163 assertions + += 1.6.2 = + +_Release date: 2026-08-17_ + +**Added** + +* Recommendation notice for the Manager (by ROBOTSTXT) plugin: when it is not installed and active, a dismissible notice appears on the Plugins screen and a permanent notice is shown on the plugin settings page, since updates are delivered through the Manager plugin. + +**Changed** + +* Updates are now handled by the Manager (by ROBOTSTXT) plugin. The bundled self-updater (robotstxt-updater.php and update.json) has been removed. +* Plugin and update URLs moved to robotstxt.software. +* Minimum WordPress version lowered from 6.4 to 5.6 after a full compatibility review (the code only requires WordPress 5.3+ functions, and WordPress 5.6 is the first release that runs on the required PHP 8.0). + +**Compatibility** + +* WordPress: 5.6 – 7.1 +* PHP: 8.0 – 8.5 + +**Tests** + +* PHP Coding Standards: PHP_CodeSniffer 3.13.6 / WPCS 3.4.1 — 0 errors +* PHPStan: level 9 — 0 errors +* PHPCompatibility: 8.0–8.5 — 0 issues +* PHPUnit: 9.6.36 — 59 tests, 148 assertions + = 1.6.1 = _Release date: 2026-08-14_ diff --git a/includes/admin/class-dashboard-page.php b/includes/admin/class-dashboard-page.php index fdf4b09..7517c0e 100644 --- a/includes/admin/class-dashboard-page.php +++ b/includes/admin/class-dashboard-page.php @@ -24,6 +24,18 @@ class Dashboard_Page { */ public const PAGE_SLUG = 'robotstxt-2fa-dashboard'; + /** + * Brand SVG menu icon (shield with keyhole) as a base64 data URI. + * + * WordPress core renders base64-encoded SVG data URIs natively in admin + * menus (centered at 20px via the .wp-menu-image.svg CSS class), which + * keeps the icon crisp and independent of the Dashicons font while + * remaining fully backward compatible. + * + * @since 1.6.9 + */ + public const MENU_ICON = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgdmlld0JveD0iMCAwIDIwIDIwIiByb2xlPSJpbWciIGFyaWEtaGlkZGVuPSJ0cnVlIiBmb2N1c2FibGU9ImZhbHNlIj48cGF0aCBmaWxsPSIjMDM4N2M5IiBkPSJNMTAgMSAxOCAzLjl2NS4zYzAgNS40LTMuMyA4LjYtOCA5LjgtNC43LTEuMi04LTQuNC04LTkuOFYzLjlaIi8+PGNpcmNsZSBjeD0iMTAiIGN5PSI4IiByPSIyLjIiIGZpbGw9IiNmZmVmZDQiLz48cGF0aCBmaWxsPSIjZmZlZmQ0IiBkPSJNOC44IDkuOSA3LjYgMTMuN2g0LjhMMTEuMiA5LjlaIi8+PC9zdmc+'; + /** * Failed attempts log. * @@ -108,7 +120,7 @@ class Dashboard_Page { 'manage_options', self::PAGE_SLUG, array( $this, 'render_page' ), - 'dashicons-shield' + self::MENU_ICON ); add_submenu_page( diff --git a/includes/admin/class-manager-notice.php b/includes/admin/class-manager-notice.php new file mode 100644 index 0000000..7fb1e2d --- /dev/null +++ b/includes/admin/class-manager-notice.php @@ -0,0 +1,198 @@ + $data ) { + $slug = dirname( $file ); + + if ( '.' === $slug ) { + $slug = basename( $file, '.php' ); + } + + if ( 'robotstxt-manager' === $slug ) { + return is_plugin_active( $file ); + } + } + + return false; + } + + /** + * Show a dismissible notice on the plugins list screen when the manager is missing. + * + * @since 1.6.2 + * + * @return void + */ + public function maybe_show_plugins_notice(): void { + $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; + + if ( null === $screen ) { + return; + } + + if ( ! in_array( $screen->id, array( 'plugins', 'plugins-network' ), true ) ) { + return; + } + + if ( ! current_user_can( 'manage_options' ) ) { + return; + } + + if ( self::is_manager_active() ) { + return; + } + + if ( get_user_meta( get_current_user_id(), self::DISMISSED_META_KEY, true ) ) { + return; + } + + $dismiss_url = wp_nonce_url( + add_query_arg( 'action', self::DISMISS_ACTION, self_admin_url( 'admin.php' ) ), + self::DISMISS_ACTION + ); + ?> +
+

+ + Manager (by ROBOTSTXT) to be installed and active to receive updates.', 'robotstxt-2fa' ), + esc_url( self::MANAGER_URL ) + ) + ); + ?> +

+

+ +

+
+ +
+

+ + Manager (by ROBOTSTXT) to be installed and active to receive updates.', 'robotstxt-2fa' ), + esc_url( self::MANAGER_URL ) + ) + ); + ?> +

+
+ */ private function get_candidates_from_wordfence(): array { + /** + * WordPress database abstraction. Typed for PHPStan level max. + * + * @var \wpdb $wpdb + */ global $wpdb; $table = $wpdb->prefix . self::WORDFENCE_TABLE; @@ -550,21 +555,17 @@ class Migration_Page { return array(); } - // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table names are trusted constants. + // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is a trusted prefix constant; the user ID is a validated integer. $rows = $wpdb->get_results( "SELECT s.user_id, s.secret FROM `{$table}` s", ARRAY_A ); // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared - if ( ! is_array( $rows ) ) { - return array(); - } - $candidates = array(); foreach ( $rows as $row ) { - if ( ! is_array( $row ) || ! isset( $row['user_id'] ) || ! is_numeric( $row['user_id'] ) ) { + if ( ! isset( $row['user_id'] ) || ! is_numeric( $row['user_id'] ) ) { continue; } @@ -716,14 +717,19 @@ class Migration_Page { * @return string */ private function read_wordfence_secret( int $user_id ): string { + /** + * WordPress database abstraction. Typed for PHPStan level max. + * + * @var \wpdb $wpdb + */ global $wpdb; $table = $wpdb->prefix . self::WORDFENCE_TABLE; - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is a trusted constant. - $secret_binary = $wpdb->get_var( $wpdb->prepare( "SELECT `secret` FROM `{$table}` WHERE `user_id` = %d LIMIT 1", $user_id ) ); + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is a trusted prefix constant; the user ID is a validated integer. + $secret_binary = $wpdb->get_var( "SELECT `secret` FROM `{$table}` WHERE `user_id` = {$user_id} LIMIT 1" ); - if ( ! is_string( $secret_binary ) || '' === $secret_binary ) { + if ( ! is_string( $secret_binary ) ) { return ''; } diff --git a/includes/admin/class-settings-page.php b/includes/admin/class-settings-page.php index 342a1f4..94c9036 100644 --- a/includes/admin/class-settings-page.php +++ b/includes/admin/class-settings-page.php @@ -101,6 +101,8 @@ class Settings_Page { settings_errors( self::OPTION_NAME ); + Manager_Notice::render_settings_notice(); + $form_action = $this->is_network_context() ? network_admin_url( 'edit.php?action=robotstxt_2fa_network_save' ) : 'options.php'; @@ -429,8 +431,13 @@ class Settings_Page { $role_details ) : ?> + - + $method_label ) : ?>