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:
parent
b88a906e5e
commit
6bc5b06d20
@ -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,
|
||||
|
@ -588,7 +588,7 @@ function rest_handle_deprecated_argument( $function, $message, $version ) {
|
||||
if ( ! WP_DEBUG || headers_sent() ) {
|
||||
return;
|
||||
}
|
||||
if ( ! empty( $message ) ) {
|
||||
if ( $message ) {
|
||||
/* translators: 1: Function name, 2: WordPress version number, 3: Error message. */
|
||||
$string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function, $version, $message );
|
||||
} else {
|
||||
@ -613,14 +613,14 @@ function rest_handle_doing_it_wrong( $function, $message, $version ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_null( $version ) ) {
|
||||
/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message */
|
||||
$string = __( '%1$s (%2$s)' );
|
||||
$string = sprintf( $string, $function, $message );
|
||||
} else {
|
||||
/* translators: Developer debugging message. 1: PHP function name, 2: Version information message, 3: Explanatory message. */
|
||||
if ( $version ) {
|
||||
/* translators: Developer debugging message. 1: PHP function name, 2: WordPress version number, 3: Explanatory message. */
|
||||
$string = __( '%1$s (since %2$s; %3$s)' );
|
||||
$string = sprintf( $string, $function, $version, $message );
|
||||
} else {
|
||||
/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message. */
|
||||
$string = __( '%1$s (%2$s)' );
|
||||
$string = sprintf( $string, $function, $message );
|
||||
}
|
||||
|
||||
header( sprintf( 'X-WP-DoingItWrong: %s', $string ) );
|
||||
|
Loading…
Reference in New Issue
Block a user