ap_sanitize_unslash( string|array $str, boolean|string $from = false, mixed $default_val = '' )
Description #
Sanitize and unslash string or array or post/get value at the same time.
Parameters #
- $strstring | array (Required) String or array to sanitize. Or post/get key name.
- $fromboolean | string (Optional) Get value from
$_REQUEST
orquery_var
. Valid values: request, query_var. Default value: false - $default_valmixed (Optional) Default value if variable not found. Default value: ''
Source #
File: includes/functions.php
function ap_sanitize_unslash( $str, $from = false, $default_val = '' ) { // If not false then get from $_REQUEST or query_var. if ( false !== $from ) { if ( in_array( strtolower( $from ), array( 'request', 'post', 'get', 'p', 'g', 'r' ), true ) ) { $str = ap_isset_post_value( $str, $default_val ); } elseif ( 'query_var' === $from ) { $str = get_query_var( $str ); } } if ( empty( $str ) ) { return $default_val; } if ( is_array( $str ) ) { $str = wp_unslash( $str ); return array_map( 'sanitize_text_field', $str ); } return sanitize_text_field( wp_unslash( $str ) ); }
Expand full source code Collapse full source code View on GitHub: includes/functions.php:1181
Add your comment