Input::prepare()
Description #
Prepare field.
Source #
File: lib/form/class-input.php
protected function prepare() { $this->args = wp_parse_args( $this->args, array( 'subtype' => 'text', 'label' => __( 'AnsPress Input Field', 'anspress-question-answer' ), ) ); // Remove label if custom html. if ( ! empty( $this->args['html'] ) ) { unset( $this->args['label'] ); } $this->set_subtype(); // Call parent prepare(). parent::prepare(); $sanitize_subtype = array( 'number' => 'intval', 'email' => 'email', 'url' => 'esc_url', ); // Make sure all text field are sanitized. if ( in_array( $this->subtype, array_keys( $sanitize_subtype ), true ) ) { $this->sanitize_cb = array_merge( array( $sanitize_subtype[ $this->subtype ] ), $this->sanitize_cb ); } else { $this->sanitize_cb = array_merge( array( 'text_field' ), $this->sanitize_cb ); } $validate_subtype = array( 'number' => 'is_numeric', 'email' => 'is_email', 'url' => 'is_url', ); if ( in_array( $this->subtype, array_keys( $validate_subtype ), true ) ) { $this->validate_cb = array_merge( array( $validate_subtype[ $this->subtype ] ), $this->validate_cb ); } }
Expand full source code Collapse full source code View on GitHub: lib/form/class-input.php:50
Add your comment