Textarea()

Description #

The Textarea type field object.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: lib/form/class-textarea.php

class Textarea extends Field {
	/**
	 * The field type.
	 *
	 * @var string
	 */
	public $type = 'textarea';

	/**
	 * Prepare field.
	 *
	 * @return void
	 */
	protected function prepare() {
		$this->args = wp_parse_args(
			$this->args,
			array(
				'label' => __( 'AnsPress Textarea Field', 'anspress-question-answer' ),
				'attr'  => array(
					'rows' => 8,
				),
			)
		);

		// Call parent prepare().
		parent::prepare();
		$this->sanitize_cb = array_merge( array( 'textarea_field' ), $this->sanitize_cb );
	}

	/**
	 * Field markup.
	 *
	 * @return void
	 */
	public function field_markup() {
		parent::field_markup();

		$this->add_html( '<textarea' . $this->common_attr() . $this->custom_attr() . '>' );
		$this->add_html( esc_textarea( $this->value() ) );
		$this->add_html( '</textarea>' );

		/** This action is documented in lib/form/class-input.php */
		do_action_ref_array( 'ap_after_field_markup', array( &$this ) );
	}
}

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