Tags::prepare()
Description #
Prepare field.
Source #
File: lib/form/class-tags.php
protected function prepare() {
$this->args = wp_parse_args(
$this->args,
array(
'label' => __( 'AnsPress Tags Field', 'anspress-question-answer' ),
'array_max' => 3,
'array_min' => 2,
'terms_args' => array(
'taxonomy' => 'question_tag',
'hide_empty' => false,
'fields' => 'id=>name',
),
'options' => 'terms',
'js_options' => array(),
)
);
$js_options = array(
'maxItems' => $this->args['array_max'],
'form' => $this->form_name,
'id' => $this->id(),
'field' => $this->original_name,
'nonce' => wp_create_nonce( 'tags_' . $this->form_name . $this->original_name ),
'create' => false,
'labelAdd' => __( 'Add', 'anspress-question-answer' ),
);
$this->args['js_options'] = wp_parse_args( $this->args['js_options'], $js_options );
// Call parent prepare().
parent::prepare();
// Make sure field is sanitized.
$this->sanitize_cb = array_merge( array( 'array_remove_empty', 'tags_field' ), $this->sanitize_cb );
$this->validate_cb = array_merge( array( 'is_array', 'array_max', 'array_min' ), $this->validate_cb );
}
Expand full source code Collapse full source code View on GitHub: lib/form/class-tags.php:40
Add your comment