acf_field_taxonomy::initializepublicACF 5.0.0

This function will setup the field type data

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

Хуков нет.

Возвращает

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

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

$acf_field_taxonomy = new acf_field_taxonomy();
$acf_field_taxonomy->initialize();

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

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

Код acf_field_taxonomy::initialize() ACF 6.4.2

public function initialize() {
	$this->name          = 'taxonomy';
	$this->label         = __( 'Taxonomy', 'acf' );
	$this->category      = 'relational';
	$this->description   = __( 'Allows the selection of one or more taxonomy terms based on the criteria and options specified in the fields settings.', 'acf' );
	$this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-taxonomy.png';
	$this->doc_url       = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/taxonomy/', 'docs', 'field-type-selection' );
	$this->defaults      = array(
		'taxonomy'             => 'category',
		'field_type'           => 'checkbox',
		'multiple'             => 0,
		'allow_null'           => 0,
		'return_format'        => 'id',
		'add_term'             => 1, // 5.2.3
		'load_terms'           => 0, // 5.2.7
		'save_terms'           => 0, // 5.2.7
		'bidirectional_target' => array(),
	);

	// Register filter variations.
	acf_add_filter_variations( 'acf/fields/taxonomy/query', array( 'name', 'key' ), 1 );
	acf_add_filter_variations( 'acf/fields/taxonomy/result', array( 'name', 'key' ), 2 );

	// ajax
	add_action( 'wp_ajax_acf/fields/taxonomy/query', array( $this, 'ajax_query' ) );
	add_action( 'wp_ajax_nopriv_acf/fields/taxonomy/query', array( $this, 'ajax_query' ) );
	add_action( 'wp_ajax_acf/fields/taxonomy/add_term', array( $this, 'ajax_add_term' ) );
	add_filter( 'acf/conditional_logic/choices', array( $this, 'render_field_taxonomy_conditional_choices' ), 10, 3 );

	// actions
	add_action( 'acf/save_post', array( $this, 'save_post' ), 15, 1 );
}