Skip to content

Commit

Permalink
fix(twepisodeimporter): handle contributor image value if string
Browse files Browse the repository at this point in the history
- change preview cookie name
  • Loading branch information
rpeterman-gp committed Apr 9, 2024
1 parent 256476e commit 4a4cbd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion wp-content/plugins/tw-episode-importer/api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ function ( $contributor_name ) {

$contributor_image = get_field( 'image', 'contributor_' . $contributor_term->term_id );
if ( $contributor_image ) {
$author['image'] = $contributor_image['url'];
$author['image'] = is_array( $contributor_image ) ? $contributor_image['url'] : $contributor_image;
}

return $author;
Expand Down
11 changes: 6 additions & 5 deletions wp-content/themes/the-world/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,19 @@ function tw_preview_post_link( $preview_link, $post ) {
* @return void
*/
function tw_init_set_auth_cookie() {
$auth = new WPGraphQL\JWT_Authentication\Auth();
$secret_key = $auth->get_secret_key();
$user = wp_get_current_user();
$auth = new WPGraphQL\JWT_Authentication\Auth();
$secret_key = $auth->get_secret_key();
$user = wp_get_current_user();
$cookie_name = 'tw-can_preview';

if ( $user && $secret_key && ! isset( $_COOKIE['STYXKEY-can_preview'] ) ) {
if ( $user && $secret_key && ! isset( $_COOKIE[ $cookie_name ] ) ) {
$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( $user );

setcookie(
'STYXKEY-can_preview',
$cookie_name,
$token,
array(
'expires' => 0,
Expand Down

0 comments on commit 4a4cbd3

Please sign in to comment.