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 | settings/settings-browser.php +29 -16 2.7.23.7.7 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * Settings class for browser language preference detection
5 8 *
@@ -5,8 +8,14 @@
5 8 *
6 9 * @since 1.8
7 10 */
8 11 class PLL_Settings_Browser extends PLL_Settings_Module {
12 + /**
13 + * Stores the display order priority.
14 + *
15 + * @var int
16 + */
17 + public $priority = 20;
9 18
10 19 /**
11 20 * Constructor
12 21 *
@@ -14,16 +23,18 @@
14 23 *
15 24 * @param object $polylang polylang object
16 25 */
17 26 public function __construct( &$polylang ) {
27 + // Needed for `$this->is_available()`, which is used before calling the parent's constructor.
18 28 $this->options = &$polylang->options;
29 +
19 30 parent::__construct(
20 31 $polylang,
21 32 array(
22 33 'module' => 'browser',
23 34 'title' => __( 'Detect browser language', 'polylang' ),
24 - 'description' => __( 'When the front page is visited, set the language according to the browser preference', 'polylang' ),
25 - 'active_option' => $this->is_available() ? 'browser' : false,
35 + 'description' => __( 'When the front page is visited, redirects to itself in the browser preferred language. As this doesn\'t work if it is cached, Polylang will attempt to disable the front page cache for known cache plugins.', 'polylang' ),
36 + 'active_option' => $this->is_available() ? 'browser' : 'none',
26 37 )
27 38 );
28 39
29 40 if ( ! class_exists( 'PLL_Xdata_Domain', true ) ) {
@@ -57,8 +68,10 @@
57 68 * Displays the javascript to handle dynamically the change in url modifications
58 69 * as the preferred browser language is not used when the language is set from different domains
59 70 *
60 71 * @since 1.8
72 + *
73 + * @return void
61 74 */
62 75 public function print_js() {
63 76 wp_enqueue_script( 'jquery' );
64 77
@@ -73,22 +86,22 @@
73 86
74 87 $deactivated = sprintf( '<span class="deactivated">%s</span>', $this->action_links['deactivated'] );
75 88
76 89 ?>
77 - <script type='text/javascript'>
78 - //<![CDATA[
79 - ( function( $ ){
80 - $( "input[name='force_lang']" ).change( function() {
81 - var value = $( this ).val();
82 - if ( 3 > value ) {
83 - $( "#pll-module-browser" ).<?php echo $func; // phpcs:ignore WordPress.Security.EscapeOutput ?>.children( "td" ).children( ".row-actions" ).html( '<?php echo $link; // phpcs:ignore WordPress.Security.EscapeOutput ?>' );
84 - }
85 - else {
86 - $( "#pll-module-browser" ).removeClass( "active" ).addClass( "inactive" ).children( "td" ).children( ".row-actions" ).html( '<?php echo $deactivated; // phpcs:ignore WordPress.Security.EscapeOutput ?>' );
87 - }
88 - } );
89 - } )( jQuery );
90 - // ]]>
90 + <script>
91 + jQuery(
92 + function( $ ){
93 + $( "input[name='force_lang']" ).on( 'change', function() {
94 + var value = $( this ).val();
95 + if ( 3 > value ) {
96 + $( "#pll-module-browser" ).<?php echo $func; // phpcs:ignore WordPress.Security.EscapeOutput ?>.children( "td" ).children( ".row-actions" ).html( '<?php echo $link; // phpcs:ignore WordPress.Security.EscapeOutput ?>' );
97 + }
98 + else {
99 + $( "#pll-module-browser" ).removeClass( "active" ).addClass( "inactive" ).children( "td" ).children( ".row-actions" ).html( '<?php echo $deactivated; // phpcs:ignore WordPress.Security.EscapeOutput ?>' );
100 + }
101 + } );
102 + }
103 + );
91 104 </script>
92 105 <?php
93 106 }
94 107 }