ACF_Taxonomy_Field_Walker::start_el │ public │ ACF 1.0.0

Start the element output.

Method of the class: ACF_Taxonomy_Field_Walker{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ACF_Taxonomy_Field_Walker = new ACF_Taxonomy_Field_Walker();
$ACF_Taxonomy_Field_Walker->start_el( $output, $term, $depth, $args, $id );
$output(string) (required) (passed by reference — &)
Used to append additional content (passed by reference).
$term(WP_Term) (required)
The current term object.
$depth(int)
Depth of the term in reference to parents.
$args(array)
An array of arguments. @see wp_terms_checklist().
Default: array()
$id(int)
ID of the current term.

Notes

See: Walker::start_el()

Changelog

Since 1.0.0 Introduced.

ACF_Taxonomy_Field_Walker::start_el() code ACF 6.8.8

public function start_el( &$output, $term, $depth = 0, $args = array(), $id = 0 ) {
	$is_selected = in_array( $term->term_id, $this->field['value'] );

	// Generate array of checkbox input attributes.
	$input_attrs = array(
		'type'  => $this->field['field_type'],
		'name'  => $this->field['name'],
		'value' => $term->term_id,
	);
	if ( $is_selected ) {
		$input_attrs['checked'] = true;
	}

	$output .= "\n" . '<li data-id="' . esc_attr( $term->term_id ) . '">' .
	'<label' . ( $is_selected ? ' class="selected"' : '' ) . '>' .
		'<input ' . acf_esc_attrs( $input_attrs ) . '/> ' .
		'<span>' . acf_esc_html( $term->name ) . '</span>' .
	'</label>';
}