Skip to content

Improve Preview [ED-14320]#1

Open
baghdasarovelementor wants to merge 5 commits intomainfrom
fix/ED-14320-fix-elementor-drafts-can-be-viewed-by-anyone-with-the-article-url-preview-true
Open

Improve Preview [ED-14320]#1
baghdasarovelementor wants to merge 5 commits intomainfrom
fix/ED-14320-fix-elementor-drafts-can-be-viewed-by-anyone-with-the-article-url-preview-true

Conversation

@baghdasarovelementor
Copy link
Copy Markdown
Owner

PR Checklist

Description

Improve Preview

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Quality assurance

  • I have tested this code to the best of my abilities
  • I have added unittests to verify the code works as intended
  • Docs have been added / updated (for bug fixes / features)

@baghdasarovelementor baghdasarovelementor self-assigned this Apr 26, 2024
Comment thread core/documents-manager.php Outdated
public function get_doc_for_frontend( $post_id ) {
if ( is_preview() || Plugin::$instance->preview->is_preview_mode() ) {
$is_preview = is_preview() && isset( $_GET['preview_id'] ) && $post_id === (int) $_GET['preview_id'];
$is_nonce_verify = isset( $_GET['preview_id'] ) && wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$is_nonce_verify = isset( $_GET['preview_id'] ) && wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] );
$is_nonce_verify = isset( $_GET['preview_id'] ) && wp_verify_nonce( Utils::get_super_global_value( $_GET, 'preview_nonce' ), 'post_preview_' . (int) $_GET['preview_id'] );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the others

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@baghdasarovelementor baghdasarovelementor force-pushed the fix/ED-14320-fix-elementor-drafts-can-be-viewed-by-anyone-with-the-article-url-preview-true branch from e795af0 to ad2ac73 Compare April 26, 2024 13:02
Comment thread core/documents-manager.php Outdated
*/
public function get_doc_for_frontend( $post_id ) {
if ( is_preview() || Plugin::$instance->preview->is_preview_mode() ) {
$is_preview = is_preview() && isset( $_GET['preview_id'] ) && $post_id === (int) Utils::get_super_global_value( $_GET, 'preview_id' );
Copy link
Copy Markdown

@louiswol94 louiswol94 Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the isset( $_GET['preview_id'] )? IIRC Utils::get_super_global_value() already handles the isset.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread core/documents-manager.php Outdated
Comment on lines +278 to +279
$is_preview = is_preview() && $post_id === (int) Utils::get_super_global_value( $_GET, 'preview_id' );
$is_nonce_verify = wp_verify_nonce( Utils::get_super_global_value( $_GET, 'preview_nonce' ), 'post_preview_' . (int) Utils::get_super_global_value( $_GET, 'preview_id' ) );
Copy link
Copy Markdown

@louiswol94 louiswol94 Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$is_preview = is_preview() && $post_id === (int) Utils::get_super_global_value( $_GET, 'preview_id' );
$is_nonce_verify = wp_verify_nonce( Utils::get_super_global_value( $_GET, 'preview_nonce' ), 'post_preview_' . (int) Utils::get_super_global_value( $_GET, 'preview_id' ) );
$preview_id = (int) Utils::get_super_global_value( $_GET, 'preview_id' );
$is_preview = is_preview() && $post_id === $preview_id;
$is_nonce_verify = wp_verify_nonce( Utils::get_super_global_value( $_GET, 'preview_nonce' ), 'post_preview_' . $preview_id;

Sorry one more. You can cache (int) Utils::get_super_global_value( $_GET, 'preview_id' ); in a variable.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

…wed-by-anyone-with-the-article-url-preview-true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants