PluginProbe
Polylang / 3.1.4
Polylang v3.1.4
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 +19 -11 2.83.1.4 View file →
@@ -11,8 +11,13 @@
11 11 *
12 12 * @since 2.0
13 13 */
14 14 class PLL_WPML_API {
15 + /**
16 + * Stores the original language when the language is switched.
17 + *
18 + * @var PLL_Language
19 + */
15 20 private static $original_language = null;
16 21
17 22 /**
18 23 * Constructor
@@ -125,20 +130,18 @@
125 130 }
126 131
127 132 /**
128 133 * In WPML, get a language's native and translated name for display in a custom language switcher
129 - * Since Polylang does not implement the translated name, always returns only the native name
134 + * Since Polylang does not implement the translated name, always returns only the native name,
135 + * so the 3rd, 4th and 5th parameters are not used.
130 136 *
131 137 * @since 2.2
132 138 *
133 - * @param mixed $null Not used.
134 - * @param string $native_name The language native name.
135 - * @param string|bool $translated_name The language translated name. Not used.
136 - * @param bool $native_hidden Whether to hide the language native name or not. Not used.
137 - * @param bool $translated_hidden Whether to hide the language translated name or not. Not used.
139 + * @param mixed $null Not used.
140 + * @param string $native_name The language native name.
138 141 * @return string
139 142 */
140 - public function wpml_display_language_names( $null, $native_name, $translated_name = false, $native_hidden = false, $translated_hidden = false ) {
143 + public function wpml_display_language_names( $null, $native_name ) {
141 144 return $native_name;
142 145 }
143 146
144 147 /**
@@ -144,8 +147,10 @@
144 147 /**
145 148 * Returns an HTML hidden input field with name=”lang” and as value the current language
146 149 *
147 150 * @since 2.0
151 + *
152 + * @return void
148 153 */
149 154 public function wpml_add_language_form_field() {
150 155 $lang = pll_current_language();
151 156 $field = sprintf( '<input type="hidden" name="lang" value="%s" />', esc_attr( $lang ) );
@@ -171,12 +176,11 @@
171 176 * Find out whether the current language text direction is RTL or not
172 177 *
173 178 * @since 2.0
174 179 *
175 - * @param mixed $null Not used
176 180 * @return bool
177 181 */
178 - public function wpml_is_rtl( $null ) {
182 + public function wpml_is_rtl() {
179 183 return pll_current_language( 'is_rtl' );
180 184 }
181 185
182 186 /**
@@ -186,8 +190,9 @@
186 190 * @since 2.7
187 191 *
188 192 * @param null|string $lang Language code to switch into, restores the original language if null.
189 193 * @param bool|string $cookie Optionally also switches the cookie.
194 + * @return void
190 195 */
191 196 public static function wpml_switch_language( $lang = null, $cookie = false ) {
192 197 if ( null === self::$original_language ) {
193 198 self::$original_language = PLL()->curlang;
@@ -220,10 +225,13 @@
220 225 public function wpml_element_language_code( $language_code, $args ) {
221 226 $type = $args['element_type'];
222 227 $id = $args['element_id'];
223 228 $pll_type = ( 'post' == $type || pll_is_translated_post_type( $type ) ) ? 'post' : ( 'term' == $type || pll_is_translated_taxonomy( $type ) ? 'term' : false );
224 - if ( 'term' === $pll_type && $term = get_term_by( 'term_taxonomy_id', $id ) ) {
225 - $id = $term->term_id;
229 + if ( 'term' === $pll_type ) {
230 + $term = get_term_by( 'term_taxonomy_id', $id );
231 + if ( $term instanceof WP_Term ) {
232 + $id = $term->term_id;
233 + }
226 234 }
227 235 return $pll_type ? call_user_func( "pll_get_{$pll_type}_language", $id ) : $language_code;
228 236 }
229 237