Changeset 50695 for trunk/src/wp-includes/rest-api/class-wp-rest-server.php
- Timestamp:
- 04/09/2021 09:26:07 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r50150 r50695 265 265 } 266 266 267 $content_type = isset( $_GET['_jsonp'] ) ? 'application/javascript' : 'application/json'; 267 /** 268 * Filters whether JSONP is enabled for the REST API. 269 * 270 * @since 4.4.0 271 * 272 * @param bool $jsonp_enabled Whether JSONP is enabled. Default true. 273 */ 274 $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); 275 276 $jsonp_callback = false; 277 if ( isset( $_GET['_jsonp'] ) ) { 278 $jsonp_callback = $_GET['_jsonp']; 279 } 280 281 $content_type = ( $jsonp_callback && $jsonp_enabled ) ? 'application/javascript' : 'application/json'; 268 282 $this->send_header( 'Content-Type', $content_type . '; charset=' . get_option( 'blog_charset' ) ); 269 283 $this->send_header( 'X-Robots-Tag', 'noindex' ); … … 356 370 ); 357 371 358 /** 359 * Filters whether JSONP is enabled for the REST API. 360 * 361 * @since 4.4.0 362 * 363 * @param bool $jsonp_enabled Whether JSONP is enabled. Default true. 364 */ 365 $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); 366 367 $jsonp_callback = null; 368 369 if ( isset( $_GET['_jsonp'] ) ) { 372 if ( $jsonp_callback ) { 370 373 if ( ! $jsonp_enabled ) { 371 374 echo $this->json_error( 'rest_callback_disabled', __( 'JSONP support is disabled on this site.' ), 400 ); … … 373 376 } 374 377 375 $jsonp_callback = $_GET['_jsonp'];376 378 if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { 377 379 echo $this->json_error( 'rest_callback_invalid', __( 'Invalid JSONP callback function.' ), 400 );
Note: See TracChangeset
for help on using the changeset viewer.