v1.6.3
This commit is contained in:
parent
3e4433cd13
commit
511d2fefae
2 changed files with 103 additions and 50 deletions
|
|
@ -20,11 +20,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
*/
|
||||
class Manager_Notice {
|
||||
|
||||
/**
|
||||
* Basename of the Manager plugin main file.
|
||||
*/
|
||||
private const MANAGER_BASENAME = 'robotstxt-manager/robotstxt-manager.php';
|
||||
|
||||
/**
|
||||
* URL of the Manager plugin page.
|
||||
*/
|
||||
|
|
@ -56,16 +51,35 @@ class Manager_Notice {
|
|||
/**
|
||||
* Whether the Manager (by ROBOTSTXT) plugin is active.
|
||||
*
|
||||
* Uses the ecosystem presence constant (Manager 1.6.2+) and falls back
|
||||
* to a plugin-list scan for older Manager versions.
|
||||
*
|
||||
* @since 1.6.2
|
||||
*
|
||||
* @return bool True when the manager plugin is active.
|
||||
* @return bool True when the Manager plugin is present and activated.
|
||||
*/
|
||||
public static function is_manager_active(): bool {
|
||||
if ( ! function_exists( 'is_plugin_active' ) ) {
|
||||
if ( defined( 'ROBOTSTXT_MANAGER_NOTICED' ) && ROBOTSTXT_MANAGER_NOTICED ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'get_plugins' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
return is_plugin_active( self::MANAGER_BASENAME );
|
||||
foreach ( get_plugins() as $file => $data ) {
|
||||
$slug = dirname( $file );
|
||||
|
||||
if ( '.' === $slug ) {
|
||||
$slug = basename( $file, '.php' );
|
||||
}
|
||||
|
||||
if ( 'robotstxt-manager' === $slug ) {
|
||||
return is_plugin_active( $file );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -233,6 +233,46 @@ class Login_Form_Manager {
|
|||
add_filter( 'login_message', array( $this, 'filter_login_message' ) );
|
||||
add_filter( 'authenticate', array( $this, 'maybe_complete_verification' ), 5, 3 );
|
||||
add_filter( 'authenticate', array( $this, 'enforce_verification_challenge' ), 30, 3 );
|
||||
add_action( 'init', array( $this, 'maybe_remove_altcha_interceptor' ), 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the ALTCHA Spam Protection login interceptor during the 2FA stage.
|
||||
*
|
||||
* ALTCHA's "Protect login" feature rejects any wp-login.php POST that does
|
||||
* not carry a fresh proof-of-work payload (HTTP 403). Its JavaScript only
|
||||
* produces that payload for classic username + password submissions, while
|
||||
* the verification stage intentionally omits the password field, so every
|
||||
* legitimate 2FA submission would otherwise be blocked. Human verification
|
||||
* already happened on the first login step; this stage is protected by the
|
||||
* pending-stage token, the stage nonce, and the failed-attempts lockout.
|
||||
*
|
||||
* @since 1.6.2
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_remove_altcha_interceptor(): void {
|
||||
if ( ! $this->is_verification_stage() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! has_action( 'init', 'altcha_interceptor' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wp_filter;
|
||||
|
||||
if ( ! isset( $wp_filter['init'] ) || ! $wp_filter['init'] instanceof \WP_Hook ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( array_keys( $wp_filter['init']->callbacks ) as $priority ) {
|
||||
if ( isset( $wp_filter['init']->callbacks[ $priority ]['altcha_interceptor'] ) ) {
|
||||
remove_action( 'init', 'altcha_interceptor', (int) $priority );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue