PluginProbe
Polylang / 2.5
Polylang v2.5
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 | modules/wpml/wpml-api.php +4 -34 2.72.5 View file →
@@ -8,9 +8,8 @@
8 8 *
9 9 * @since 2.0
10 10 */
11 11 class PLL_WPML_API {
12 - private static $original_language = null;
13 12
14 13 /**
15 14 * Constructor
16 15 *
@@ -29,9 +28,9 @@
29 28 add_action( 'wpml_add_language_form_field', array( $this, 'wpml_add_language_form_field' ) );
30 29 add_filter( 'wpml_language_is_active', array( $this, 'wpml_language_is_active' ), 10, 2 );
31 30 add_filter( 'wpml_is_rtl', array( $this, 'wpml_is_rtl' ) );
32 31 // wpml_language_form_input_field => See wpml_add_language_form_field
33 - // wpml_language_has_switched => See wpml_switch_language
32 + // wpml_language_has_switched => not implemented
34 33 // wpml_element_trid => not implemented
35 34 // wpml_get_element_translations => not implemented
36 35 // wpml_language_switcher => not implemented
37 36 // wpml_browser_redirect_language_params => not implemented
@@ -42,9 +41,9 @@
42 41
43 42 // Retrieving Language Information for Content
44 43
45 44 add_filter( 'wpml_post_language_details', 'wpml_get_language_information', 10, 2 );
46 - add_action( 'wpml_switch_language', array( __CLASS__, 'wpml_switch_language' ), 10, 2 );
45 + // wpml_switch_language => not implemented
47 46 add_filter( 'wpml_element_language_code', array( $this, 'wpml_element_language_code' ), 10, 3 );
48 47 // wpml_element_language_details => not applicable
49 48
50 49 // Retrieving Localized Content
@@ -146,9 +145,9 @@
146 145 public function wpml_add_language_form_field() {
147 146 $lang = pll_current_language();
148 147 $field = sprintf( '<input type="hidden" name="lang" value="%s" />', esc_attr( $lang ) );
149 148 $field = apply_filters( 'wpml_language_form_input_field', $field, $lang );
150 - echo $field; // phpcs:ignore WordPress.Security.EscapeOutput
149 + echo $field;
151 150 }
152 151
153 152 /**
154 153 * Find out if a specific language is enabled for the site
@@ -176,37 +175,8 @@
176 175 return pll_current_language( 'is_rtl' );
177 176 }
178 177
179 178 /**
180 - * Switches whole site to the given language or restores the language that was set when first calling this function.
181 - * Unlike the WPML original action, it is not possible to set the current language and the cookie to different values.
182 - *
183 - * @since 2.7
184 - *
185 - * @param null|string $lang Language code to switch into, restores the original language if null.
186 - * @param bool|string $cookie Optionally also switches the cookie.
187 - */
188 - public static function wpml_switch_language( $lang = null, $cookie = false ) {
189 - if ( null === self::$original_language ) {
190 - self::$original_language = PLL()->curlang;
191 - }
192 -
193 - if ( empty( $lang ) ) {
194 - PLL()->curlang = self::$original_language;
195 - } elseif ( 'all' === $lang ) {
196 - PLL()->curlang = null;
197 - } elseif ( in_array( $lang, pll_languages_list() ) ) {
198 - PLL()->curlang = PLL()->model->get_language( $lang );
199 - }
200 -
201 - if ( $cookie && isset( PLL()->choose_lang ) ) {
202 - PLL()->choose_lang->maybe_setcookie();
203 - }
204 -
205 - do_action( 'wpml_language_has_switched', $lang, $cookie, self::$original_language );
206 - }
207 -
208 - /**
209 179 * Get the language code for a translatable element
210 180 *
211 181 * @since 2.0
212 182 *
@@ -217,9 +187,9 @@
217 187 public function wpml_element_language_code( $language_code, $args ) {
218 188 $type = $args['element_type'];
219 189 $id = $args['element_id'];
220 190 $pll_type = ( 'post' == $type || pll_is_translated_post_type( $type ) ) ? 'post' : ( 'term' == $type || pll_is_translated_taxonomy( $type ) ? 'term' : false );
221 - if ( 'term' === $pll_type && $term = get_term_by( 'term_taxonomy_id', $id ) ) {
191 + if ( 'term' === $pll_type && $term = wpcom_vip_get_term_by( 'term_taxonomy_id', $id ) ) {
222 192 $id = $term->term_id;
223 193 }
224 194 return $pll_type ? call_user_func( "pll_get_{$pll_type}_language", $id ) : $language_code;
225 195 }