wpcf7_flamingo_add_channel

The Contact Form 7 wpcf7 flamingo add channel function.

Description

wpcf7_flamingo_add_channel( $slug, (string) $name = '' ); 

Parameters (2)

0. $slug
The slug.
1. $name — Optional. (string) => ''
The name.

Usage

  1. if ( !function_exists( 'wpcf7_flamingo_add_channel' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/modules/flamingo.php'; 
  3.  
  4. // The slug. 
  5. $slug = null; 
  6.  
  7. // The name. 
  8. $name = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wpcf7_flamingo_add_channel($slug, $name); 
  12.  

Defined (1)

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

/modules/flamingo.php  
  1. function wpcf7_flamingo_add_channel( $slug, $name = '' ) { 
  2. if ( ! class_exists( 'Flamingo_Inbound_Message' ) ) { 
  3. return false; 
  4.  
  5. $parent = term_exists( 'contact-form-7',  
  6. Flamingo_Inbound_Message::channel_taxonomy ); 
  7.  
  8. if ( ! $parent ) { 
  9. $parent = wp_insert_term( __( 'Contact Form 7', 'contact-form-7' ),  
  10. Flamingo_Inbound_Message::channel_taxonomy,  
  11. array( 'slug' => 'contact-form-7' ) ); 
  12.  
  13. if ( is_wp_error( $parent ) ) { 
  14. return false; 
  15.  
  16. $parent = (int) $parent['term_id']; 
  17.  
  18. if ( ! is_taxonomy_hierarchical( Flamingo_Inbound_Message::channel_taxonomy ) ) { 
  19. // backward compat for Flamingo 1.0.4 and lower 
  20. return $parent; 
  21.  
  22. if ( empty( $name ) ) { 
  23. $name = $slug; 
  24.  
  25. $channel = term_exists( $slug,  
  26. Flamingo_Inbound_Message::channel_taxonomy,  
  27. $parent ); 
  28.  
  29. if ( ! $channel ) { 
  30. $channel = wp_insert_term( $name,  
  31. Flamingo_Inbound_Message::channel_taxonomy,  
  32. array( 'slug' => $slug, 'parent' => $parent ) ); 
  33.  
  34. if ( is_wp_error( $channel ) ) { 
  35. return false; 
  36.  
  37. return (int) $channel['term_id'];