Opened 4 years ago
Closed 4 years ago
#1091 closed defect (fixed)
plugins should be able to modify a post's css class without template edits
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.0 |
| Component: | Back-end | Version: | 0.9.0.4 |
| Severity: | normal | 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;
(In [2093]) Make post_del_class() always fire it's filter. Fixes #1091, props _ck_