CMB2_Type_Taxonomy_Multicheck

CMB taxonomy_multicheck field type.

Defined (1)

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

/vendor/wordimpress/maps-builder-core/includes/libraries/metabox/includes/types/CMB2_Type_Taxonomy_Multicheck.php  
  1. class CMB2_Type_Taxonomy_Multicheck extends CMB2_Type_Taxonomy_Base { 
  2.  
  3. public function render() { 
  4. $field = $this->field; 
  5. $names = $this->get_object_terms(); 
  6.  
  7. $saved_terms = is_wp_error( $names ) || empty( $names ) 
  8. ? $field->get_default() 
  9. : wp_list_pluck( $names, 'slug' ); 
  10. $terms = $this->get_terms(); 
  11. $name = $this->_name() . '[]'; 
  12. $options = ''; $i = 1; 
  13.  
  14. if ( ! $terms ) { 
  15. $options .= sprintf( '<li><label>%s</label></li>', esc_html( $this->_text( 'no_terms_text', __( 'No terms', 'cmb2' ) ) ) ); 
  16. } else { 
  17.  
  18. foreach ( $terms as $term ) { 
  19. $args = array( 
  20. 'value' => $term->slug,  
  21. 'label' => $term->name,  
  22. 'type' => 'checkbox',  
  23. 'name' => $name,  
  24. ); 
  25.  
  26. if ( is_array( $saved_terms ) && in_array( $term->slug, $saved_terms ) ) { 
  27. $args['checked'] = 'checked'; 
  28. $options .= $this->types->list_input( $args, $i ); 
  29. $i++; 
  30.  
  31. $classes = false === $field->args( 'select_all_button' ) 
  32. ? 'cmb2-checkbox-list no-select-all cmb2-list' 
  33. : 'cmb2-checkbox-list cmb2-list'; 
  34.  
  35. return $this->rendered( 
  36. $this->types->radio( array( 'class' => $classes, 'options' => $options ), 'taxonomy_multicheck' ) 
  37. );