PluginProbe
Polylang / 3.1.4
Polylang v3.1.4
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 +10 -6 2.93.1.4 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,19 +18,22 @@
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 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,
@@ -54,8 +57,9 @@
54 57 * @type bool $secure Should the cookie be sent only over https?
55 58 * @type bool $httponly Should the cookie accessed only over http protocol? Defaults to false.
56 59 * @type string $samesite Either 'Strict', 'Lax' or 'None', defaults to 'Lax'.
57 60 * }
61 + * @return void
58 62 */
59 63 public static function set( $lang, $args = array() ) {
60 64 $args = self::parse_args( $args );
61 65