| @@ -25,9 +25,8 @@ | ||
| 25 | 25 | add_action( 'widgets_init', array( $this, 'widgets_init' ) ); |
| 26 | 26 | |
| 27 | 27 | // User defined strings translations |
| 28 | 28 | add_action( 'pll_language_defined', array( $this, 'load_strings_translations' ), 5 ); |
| 29 | - add_action( 'change_locale', array( $this, 'load_strings_translations' ) ); // Since WP 4.7 | |
| 30 | 29 | |
| 31 | 30 | // Switch_to_blog |
| 32 | 31 | add_action( 'switch_blog', array( $this, 'switch_blog' ), 10, 2 ); |
| 33 | 32 | } |
| @@ -32,37 +31,8 @@ | ||
| 32 | 31 | add_action( 'switch_blog', array( $this, 'switch_blog' ), 10, 2 ); |
| 33 | 32 | } |
| 34 | 33 | |
| 35 | 34 | /** |
| 36 | - * Instantiate classes always needed | |
| 37 | - * | |
| 38 | - * @since 2.6 | |
| 39 | - */ | |
| 40 | - public function init() { | |
| 41 | - // REST API | |
| 42 | - if ( class_exists( 'PLL_REST_API' ) ) { | |
| 43 | - $this->rest_api = new PLL_REST_API( $this ); | |
| 44 | - } | |
| 45 | - | |
| 46 | - if ( $this->model->get_languages_list() ) { | |
| 47 | - // Used by content duplicate and post synchronization | |
| 48 | - if ( class_exists( 'PLL_Sync_Content' ) ) { | |
| 49 | - $this->sync_content = new PLL_Sync_Content( $this ); | |
| 50 | - } | |
| 51 | - | |
| 52 | - // Active languages | |
| 53 | - if ( class_exists( 'PLL_Active_Languages' ) ) { | |
| 54 | - $this->active_languages = new PLL_Active_Languages( $this ); | |
| 55 | - } | |
| 56 | - | |
| 57 | - // Share post slugs | |
| 58 | - if ( get_option( 'permalink_structure' ) && $this->options['force_lang'] && class_exists( 'PLL_Share_Post_Slug' ) ) { | |
| 59 | - $this->share_post_slug = new PLL_Share_Post_Slug( $this ); | |
| 60 | - } | |
| 61 | - } | |
| 62 | - } | |
| 63 | - | |
| 64 | - /** | |
| 65 | 35 | * Registers our widgets |
| 66 | 36 | * |
| 67 | 37 | * @since 0.1 |
| 68 | 38 | */ |
| @@ -79,26 +49,13 @@ | ||
| 79 | 49 | /** |
| 80 | 50 | * Loads user defined strings translations |
| 81 | 51 | * |
| 82 | 52 | * @since 1.2 |
| 83 | - * @since 2.1.3 $locale parameter added. | |
| 84 | - * | |
| 85 | - * @param string $locale Locale. Defaults to current locale. | |
| 86 | 53 | */ |
| 87 | - public function load_strings_translations( $locale = '' ) { | |
| 88 | - if ( empty( $locale ) ) { | |
| 89 | - $locale = get_locale(); | |
| 90 | - } | |
| 91 | - | |
| 92 | - $language = $this->model->get_language( $locale ); | |
| 93 | - | |
| 94 | - if ( ! empty( $language ) ) { | |
| 95 | - $mo = new PLL_MO(); | |
| 96 | - $mo->import_from_db( $language ); | |
| 97 | - $GLOBALS['l10n']['pll_string'] = &$mo; | |
| 98 | - } else { | |
| 99 | - unset( $GLOBALS['l10n']['pll_string'] ); | |
| 100 | - } | |
| 54 | + public function load_strings_translations() { | |
| 55 | + $mo = new PLL_MO(); | |
| 56 | + $mo->import_from_db( $this->model->get_language( get_locale() ) ); | |
| 57 | + $GLOBALS['l10n']['pll_string'] = &$mo; | |
| 101 | 58 | } |
| 102 | 59 | |
| 103 | 60 | /** |
| 104 | 61 | * Resets some variables when switching blog |
| @@ -105,10 +62,8 @@ | ||
| 105 | 62 | * Applies only if Polylang is active on the new blog |
| 106 | 63 | * |
| 107 | 64 | * @since 1.5.1 |
| 108 | 65 | * |
| 109 | - * @param int $new_blog | |
| 110 | - * @param int $old_blog | |
| 111 | 66 | * @return bool not used by WP but by child class |
| 112 | 67 | */ |
| 113 | 68 | public function switch_blog( $new_blog, $old_blog ) { |
| 114 | 69 | $plugins = ( $sitewide_plugins = get_site_option( 'active_sitewide_plugins' ) ) && is_array( $sitewide_plugins ) ? array_keys( $sitewide_plugins ) : array(); |
| @@ -117,9 +72,8 @@ | ||
| 117 | 72 | // 2nd test needed when Polylang is not networked activated |
| 118 | 73 | // 3rd test needed when Polylang is networked activated and a new site is created |
| 119 | 74 | if ( $new_blog != $old_blog && in_array( POLYLANG_BASENAME, $plugins ) && get_option( 'polylang' ) ) { |
| 120 | 75 | $this->options = get_option( 'polylang' ); // Needed for menus |
| 121 | - remove_action( 'pre_option_rewrite_rules', array( $this->links_model, 'prepare_rewrite_rules' ) ); | |
| 122 | 76 | $this->links_model = $this->model->get_links_model(); |
| 123 | 77 | return true; |
| 124 | 78 | } |
| 125 | 79 | return false; |
| @@ -138,32 +92,19 @@ | ||
| 138 | 92 | public function __call( $func, $args ) { |
| 139 | 93 | foreach ( $this as $prop => &$obj ) { |
| 140 | 94 | if ( is_object( $obj ) && method_exists( $obj, $func ) ) { |
| 141 | 95 | if ( WP_DEBUG ) { |
| 142 | - $debug = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions | |
| 96 | + $debug = debug_backtrace(); | |
| 143 | 97 | $i = 1 + empty( $debug[1]['line'] ); // The file and line are in $debug[2] if the function was called using call_user_func |
| 144 | - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions | |
| 145 | - sprintf( | |
| 146 | - '%1$s was called incorrectly in %3$s on line %4$s: the call to $polylang->%1$s() has been deprecated in Polylang 1.2, use PLL()->%2$s->%1$s() instead.' . "\nError handler", | |
| 147 | - esc_html( $func ), | |
| 148 | - esc_html( $prop ), | |
| 149 | - esc_html( $debug[ $i ]['file'] ), | |
| 150 | - absint( $debug[ $i ]['line'] ) | |
| 151 | - ) | |
| 152 | - ); | |
| 98 | + trigger_error( sprintf( | |
| 99 | + '%1$s was called incorrectly in %3$s on line %4$s: the call to $polylang->%1$s() has been deprecated in Polylang 1.2, use PLL()->%2$s->%1$s() instead.' . "\nError handler", | |
| 100 | + $func, $prop, $debug[ $i ]['file'], $debug[ $i ]['line'] | |
| 101 | + ) ); | |
| 153 | 102 | } |
| 154 | 103 | return call_user_func_array( array( $obj, $func ), $args ); |
| 155 | 104 | } |
| 156 | 105 | } |
| 157 | 106 | |
| 158 | - $debug = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions | |
| 159 | - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions | |
| 160 | - sprintf( | |
| 161 | - 'Call to undefined function PLL()->%1$s() in %2$s on line %3$s' . "\nError handler", | |
| 162 | - esc_html( $func ), | |
| 163 | - esc_html( $debug[0]['file'] ), | |
| 164 | - absint( $debug[0]['line'] ) | |
| 165 | - ), | |
| 166 | - E_USER_ERROR | |
| 167 | - ); | |
| 107 | + $debug = debug_backtrace(); | |
| 108 | + trigger_error( sprintf( 'Call to undefined function PLL()->%1$s() in %2$s on line %3$s' . "\nError handler", $func, $debug[0]['file'], $debug[0]['line'] ), E_USER_ERROR ); | |
| 168 | 109 | } |
| 169 | 110 | } |