| @@ -51,9 +51,8 @@ | ||
| 51 | 51 | /** |
| 52 | 52 | * Starts the output of the dropdown list |
| 53 | 53 | * |
| 54 | 54 | * @since 1.2 |
| 55 | - * @since 2.6.7 Use $max_depth and ...$args parameters to follow the move of WP 5.3 | |
| 56 | 55 | * |
| 57 | 56 | * List of parameters accepted in $args: |
| 58 | 57 | * |
| 59 | 58 | * flag => display the selected language flag in front of the dropdown if set to 1, defaults to 0 |
| @@ -63,32 +62,14 @@ | ||
| 63 | 62 | * id => the select id attribute, defaults to $args['name'] |
| 64 | 63 | * class => the class attribute |
| 65 | 64 | * disabled => disables the dropdown if set to 1 |
| 66 | 65 | * |
| 67 | - * @param array $elements An array of elements. | |
| 68 | - * @param int $max_depth The maximum hierarchical depth. | |
| 69 | - * @param mixed ...$args Additional arguments. | |
| 70 | - * @return string The hierarchical item output. | |
| 66 | + * @param array $elements elements to display | |
| 67 | + * @param array $args | |
| 68 | + * @return string | |
| 71 | 69 | */ |
| 72 | - public function walk( $elements, $max_depth, ...$args ) { // // phpcs:ignore WordPressVIPMinimum.Classes.DeclarationCompatibility.DeclarationCompatibility | |
| 70 | + public function walk( $elements, $args = array() ) { | |
| 73 | 71 | $output = ''; |
| 74 | - | |
| 75 | - if ( is_array( $max_depth ) ) { | |
| 76 | - // Backward compatibility with Polylang < 2.6.7 | |
| 77 | - if ( WP_DEBUG ) { | |
| 78 | - trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions | |
| 79 | - sprintf( | |
| 80 | - '%s was called incorrectly. The method expects an integer as second parameter since Polylang 2.6.7', | |
| 81 | - __METHOD__ | |
| 82 | - ) | |
| 83 | - ); | |
| 84 | - } | |
| 85 | - $args = $max_depth; | |
| 86 | - $max_depth = -1; | |
| 87 | - } else { | |
| 88 | - $args = isset( $args[0] ) ? $args[0] : array(); | |
| 89 | - } | |
| 90 | - | |
| 91 | 72 | $args = wp_parse_args( $args, array( 'value' => 'slug', 'name' => 'lang_choice' ) ); |
| 92 | 73 | |
| 93 | 74 | if ( ! empty( $args['flag'] ) ) { |
| 94 | 75 | $current = wp_list_filter( $elements, array( $args['value'] => $args['selected'] ) ); |
| @@ -100,13 +81,13 @@ | ||
| 100 | 81 | } |
| 101 | 82 | |
| 102 | 83 | $output .= sprintf( |
| 103 | 84 | '<select name="%1$s"%2$s%3$s%4$s>' . "\n" . '%5$s' . "\n" . '</select>' . "\n", |
| 104 | - esc_attr( $args['name'] ), | |
| 105 | - isset( $args['id'] ) && ! $args['id'] ? '' : ' id="' . ( empty( $args['id'] ) ? esc_attr( $args['name'] ) : esc_attr( $args['id'] ) ) . '"', | |
| 85 | + $name = esc_attr( $args['name'] ), | |
| 86 | + isset( $args['id'] ) && ! $args['id'] ? '' : ' id="' . ( empty( $args['id'] ) ? $name : esc_attr( $args['id'] ) ) . '"', | |
| 106 | 87 | empty( $args['class'] ) ? '' : ' class="' . esc_attr( $args['class'] ) . '"', |
| 107 | 88 | disabled( empty( $args['disabled'] ), false, false ), |
| 108 | - parent::walk( $elements, $max_depth, $args ) | |
| 89 | + parent::walk( $elements, -1, $args ) | |
| 109 | 90 | ); |
| 110 | 91 | |
| 111 | 92 | return $output; |
| 112 | 93 | } |