acf_field_taxonomy::render_fieldpublicACF 3.6

Renders the Taxonomy field.

Метод класса: acf_field_taxonomy{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$acf_field_taxonomy = new acf_field_taxonomy();
$acf_field_taxonomy->render_field( $field );
$field(массив) (обязательный)
The field settings array.

Список изменений

С версии 3.6 Введена.

Код acf_field_taxonomy::render_field() ACF 6.4.2

<?php
public function render_field( $field ) {
	// force value to array
	$field['value'] = acf_get_array( $field['value'] );

	$nonce = wp_create_nonce( 'acf_field_' . $this->name . '_' . $field['key'] );

	// 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'],
		'data-nonce'      => $nonce,
	);
	// 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, $nonce );
	} elseif ( $field['field_type'] == 'multi_select' ) {
		$field['multiple'] = 1;

		$this->render_field_select( $field, $nonce );
	} elseif ( $field['field_type'] == 'radio' ) {
		$this->render_field_checkbox( $field );
	} elseif ( $field['field_type'] == 'checkbox' ) {
		$this->render_field_checkbox( $field );
	}

	?>
</div>
	<?php
}