BP_REST_Topics_Endpoint::get_topic_tags( int $topic_id )
Get Topic Tags.
Description
Parameters
- $topic_id
-
(Required) ID of the topic.
Return
(mixed|void)
Source
File: bp-forums/classes/class-bp-rest-topics-endpoint.php
public function get_topic_tags( $topic_id ) {
if ( empty( $topic_id ) ) {
return;
}
// Topic is spammed so display pre-spam terms.
if ( bbp_is_topic_spam( $topic_id ) ) {
// Get pre-spam terms.
$new_terms = get_post_meta( $topic_id, '_bbp_spam_topic_tags', true );
// If terms exist, explode them and compile the return value.
if ( empty( $new_terms ) ) {
$new_terms = '';
}
// Topic is not spam so get real terms.
} else {
$terms = array_filter( (array) get_the_terms( $topic_id, bbp_get_topic_tag_tax_id() ) );
// Loop through them.
foreach ( $terms as $term ) {
$new_terms[] = $term->name;
}
}
// Set the return value.
$topic_tags = ( ! empty( $new_terms ) ) ? implode( ', ', $new_terms ) : '';
return apply_filters( 'bbp_get_form_topic_tags', esc_attr( $topic_tags ) );
}
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.