bbp_unstick_topic( int $topic_id )
Unsticks a topic both from front and it’s forum
Description
Parameters
- $topic_id
-
(Optional) Topic id
Return
(bool) Always true.
Source
File: bp-forums/topics/functions.php
3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 | function bbp_unstick_topic( $topic_id = 0 ) { $topic_id = bbp_get_topic_id( $topic_id ); $super = bbp_is_topic_super_sticky( $topic_id ); $forum_id = empty ( $super ) ? bbp_get_topic_forum_id( $topic_id ) : 0; $stickies = bbp_get_stickies( $forum_id ); $offset = array_search ( $topic_id , $stickies ); do_action( 'bbp_unstick_topic' , $topic_id ); if ( empty ( $stickies ) ) { $success = true; } elseif ( !in_array( $topic_id , $stickies ) ) { $success = true; } elseif ( false === $offset ) { $success = true; } else { array_splice ( $stickies , $offset , 1 ); if ( empty ( $stickies ) ) { $success = ! empty ( $super ) ? delete_option( '_bbp_super_sticky_topics' ) : delete_post_meta( $forum_id , '_bbp_sticky_topics' ); } else { $success = ! empty ( $super ) ? update_option( '_bbp_super_sticky_topics' , $stickies ) : update_post_meta( $forum_id , '_bbp_sticky_topics' , $stickies ); } } do_action( 'bbp_unsticked_topic' , $topic_id , $success ); return (bool) $success ; } |
Changelog
Version | Description |
---|---|
bbPress (r2754) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.