| @@ -23,15 +23,17 @@ | ||
| 23 | 23 | * |
| 24 | 24 | * @param object $polylang polylang object |
| 25 | 25 | */ |
| 26 | 26 | public function __construct( &$polylang ) { |
| 27 | + // Needed for `$this->is_available()`, which is used before calling the parent's constructor. | |
| 27 | 28 | $this->options = &$polylang->options; |
| 29 | + | |
| 28 | 30 | parent::__construct( |
| 29 | 31 | $polylang, |
| 30 | 32 | array( |
| 31 | 33 | 'module' => 'browser', |
| 32 | 34 | 'title' => __( 'Detect browser language', 'polylang' ), |
| 33 | - 'description' => __( 'When the front page is visited, set the language according to the browser preference', 'polylang' ), | |
| 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' ), | |
| 34 | 36 | 'active_option' => $this->is_available() ? 'browser' : false, |
| 35 | 37 | ) |
| 36 | 38 | ); |
| 37 | 39 | |
| @@ -66,8 +68,10 @@ | ||
| 66 | 68 | * Displays the javascript to handle dynamically the change in url modifications |
| 67 | 69 | * as the preferred browser language is not used when the language is set from different domains |
| 68 | 70 | * |
| 69 | 71 | * @since 1.8 |
| 72 | + * | |
| 73 | + * @return void | |
| 70 | 74 | */ |
| 71 | 75 | public function print_js() { |
| 72 | 76 | wp_enqueue_script( 'jquery' ); |
| 73 | 77 | |
| @@ -84,19 +88,21 @@ | ||
| 84 | 88 | |
| 85 | 89 | ?> |
| 86 | 90 | <script type='text/javascript'> |
| 87 | 91 | //<![CDATA[ |
| 88 | - ( function( $ ){ | |
| 89 | - $( "input[name='force_lang']" ).change( function() { | |
| 90 | - var value = $( this ).val(); | |
| 91 | - if ( 3 > value ) { | |
| 92 | - $( "#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 ?>' ); | |
| 93 | - } | |
| 94 | - else { | |
| 95 | - $( "#pll-module-browser" ).removeClass( "active" ).addClass( "inactive" ).children( "td" ).children( ".row-actions" ).html( '<?php echo $deactivated; // phpcs:ignore WordPress.Security.EscapeOutput ?>' ); | |
| 96 | - } | |
| 97 | - } ); | |
| 98 | - } )( jQuery ); | |
| 92 | + jQuery( | |
| 93 | + function( $ ){ | |
| 94 | + $( "input[name='force_lang']" ).on( 'change', function() { | |
| 95 | + var value = $( this ).val(); | |
| 96 | + if ( 3 > value ) { | |
| 97 | + $( "#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 ?>' ); | |
| 98 | + } | |
| 99 | + else { | |
| 100 | + $( "#pll-module-browser" ).removeClass( "active" ).addClass( "inactive" ).children( "td" ).children( ".row-actions" ).html( '<?php echo $deactivated; // phpcs:ignore WordPress.Security.EscapeOutput ?>' ); | |
| 101 | + } | |
| 102 | + } ); | |
| 103 | + } | |
| 104 | + ); | |
| 99 | 105 | // ]]> |
| 100 | 106 | </script> |
| 101 | 107 | <?php |
| 102 | 108 | } |