Input::prepare()
Description #
Prepare field.
Source #
File: lib/form/class-input.php
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | 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