llms_sanitize_with_safelist( mixed $needle, array $safelist, mixed $default = null )

Check that the test value is a member of a specific array for sanitization purposes.


Parameters Parameters

$needle

(mixed) (Required) Value to be tested.

$safelist

(array) (Required) Array of safelist values.

$default

(mixed) (Optional) Default value to return if the needle is not in the safelist. Defaults to the first value in the safelist array if not provided.

Default value: null


Top ↑

Source Source

File: includes/llms.functions.core.php

function llms_sanitize_with_safelist( $needle, $safelist, $default = null ) {
	if ( ! in_array( $needle, $safelist ) ) {
		if ( isset( $default ) ) {
			return $default;
		} else {
			return $safelist[0];
		}
	} else {
		return $needle;
	}
}


Top ↑

Changelog Changelog

Changelog
Version Description
7.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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