LLMS_Post_Model::scrub_field( mixed $val, string $type )

Scrub fields according to datatype


Description Description


Parameters Parameters

$val

(mixed) (Required) property value to scrub

$type

(string) (Required) data type


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/abstracts/abstract.llms.post.model.php

	protected function scrub_field( $val, $type ) {

		if ( 'html' !== $type && 'array' !== $type ) {
			$val = strip_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 );

		}// End switch().

		return $val;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: