WordPress.org

Make WordPress Core

Ticket #47678: 47678-walk_category_tree.patch

File 47678-walk_category_tree.patch, 1.5 KB (added by jrf, 14 months ago)

Simplify & modernize walk_category_tree() Includes minor documentation fixes.

  • src/wp-includes/category-template.php

    From a1d81cda6435981c565c93159316bfcd8d667da6 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Thu, 18 Jul 2019 02:31:55 +0200
    Subject: [PATCH] Simplify & modernize walk_category_tree()
    
    Includes minor documentation fixes.
    ---
     src/wp-includes/category-template.php | 11 ++++++-----
     1 file changed, 6 insertions(+), 5 deletions(-)
    
    diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php
    index 1b2da3c122..2f67df1ec5 100644
    a b function _wp_object_count_sort_cb( $a, $b ) { 
    10591059 *
    10601060 * @uses Walker_Category to create HTML list content.
    10611061 * @since 2.1.0
    1062  * @see Walker_Category::walk() for parameters and return description.
     1062 * @see Walker::walk() for parameters and return description.
     1063 *
     1064 * @param mixed ...$args Elements array, maximum hierarchical depth and optional additional arguments.
    10631065 * @return string
    10641066 */
    1065 function walk_category_tree() {
    1066         $args = func_get_args();
    1067         // the user's options are the third parameter
     1067function walk_category_tree( ...$args ) {
     1068        // The user's options are the third parameter.
    10681069        if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) {
    10691070                $walker = new Walker_Category;
    10701071        } else {
    10711072                $walker = $args[2]['walker'];
    10721073        }
    1073         return call_user_func_array( array( $walker, 'walk' ), $args );
     1074        return $walker->walk( ...$args );
    10741075}
    10751076
    10761077/**