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.


Top ↑

Return Return

(mixed)


Top ↑

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;

	}

Top ↑

Changelog 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.

Top ↑

User Contributed Notes User Contributed Notes

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