PluginProbe
Polylang / 3.1
Polylang v3.1
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/switcher.php +30 -16 3.03.1 View file →
@@ -125,9 +125,16 @@
125 125 $id = (int) $language->term_id;
126 126 $order = (int) $language->term_group;
127 127 $slug = $language->slug;
128 128 $locale = $language->get_locale( 'display' );
129 - $classes = array( 'lang-item', 'lang-item-' . $id, 'lang-item-' . esc_attr( $slug ) );
129 + $item_classes = array( 'lang-item', 'lang-item-' . $id, 'lang-item-' . esc_attr( $slug ) );
130 + $classes = isset( $args['classes'] ) && is_array( $args['classes'] ) ?
131 + array_merge(
132 + $item_classes,
133 + $args['classes']
134 + ) :
135 + $item_classes;
136 + $link_classes = isset( $args['link_classes'] ) ? $args['link_classes'] : array();
130 137 $current_lang = $this->get_current_language( $args ) === $slug;
131 138
132 139 if ( $current_lang ) {
133 140 if ( $args['hide_current'] && ! ( $args['dropdown'] && ! $args['raw'] ) ) {
@@ -168,9 +175,9 @@
168 175 $classes[] = 'lang-item-first';
169 176 $first = false;
170 177 }
171 178
172 - $out[ $slug ] = compact( 'id', 'order', 'slug', 'locale', 'name', 'url', 'flag', 'current_lang', 'no_translation', 'classes' );
179 + $out[ $slug ] = compact( 'id', 'order', 'slug', 'locale', 'name', 'url', 'flag', 'current_lang', 'no_translation', 'classes', 'link_classes' );
173 180 }
174 181
175 182 return $out;
176 183 }
@@ -184,22 +191,24 @@
184 191 * @param PLL_Links $links Instance of PLL_Links.
185 192 * @param array $args {
186 193 * Optional array of arguments.
187 194 *
188 - * @type int $dropdown The list is displayed as dropdown if set, defaults to 0.
189 - * @type int $echo Echoes the list if set to 1, defaults to 1.
190 - * @type int $hide_if_empty Hides languages with no posts ( or pages ) if set to 1, defaults to 1.
191 - * @type int $show_flags Displays flags if set to 1, defaults to 0.
192 - * @type int $show_names Shows language names if set to 1, defaults to 1.
193 - * @type string $display_names_as Whether to display the language name or its slug, valid options are 'slug' and 'name', defaults to name.
194 - * @type int $force_home Will always link to home in translated language if set to 1, defaults to 0.
195 - * @type int $hide_if_no_translation Hides the link if there is no translation if set to 1, defaults to 0.
196 - * @type int $hide_current Hides the current language if set to 1, defaults to 0.
197 - * @type int $post_id Returns links to the translations of the post defined by post_id if set, defaults not set.
198 - * @type int $raw Return a raw array instead of html markup if set to 1, defaults to 0.
199 - * @type string $item_spacing Whether to preserve or discard whitespace between list items, valid options are 'preserve' and 'discard', defaults to 'preserve'.
200 - * @type int $admin_render Allows to force the current language code in an admin context if set, default to 0. Need to set the admin_current_lang argument below.
201 - * @type string $admin_current_lang The current language code in an admin context. Need to set the admin_render to 1, defaults not set.
195 + * @type int $dropdown The list is displayed as dropdown if set, defaults to 0.
196 + * @type int $echo Echoes the list if set to 1, defaults to 1.
197 + * @type int $hide_if_empty Hides languages with no posts ( or pages ) if set to 1, defaults to 1.
198 + * @type int $show_flags Displays flags if set to 1, defaults to 0.
199 + * @type int $show_names Shows language names if set to 1, defaults to 1.
200 + * @type string $display_names_as Whether to display the language name or its slug, valid options are 'slug' and 'name', defaults to name.
201 + * @type int $force_home Will always link to home in translated language if set to 1, defaults to 0.
202 + * @type int $hide_if_no_translation Hides the link if there is no translation if set to 1, defaults to 0.
203 + * @type int $hide_current Hides the current language if set to 1, defaults to 0.
204 + * @type int $post_id Returns links to the translations of the post defined by post_id if set, defaults not set.
205 + * @type int $raw Return a raw array instead of html markup if set to 1, defaults to 0.
206 + * @type string $item_spacing Whether to preserve or discard whitespace between list items, valid options are 'preserve' and 'discard', defaults to 'preserve'.
207 + * @type int $admin_render Allows to force the current language code in an admin context if set, default to 0. Need to set the admin_current_lang argument below.
208 + * @type string $admin_current_lang The current language code in an admin context. Need to set the admin_render to 1, defaults not set.
209 + * @type string[] $classes A list of CSS classes to set to each elements outputted.
210 + * @type string[] $link_classes A list of CSS classes to set to each link outputted.
202 211 * }
203 212 * @return string|array either the html markup of the switcher or the raw elements to build a custom language switcher
204 213 */
205 214 public function the_languages( $links, $args = array() ) {
@@ -213,8 +222,13 @@
213 222 *
214 223 * @param array $args
215 224 */
216 225 $args = apply_filters( 'pll_the_languages_args', $args );
226 +
227 + // Force not to hide the language for the widget preview even if the option is checked.
228 + if ( $this->links instanceof PLL_Admin_Links ) {
229 + $args['hide_if_no_translation'] = 0;
230 + }
217 231
218 232 // Prevents showing empty options in dropdown
219 233 if ( $args['dropdown'] ) {
220 234 $args['show_names'] = 1;