Automattic\WooCommerce\Admin\Notes

DataStore::get_escaped_arguments_array_by_key()privateWC 1.0

Parses the query arguments passed in as arrays and escapes the values.

{} It's a method of the class: DataStore{}

No Hooks.

Return

Array. the escaped array of argument values.

Usage

// private - for code of main (parent) class only
$result = $this->get_escaped_arguments_array_by_key( $args, $key, $allowed_types );
$args(array)
the query arguments.
Default: array()
$key(string)
the key of the specific argument.
Default: ''
$allowed_types(array|null)
optional allowed_types if only a specific set is allowed.
Default: null

Code of DataStore::get_escaped_arguments_array_by_key() WC 6.6.1

private function get_escaped_arguments_array_by_key( $args = array(), $key = '', $allowed_types = null ) {
	$arg_array = array();
	if ( isset( $args[ $key ] ) ) {
		foreach ( $args[ $key ] as $args_type ) {
			$args_type = trim( $args_type );
			$allowed   = is_null( $allowed_types ) || in_array( $args_type, $allowed_types, true );
			if ( $allowed ) {
				$arg_array[] = sprintf( "'%s'", esc_sql( $args_type ) );
			}
		}
	}
	return $arg_array;
}