diff --git a/.tests/php/unit/Helpers/PagesTest.php b/.tests/php/unit/Helpers/PagesTest.php index 40417d04..010e518d 100644 --- a/.tests/php/unit/Helpers/PagesTest.php +++ b/.tests/php/unit/Helpers/PagesTest.php @@ -91,8 +91,9 @@ public function test_is_elementor_pro_edit_page(): void { // Request 2. unset( $_GET, $_POST, $_SERVER ); - $_GET['elementor-preview'] = 'some'; - $_SERVER['REQUEST_URI'] = '/elementor'; + $_GET['preview_id'] = 'some'; + $_GET['preview_nonce'] = 'some'; + $_GET['preview'] = 'true'; self::assertTrue( Pages::is_elementor_pro_edit_page() ); @@ -102,13 +103,6 @@ public function test_is_elementor_pro_edit_page(): void { $_POST['action'] = 'elementor_ajax'; self::assertTrue( Pages::is_elementor_pro_edit_page() ); - - // Request 4. - unset( $_GET, $_POST, $_SERVER ); - - $_GET['elementor-preview'] = 'some'; - - self::assertTrue( Pages::is_elementor_pro_edit_page() ); } /** diff --git a/readme.txt b/readme.txt index 2946abf7..306d8947 100644 --- a/readme.txt +++ b/readme.txt @@ -583,6 +583,7 @@ Instructions for popular native integrations are below: * Fixed appearance of Formidable Forms with "Turn Off When Logged In" setting. * Fixed appearance of WPForms editor with "Turn Off When Logged In" setting. * Fixed fatal error on Gravity Forms Entries page. +* Fixed Elementor preview. * Fixed Ninja Forms preview. * Fixed hCaptcha nonce error on MailPoet admin pages. * Fixed frontend error when recaptcha was activated in wpDiscuz. diff --git a/src/php/Helpers/Pages.php b/src/php/Helpers/Pages.php index 6fcd1a6c..42ac9b74 100644 --- a/src/php/Helpers/Pages.php +++ b/src/php/Helpers/Pages.php @@ -57,6 +57,7 @@ public static function is_elementor_pro_edit_page(): bool { // phpcs:disable WordPress.Security.NonceVerification.Recommended $request_uri = Request::filter_input( INPUT_SERVER, 'REQUEST_URI' ); $get_action = Request::filter_input( INPUT_GET, 'action' ); + $preview = Request::filter_input( INPUT_GET, 'preview' ); $post_action = Request::filter_input( INPUT_POST, 'action' ); $request1 = ( @@ -65,15 +66,14 @@ public static function is_elementor_pro_edit_page(): bool { 'elementor' === $get_action ); $request2 = ( - isset( $_GET['elementor-preview'] ) && - 0 === strpos( $request_uri, '/elementor' ) + isset( $_GET['preview_id'], $_GET['preview_nonce'] ) && + filter_var( $preview, FILTER_VALIDATE_BOOLEAN ) ); $request3 = 'elementor_ajax' === $post_action; - $request4 = isset( $_GET['elementor-preview'] ); // phpcs:enable WordPress.Security.NonceVerification - return $request1 || $request2 || $request3 || $request4; + return $request1 || $request2 || $request3; } /**