[wp-trac] [WordPress Trac] #22271: get_post_class() does not always apply filter to output

WordPress Trac noreply at wordpress.org
Sat Nov 3 20:00:28 UTC 2012


#22271: get_post_class() does not always apply filter to output
-----------------------------+------------------------------
 Reporter:  F J Kaiser       |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Template         |     Version:  3.4
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |
-----------------------------+------------------------------
Changes (by scribu):

 * keywords:  has-patch dev-feedback => has-patch close


Comment:

 Anyway, back to the topic at hand:

 #22271

 Example breakage:

 {{{
 function my_old_callback( $classes, $class, $post ) {
   if ( 'foo' == $post->post_type )
     $classes[] = 'bar';

   return $classes;
 }
 add_filter( 'post_class', 'my_old_callback', 10, 3 );
 }}}

 With the patch applied, my_old_callback will break when $post is null and
 would have to be amended, like so:

 {{{
 function my_old_callback( $classes, $class, $post ) {
   if ( $post && 'foo' == $post->post_type )
     $classes[] = 'foo2';

   return $classes;
 }
 }}}

 This is clearly a change that would break backwards compatibility.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22271#comment:16>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list