| Server IP : 91.134.83.25 / Your IP : 216.73.216.137 Web Server : Apache System : Linux plesk.serveurapc.fr 6.1.0-51-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.177-1 (2026-07-16) x86_64 User : marrasse ( 10057) PHP Version : 8.2.32 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/as-cp.fr/wpascp/wp-content/plugins/wp-rocket/inc/Engine/MCP/Auth/ |
Upload File : |
<?php
/**
* OAuth 2.1 Rewrite Rules.
*
* Registers the WordPress rewrite rules and query var used to route the
* five OAuth endpoints (authorize, authorize-callback, token, consent,
* revoke).
*/
declare( strict_types=1 );
namespace WP_Rocket\Engine\MCP\Auth;
use WP_Rocket\Engine\Activation\ActivationInterface;
/**
* Registers OAuth endpoint rewrite rules and the query var used to route them.
*/
class Rewrite implements ActivationInterface {
/**
* WordPress query var used to route OAuth endpoint requests.
*/
const OAUTH_QUERY_VAR = 'mcp_oauth_endpoint'; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
/**
* Registers this class's activation callback.
*
* @return void
*/
public function activate() {
add_action( 'rocket_activation', [ $this, 'register_oauth_rewrite_rules' ] );
}
/**
* Register WordPress rewrite rules for all five OAuth endpoints.
*
* Called both on the 'init' action (normal page load) and during plugin
* activation to ensure rules are present before flush_rewrite_rules().
*
* @return void
*/
public function register_oauth_rewrite_rules(): void {
add_rewrite_rule( '^oauth/authorize$', 'index.php?' . self::OAUTH_QUERY_VAR . '=authorize', 'top' );
add_rewrite_rule( '^oauth/authorize-callback$', 'index.php?' . self::OAUTH_QUERY_VAR . '=authorize-callback', 'top' );
add_rewrite_rule( '^oauth/token$', 'index.php?' . self::OAUTH_QUERY_VAR . '=token', 'top' );
add_rewrite_rule( '^oauth/consent$', 'index.php?' . self::OAUTH_QUERY_VAR . '=consent', 'top' );
add_rewrite_rule( '^oauth/revoke$', 'index.php?' . self::OAUTH_QUERY_VAR . '=revoke', 'top' );
}
/**
* Add the OAuth query var to WordPress's list of recognised vars.
*
* @param string[] $vars Existing query vars.
* @return string[] Modified list.
*/
public function add_oauth_query_vars( array $vars ): array {
$vars[] = self::OAUTH_QUERY_VAR;
return $vars;
}
}