Title: wp_check_jsonp_callback
Published: August 16, 2016
Last modified: February 24, 2026

---

# wp_check_jsonp_callback( string $callback ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#wp--skip-link--target)

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

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#description)󠁿

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#parameters)󠁿

 `$callback`stringrequired

Supplied JSONP callback function name.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#return)󠁿

 bool Whether the callback function name is valid.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L4638)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L4638-L4646)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_is_jsonp_request()](https://developer.wordpress.org/reference/functions/wp_is_jsonp_request/)`wp-includes/load.php` |

Checks whether current request is a JSONP request, or is expecting a JSONP response.

  | 
| [WP_REST_Server::serve_request()](https://developer.wordpress.org/reference/classes/wp_rest_server/serve_request/)`wp-includes/rest-api/class-wp-rest-server.php` |

Handles serving a REST API request.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_check_jsonp_callback/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.6.0](https://developer.wordpress.org/reference/since/4.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_check_jsonp_callback%2F)
before being able to contribute a note or feedback.