WordPress.org

Make WordPress Core

Ticket #40760: 40760.diff

File 40760.diff, 1.0 KB (added by rahulsprajapati, 3 years ago)

Add the filters available in the 3 main Walker classes to Walker_Page class.

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

    diff --git a/src/wp-includes/class-walker-page.php b/src/wp-includes/class-walker-page.php
    index 8bec66f..2418a67 100644
    a b class Walker_Page extends Walker { 
    6161                        $n = '';
    6262                }
    6363                $indent = str_repeat( $t, $depth );
    64                 $output .= "{$n}{$indent}<ul class='children'>{$n}";
     64
     65                // Default CSS class.
     66                $classes = array( 'children' );
     67
     68                /**
     69                 * Filters the CSS class(es) applied to a page children list element.
     70                 *
     71                 * @since 4.8.0
     72                 *
     73                 * @param array $classes The CSS classes that are applied to the menu `<ul>` element.
     74                 * @param array $args    Arguments for outputting the next level.
     75                 * @param int   $depth   Depth of page. Used for padding.
     76                 */
     77                $class_names = join( ' ', apply_filters( 'page_children_list_css_class', $classes, $args, $depth ) );
     78                $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
     79
     80                $output .= "{$n}{$indent}<ul {$class_names}>{$n}";
    6581        }
    6682
    6783        /**