acf_taxonomy_field_walker

The Advanced Custom Fields acf taxonomy field walker class.

Defined (1)

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

/core/fields/taxonomy.php  
  1. class acf_taxonomy_field_walker extends Walker 
  2. // vars 
  3. var $field = null,  
  4. $tree_type = 'category',  
  5. $db_fields = array ( 'parent' => 'parent', 'id' => 'term_id' ); 
  6.  
  7.  
  8. // construct 
  9. function __construct( $field ) 
  10. $this->field = $field; 
  11.  
  12.  
  13. // start_el 
  14. function start_el( &$output, $term, $depth = 0, $args = array(), $current_object_id = 0) 
  15. // vars 
  16. $selected = in_array( $term->term_id, $this->field['value'] ); 
  17.  
  18. if( $this->field['field_type'] == 'checkbox' ) 
  19. $output .= '<li><label class="selectit"><input type="checkbox" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checked"' : '') . ' /> ' . $term->name . '</label>'; 
  20. elseif( $this->field['field_type'] == 'radio' ) 
  21. $output .= '<li><label class="selectit"><input type="radio" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checkbox"' : '') . ' /> ' . $term->name . '</label>'; 
  22. elseif( $this->field['field_type'] == 'select' ) 
  23. $indent = str_repeat("— ", $depth); 
  24. $output .= '<option value="' . $term->term_id . '" ' . ($selected ? 'selected="selected"' : '') . '>' . $indent . $term->name . '</option>'; 
  25.  
  26.  
  27.  
  28. //end_el 
  29. function end_el( &$output, $term, $depth = 0, $args = array() ) 
  30. if( in_array($this->field['field_type'], array('checkbox', 'radio')) ) 
  31. $output .= '</li>'; 
  32.  
  33. $output .= "\n"; 
  34.  
  35.  
  36. // start_lvl 
  37. function start_lvl( &$output, $depth = 0, $args = array() ) 
  38. // indent 
  39. //$output .= str_repeat( "\t", $depth); 
  40.  
  41.  
  42. // wrap element 
  43. if( in_array($this->field['field_type'], array('checkbox', 'radio')) ) 
  44. $output .= '<ul class="children">' . "\n"; 
  45.  
  46.  
  47. // end_lvl 
  48. function end_lvl( &$output, $depth = 0, $args = array() ) 
  49. // indent 
  50. //$output .= str_repeat( "\t", $depth); 
  51.  
  52.  
  53. // wrap element 
  54. if( in_array($this->field['field_type'], array('checkbox', 'radio')) ) 
  55. $output .= '</ul>' . "\n"; 
  56.