| 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 |
|