| @@ -26,28 +26,21 @@ | ||
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * Currently all tested cache plugins don't send cookies with cached pages. | |
| 31 | - * This makes us impossible to know the language of the last browsed page. | |
| 32 | - * This functions allows to create the cookie in javascript as a workaround. | |
| 30 | + * Currently all tested cache plugins don't send cookies with cached pages | |
| 31 | + * This makes us impossible know the language of the last browsed page | |
| 32 | + * This functions allows to create the cookie in javascript as a workaround | |
| 33 | 33 | * |
| 34 | 34 | * @since 2.3 |
| 35 | 35 | */ |
| 36 | 36 | public function add_cookie_script() { |
| 37 | - // Embeds should not set the cookie. | |
| 38 | - if ( is_embed() ) { | |
| 39 | - return; | |
| 40 | - } | |
| 41 | - | |
| 42 | - $domain = ( 2 === PLL()->options['force_lang'] ) ? wp_parse_url( PLL()->links_model->home, PHP_URL_HOST ) : COOKIE_DOMAIN; | |
| 43 | - $samesite = ( 3 === PLL()->options['force_lang'] ) ? 'None' : 'Lax'; | |
| 44 | - | |
| 37 | + $domain = ( 2 == PLL()->options['force_lang'] ) ? wp_parse_url( PLL()->links_model->home, PHP_URL_HOST ) : COOKIE_DOMAIN; | |
| 45 | 38 | $js = sprintf( |
| 46 | 39 | '(function() { |
| 47 | 40 | var expirationDate = new Date(); |
| 48 | 41 | expirationDate.setTime( expirationDate.getTime() + %d * 1000 ); |
| 49 | - document.cookie = "%s=%s; expires=" + expirationDate.toUTCString() + "; path=%s%s%s%s"; | |
| 42 | + document.cookie = "%s=%s; expires=" + expirationDate.toUTCString() + "; path=%s%s%s"; | |
| 50 | 43 | }());', |
| 51 | 44 | esc_js( apply_filters( 'pll_cookie_expiration', YEAR_IN_SECONDS ) ), |
| 52 | 45 | esc_js( PLL_COOKIE ), |
| 53 | 46 | esc_js( pll_current_language() ), |
| @@ -52,10 +45,9 @@ | ||
| 52 | 45 | esc_js( PLL_COOKIE ), |
| 53 | 46 | esc_js( pll_current_language() ), |
| 54 | 47 | esc_js( COOKIEPATH ), |
| 55 | 48 | $domain ? '; domain=' . esc_js( $domain ) : '', |
| 56 | - is_ssl() ? '; secure' : '', | |
| 57 | - '; SameSite=' . $samesite | |
| 49 | + is_ssl() ? '; secure' : '' | |
| 58 | 50 | ); |
| 59 | 51 | echo '<script type="text/javascript">' . $js . '</script>'; // phpcs:ignore WordPress.Security.EscapeOutput |
| 60 | 52 | } |
| 61 | 53 | |