Skip to content

Commit

Permalink
Fix Elementor preview.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Aug 22, 2024
1 parent 9baa546 commit 13ac207
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
12 changes: 3 additions & 9 deletions .tests/php/unit/Helpers/PagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() );

Expand All @@ -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() );
}

/**
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/php/Helpers/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit 13ac207

Please sign in to comment.