WordPress.org

Make WordPress Core

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

File class-wp-walker.php.diff, 508 bytes (added by jackreichert, 8 years ago)

adds condition to walker class to prevent random child

  • 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..fdff493 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];