This commit is contained in:
Javier Casares 2026-09-11 10:29:29 +00:00
commit e568b54336
5 changed files with 62 additions and 15 deletions

View file

@ -1,5 +1,25 @@
== Changelog == == Changelog ==
= 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 = = 1.6.3 =
_Release date: 2026-08-24_ _Release date: 2026-08-24_

View file

@ -236,6 +236,33 @@ class Login_Form_Manager {
add_action( 'init', array( $this, 'maybe_remove_altcha_interceptor' ), 0 ); add_action( 'init', array( $this, 'maybe_remove_altcha_interceptor' ), 0 );
} }
/**
* Retrieve the canonical wp-login.php URL used for 2FA stage navigation.
*
* Builds the URL from the real wp-login.php path instead of wp_login_url().
* The `login_url` filter applied by wp_login_url() can be hijacked by
* third-party plugins (for example Restrict Content Pro's "Hijack Login
* URL" option) to return a membership page, which would send the user to a
* page where the verification form cannot render: core only fires the
* login_init hook when wp-login.php itself loads. This mirrors the URL
* construction wp_login_url() performs before its filter runs.
*
* @since 1.6.4
*
* @param string $redirect_to Optional redirect_to value to carry over.
*
* @return string Absolute wp-login.php URL with optional redirect_to parameter.
*/
public static function get_canonical_login_url( string $redirect_to = '' ): string {
$url = site_url( 'wp-login.php', 'login' );
if ( '' !== $redirect_to ) {
$url = add_query_arg( 'redirect_to', urlencode( $redirect_to ), $url );
}
return $url;
}
/** /**
* Disable the ALTCHA Spam Protection login interceptor during the 2FA stage. * Disable the ALTCHA Spam Protection login interceptor during the 2FA stage.
* *
@ -863,7 +890,7 @@ class Login_Form_Manager {
self::QUERY_STAGE_TOKEN => $stage_token, self::QUERY_STAGE_TOKEN => $stage_token,
); );
$login_url = wp_login_url( $redirect_to ); $login_url = self::get_canonical_login_url( $redirect_to );
$login_url = add_query_arg( $query_args, $login_url ); $login_url = add_query_arg( $query_args, $login_url );
wp_safe_redirect( $login_url ); wp_safe_redirect( $login_url );
@ -1433,7 +1460,7 @@ class Login_Form_Manager {
*/ */
private function get_stage_url( array $extra_args = array() ): string { private function get_stage_url( array $extra_args = array() ): string {
$redirect_to = $this->get_requested_redirect(); $redirect_to = $this->get_requested_redirect();
$login_url = wp_login_url( $redirect_to ); $login_url = self::get_canonical_login_url( $redirect_to );
$args = array( $args = array(
self::QUERY_STAGE => self::STAGE_VERIFY, self::QUERY_STAGE => self::STAGE_VERIFY,

View file

@ -4,7 +4,7 @@ Tags: security, two-factor authentication, login, otp
Requires at least: 5.6 Requires at least: 5.6
Tested up to: 7.0 Tested up to: 7.0
Requires PHP: 8.0 Requires PHP: 8.0
Stable tag: 1.6.3 Stable tag: 1.6.4
License: GPLv3 or later License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html License URI: https://www.gnu.org/licenses/gpl-3.0.html
@ -59,6 +59,14 @@ Yes. Activate the plugin at the network level. Network administrators can set an
== Changelog == == Changelog ==
= 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.
= 1.6.3 = = 1.6.3 =
_Release date: 2026-08-24_ _Release date: 2026-08-24_
@ -85,14 +93,6 @@ _Release date: 2026-08-17_
* Plugin and update URLs moved to `robotstxt.software`. * 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). * 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).
= 1.6.1 =
_Release date: 2026-08-14_
**Fixed**
* Fatal error during editor autosaves: the `[robotstxt_2fa_profile]` shortcode expanded when WordPress applied content filters to a post revision via REST (for example, an article that merely mentions the shortcode in its text). In that context the wp-admin render helpers are not loaded, causing a fatal error. The shortcode now bails out early on REST requests and loads the required wp-admin includes on demand elsewhere.
= Previous versions = = Previous versions =
For the full changelog see the [changelog](https://www.robotstxt.software/plugins/robotstxt-2fa/) page. For the full changelog see the [changelog](https://www.robotstxt.software/plugins/robotstxt-2fa/) page.

View file

@ -4,7 +4,7 @@
* Plugin URI: https://www.robotstxt.software/plugins/robotstxt-2fa/ * Plugin URI: https://www.robotstxt.software/plugins/robotstxt-2fa/
* Update URI: https://www.robotstxt.software/plugins/robotstxt-2fa/ * Update URI: https://www.robotstxt.software/plugins/robotstxt-2fa/
* Description: Adds two-factor authentication to the WordPress login flow. * Description: Adds two-factor authentication to the WordPress login flow.
* Version: 1.6.3 * Version: 1.6.4
* Author: ROBOTSTXT * Author: ROBOTSTXT
* Author URI: https://www.robotstxt.software/ * Author URI: https://www.robotstxt.software/
* Text Domain: robotstxt-2fa * Text Domain: robotstxt-2fa
@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
if ( ! defined( 'ROBOTSTXT_2FA_VERSION' ) ) { if ( ! defined( 'ROBOTSTXT_2FA_VERSION' ) ) {
define( 'ROBOTSTXT_2FA_VERSION', '1.6.3' ); define( 'ROBOTSTXT_2FA_VERSION', '1.6.4' );
} }
if ( ! defined( 'ROBOTSTXT_2FA_FILE' ) ) { if ( ! defined( 'ROBOTSTXT_2FA_FILE' ) ) {

View file

@ -3,7 +3,7 @@
'name' => 'robotstxt/robotstxt-2fa', 'name' => 'robotstxt/robotstxt-2fa',
'pretty_version' => 'dev-main', 'pretty_version' => 'dev-main',
'version' => 'dev-main', 'version' => 'dev-main',
'reference' => '2f5ed132e25529d95b04f81bfd33dfdbcb0fc487', 'reference' => '54a0dd9b62465320c6e7045c568aa258925b208e',
'type' => 'wordpress-plugin', 'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@ -40,7 +40,7 @@
'robotstxt/robotstxt-2fa' => array( 'robotstxt/robotstxt-2fa' => array(
'pretty_version' => 'dev-main', 'pretty_version' => 'dev-main',
'version' => 'dev-main', 'version' => 'dev-main',
'reference' => '2f5ed132e25529d95b04f81bfd33dfdbcb0fc487', 'reference' => '54a0dd9b62465320c6e7045c568aa258925b208e',
'type' => 'wordpress-plugin', 'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),