Skip to content

Commit

Permalink
fix: logged out redirect to headless domain was sending broken link (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ccorda authored Jun 7, 2022
1 parent a29ecd8 commit a479422
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions wordpress/wp-content/themes/headless/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
if ($preview_domain) {
$headless_domain = rtrim($preview_domain, '/');
} else {
$headless_domain = $staging_headless_domain;
$headless_domain = rtrim($staging_headless_domain, '/');
}
} else {
define('WP_HOST', 'production');
if ($preview_domain) {
$headless_domain = rtrim($preview_domain, '/');
} else {
$headless_domain = $production_headless_domain;
$headless_domain = rtrim($production_headless_domain, '/');
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ function headless_redirect(){
global $headless_domain;

$post_type = get_post_type(get_the_ID());
$slug = ltrim(str_replace(home_url(), '', get_permalink(get_the_ID())), '/');
$url = get_permalink(get_the_ID());
$slug = parse_url($url, PHP_URL_PATH);
$redirect = '';

// check if preview and user has edit ability.
// if so, redirect to preview path

if ( is_preview() ) {
if ( current_user_can( 'edit_posts' ) ) {
$revisions = wp_get_post_revisions(
Expand All @@ -43,7 +44,6 @@ function headless_redirect(){
}

// else do standard redirect tree

if ($slug) {
if ( current_user_can( 'edit_posts' ) ) {
$auth_code = wpe_headless_generate_authentication_code(
Expand Down

0 comments on commit a479422

Please sign in to comment.