Ticket #47188: 47188.diff
File 47188.diff, 1.2 KB (added by , 6 years ago) |
---|
-
src/wp-includes/rest-api.php
179 179 180 180 // Default serving. 181 181 add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' ); 182 add_filter( 'rest_pre_serve_request', 'rest_add_wp_die_handler_filter', 10 ); 182 183 add_filter( 'rest_post_dispatch', 'rest_send_allow_header', 10, 3 ); 183 184 add_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10, 3 ); 184 185 … … 646 647 } 647 648 648 649 /** 650 * Add the filter for the custom wp_die handler. 651 * 652 * This is hooked on rest_pre_dispatch, so any uses of wp_die in endpoints 653 * will be wrapped by our custom wp_die handler to output JSON rather than the 654 * usual HTML error page. 655 * 656 * @since 5.3.0 657 */ 658 function rest_add_wp_die_handler_filter() { 659 add_filter( 'wp_die_handler', 'rest_wp_die_handler_callback' ); 660 } 661 662 /** 663 * Callback to set the wp_die handler to rest_wp_die_handler. 664 * 665 * @return string 666 * @since 5.3.0 667 */ 668 function rest_wp_die_handler_callback() { 669 return '_json_wp_die_handler'; 670 } 671 672 /** 649 673 * Sends the "Allow" header to state all methods that can be sent to the current route. 650 674 * 651 675 * @since 4.4.0