Skip to content

Commit

Permalink
fix(theme): preview cookie name
Browse files Browse the repository at this point in the history
  • Loading branch information
rpeterman-gp committed Mar 14, 2024
1 parent eb1272c commit cefa860
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions wp-content/themes/the-world/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function tw_preview_post_link( $preview_link, $post ) {

if ( ! function_exists( 'tw_init_set_auth_cookie' ) ) {
/**
* Set cookie to store auth token. SHould be an http cookies.
* Set cookie to store auth token. Should be an http cookie.
* Assume frontend will be served from the same domain.
*
* @return void
Expand All @@ -107,14 +107,14 @@ function tw_init_set_auth_cookie() {
$auth = new WPGraphQL\JWT_Authentication\Auth();
$secret_key = $auth->get_secret_key();

if ( $secret_key && ! isset( $_COOKIE['wp_can_preview'] ) ) {
if ( $secret_key && ! isset( $_COOKIE['wp-can_preview'] ) ) {
$hostname = wp_parse_url( get_site_url(), PHP_URL_HOST );
// NOTE: Regex assumes front-end domains will use single segment TLD's.
$domain = trim( preg_replace( '~.*?\.?((?:\.?[\w_-]+){2})$~', '$1', $hostname ), '.' );
$token = $auth->get_refresh_token( wp_get_current_user() );

setcookie(
'wp_can_preview',
'wp-can_preview',
$token,
array(
'expires' => 0,
Expand Down

0 comments on commit cefa860

Please sign in to comment.