diff --git a/mu-plugin/plausible-proxy-speed-module.php b/mu-plugin/plausible-proxy-speed-module.php index 41d59f1..32c6bd1 100644 --- a/mu-plugin/plausible-proxy-speed-module.php +++ b/mu-plugin/plausible-proxy-speed-module.php @@ -4,7 +4,7 @@ * Description: Speeds up Plausible Analytics' proxy for avoiding ad blockers. * Plugin URI: https://plausible.io * Author: Plausible HQ - * Version: 1.0.1 + * Version: 1.0.2 * Author URI: https://plausible.io * * Text Domain: plausible-analytics @@ -68,6 +68,17 @@ private function is_proxy_request() { return false; } + /** + * @see rest_url() requires $wp_rewrite to be set. If it's not set yet, just assume this isn't a proxy request. + * + * @since v1.0.2 + */ + global $wp_rewrite; + + if ( $wp_rewrite === null ) { + return false; + } + $expected = function_exists( 'rest_url' ) ? untrailingslashit( (string) wp_parse_url( rest_url( trim( $namespace, '/' ) ), PHP_URL_PATH ) ) : '/wp-json/' . trim( $namespace, '/' );