From 2245a4e3908ae340910aaeba582471b1598c8bbe Mon Sep 17 00:00:00 2001 From: Jake Spurlock Date: Tue, 23 Jun 2020 23:02:09 +0000 Subject: [PATCH] REST API: Ensure depracation errors are called while preloading data with the REST API. Fixes #50318. Props dlh, TimothyBlynJacobs. git-svn-id: https://develop.svn.wordpress.org/trunk@48150 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rest-api.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index da594f3e08..ac422b27aa 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -178,11 +178,13 @@ function rest_api_register_rewrites() { * @since 4.4.0 */ function rest_api_default_filters() { - // Deprecated reporting. - add_action( 'deprecated_function_run', 'rest_handle_deprecated_function', 10, 3 ); - add_filter( 'deprecated_function_trigger_error', '__return_false' ); - add_action( 'deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3 ); - add_filter( 'deprecated_argument_trigger_error', '__return_false' ); + if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { + // Deprecated reporting. + add_action( 'deprecated_function_run', 'rest_handle_deprecated_function', 10, 3 ); + add_filter( 'deprecated_function_trigger_error', '__return_false' ); + add_action( 'deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3 ); + add_filter( 'deprecated_argument_trigger_error', '__return_false' ); + } // Default serving. add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );