Changeset 45015
- Timestamp:
- 03/26/2019 10:25:47 PM (5 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r44981 r45015 2990 2990 */ 2991 2991 $function = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' ); 2992 } elseif ( wp_is_jsonp_request() ) { 2993 /** 2994 * Filters the callback for killing WordPress execution for JSONP requests. 2995 * 2996 * @since 5.2.0 2997 * 2998 * @param callable $function Callback function name. 2999 */ 3000 $function = apply_filters( 'wp_die_jsonp_handler', '_jsonp_wp_die_handler' ); 2992 3001 } elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { 2993 3002 /** … … 3243 3252 3244 3253 echo wp_json_encode( $data ); 3254 if ( $r['exit'] ) { 3255 die(); 3256 } 3257 } 3258 3259 /** 3260 * Kill WordPress execution and display JSONP message with error message. 3261 * 3262 * This is the handler for wp_die when processing JSONP requests. 3263 * 3264 * @since 5.2.0 3265 * @access private 3266 * 3267 * @param string $message Error message. 3268 * @param string $title Optional. Error title. Default empty. 3269 * @param string|array $args Optional. Arguments to control behavior. Default empty array. 3270 */ 3271 function _jsonp_wp_die_handler( $message, $title = '', $args = array() ) { 3272 list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); 3273 3274 $data = array( 3275 'code' => $r['code'], 3276 'message' => $message, 3277 'data' => array( 3278 'status' => $r['response'], 3279 ), 3280 'additional_errors' => $r['additional_errors'], 3281 ); 3282 3283 if ( ! headers_sent() ) { 3284 header( 'Content-Type: application/javascript; charset=utf-8' ); 3285 header( 'X-Content-Type-Options: nosniff' ); 3286 header( 'X-Robots-Tag: noindex' ); 3287 if ( null !== $r['response'] ) { 3288 status_header( $r['response'] ); 3289 } 3290 nocache_headers(); 3291 } 3292 3293 $result = wp_json_encode( $data ); 3294 $jsonp_callback = $_GET['_jsonp']; 3295 echo '/**/' . $jsonp_callback . '(' . $result . ')'; 3245 3296 if ( $r['exit'] ) { 3246 3297 die(); -
trunk/src/wp-includes/load.php
r44973 r45015 1502 1502 1503 1503 } 1504 1505 /** 1506 * Checks whether current request is a JSONP request, or is expecting a JSONP response. 1507 * 1508 * @since 5.2.0 1509 * 1510 * @return bool True if JSONP request, false otherwise. 1511 */ 1512 function wp_is_jsonp_request() { 1513 if ( ! isset( $_GET['_jsonp'] ) ) { 1514 return false; 1515 } 1516 1517 if ( ! function_exists( 'wp_check_jsonp_callback' ) ) { 1518 require_once ABSPATH . WPINC . '/functions.php'; 1519 } 1520 1521 $jsonp_callback = $_GET['_jsonp']; 1522 if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) { 1523 return false; 1524 } 1525 1526 /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ 1527 $jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true ); 1528 1529 return $jsonp_enabled; 1530 1531 }
Note: See TracChangeset
for help on using the changeset viewer.