Skip to:
Content

Opened 5 years ago

Closed 5 years ago

#1091 closed defect (fixed)

plugins should be able to modify a post's css class without template edits

Reported by: _ck_ Owned by:
Milestone: 1.0 Priority: normal
Severity: normal Version: 0.9.0.4
Component: Back-end Keywords:
Cc:

Description

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;

Change History (1)

comment:1 sambauers5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [2093]) Make post_del_class() always fire it's filter. Fixes #1091, props _ck_

Note: See TracTickets for help on using tickets.