Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preview URL filter #81

Merged
merged 3 commits into from
Feb 21, 2024
Merged

Add preview URL filter #81

merged 3 commits into from
Feb 21, 2024

Conversation

alecgeatches
Copy link
Contributor

Description

See discussion in #70. It can be difficult to set up home_url() to point to a decoupled front end for previews, but ensure WordPress continues to function normally. For flexibility, we're adding this filter to modify the preview URL destination separately:

/**
 * Filter preview URL before redirect.
 *
 * @param  $preview_url     Generated preview URL, based on home_url().
 * @param  $preview_token   Token used to view the preview.
 * @param  $post_id         ID of the post being previewed.
 */
$preview_url = apply_filters( 'vip_decoupled_preview_url', $preview_url, $preview_token, $post->ID );

Note that wp_safe_redirect() has also been changed to wp_redirect(), as the former will not allow redirection outside of the home domain.

…n, use wp_redirect over wp_safe_redirect to allow remote domains
@alecgeatches alecgeatches self-assigned this Feb 21, 2024
@alecgeatches alecgeatches requested a review from a team as a code owner February 21, 2024 19:27
@alecgeatches alecgeatches merged commit 0ac8ae3 into trunk Feb 21, 2024
2 checks passed
@alecgeatches alecgeatches deleted the add/preview-url-filter branch February 21, 2024 22:27
@alecgeatches alecgeatches mentioned this pull request Mar 27, 2024
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.

1 participant