[wp-trac] Re: [WordPress Trac] #4004: New filter for page title attribute in wp_list_pages output

WordPress Trac wp-trac at lists.automattic.com
Wed Apr 4 22:11:27 GMT 2007


#4004: New filter for page title attribute in wp_list_pages output
---------------------------------------------------+------------------------
 Reporter:  Dickie                                 |        Owner:  ryan 
     Type:  enhancement                            |       Status:  new  
 Priority:  normal                                 |    Milestone:  2.2  
Component:  Template                               |      Version:  2.1.3
 Severity:  normal                                 |   Resolution:       
 Keywords:  filter wp_list_pages has-patch commit  |  
---------------------------------------------------+------------------------
Comment (by Dickie):

 I am not sure about my last patch now, if we really must pass the title
 Attribute through "the_title" filter, then the attribute filter should go
 second. (like this)
 {{{
 // As the post title is needed in two places, rather than process the
 filter twice, store it in $title
 $title = apply_filters('the_title', $page->post_title);
 // The title will also be run through another filter to determine the
 title attribute for the link
 $output .= $indent . '<li class="' . $css_class . '"><a href="' .
 get_page_link($page->ID) . '" title="' .
 attribute_escape(apply_filters('walker_page_title',$title, $page)) . '">'
 . $title . '</a>';

 }}}

 But I cant help feeling that this is a bad idea... the anchor title
 attribute is a label for the link, and as such is likely to be completely
 different from the Title of the post itself. therefore I think that this
 solution is the better one, which is more similar to my first patch before
 the "the_title" filters were added

 {{{
 $output .= $indent . '<li class="' . $css_class . '"><a href="' .
 get_page_link($page->ID) . '" title="' .
 attribute_escape(apply_filters('walker_page_title',$page->post_title,
 $page)) . '">' . apply_filters('the_title', $page->post_title) . '</a>';

 }}}

 Also, I still feel strongly and agree with westi on this, that the $page
 var needs to be sent to the filter to give it some context.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4004#comment:10>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list