REST API: Correct the check for $version argument in rest_handle_doing_it_wrong().

Move `WP_REST_Response` and `WP_Error` class names out of the translatable string.

Follow-up to [48327], [48361].

See #36271.

git-svn-id: https://develop.svn.wordpress.org/trunk@48367 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-07-07 09:54:27 +00:00
parent b88a906e5e
commit 6bc5b06d20
2 changed files with 18 additions and 9 deletions

View File

@@ -4039,7 +4039,16 @@ function _wp_json_prepare_data( $data ) {
*/
function wp_send_json( $response, $status_code = null ) {
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
_doing_it_wrong( __FUNCTION__, __( 'Return a WP_REST_Response or WP_Error object from your callback when using the REST API.' ), '5.5.0' );
_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: 1: WP_REST_Response, 2: WP_Error */
__( 'Return a %1$s or %2$s object from your callback when using the REST API.' ),
'WP_REST_Response',
'WP_Error'
),
'5.5.0'
);
}
if ( ! headers_sent() ) {
@@ -5184,7 +5193,7 @@ function _doing_it_wrong( $function, $message, $version ) {
trigger_error(
sprintf(
/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Version information message. */
/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: WordPress version number. */
__( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ),
$function,
$message,