PluginProbe
Polylang / 3.7
Polylang v3.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
polylang / include / Options / Business / Browser.php

Browser.php in Polylang 3.7, at include/Options/Business/Browser.php

72 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Polylang
4 */
5
6 namespace WP_Syntex\Polylang\Options\Business;
7
8 use WP_Error;
9 use WP_Syntex\Polylang\Options\Primitive\Abstract_Boolean;
10 use WP_Syntex\Polylang\Options\Options;
11
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * Class defining the "Detect browser language" boolean option.
16 * /!\ Sanitization depends on `force_lang`: this option must be set AFTER `force_lang`.
17 *
18 * @since 3.7
19 */
20 class Browser extends Abstract_Boolean {
21 /**
22 * Returns option key.
23 *
24 * @since 3.7
25 *
26 * @return string
27 *
28 * @phpstan-return 'browser'
29 */
30 public static function key(): string {
31 return 'browser';
32 }
33
34 /**
35 * Sanitizes option's value.
36 * Can populate the `$errors` property with blocking and non-blocking errors: in case of non-blocking errors,
37 * the value is sanitized and can be stored.
38 *
39 * @since 3.7
40 *
41 * @param bool $value Value to sanitize.
42 * @param Options $options All options.
43 * @return bool|WP_Error The sanitized value. An instance of `WP_Error` in case of blocking error.
44 */
45 protected function sanitize( $value, Options $options ) {
46 if ( 3 === $options->get( 'force_lang' ) && ! class_exists( 'PLL_Xdata_Domain', true ) ) {
47 // Cannot share cookies between domains without Polylang Pro.
48 return false;
49 }
50
51 /** @var bool|WP_Error */
52 $value = parent::sanitize( $value, $options );
53 return $value;
54 }
55
56 /**
57 * Returns the description used in the JSON schema.
58 *
59 * @since 3.7
60 *
61 * @return string
62 */
63 protected function get_description(): string {
64 return sprintf(
65 /* translators: %1$s and %2$s are "true/false" values. */
66 __( 'Detect preferred browser language on front page: %1$s to detect, %2$s to not detect.', 'polylang' ),
67 '`true`',
68 '`false`'
69 );
70 }
71 }
72