CMB2_Display_Taxonomy_Multicheck

The CMB2 CMB2 Display Taxonomy Multicheck class.

Defined (1)

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

/includes/CMB2_Field_Display.php  
  1. class CMB2_Display_Taxonomy_Multicheck extends CMB2_Field_Display { 
  2. /** 
  3. * Display taxonomy values. 
  4. * @since 2.2.2 
  5. */ 
  6. protected function _display() { 
  7. $taxonomy = $this->field->args( 'taxonomy' ); 
  8. $field_type = new CMB2_Type_Taxonomy_Multicheck( new CMB2_Types( $this->field ) ); 
  9. $terms = $field_type->get_object_terms(); 
  10.  
  11. if ( is_wp_error( $terms ) || empty( $terms ) && ( $default = $this->field->get_default() ) ) { 
  12. $terms = array(); 
  13. if ( is_array( $default ) ) { 
  14. foreach ( $default as $slug ) { 
  15. $terms[] = get_term_by( 'slug', $slug, $taxonomy ); 
  16. } else { 
  17. $terms[] = get_term_by( 'slug', $default, $taxonomy ); 
  18.  
  19. if ( is_array( $terms ) ) { 
  20.  
  21. $links = array(); 
  22. foreach ( $terms as $term ) { 
  23. $link = get_edit_term_link( $term->term_id, $taxonomy ); 
  24. $links[] = '<a href="'. esc_url( $link ) .'">'. esc_html( $term->name ) .'</a>'; 
  25. // Then loop and output. 
  26. echo '<div class="cmb2-taxonomy-terms-', esc_attr( $taxonomy ), '">'; 
  27. echo implode( ', ', $links ); 
  28. echo '</div>';