PluginProbe
Polylang / 2.1
Polylang v2.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/walker-list.php +12 -44 2.8.22.1 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Displays a language list
8 5 *
@@ -8,9 +5,9 @@
8 5 *
9 6 * @since 1.2
10 7 */
11 8 class PLL_Walker_List extends Walker {
12 - public $db_fields = array( 'parent' => 'parent', 'id' => 'id' );
9 + var $db_fields = array( 'parent' => 'parent', 'id' => 'id' );
13 10
14 11 /**
15 12 * Outputs one element
16 13 *
@@ -15,24 +12,18 @@
15 12 * Outputs one element
16 13 *
17 14 * @since 1.2
18 15 *
19 - * @param string $output Passed by reference. Used to append additional content.
20 - * @param object $element The data object.
21 - * @param int $depth Depth of the item.
22 - * @param array $args An array of additional arguments.
23 - * @param int $current_object_id ID of the current item.
16 + * @see Walker::start_el
24 17 */
25 - public function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) {
18 + function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) {
26 19 $output .= sprintf(
27 - '%6$s<li class="%1$s"><a lang="%2$s" hreflang="%2$s" href="%3$s">%4$s%5$s</a></li>%7$s',
20 + "\t".'<li class="%1$s"><a lang="%2$s" hreflang="%2$s" href="%3$s">%4$s%5$s</a></li>'."\n",
28 21 esc_attr( implode( ' ', $element->classes ) ),
29 22 esc_attr( $element->locale ),
30 23 esc_url( $element->url ),
31 24 $element->flag,
32 - $args['show_flags'] && $args['show_names'] ? sprintf( '<span style="margin-%1$s:0.3em;">%2$s</span>', is_rtl() ? 'right' : 'left', esc_html( $element->name ) ) : esc_html( $element->name ),
33 - 'discard' === $args['item_spacing'] ? '' : "\t",
34 - 'discard' === $args['item_spacing'] ? '' : "\n"
25 + $args['show_flags'] && $args['show_names'] ? '<span style="margin-left:0.3em;">' . esc_html( $element->name ) . '</span>' : esc_html( $element->name )
35 26 );
36 27 }
37 28
38 29 /**
@@ -39,16 +30,11 @@
39 30 * Overrides Walker::display_element as it expects an object with a parent property
40 31 *
41 32 * @since 1.2
42 33 *
43 - * @param object $element Data object.
44 - * @param array $children_elements List of elements to continue traversing.
45 - * @param int $max_depth Max depth to traverse.
46 - * @param int $depth Depth of current element.
47 - * @param array $args An array of arguments.
48 - * @param string $output Passed by reference. Used to append additional content.
34 + * @see Walker::display_element
49 35 */
50 - public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
36 + function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
51 37 $element = (object) $element; // Make sure we have an object
52 38 $element->parent = $element->id = 0; // Don't care about this
53 39 parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
54 40 }
@@ -56,31 +42,13 @@
56 42 /**
57 43 * Overrides Walker:walk to set depth argument
58 44 *
59 45 * @since 1.2
60 - * @since 2.6.7 Use $max_depth and ...$args parameters to follow the move of WP 5.3
61 46 *
62 - * @param array $elements An array of elements.
63 - * @param int $max_depth The maximum hierarchical depth.
64 - * @param mixed ...$args Additional arguments.
65 - * @return string The hierarchical item output.
47 + * @param array $elements elements to display
48 + * @param array $args
49 + * @return string
66 50 */
67 - public function walk( $elements, $max_depth, ...$args ) { // phpcs:ignore WordPressVIPMinimum.Classes.DeclarationCompatibility.DeclarationCompatibility
68 - if ( is_array( $max_depth ) ) {
69 - // Backward compatibility with Polylang < 2.6.7
70 - if ( WP_DEBUG ) {
71 - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions
72 - sprintf(
73 - '%s was called incorrectly. The method expects an integer as second parameter since Polylang 2.6.7',
74 - __METHOD__
75 - )
76 - );
77 - }
78 - $args = $max_depth;
79 - $max_depth = -1;
80 - } else {
81 - $args = isset( $args[0] ) ? $args[0] : array();
82 - }
83 -
84 - return parent::walk( $elements, $max_depth, $args );
51 + function walk( $elements, $args = array() ) {
52 + return parent::walk( $elements, -1, $args );
85 53 }
86 54 }