wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_check_jsonp_callback › WordPress Function

Seit4.6.0
Veraltetn/v
wp_check_jsonp_callback ( $callback )
Parameter:
  • (string) $callback Supplied JSONP callback function name.
    Erforderlich: Ja
Gibt zurück:
  • (bool) Whether the callback function name is valid.
Definiert in:
Codex:

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.


Quellcode

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;
}