Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/15/2015 05:29:22 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Terms: Update functions for getting terms & term names to be more flexible & reusable by other functions. See #459.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/topics/functions.php

    r5829 r5837  
    36823682 * Get topic tags for a specific topic ID
    36833683 *
     3684 * @since bbPress (r5836)
     3685 *
     3686 * @param int $topic_id
     3687 *
     3688 * @return string
     3689 */
     3690function bbp_get_topic_tags( $topic_id = 0 ) {
     3691    $topic_id   = bbp_get_topic_id( $topic_id );
     3692    $terms      = (array) get_the_terms( $topic_id, bbp_get_topic_tag_tax_id() );
     3693    $topic_tags = array_filter( $terms );
     3694
     3695    return apply_filters( 'bbp_get_topic_tags', $topic_tags, $topic_id );
     3696}
     3697
     3698/**
     3699 * Get topic tags for a specific topic ID
     3700 *
    36843701 * @since bbPress (r4165)
    36853702 *
    3686  * @param int $topic_id
     3703 * @param int    $topic_id
    36873704 * @param string $sep
     3705 *
    36883706 * @return string
    36893707 */
    36903708function bbp_get_topic_tag_names( $topic_id = 0, $sep = ', ' ) {
    3691     $topic_id   = bbp_get_topic_id( $topic_id );
    3692     $topic_tags = array_filter( (array) get_the_terms( $topic_id, bbp_get_topic_tag_tax_id() ) );
    3693     $terms      = array();
    3694     foreach ( $topic_tags as $term ) {
    3695         $terms[] = $term->name;
    3696     }
    3697     $terms = ! empty( $terms ) ? implode( $sep, $terms ) : '';
    3698 
    3699     return apply_filters( 'bbp_get_topic_tags', $terms, $topic_id );
     3709    $topic_tags = bbp_get_topic_tags( $topic_id );
     3710    $pluck      = wp_list_pluck( $topic_tags, 'name' );
     3711    $terms      = ! empty( $pluck ) ? implode( $sep, $pluck ) : '';
     3712
     3713    return apply_filters( 'bbp_get_topic_tag_names', $terms, $topic_id, $sep );
    37003714}
    37013715
Note: See TracChangeset for help on using the changeset viewer.