Make WordPress Core

Changeset 48367


Ignore:
Timestamp:
07/07/2020 09:54:27 AM (6 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r48361 r48367  
    40404040function wp_send_json( $response, $status_code = null ) {
    40414041        if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
    4042                 _doing_it_wrong( __FUNCTION__, __( 'Return a WP_REST_Response or WP_Error object from your callback when using the REST API.' ), '5.5.0' );
     4042                _doing_it_wrong(
     4043                        __FUNCTION__,
     4044                        sprintf(
     4045                                /* translators: 1: WP_REST_Response, 2: WP_Error */
     4046                                __( 'Return a %1$s or %2$s object from your callback when using the REST API.' ),
     4047                                'WP_REST_Response',
     4048                                'WP_Error'
     4049                        ),
     4050                        '5.5.0'
     4051                );
    40434052        }
    40444053
     
    51855194                        trigger_error(
    51865195                                sprintf(
    5187                                         /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Version information message. */
     5196                                        /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: WordPress version number. */
    51885197                                        __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ),
    51895198                                        $function,
  • trunk/src/wp-includes/rest-api.php

    r48361 r48367  
    589589                return;
    590590        }
    591         if ( ! empty( $message ) ) {
     591        if ( $message ) {
    592592                /* translators: 1: Function name, 2: WordPress version number, 3: Error message. */
    593593                $string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function, $version, $message );
     
    614614        }
    615615
    616         if ( is_null( $version ) ) {
    617                 /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message */
     616        if ( $version ) {
     617                /* translators: Developer debugging message. 1: PHP function name, 2: WordPress version number, 3: Explanatory message. */
     618                $string = __( '%1$s (since %2$s; %3$s)' );
     619                $string = sprintf( $string, $function, $version, $message );
     620        } else {
     621                /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message. */
    618622                $string = __( '%1$s (%2$s)' );
    619623                $string = sprintf( $string, $function, $message );
    620         } else {
    621                 /* translators: Developer debugging message. 1: PHP function name, 2: Version information message, 3: Explanatory message. */
    622                 $string = __( '%1$s (since %2$s; %3$s)' );
    623                 $string = sprintf( $string, $function, $version, $message );
    624624        }
    625625
Note: See TracChangeset for help on using the changeset viewer.