Make WordPress Core

Ticket #10916: classes_list_page_filters.diff

File classes_list_page_filters.diff, 1.8 KB (added by Sam_a, 15 years ago)

Adds 'page_anchor_contents' and 'page_anchor_attributes' filter hooks to Walker_Page class

  • wp-includes/classes.php

     
    11641164         * @param int $depth Depth of page. Used for padding.
    11651165         * @param int $current_page Page ID.
    11661166         * @param array $args
     1167         * @uses apply_filters Calls 'page_css_class' filter on HTML list item's class attribute value, passing $page
     1168         * @uses apply_filters Calls 'page_anchor_attributes' filter on associative array of HTML anchor's attribute names and values, passing $page
     1169         * @uses apply_filters Calls 'page_anchor_contents' filter on HTML anchor's contents, passing $page
    11671170         */
    11681171        function start_el(&$output, $page, $depth, $args, $current_page) {
    11691172                if ( $depth )
     
    11871190
    11881191                $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page));
    11891192
    1190                 $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . esc_attr(apply_filters('the_title', $page->post_title)) . '">' . $link_before . apply_filters('the_title', $page->post_title) . $link_after . '</a>';
     1193                $anchor_attributes = apply_filters( 'page_anchor_attributes', array(
     1194                                'href' => get_page_link($page->ID)
     1195                                , 'title' => apply_filters('the_title', $page->post_title))
     1196                        , $page );
     1197                $anchor_contents = apply_filters( 'page_anchor_contents'
     1198                        , $link_before . apply_filters('the_title', $page->post_title) . $link_after
     1199                        , $page );
    11911200
     1201                $anchor = '<a';
     1202                foreach ( $anchor_attributes as $name => $value ) {
     1203                        $anchor .= sprintf( ' %1$s="%2$s"', tag_escape($name), esc_attr($value) );
     1204                }
     1205                $anchor .= '>' . $anchor_contents . '</a>';
     1206
     1207                $output .= $indent . '<li class="' . $css_class . '">' . $anchor;
     1208
    11921209                if ( !empty($show_date) ) {
    11931210                        if ( 'modified' == $show_date )
    11941211                                $time = $page->post_modified;