bbp_get_topic_stick_link( mixed $args = '' )
Return the stick link of the topic
Description
Parameters
- $args
-
(mixed) (Optional) This function supports these args: - id: Optional. Topic id - link_before: Before the link - link_after: After the link - stick_text: Stick text - unstick_text: Unstick text - super_text: Stick to front text
Default value: ''
Return
(string) Topic stick link
Source
File: bp-forums/topics/template.php
function bbp_get_topic_stick_link( $args = '' ) { // Parse arguments against default values $r = bbp_parse_args( $args, array( 'id' => 0, 'link_before' => '', 'link_after' => '', 'stick_text' => esc_html__( 'Stick', 'buddyboss' ), 'unstick_text' => esc_html__( 'Unstick', 'buddyboss' ), 'super_text' => esc_html__( '(to front)', 'buddyboss' ), ), 'get_topic_stick_link' ); $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) return; $is_sticky = bbp_is_topic_sticky( $topic->ID ); $stick_uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_stick', 'topic_id' => $topic->ID ) ); $stick_uri = wp_nonce_url( $stick_uri, 'stick-topic_' . $topic->ID ); $stick_display = ( true === $is_sticky ) ? $r['unstick_text'] : $r['stick_text']; $stick_display = '<a href="' . esc_url( $stick_uri ) . '" class="bbp-topic-sticky-link">' . $stick_display . '</a>'; if ( empty( $is_sticky ) ) { $super_uri = add_query_arg( array( 'action' => 'bbp_toggle_topic_stick', 'topic_id' => $topic->ID, 'super' => 1 ) ); $super_uri = wp_nonce_url( $super_uri, 'stick-topic_' . $topic->ID ); $super_display = ' <a href="' . esc_url( $super_uri ) . '" class="bbp-topic-super-sticky-link">' . $r['super_text'] . '</a>'; } else { $super_display = ''; } // Combine the HTML into 1 string $retval = $r['link_before'] . $stick_display . $super_display . $r['link_after']; return apply_filters( 'bbp_get_topic_stick_link', $retval, $r ); }
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.