| @@ -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,15 +5,8 @@ | ||
| 8 | 5 | * |
| 9 | 6 | * @since 1.2 |
| 10 | 7 | */ |
| 11 | 8 | 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 | - */ | |
| 19 | 9 | public $db_fields = array( 'parent' => 'parent', 'id' => 'id' ); |
| 20 | 10 | |
| 21 | 11 | /** |
| 22 | 12 | * Outputs one element |
| @@ -22,16 +12,15 @@ | ||
| 22 | 12 | * Outputs one element |
| 23 | 13 | * |
| 24 | 14 | * @since 1.2 |
| 25 | 15 | * |
| 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 | |
| 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. | |
| 32 | 21 | */ |
| 33 | - public function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 22 | + public function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) { | |
| 34 | 23 | $output .= sprintf( |
| 35 | 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', |
| 36 | 25 | esc_attr( implode( ' ', $element->classes ) ), |
| 37 | 26 | esc_attr( $element->locale ), |
| @@ -47,17 +36,16 @@ | ||
| 47 | 36 | * Overrides Walker::display_element as it expects an object with a parent property |
| 48 | 37 | * |
| 49 | 38 | * @since 1.2 |
| 50 | 39 | * |
| 51 | - * @param stdClass $element Data object. | |
| 52 | - * @param array $children_elements List of elements to continue traversing. | |
| 53 | - * @param int $max_depth Max depth to traverse. | |
| 54 | - * @param int $depth Depth of current element. | |
| 55 | - * @param array $args An array of arguments. | |
| 56 | - * @param string $output Passed by reference. Used to append additional content. | |
| 57 | - * @return void | |
| 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. | |
| 58 | 46 | */ |
| 59 | - public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { | |
| 47 | + public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { | |
| 60 | 48 | $element = (object) $element; // Make sure we have an object |
| 61 | 49 | $element->parent = $element->id = 0; // Don't care about this |
| 62 | 50 | parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
| 63 | 51 | } |
| @@ -73,9 +61,9 @@ | ||
| 73 | 61 | * @param mixed ...$args Additional arguments. |
| 74 | 62 | * @return string The hierarchical item output. |
| 75 | 63 | */ |
| 76 | 64 | public function walk( $elements, $max_depth, ...$args ) { // phpcs:ignore WordPressVIPMinimum.Classes.DeclarationCompatibility.DeclarationCompatibility |
| 77 | - if ( is_array( $max_depth ) ) { // @phpstan-ignore-line | |
| 65 | + if ( is_array( $max_depth ) ) { | |
| 78 | 66 | // Backward compatibility with Polylang < 2.6.7 |
| 79 | 67 | if ( WP_DEBUG ) { |
| 80 | 68 | trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions |
| 81 | 69 | sprintf( |