Skip to content

Commit

Permalink
refactor: only add _tenup_preview_link for preview requests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Mar 10, 2024
1 parent d7328d2 commit 85f4f2e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wp/headless-wp/includes/classes/Preview/PreviewLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class PreviewLink {
public function register() {
add_filter( 'template_include', [ $this, 'handle_preview' ], 20 );

add_action( 'rest_api_init', [ $this, 'add_preview_link_field' ] );
// only add _tenup_preview_link for preview authenticated requests
if ( PreviewToken::get_payload_from_token() ) {
add_action( 'rest_api_init', [ $this, 'add_preview_link_field' ] );
}
}

/**
Expand Down

0 comments on commit 85f4f2e

Please sign in to comment.