Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/duracelltomi/gtm4wp
Browse files Browse the repository at this point in the history
  • Loading branch information
duracelltomi committed Mar 18, 2024
2 parents 68c07ba + 309de01 commit e27b78f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions integration/youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ function gtm4wp_youtube( $return, $url, $data ) {

if ( false !== strpos( $return, 'youtube.com' ) ) {
return str_replace( 'feature=oembed', 'feature=oembed&enablejsapi=1&origin=' . $site_url_parts['scheme'] . '://' . $site_url_parts['host'], $return );
} else {
return $return;
}
}

return $return;
}

add_filter( 'oembed_result', 'gtm4wp_youtube', 10, 3 );
Expand Down
17 changes: 8 additions & 9 deletions public/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
*
* @since 1.2
*/
$GLOBALS['gtm4wp_datalayer_name'] = $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_DATALAYER_NAME ];

if ( empty( $GLOBALS['gtm4wp_options'] ) || ( '' === $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_DATALAYER_NAME ] ) ) {
$GLOBALS['gtm4wp_datalayer_name'] = 'dataLayer';
} else {
$GLOBALS['gtm4wp_datalayer_name'] = $GLOBALS['gtm4wp_options'][ GTM4WP_OPTION_DATALAYER_NAME ];
}

/**
Expand Down Expand Up @@ -175,10 +175,10 @@ function gtm4wp_add_basic_datalayer_data( $data_layer ) {
}

if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_LOGGEDIN ] ) {
$data_layer['visitorLoginState'] = 'logged-out';

if ( is_user_logged_in() ) {
$data_layer['visitorLoginState'] = 'logged-in';
} else {
$data_layer['visitorLoginState'] = 'logged-out';
}
}

Expand Down Expand Up @@ -393,10 +393,10 @@ function gtm4wp_add_basic_datalayer_data( $data_layer ) {
$data_layer['siteSearchFrom'] = '';
if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
$referer_url_parts = explode( '?', esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) );
$data_layer['siteSearchFrom'] = $referer_url_parts[0];

if ( count( $referer_url_parts ) > 1 ) {
$data_layer['siteSearchFrom'] = $referer_url_parts[0] . '?' . rawurlencode( $referer_url_parts[1] );
} else {
$data_layer['siteSearchFrom'] = $referer_url_parts[0];
}
}
$data_layer['siteSearchResults'] = $wp_query->post_count;
Expand Down Expand Up @@ -526,7 +526,8 @@ function( $class ) {
if ( '' !== $client_ip ) {
if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] ) {
$weatherdata = get_transient( 'gtm4wp-weatherdata-' . esc_attr( $client_ip ) );

$data_layer['weatherDataStatus'] = 'No weather data in cache (' . esc_attr( $client_ip ) . ')';

if ( false !== $weatherdata ) {
$data_layer['weatherCategory'] = $weatherdata->weather[0]->main;
$data_layer['weatherDescription'] = $weatherdata->weather[0]->description;
Expand All @@ -536,8 +537,6 @@ function( $class ) {
$data_layer['weatherWindDeg'] = ( isset( $weatherdata->wind->deg ) ? $weatherdata->wind->deg : '' );
$data_layer['weatherFullWeatherData'] = $weatherdata;
$data_layer['weatherDataStatus'] = 'Read from cache';
} else {
$data_layer['weatherDataStatus'] = 'No weather data in cache (' . esc_attr( $client_ip ) . ')';
}
}

Expand Down

0 comments on commit e27b78f

Please sign in to comment.