LLMS_Post_Model::scrub_field( mixed $val, string $type )
Scrub fields according to datatype
Parameters Parameters
- $val
-
(mixed) (Required) Property value to scrub.
- $type
-
(string) (Required) Data type.
Return Return
(mixed)
Source Source
File: includes/abstracts/abstract.llms.post.model.php
protected function scrub_field( $val, $type ) {
if ( is_string( $val ) && 'html' !== $type ) {
$val = wp_strip_all_tags( $val );
}
switch ( $type ) {
case 'absint':
$val = absint( $val );
break;
case 'array':
if ( '' === $val ) {
$val = array();
}
$val = (array) $val;
break;
case 'bool':
case 'boolean':
$val = boolval( $val );
break;
case 'float':
$val = floatval( $val );
break;
case 'html':
$this->allowed_post_tags_set();
$val = wp_kses_post( $val ?? '' );
$this->allowed_post_tags_unset();
break;
case 'int':
$val = intval( $val );
break;
case 'yesno':
$val = 'yes' === $val ? 'yes' : 'no';
break;
case 'text':
case 'string':
default:
$val = sanitize_text_field( $val );
}
return $val;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 5.9.0 | Use wp_strip_all_tags() in favor of strip_tags(). Only strip tags from string values. Coerce null html input to an empty string. |
| 3.19.2 | Unknown. |
| 3.0.0 | Introduced. |