Make WordPress Core

Ticket #15667: class-wp-walker.php.1.diff

File class-wp-walker.php.1.diff, 510 bytes (added by willmot, 11 years ago)

Don't assume that the first element is root when there are no parent elements if depth=1

  • src/wp-includes/class-wp-walker.php

    diff --git src/wp-includes/class-wp-walker.php src/wp-includes/class-wp-walker.php
    index 547defe..77c6f6c 100644
    class Walker { 
    219219                 * When none of the elements is top level.
    220220                 * Assume the first one must be root of the sub elements.
    221221                 */
    222                 if ( empty($top_level_elements) ) {
     222                if ( empty($top_level_elements) && $max_depth !== 1 ) {
    223223
    224224                        $first = array_slice( $elements, 0, 1 );
    225225                        $root = $first[0];