PluginProbe
Polylang / 2.0
Polylang v2.0
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
polylang / include / walker-list.php

walker-list.php in Polylang 2.0, at include/walker-list.php

55 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Displays a language list
5 *
6 * @since 1.2
7 */
8 class PLL_Walker_List extends Walker {
9 var $db_fields = array( 'parent' => 'parent', 'id' => 'id' );
10
11 /**
12 * Outputs one element
13 *
14 * @since 1.2
15 *
16 * @see Walker::start_el
17 */
18 function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) {
19 $output .= sprintf(
20 "\t".'<li class="%1$s"><a lang="%2$s" hreflang="%2$s" href="%3$s">%4$s%5$s</a></li>'."\n",
21 esc_attr( implode( ' ', $element->classes ) ),
22 esc_attr( $element->locale ),
23 esc_url( $element->url ),
24 $element->flag,
25 $args['show_flags'] && $args['show_names'] ? '<span style="margin-left:0.3em;">' . esc_html( $element->name ) . '</span>' : esc_html( $element->name )
26 );
27 }
28
29 /**
30 * Overrides Walker::display_element as it expects an object with a parent property
31 *
32 * @since 1.2
33 *
34 * @see Walker::display_element
35 */
36 function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
37 $element = (object) $element; // Make sure we have an object
38 $element->parent = $element->id = 0; // Don't care about this
39 parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
40 }
41
42 /**
43 * Overrides Walker:walk to set depth argument
44 *
45 * @since 1.2
46 *
47 * @param array $elements elements to display
48 * @param array $args
49 * @return string
50 */
51 function walk( $elements, $args = array() ) {
52 return parent::walk( $elements, -1, $args );
53 }
54 }
55