PluginProbe
Polylang / 2.3.6
Polylang v2.3.6
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/olt-manager.php +8 -11 2.82.3.6 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * It is best practice that plugins do nothing before plugins_loaded is fired
8 5 * so it is what Polylang intends to do
@@ -12,9 +9,9 @@
12 9 *
13 10 * @since 1.2
14 11 */
15 12 class PLL_OLT_Manager {
16 - protected static $instance; // For singleton
13 + static protected $instance; // For singleton
17 14 protected $default_locale;
18 15 protected $list_textdomains = array(); // All text domains
19 16 public $labels = array(); // Post types and taxonomies labels to translate
20 17
@@ -29,9 +26,9 @@
29 26 add_filter( 'pre_update_option_active_sitewide_plugins', array( $this, 'make_polylang_first' ) );
30 27
31 28 // Overriding load text domain only on front since WP 4.7
32 29 // FIXME test get_user_locale for backward compatibility with WP < 4.7
33 - if ( is_admin() && ! Polylang::is_ajax_on_front() && function_exists( 'get_user_locale' ) ) {
30 + if ( is_admin() && function_exists( 'get_user_locale' ) ) {
34 31 return;
35 32 }
36 33
37 34 // Saves the default locale before we start any language manipulation
@@ -41,11 +38,13 @@
41 38 add_filter( 'load_textdomain_mofile', array( $this, 'load_textdomain_mofile' ), 10, 2 );
42 39 add_filter( 'gettext', array( $this, 'gettext' ), 10, 3 );
43 40 add_filter( 'gettext_with_context', array( $this, 'gettext_with_context' ), 10, 4 );
44 41
45 - // Loads text domains
46 - add_action( 'pll_language_defined', array( $this, 'load_textdomains' ), 2 ); // After PLL_Frontend::pll_language_defined
47 - add_action( 'pll_no_language_defined', array( $this, 'load_textdomains' ) );
42 + if ( ! Polylang::is_ajax_on_front() ) {
43 + // Loads text domains
44 + add_action( 'pll_language_defined', array( $this, 'load_textdomains' ), 2 ); // After PLL_Frontend::pll_language_defined
45 + add_action( 'pll_no_language_defined', array( $this, 'load_textdomains' ) );
46 + }
48 47 }
49 48
50 49 /**
51 50 * Access to the single instance of the class
@@ -53,9 +52,9 @@
53 52 * @since 1.7
54 53 *
55 54 * @return object
56 55 */
57 - public static function instance() {
56 + static public function instance() {
58 57 if ( empty( self::$instance ) ) {
59 58 self::$instance = new self();
60 59 }
61 60
@@ -218,13 +217,11 @@
218 217
219 218 foreach ( $type->labels as $key => $label ) {
220 219 if ( is_string( $label ) && isset( $this->labels[ $label ] ) ) {
221 220 if ( empty( $translated[ $label ] ) ) {
222 - // PHPCS:disable WordPress.WP.I18n
223 221 $type->labels->$key = $translated[ $label ] = isset( $this->labels[ $label ]['context'] ) ?
224 222 _x( $label, $this->labels[ $label ]['context'], $this->labels[ $label ]['domain'] ) :
225 223 __( $label, $this->labels[ $label ]['domain'] );
226 - // PHPCS:enable
227 224 }
228 225 else {
229 226 $type->labels->$key = $translated[ $label ];
230 227 }