wp_check_jsonp_callback()WP 4.6.0

Checks that a JSONP callback is a valid JavaScript callback name.

Only allows alphanumeric characters and the dot character in callback function names. This helps to mitigate XSS attacks caused by directly outputting user input.

Хуков нет.

Возвращает

true|false. Whether the callback function name is valid.

Использование

wp_check_jsonp_callback( $callback );
$callback(строка) (обязательный)
Supplied JSONP callback function name.

Список изменений

С версии 4.6.0 Введена.

Код wp_check_jsonp_callback() WP 6.0.2

function wp_check_jsonp_callback( $callback ) {
	if ( ! is_string( $callback ) ) {
		return false;
	}

	preg_replace( '/[^\w\.]/', '', $callback, -1, $illegal_char_count );

	return 0 === $illegal_char_count;
}