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