WordPress.org

Make WordPress Core

Ticket #15811: patch

File patch, 1.8 KB (added by lewebmobile, 3 years ago)

Patch to add a parameter to avoid self-referrent links in wp_list_pages / wp_page_menu

  • wp-includes/post-template.php

     
    805805                'title_li' => __('Pages'), 'echo' => 1, 
    806806                'authors' => '', 'sort_column' => 'menu_order, post_title', 
    807807                'link_before' => '', 'link_after' => '', 'walker' => '', 
     808                'self_link' => 1 
    808809        ); 
    809810 
    810811        $r = wp_parse_args( $args, $defaults ); 
     
    871872 * @param array|string $args 
    872873 */ 
    873874function wp_page_menu( $args = array() ) { 
    874         $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 
     875        $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '', 'self_link' => 1); 
    875876        $args = wp_parse_args( $args, $defaults ); 
    876877        $args = apply_filters( 'wp_page_menu_args', $args ); 
    877878 
     
    10331034 
    10341035                $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page)); 
    10351036 
    1036                 $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '" title="' . esc_attr( wp_strip_all_tags( apply_filters( 'the_title', $page->post_title, $page->ID ) ) ) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>'; 
     1037                $output .= $indent . '<li class="' . $css_class . '">' . ( $page->ID != $current_page || $self_link ? '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr( wp_strip_all_tags( apply_filters( 'the_title', $page->post_title, $page->ID ) ) ) . '">' : '' ). $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . ( $page->ID != $current_page || $self_link ? '</a>' : '' ); 
    10371038 
    10381039                if ( !empty($show_date) ) { 
    10391040                        if ( 'modified' == $show_date )