LLMS_Form_Validator::sanitize_field( mixed $posted_value, array $field )
Sanitize a single field according to its type
Parameters Parameters
- $posted_value
-
(mixed) (Required) User-submitted (dirty) value.
- $field
-
(array) (Required) LifterLMS field settings.
Return Return
(mixed)
Source Source
File: includes/forms/class-llms-form-validator.php
public function sanitize_field( $posted_value, $field ) { $map = array( 'email' => 'sanitize_email', 'number' => array( $this, 'sanitize_field_number' ), 'tel' => array( $this, 'sanitize_field_tel' ), 'textarea' => 'sanitize_textarea_field', 'url' => 'esc_url_raw', ); $func = isset( $map[ $field['type'] ] ) ? $map[ $field['type'] ] : 'sanitize_text_field'; // Turn the submitted value into array, so to unify sanitization of scalar and array posted values. $to_sanitize = is_array( $posted_value ) ? $posted_value : array( $posted_value ); $sanitized = array(); foreach ( $to_sanitize as $value ) { $sanitized[] = trim( call_user_func( $func, $value ) ); } return is_array( $posted_value ) ? $sanitized : $sanitized[0]; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |