PluginProbe
Polylang / 3.1.4
Polylang v3.1.4
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 +29 -16 2.7.23.1.4 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * Displays a language list
5 8 *
@@ -5,8 +8,15 @@
5 8 *
6 9 * @since 1.2
7 10 */
8 11 class PLL_Walker_List extends Walker {
12 + /**
13 + * Database fields to use.
14 + *
15 + * @see https://developer.wordpress.org/reference/classes/walker/#properties Walker::$db_fields.
16 + *
17 + * @var array
18 + */
9 19 public $db_fields = array( 'parent' => 'parent', 'id' => 'id' );
10 20
11 21 /**
12 22 * Outputs one element
@@ -12,17 +22,18 @@
12 22 * Outputs one element
13 23 *
14 24 * @since 1.2
15 25 *
16 - * @param string $output Passed by reference. Used to append additional content.
17 - * @param object $element The data object.
18 - * @param int $depth Depth of the item.
19 - * @param array $args An array of additional arguments.
20 - * @param int $current_object_id ID of the current item.
26 + * @param string $output Passed by reference. Used to append additional content.
27 + * @param stdClass $element The data object.
28 + * @param int $depth Depth of the item.
29 + * @param array $args An array of additional arguments.
30 + * @param int $current_object_id ID of the current item.
31 + * @return void
21 32 */
22 - public function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) {
33 + public function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
23 34 $output .= sprintf(
24 - '%6$s<li class="%1$s"><a lang="%2$s" hreflang="%2$s" href="%3$s">%4$s%5$s</a></li>%7$s',
35 + '%6$s<li class="%1$s"><a %8$s lang="%2$s" hreflang="%2$s" href="%3$s">%4$s%5$s</a></li>%7$s',
25 36 esc_attr( implode( ' ', $element->classes ) ),
26 37 esc_attr( $element->locale ),
27 38 esc_url( $element->url ),
28 39 $element->flag,
@@ -27,9 +38,10 @@
27 38 esc_url( $element->url ),
28 39 $element->flag,
29 40 $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 ),
30 41 'discard' === $args['item_spacing'] ? '' : "\t",
31 - 'discard' === $args['item_spacing'] ? '' : "\n"
42 + 'discard' === $args['item_spacing'] ? '' : "\n",
43 + empty( $element->link_classes ) ? '' : 'class="' . esc_attr( implode( ' ', $element->link_classes ) ) . '"'
32 44 );
33 45 }
34 46
35 47 /**
@@ -36,16 +48,17 @@
36 48 * Overrides Walker::display_element as it expects an object with a parent property
37 49 *
38 50 * @since 1.2
39 51 *
40 - * @param object $element Data object.
41 - * @param array $children_elements List of elements to continue traversing.
42 - * @param int $max_depth Max depth to traverse.
43 - * @param int $depth Depth of current element.
44 - * @param array $args An array of arguments.
45 - * @param string $output Passed by reference. Used to append additional content.
52 + * @param stdClass $element Data object.
53 + * @param array $children_elements List of elements to continue traversing.
54 + * @param int $max_depth Max depth to traverse.
55 + * @param int $depth Depth of current element.
56 + * @param array $args An array of arguments.
57 + * @param string $output Passed by reference. Used to append additional content.
58 + * @return void
46 59 */
47 - public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
60 + public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
48 61 $element = (object) $element; // Make sure we have an object
49 62 $element->parent = $element->id = 0; // Don't care about this
50 63 parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
51 64 }
@@ -61,9 +74,9 @@
61 74 * @param mixed ...$args Additional arguments.
62 75 * @return string The hierarchical item output.
63 76 */
64 77 public function walk( $elements, $max_depth, ...$args ) { // phpcs:ignore WordPressVIPMinimum.Classes.DeclarationCompatibility.DeclarationCompatibility
65 - if ( is_array( $max_depth ) ) {
78 + if ( is_array( $max_depth ) ) { // @phpstan-ignore-line
66 79 // Backward compatibility with Polylang < 2.6.7
67 80 if ( WP_DEBUG ) {
68 81 trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions
69 82 sprintf(