bbp_stick_topic( int $topic_id, int $super = false )
Sticks a topic to a forum or front
Description Description
Parameters Parameters
- $topic_id
-
(Optional) Topic id
- $super
-
(Optional) Should we make the topic a super sticky?
Default value: false
Return Return
(bool) True on success, false on failure
Source Source
File: includes/topics/functions.php
function bbp_stick_topic( $topic_id = 0, $super = false ) { // Validation $topic_id = bbp_get_topic_id( $topic_id ); // Bail if a topic is not a topic (prevents revisions as stickies) if ( ! bbp_is_topic( $topic_id ) ) { return false; } do_action( 'bbp_stick_topic', $topic_id, $super ); // Maybe get the forum ID if not getting supers $forum_id = empty( $super ) ? bbp_get_topic_forum_id( $topic_id ) : 0; // Get the stickies, maybe from the forum ID $stickies = bbp_get_stickies( $forum_id ); // Add the topic to the stickies $stickies[] = $topic_id; // Pull out duplicates and empties $stickies = array_unique( array_filter( $stickies ) ); // Unset incorrectly stuck revisions foreach ( (array) $stickies as $key => $id ) { if ( ! bbp_is_topic( $id ) ) { unset( $stickies[ $key ] ); } } // Reset keys $stickies = array_values( $stickies ); // Update $success = ! empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies ); do_action( 'bbp_stuck_topic', $topic_id, $super, $success ); return (bool) $success; }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |