acf_field_taxonomy::render_field
Create the HTML interface for your field
Method of the class: acf_field_taxonomy{}
No Hooks.
Returns
null. Nothing (null).
Usage
$acf_field_taxonomy = new acf_field_taxonomy(); $acf_field_taxonomy->render_field( $field );
- $field(required)
- .
Changelog
| Since 3.6 | Introduced. |
acf_field_taxonomy::render_field() acf field taxonomy::render field code ACF 6.0.4
<?php
function render_field( $field ) {
// force value to array
$field['value'] = acf_get_array( $field['value'] );
// vars
$div = array(
'class' => 'acf-taxonomy-field',
'data-save' => $field['save_terms'],
'data-ftype' => $field['field_type'],
'data-taxonomy' => $field['taxonomy'],
'data-allow_null' => $field['allow_null'],
);
// get taxonomy
$taxonomy = get_taxonomy( $field['taxonomy'] );
// bail early if taxonomy does not exist
if ( ! $taxonomy ) {
return;
}
?>
<div <?php echo acf_esc_attrs( $div ); ?>>
<?php if ( $field['add_term'] && current_user_can( $taxonomy->cap->manage_terms ) ) : ?>
<div class="acf-actions -hover">
<a href="#" class="acf-icon -plus acf-js-tooltip small" data-name="add" title="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>"></a>
</div>
<?php
endif;
if ( $field['field_type'] == 'select' ) {
$field['multiple'] = 0;
$this->render_field_select( $field );
} elseif ( $field['field_type'] == 'multi_select' ) {
$field['multiple'] = 1;
$this->render_field_select( $field );
} elseif ( $field['field_type'] == 'radio' ) {
$this->render_field_checkbox( $field );
} elseif ( $field['field_type'] == 'checkbox' ) {
$this->render_field_checkbox( $field );
}
?>
</div>
<?php
}