PluginProbe
Polylang / 3.7.7
Polylang v3.7.7
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | include/cookie.php +32 -8 3.0.23.7.7 View file →
@@ -9,9 +9,9 @@
9 9 * @since 2.9
10 10 */
11 11 class PLL_Cookie {
12 12 /**
13 - * Parses the cookie parameters
13 + * Parses the cookie parameters.
14 14 *
15 15 * @since 2.9
16 16 *
17 17 * @param array $args {@see PLL_Cookie::set()}
@@ -18,27 +18,51 @@
18 18 * @return array
19 19 */
20 20 protected static function parse_args( $args ) {
21 21 /**
22 - * Filter the Polylang cookie duration
23 - * /!\ this filter may be fired *before* the theme is loaded
22 + * Filters the Polylang cookie duration.
24 23 *
24 + * If a cookie duration of 0 is specified, a session cookie will be set.
25 + * If a negative cookie duration is specified, the cookie is removed.
26 + * /!\ This filter may be fired *before* the theme is loaded.
27 + *
25 28 * @since 1.8
26 29 *
27 - * @param int $duration cookie duration in seconds
30 + * @param int $duration Cookie duration in seconds.
28 31 */
29 - $expiration = apply_filters( 'pll_cookie_expiration', YEAR_IN_SECONDS );
32 + $expiration = (int) apply_filters( 'pll_cookie_expiration', YEAR_IN_SECONDS );
30 33
31 34 $defaults = array(
32 - 'expires' => time() + $expiration,
35 + 'expires' => 0 !== $expiration ? time() + $expiration : 0,
33 36 'path' => COOKIEPATH,
34 - 'domain' => COOKIE_DOMAIN, // Cookie domain must be set to false for localhost ( default value for COOKIE_DOMAIN ) thanks to Stephen Harris.
37 + 'domain' => COOKIE_DOMAIN, // Cookie domain must be set to false for localhost (default value for `COOKIE_DOMAIN`) thanks to Stephen Harris.
35 38 'secure' => is_ssl(),
36 39 'httponly' => false,
37 40 'samesite' => 'Lax',
38 41 );
39 42
40 - return wp_parse_args( $args, $defaults );
43 + $args = wp_parse_args( $args, $defaults );
44 +
45 + /**
46 + * Filters the Polylang cookie arguments.
47 + * /!\ This filter may be fired *before* the theme is loaded.
48 + *
49 + * @since 3.6
50 + *
51 + * @param array $args {
52 + * Optional. Array of arguments for setting the cookie.
53 + *
54 + * @type int $expires Cookie duration.
55 + * If a cookie duration of 0 is specified, a session cookie will be set.
56 + * If a negative cookie duration is specified, the cookie is removed.
57 + * @type string $path Cookie path.
58 + * @type string $domain Cookie domain. Must be set to false for localhost (default value for `COOKIE_DOMAIN`).
59 + * @type bool $secure Should the cookie be sent only over https?
60 + * @type bool $httponly Should the cookie be accessed only over http protocol?.
61 + * @type string $samesite Either 'Strict', 'Lax' or 'None'.
62 + * }
63 + */
64 + return (array) apply_filters( 'pll_cookie_args', $args );
41 65 }
42 66
43 67 /**
44 68 * Sets the cookie.