bb_create_tag

Bb_create_tag() - Creates a single bb_topic_tag.

Description

(int|bool) bb_create_tag( (string) $tag ); 

Returns (int|bool)

The TT_ID of the new bb_topic_tags or false on failure

Parameters (1)

0. $tag (string)
The (unsanitized) full name of the tag to be created

Usage

  1. if ( !function_exists( 'bb_create_tag' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-topic-tags.php'; 
  3.  
  4. // The (unsanitized) full name of the tag to be created 
  5. $tag = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_create_tag($tag); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/functions.bb-topic-tags.php  
  1. function bb_create_tag( $tag ) { 
  2. global $wp_taxonomy_object; 
  3.  
  4. if ( list($term_id, $tt_id) = $wp_taxonomy_object->is_term( $tag, 'bb_topic_tag' ) ) 
  5. return $tt_id; 
  6.  
  7. $term = $wp_taxonomy_object->insert_term( $tag, 'bb_topic_tag' ); 
  8. if ( is_wp_error( $term ) ) 
  9. return false; 
  10.  
  11. list( $term_id, $tt_id ) = $term; 
  12. if ( ! $tt_id ) 
  13. return false; 
  14.  
  15. return $tt_id;