[Bb-trac] [bbPress] #1091: plugins should be able to modify a post's css class without template edits

bbPress bb-trac at lists.bbpress.org
Tue May 19 12:16:57 GMT 2009


#1091: plugins should be able to modify a post's css class without template edits
----------------------+-----------------------------------------------------
 Reporter:  _ck_      |       Owner:         
     Type:  defect    |      Status:  new    
 Priority:  normal    |   Milestone:  1.0    
Component:  Back-end  |     Version:  0.9.0.4
 Severity:  normal    |    Keywords:         
----------------------+-----------------------------------------------------
 It's too late to rename this template function into something more logical
 but it can still be fixed into a general purpose way to affect the class
 of posts within a topic - it's a mess because it doesn't apply the filter
 UNLESS the post has a non-standard status. Instead it should ALWAYS fire
 the filter so plugins can tie into it and give certain posts special css
 classes.

 {{{
 function post_del_class( $post_id = 0 ) {
        $bb_post = bb_get_post( get_post_id( $post_id ) );
        switch ( $bb_post->post_status ) :
        case 0 : return ''; break;
        case 1 : return 'deleted'; break;
        default: return apply_filters( 'post_del_class',
 $bb_post->post_status, $bb_post->post_id );
        endswitch;
 }
 }}}

 make it more like this so the filter ALWAYS fires (untested and probably
 needs some better logic but would have backwards compatibility)

 {{{
 function post_del_class( $post_id = 0 ) {
        $bb_post = bb_get_post( get_post_id( $post_id ) );
        switch ( $bb_post->post_status ) :
        case 0 : $class=''; break;
        case 1 : $class='deleted'; break;
        endswitch;
        $test = apply_filters( 'post_del_class',
 $bb_post->post_status, $bb_post->post_id );
        return trim("$test $class");
 }
 }}}

 keep in mind you can't (shouldn't) introduce anything new that would
 require editing of templates, so this would be a workaround

 Optionally you could just make

 {{{
 function post_del_class( $post_id = 0 ) {
    $bb_post = bb_get_post( get_post_id( $post_id ) );
    return apply_filters( 'post_del_class',
 $bb_post->post_status, $bb_post->post_id );
 }

 }}}

 and make this into an actual filter for  'post_del_class'


 {{{
        switch ( $bb_post->post_status ) :
        case 0 : $class=''; break;
        case 1 : $class='deleted'; break;
        endswitch;

 }}}

-- 
Ticket URL: <http://trac.bbpress.org/ticket/1091>
bbPress <http://bbpress.org/>
Innovative forum development


More information about the Bb-trac mailing list