Code Modernisation: Introduce the spread operator in `Walker`.
Rather than relying `func_get_args()` to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable. Props jrf. See #47678. Built from https://develop.svn.wordpress.org/trunk@45624 git-svn-id: http://core.svn.wordpress.org/trunk@45435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4de2f2f49b
commit
41ea1f106d
|
@ -184,10 +184,10 @@ class Walker {
|
||||||
*
|
*
|
||||||
* @param array $elements An array of elements.
|
* @param array $elements An array of elements.
|
||||||
* @param int $max_depth The maximum hierarchical depth.
|
* @param int $max_depth The maximum hierarchical depth.
|
||||||
|
* @param mixed ...$args Optional additional arguments.
|
||||||
* @return string The hierarchical item output.
|
* @return string The hierarchical item output.
|
||||||
*/
|
*/
|
||||||
public function walk( $elements, $max_depth ) {
|
public function walk( $elements, $max_depth, ...$args ) {
|
||||||
$args = array_slice( func_get_args(), 2 );
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
//invalid parameter or nothing to walk
|
//invalid parameter or nothing to walk
|
||||||
|
@ -276,16 +276,16 @@ class Walker {
|
||||||
*
|
*
|
||||||
* @param array $elements
|
* @param array $elements
|
||||||
* @param int $max_depth The maximum hierarchical depth.
|
* @param int $max_depth The maximum hierarchical depth.
|
||||||
* @param int $page_num The specific page number, beginning with 1.
|
* @param int $page_num The specific page number, beginning with 1.
|
||||||
* @param int $per_page
|
* @param int $per_page
|
||||||
|
* @param mixed ...$args Optional additional arguments.
|
||||||
* @return string XHTML of the specified page of elements
|
* @return string XHTML of the specified page of elements
|
||||||
*/
|
*/
|
||||||
public function paged_walk( $elements, $max_depth, $page_num, $per_page ) {
|
public function paged_walk( $elements, $max_depth, $page_num, $per_page, ...$args ) {
|
||||||
if ( empty( $elements ) || $max_depth < -1 ) {
|
if ( empty( $elements ) || $max_depth < -1 ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$args = array_slice( func_get_args(), 4 );
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
$parent_field = $this->db_fields['parent'];
|
$parent_field = $this->db_fields['parent'];
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3-alpha-45623';
|
$wp_version = '5.3-alpha-45624';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue