Noptin_Form::sanitize_form_data( array $data )
Sanitizes form data
Parameters Parameters
- $data
(array) (Required) the unsanitized data.
Return Return
(array) the sanitized data
Source Source
File: includes/class-noptin-form.php
public function sanitize_form_data( $data ) { $defaults = $this->get_defaults(); // Arrays only please. if ( ! is_array( $data ) ) { return $defaults; } $data = array_merge( $defaults, $data ); $return = array(); foreach ( $data as $key => $value ) { // convert 'true' to a boolean true. if ( 'false' === $value ) { $return[ $key ] = false; continue; } // convert 'false' to a boolean false. if ( 'true' === $value ) { $return[ $key ] = true; continue; } if ( ! isset( $defaults[ $key ] ) || ! is_array( $defaults[ $key ] ) ) { $return[ $key ] = $value; continue; } // Ensure props that expect array always receive arrays. if( is_scalar( $data[ $key ] ) ) { $return[ $key ] = noptin_parse_list( $data[ $key ] ); continue; } if ( ! is_array( $data[ $key ] ) ) { $return[ $key ] = $defaults[ $key ]; continue; } $return[ $key ] = $value; } if ( empty( $return['optinType'] ) ) { $return['optinType'] = 'inpost'; } return $return; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.5 | Introduced. |