wp_check_jsonp_callback() - WordPress 函数参考中文文档

返回介绍

wp_check_jsonp_callback()

发布于 2017-09-11 字数1374 浏览 802 评论 0

wp_check_jsonp_callback( string $callback )

Checks that a JSONP callback is a valid JavaScript callback.


描述

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


参数

$callback

(string)
(Required)
Supplied JSONP callback function.


返回值

(bool) True if valid callback, otherwise false.


源代码

File: wp-includes/functions.php

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

更新日志

Version 描述
4.6.0 Introduced.

相关函数

Used By

  • wp-includes/rest-api/class-wp-rest-server.php:
    WP_REST_Server::serve_request()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!