Select::prepare()

Description #

Prepare field.

Source #

File: lib/form/class-select.php

	protected function prepare() {
		$this->args = wp_parse_args(
			$this->args,
			array(
				'label'      => __( 'AnsPress Select Field', 'anspress-question-answer' ),
				'options'    => array(),
				'terms_args' => array(
					'taxonomy'   => 'question_category',
					'hide_empty' => false,
					'fields'     => 'id=>name',
					'orderby'    => ap_opt( 'form_category_orderby' ) ? ap_opt( 'form_category_orderby' ) : 'count',
				),
			)
		);

		// Call parent prepare().
		parent::prepare();

		if ( in_array( $this->get( 'options' ), array( 'posts', 'terms' ), true ) ) {
			$this->sanitize_cb = array_merge( array( 'absint' ), $this->sanitize_cb );
		} else {
			$this->sanitize_cb = array_merge( array( 'text_field' ), $this->sanitize_cb );
		}
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment