Make WordPress Core

Ticket #41305: 41305.optimize-rest-api.2.diff

File 41305.optimize-rest-api.2.diff, 169.3 KB (added by schlessera, 8 years ago)

Refresh of the REST API practical application

  • src/wp-includes/rest-api.php

    diff --git src/wp-includes/rest-api.php src/wp-includes/rest-api.php
    index 34e1c591f6..0b503776fa 100644
    function register_rest_route( $namespace, $route, $args = array(), $override = f 
    3434                 * and namespace indexes. If you really need to register a
    3535                 * non-namespaced route, call `WP_REST_Server::register_route` directly.
    3636                 */
    37                 _doing_it_wrong( 'register_rest_route', __( 'Routes must be namespaced with plugin or theme name and version.' ), '4.4.0' );
     37                _doing_it_wrong( 'register_rest_route', _l( 'Routes must be namespaced with plugin or theme name and version.' ), '4.4.0' );
    3838                return false;
    3939        } else if ( empty( $route ) ) {
    40                 _doing_it_wrong( 'register_rest_route', __( 'Route must be specified.' ), '4.4.0' );
     40                _doing_it_wrong( 'register_rest_route', _l( 'Route must be specified.' ), '4.4.0' );
    4141                return false;
    4242        }
    4343
    function rest_handle_deprecated_function( $function, $replacement, $version ) { 
    491491        }
    492492        if ( ! empty( $replacement ) ) {
    493493                /* translators: 1: function name, 2: WordPress version number, 3: new function name */
    494                 $string = sprintf( __( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement );
     494                $string = sprintf( _l( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement );
    495495        } else {
    496496                /* translators: 1: function name, 2: WordPress version number */
    497                 $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version );
     497                $string = sprintf( _l( '%1$s (since %2$s; no alternative available)' ), $function, $version );
    498498        }
    499499
    500500        header( sprintf( 'X-WP-DeprecatedFunction: %s', $string ) );
    function rest_handle_deprecated_argument( $function, $message, $version ) { 
    515515        }
    516516        if ( ! empty( $message ) ) {
    517517                /* translators: 1: function name, 2: WordPress version number, 3: error message */
    518                 $string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function, $version, $message );
     518                $string = sprintf( _l( '%1$s (since %2$s; %3$s)' ), $function, $version, $message );
    519519        } else {
    520520                /* translators: 1: function name, 2: WordPress version number */
    521                 $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version );
     521                $string = sprintf( _l( '%1$s (since %2$s; no alternative available)' ), $function, $version );
    522522        }
    523523
    524524        header( sprintf( 'X-WP-DeprecatedParam: %s', $string ) );
    function rest_cookie_check_errors( $result ) { 
    737737        $result = wp_verify_nonce( $nonce, 'wp_rest' );
    738738
    739739        if ( ! $result ) {
    740                 return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) );
     740                return new WP_Error( 'rest_cookie_invalid_nonce', _l( 'Cookie nonce is invalid' ), array( 'status' => 403 ) );
    741741        }
    742742
    743743        // Send a refreshed nonce in header.
    function rest_validate_value_from_schema( $value, $args, $param = '' ) { 
    10421042                }
    10431043                if ( ! wp_is_numeric_array( $value ) ) {
    10441044                        /* translators: 1: parameter, 2: type name */
    1045                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'array' ) );
     1045                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $param, 'array' ) );
    10461046                }
    10471047                foreach ( $value as $index => $v ) {
    10481048                        $is_valid = rest_validate_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' );
    function rest_validate_value_from_schema( $value, $args, $param = '' ) { 
    10761076        if ( ! empty( $args['enum'] ) ) {
    10771077                if ( ! in_array( $value, $args['enum'], true ) ) {
    10781078                        /* translators: 1: parameter, 2: list of valid values */
    1079                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not one of %2$s.' ), $param, implode( ', ', $args['enum'] ) ) );
     1079                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not one of %2$s.' ), $param, implode( ', ', $args['enum'] ) ) );
    10801080                }
    10811081        }
    10821082
    10831083        if ( in_array( $args['type'], array( 'integer', 'number' ) ) && ! is_numeric( $value ) ) {
    10841084                /* translators: 1: parameter, 2: type name */
    1085                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, $args['type'] ) );
     1085                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $param, $args['type'] ) );
    10861086        }
    10871087
    10881088        if ( 'integer' === $args['type'] && round( floatval( $value ) ) !== floatval( $value ) ) {
    10891089                /* translators: 1: parameter, 2: type name */
    1090                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'integer' ) );
     1090                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $param, 'integer' ) );
    10911091        }
    10921092
    10931093        if ( 'boolean' === $args['type'] && ! rest_is_boolean( $value ) ) {
    10941094                /* translators: 1: parameter, 2: type name */
    1095                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $value, 'boolean' ) );
     1095                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $value, 'boolean' ) );
    10961096        }
    10971097
    10981098        if ( 'string' === $args['type'] && ! is_string( $value ) ) {
    10991099                /* translators: 1: parameter, 2: type name */
    1100                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'string' ) );
     1100                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $param, 'string' ) );
    11011101        }
    11021102
    11031103        if ( isset( $args['format'] ) ) {
    11041104                switch ( $args['format'] ) {
    11051105                        case 'date-time' :
    11061106                                if ( ! rest_parse_date( $value ) ) {
    1107                                         return new WP_Error( 'rest_invalid_date', __( 'Invalid date.' ) );
     1107                                        return new WP_Error( 'rest_invalid_date', _l( 'Invalid date.' ) );
    11081108                                }
    11091109                                break;
    11101110
    11111111                        case 'email' :
    11121112                                if ( ! is_email( $value ) ) {
    1113                                         return new WP_Error( 'rest_invalid_email', __( 'Invalid email address.' ) );
     1113                                        return new WP_Error( 'rest_invalid_email', _l( 'Invalid email address.' ) );
    11141114                                }
    11151115                                break;
    11161116                        case 'ip' :
    11171117                                if ( ! rest_is_ip_address( $value ) ) {
    11181118                                        /* translators: %s: IP address */
    1119                                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not a valid IP address.' ), $value ) );
     1119                                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%s is not a valid IP address.' ), $value ) );
    11201120                                }
    11211121                                break;
    11221122                }
    function rest_validate_value_from_schema( $value, $args, $param = '' ) { 
    11261126                if ( isset( $args['minimum'] ) && ! isset( $args['maximum'] ) ) {
    11271127                        if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) {
    11281128                                /* translators: 1: parameter, 2: minimum number */
    1129                                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) );
     1129                                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) );
    11301130                        } elseif ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) {
    11311131                                /* translators: 1: parameter, 2: minimum number */
    1132                                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) );
     1132                                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) );
    11331133                        }
    11341134                } elseif ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) {
    11351135                        if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) {
    11361136                                /* translators: 1: parameter, 2: maximum number */
    1137                                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) );
     1137                                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) );
    11381138                        } elseif ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) {
    11391139                                /* translators: 1: parameter, 2: maximum number */
    1140                                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) );
     1140                                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) );
    11411141                        }
    11421142                } elseif ( isset( $args['maximum'] ) && isset( $args['minimum'] ) ) {
    11431143                        if ( ! empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
    11441144                                if ( $value >= $args['maximum'] || $value <= $args['minimum'] ) {
    11451145                                        /* translators: 1: parameter, 2: minimum number, 3: maximum number */
    1146                                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
     1146                                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be between %2$d (exclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
    11471147                                }
    11481148                        } elseif ( empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
    11491149                                if ( $value >= $args['maximum'] || $value < $args['minimum'] ) {
    11501150                                        /* translators: 1: parameter, 2: minimum number, 3: maximum number */
    1151                                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
     1151                                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be between %2$d (inclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
    11521152                                }
    11531153                        } elseif ( ! empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
    11541154                                if ( $value > $args['maximum'] || $value <= $args['minimum'] ) {
    11551155                                        /* translators: 1: parameter, 2: minimum number, 3: maximum number */
    1156                                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
     1156                                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
    11571157                                }
    11581158                        } elseif ( empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
    11591159                                if ( $value > $args['maximum'] || $value < $args['minimum'] ) {
    11601160                                        /* translators: 1: parameter, 2: minimum number, 3: maximum number */
    1161                                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
     1161                                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
    11621162                                }
    11631163                        }
    11641164                }
  • src/wp-includes/rest-api/class-wp-rest-request.php

    diff --git src/wp-includes/rest-api/class-wp-rest-request.php src/wp-includes/rest-api/class-wp-rest-request.php
    index f9c6317896..3f395ca2c2 100644
    class WP_REST_Request implements ArrayAccess { 
    654654                                $error_data['json_error_message'] = json_last_error_msg();
    655655                        }
    656656
    657                         return new WP_Error( 'rest_invalid_json', __( 'Invalid JSON body passed.' ), $error_data );
     657                        return new WP_Error( 'rest_invalid_json', _l( 'Invalid JSON body passed.' ), $error_data );
    658658                }
    659659
    660660                $this->params['JSON'] = $params;
    class WP_REST_Request implements ArrayAccess { 
    802802                }
    803803
    804804                if ( $invalid_params ) {
    805                         return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
     805                        return new WP_Error( 'rest_invalid_param', sprintf( _l( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
    806806                }
    807807
    808808                return true;
    class WP_REST_Request implements ArrayAccess { 
    840840                }
    841841
    842842                if ( ! empty( $required ) ) {
    843                         return new WP_Error( 'rest_missing_callback_param', sprintf( __( 'Missing parameter(s): %s' ), implode( ', ', $required ) ), array( 'status' => 400, 'params' => $required ) );
     843                        return new WP_Error( 'rest_missing_callback_param', sprintf( _l( 'Missing parameter(s): %s' ), implode( ', ', $required ) ), array( 'status' => 400, 'params' => $required ) );
    844844                }
    845845
    846846                /*
    class WP_REST_Request implements ArrayAccess { 
    858858                                $valid_check = call_user_func( $arg['validate_callback'], $param, $this, $key );
    859859
    860860                                if ( false === $valid_check ) {
    861                                         $invalid_params[ $key ] = __( 'Invalid parameter.' );
     861                                        $invalid_params[ $key ] = _l( 'Invalid parameter.' );
    862862                                }
    863863
    864864                                if ( is_wp_error( $valid_check ) ) {
    class WP_REST_Request implements ArrayAccess { 
    868868                }
    869869
    870870                if ( $invalid_params ) {
    871                         return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
     871                        return new WP_Error( 'rest_invalid_param', sprintf( _l( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
    872872                }
    873873
    874874                return true;
  • src/wp-includes/rest-api/class-wp-rest-server.php

    diff --git src/wp-includes/rest-api/class-wp-rest-server.php src/wp-includes/rest-api/class-wp-rest-server.php
    index c69cb4834c..936d0592dc 100644
    class WP_REST_Server { 
    261261                 * @param bool $rest_enabled Whether the REST API is enabled. Default true.
    262262                 */
    263263                apply_filters_deprecated( 'rest_enabled', array( true ), '4.7.0', 'rest_authentication_errors',
    264                         __( 'The REST API can no longer be completely disabled, the rest_authentication_errors filter can be used to restrict access to the API, instead.' )
     264                        _l( 'The REST API can no longer be completely disabled, the rest_authentication_errors filter can be used to restrict access to the API, instead.' )
    265265                );
    266266
    267267                /**
    class WP_REST_Server { 
    277277
    278278                if ( isset( $_GET['_jsonp'] ) ) {
    279279                        if ( ! $jsonp_enabled ) {
    280                                 echo $this->json_error( 'rest_callback_disabled', __( 'JSONP support is disabled on this site.' ), 400 );
     280                                echo $this->json_error( 'rest_callback_disabled', _l( 'JSONP support is disabled on this site.' ), 400 );
    281281                                return false;
    282282                        }
    283283
    284284                        $jsonp_callback = $_GET['_jsonp'];
    285285                        if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) {
    286                                 echo $this->json_error( 'rest_callback_invalid', __( 'Invalid JSONP callback function.' ), 400 );
     286                                echo $this->json_error( 'rest_callback_invalid', _l( 'Invalid JSONP callback function.' ), 400 );
    287287                                return false;
    288288                        }
    289289                }
    class WP_REST_Server { 
    851851                                }
    852852
    853853                                if ( ! is_callable( $callback ) ) {
    854                                         $response = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) );
     854                                        $response = new WP_Error( 'rest_invalid_handler', _l( 'The handler for the route is invalid' ), array( 'status' => 500 ) );
    855855                                }
    856856
    857857                                if ( ! is_wp_error( $response ) ) {
    class WP_REST_Server { 
    908908                                                if ( is_wp_error( $permission ) ) {
    909909                                                        $response = $permission;
    910910                                                } elseif ( false === $permission || null === $permission ) {
    911                                                         $response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => 403 ) );
     911                                                        $response = new WP_Error( 'rest_forbidden', _l( 'Sorry, you are not allowed to do that.' ), array( 'status' => 403 ) );
    912912                                                }
    913913                                        }
    914914                                }
    class WP_REST_Server { 
    972972                        }
    973973                }
    974974
    975                 return $this->error_to_response( new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method' ), array( 'status' => 404 ) ) );
     975                return $this->error_to_response( new WP_Error( 'rest_no_route', _l( 'No route was found matching the URL and request method' ), array( 'status' => 404 ) ) );
    976976        }
    977977
    978978        /**
    class WP_REST_Server { 
    10591059                $namespace = $request['namespace'];
    10601060
    10611061                if ( ! isset( $this->namespaces[ $namespace ] ) ) {
    1062                         return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) );
     1062                        return new WP_Error( 'rest_invalid_namespace', _l( 'The specified namespace could not be found.' ), array( 'status' => 404 ) );
    10631063                }
    10641064
    10651065                $routes = $this->namespaces[ $namespace ];
  • src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
    index ed101815a1..8f29b1bce0 100644
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    7070                }
    7171
    7272                if ( ! current_user_can( 'upload_files' ) ) {
    73                         return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to upload media on this site.' ), array( 'status' => 400 ) );
     73                        return new WP_Error( 'rest_cannot_create', _l( 'Sorry, you are not allowed to upload media on this site.' ), array( 'status' => 400 ) );
    7474                }
    7575
    7676                // Attaching media to a post requires ability to edit said post.
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    7979                        $post_parent_type = get_post_type_object( $parent->post_type );
    8080
    8181                        if ( ! current_user_can( $post_parent_type->cap->edit_post, $request['post'] ) ) {
    82                                 return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to upload media to this post.' ), array( 'status' => rest_authorization_required_code() ) );
     82                                return new WP_Error( 'rest_cannot_edit', _l( 'Sorry, you are not allowed to upload media to this post.' ), array( 'status' => rest_authorization_required_code() ) );
    8383                        }
    8484                }
    8585
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    9797        public function create_item( $request ) {
    9898
    9999                if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) {
    100                         return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) );
     100                        return new WP_Error( 'rest_invalid_param', _l( 'Invalid parent type.' ), array( 'status' => 400 ) );
    101101                }
    102102
    103103                // Get the file via $_FILES or raw data.
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    203203         */
    204204        public function update_item( $request ) {
    205205                if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) {
    206                         return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) );
     206                        return new WP_Error( 'rest_invalid_param', _l( 'Invalid parent type.' ), array( 'status' => 400 ) );
    207207                }
    208208
    209209                $response = parent::update_item( $request );
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    377377                $schema = parent::get_item_schema();
    378378
    379379                $schema['properties']['alt_text'] = array(
    380                         'description'     => __( 'Alternative text to display when attachment is not displayed.' ),
     380                        'description'     => _l( 'Alternative text to display when attachment is not displayed.' ),
    381381                        'type'            => 'string',
    382382                        'context'         => array( 'view', 'edit', 'embed' ),
    383383                        'arg_options'     => array(
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    386386                );
    387387
    388388                $schema['properties']['caption'] = array(
    389                         'description' => __( 'The attachment caption.' ),
     389                        'description' => _l( 'The attachment caption.' ),
    390390                        'type'        => 'object',
    391391                        'context'     => array( 'view', 'edit', 'embed' ),
    392392                        'arg_options' => array(
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    395395                        ),
    396396                        'properties'  => array(
    397397                                'raw' => array(
    398                                         'description' => __( 'Caption for the attachment, as it exists in the database.' ),
     398                                        'description' => _l( 'Caption for the attachment, as it exists in the database.' ),
    399399                                        'type'        => 'string',
    400400                                        'context'     => array( 'edit' ),
    401401                                ),
    402402                                'rendered' => array(
    403                                         'description' => __( 'HTML caption for the attachment, transformed for display.' ),
     403                                        'description' => _l( 'HTML caption for the attachment, transformed for display.' ),
    404404                                        'type'        => 'string',
    405405                                        'context'     => array( 'view', 'edit', 'embed' ),
    406406                                        'readonly'    => true,
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    409409                );
    410410
    411411                $schema['properties']['description'] = array(
    412                         'description' => __( 'The attachment description.' ),
     412                        'description' => _l( 'The attachment description.' ),
    413413                        'type'        => 'object',
    414414                        'context'     => array( 'view', 'edit' ),
    415415                        'arg_options' => array(
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    418418                        ),
    419419                        'properties'  => array(
    420420                                'raw' => array(
    421                                         'description' => __( 'Description for the object, as it exists in the database.' ),
     421                                        'description' => _l( 'Description for the object, as it exists in the database.' ),
    422422                                        'type'        => 'string',
    423423                                        'context'     => array( 'edit' ),
    424424                                ),
    425425                                'rendered' => array(
    426                                         'description' => __( 'HTML description for the object, transformed for display.' ),
     426                                        'description' => _l( 'HTML description for the object, transformed for display.' ),
    427427                                        'type'        => 'string',
    428428                                        'context'     => array( 'view', 'edit' ),
    429429                                        'readonly'    => true,
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    432432                );
    433433
    434434                $schema['properties']['media_type'] = array(
    435                         'description'     => __( 'Attachment type.' ),
     435                        'description'     => _l( 'Attachment type.' ),
    436436                        'type'            => 'string',
    437437                        'enum'            => array( 'image', 'file' ),
    438438                        'context'         => array( 'view', 'edit', 'embed' ),
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    440440                );
    441441
    442442                $schema['properties']['mime_type'] = array(
    443                         'description'     => __( 'The attachment MIME type.' ),
     443                        'description'     => _l( 'The attachment MIME type.' ),
    444444                        'type'            => 'string',
    445445                        'context'         => array( 'view', 'edit', 'embed' ),
    446446                        'readonly'        => true,
    447447                );
    448448
    449449                $schema['properties']['media_details'] = array(
    450                         'description'     => __( 'Details about the media file, specific to its type.' ),
     450                        'description'     => _l( 'Details about the media file, specific to its type.' ),
    451451                        'type'            => 'object',
    452452                        'context'         => array( 'view', 'edit', 'embed' ),
    453453                        'readonly'        => true,
    454454                );
    455455
    456456                $schema['properties']['post'] = array(
    457                         'description'     => __( 'The ID for the associated post of the attachment.' ),
     457                        'description'     => _l( 'The ID for the associated post of the attachment.' ),
    458458                        'type'            => 'integer',
    459459                        'context'         => array( 'view', 'edit' ),
    460460                );
    461461
    462462                $schema['properties']['source_url'] = array(
    463                         'description'     => __( 'URL to the original attachment file.' ),
     463                        'description'     => _l( 'URL to the original attachment file.' ),
    464464                        'type'            => 'string',
    465465                        'format'          => 'uri',
    466466                        'context'         => array( 'view', 'edit', 'embed' ),
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    483483         */
    484484        protected function upload_from_data( $data, $headers ) {
    485485                if ( empty( $data ) ) {
    486                         return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) );
     486                        return new WP_Error( 'rest_upload_no_data', _l( 'No data supplied.' ), array( 'status' => 400 ) );
    487487                }
    488488
    489489                if ( empty( $headers['content_type'] ) ) {
    490                         return new WP_Error( 'rest_upload_no_content_type', __( 'No Content-Type supplied.' ), array( 'status' => 400 ) );
     490                        return new WP_Error( 'rest_upload_no_content_type', _l( 'No Content-Type supplied.' ), array( 'status' => 400 ) );
    491491                }
    492492
    493493                if ( empty( $headers['content_disposition'] ) ) {
    494                         return new WP_Error( 'rest_upload_no_content_disposition', __( 'No Content-Disposition supplied.' ), array( 'status' => 400 ) );
     494                        return new WP_Error( 'rest_upload_no_content_disposition', _l( 'No Content-Disposition supplied.' ), array( 'status' => 400 ) );
    495495                }
    496496
    497497                $filename = self::get_filename_from_disposition( $headers['content_disposition'] );
    498498
    499499                if ( empty( $filename ) ) {
    500                         return new WP_Error( 'rest_upload_invalid_disposition', __( 'Invalid Content-Disposition supplied. Content-Disposition needs to be formatted as `attachment; filename="image.png"` or similar.' ), array( 'status' => 400 ) );
     500                        return new WP_Error( 'rest_upload_invalid_disposition', _l( 'Invalid Content-Disposition supplied. Content-Disposition needs to be formatted as `attachment; filename="image.png"` or similar.' ), array( 'status' => 400 ) );
    501501                }
    502502
    503503                if ( ! empty( $headers['content_md5'] ) ) {
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    506506                        $actual      = md5( $data );
    507507
    508508                        if ( $expected !== $actual ) {
    509                                 return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
     509                                return new WP_Error( 'rest_upload_hash_mismatch', _l( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
    510510                        }
    511511                }
    512512
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    522522                $fp = fopen( $tmpfname, 'w+' );
    523523
    524524                if ( ! $fp ) {
    525                         return new WP_Error( 'rest_upload_file_error', __( 'Could not open file handle.' ), array( 'status' => 500 ) );
     525                        return new WP_Error( 'rest_upload_file_error', _l( 'Could not open file handle.' ), array( 'status' => 500 ) );
    526526                }
    527527
    528528                fwrite( $fp, $data );
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    636636
    637637                $params['media_type'] = array(
    638638                        'default'           => null,
    639                         'description'       => __( 'Limit result set to attachments of a particular media type.' ),
     639                        'description'       => _l( 'Limit result set to attachments of a particular media type.' ),
    640640                        'type'              => 'string',
    641641                        'enum'              => array_keys( $media_types ),
    642642                );
    643643
    644644                $params['mime_type'] = array(
    645645                        'default'     => null,
    646                         'description' => __( 'Limit result set to attachments of a particular MIME type.' ),
     646                        'description' => _l( 'Limit result set to attachments of a particular MIME type.' ),
    647647                        'type'        => 'string',
    648648                );
    649649
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    679679         */
    680680        protected function upload_from_file( $files, $headers ) {
    681681                if ( empty( $files ) ) {
    682                         return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) );
     682                        return new WP_Error( 'rest_upload_no_data', _l( 'No data supplied.' ), array( 'status' => 400 ) );
    683683                }
    684684
    685685                // Verify hash, if given.
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    689689                        $actual      = md5_file( $files['file']['tmp_name'] );
    690690
    691691                        if ( $expected !== $actual ) {
    692                                 return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
     692                                return new WP_Error( 'rest_upload_hash_mismatch', _l( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
    693693                        }
    694694                }
    695695
  • src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
    index 415ba8e9bc..ff62935da5 100644
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    6262                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    6363                        'args' => array(
    6464                                'id' => array(
    65                                         'description' => __( 'Unique identifier for the object.' ),
     65                                        'description' => _l( 'Unique identifier for the object.' ),
    6666                                        'type'        => 'integer',
    6767                                ),
    6868                        ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    7373                                'args'     => array(
    7474                                        'context'          => $this->get_context_param( array( 'default' => 'view' ) ),
    7575                                        'password' => array(
    76                                                 'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
     76                                                'description' => _l( 'The password for the parent post of the comment (if the post is password protected).' ),
    7777                                                'type'        => 'string',
    7878                                        ),
    7979                                ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    9292                                        'force'    => array(
    9393                                                'type'        => 'boolean',
    9494                                                'default'     => false,
    95                                                 'description' => __( 'Whether to bypass trash and force deletion.' ),
     95                                                'description' => _l( 'Whether to bypass trash and force deletion.' ),
    9696                                        ),
    9797                                        'password' => array(
    98                                                 'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
     98                                                'description' => _l( 'The password for the parent post of the comment (if the post is password protected).' ),
    9999                                                'type'        => 'string',
    100100                                        ),
    101101                                ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    119119                                $post = get_post( $post_id );
    120120
    121121                                if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post, $request ) ) {
    122                                         return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     122                                        return new WP_Error( 'rest_cannot_read_post', _l( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    123123                                } elseif ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) {
    124                                         return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) );
     124                                        return new WP_Error( 'rest_cannot_read', _l( 'Sorry, you are not allowed to read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) );
    125125                                }
    126126                        }
    127127                }
    128128
    129129                if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
    130                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
     130                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
    131131                }
    132132
    133133                if ( ! current_user_can( 'edit_posts' ) ) {
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    149149                        }
    150150
    151151                        if ( ! empty( $forbidden_params ) ) {
    152                                 return new WP_Error( 'rest_forbidden_param', sprintf( __( 'Query parameter not permitted: %s' ), implode( ', ', $forbidden_params ) ), array( 'status' => rest_authorization_required_code() ) );
     152                                return new WP_Error( 'rest_forbidden_param', sprintf( _l( 'Query parameter not permitted: %s' ), implode( ', ', $forbidden_params ) ), array( 'status' => rest_authorization_required_code() ) );
    153153                        }
    154154                }
    155155
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    309309         * @return WP_Comment|WP_Error Comment object if ID is valid, WP_Error otherwise.
    310310         */
    311311        protected function get_comment( $id ) {
    312                 $error = new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment ID.' ), array( 'status' => 404 ) );
     312                $error = new WP_Error( 'rest_comment_invalid_id', _l( 'Invalid comment ID.' ), array( 'status' => 404 ) );
    313313                if ( (int) $id <= 0 ) {
    314314                        return $error;
    315315                }
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    323323                if ( ! empty( $comment->comment_post_ID ) ) {
    324324                        $post = get_post( (int) $comment->comment_post_ID );
    325325                        if ( empty( $post ) ) {
    326                                 return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
     326                                return new WP_Error( 'rest_post_invalid_id', _l( 'Invalid post ID.' ), array( 'status' => 404 ) );
    327327                        }
    328328                }
    329329
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    345345                }
    346346
    347347                if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
    348                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
     348                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
    349349                }
    350350
    351351                $post = get_post( $comment->comment_post_ID );
    352352
    353353                if ( ! $this->check_read_permission( $comment, $request ) ) {
    354                         return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     354                        return new WP_Error( 'rest_cannot_read', _l( 'Sorry, you are not allowed to read this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    355355                }
    356356
    357357                if ( $post && ! $this->check_read_post_permission( $post, $request ) ) {
    358                         return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     358                        return new WP_Error( 'rest_cannot_read_post', _l( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    359359                }
    360360
    361361                return true;
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    392392        public function create_item_permissions_check( $request ) {
    393393                if ( ! is_user_logged_in() ) {
    394394                        if ( get_option( 'comment_registration' ) ) {
    395                                 return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
     395                                return new WP_Error( 'rest_comment_login_required', _l( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
    396396                        }
    397397
    398398                        /**
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    409409                         */
    410410                        $allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request );
    411411                        if ( ! $allow_anonymous ) {
    412                                 return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
     412                                return new WP_Error( 'rest_comment_login_required', _l( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
    413413                        }
    414414                }
    415415
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    417417                if ( isset( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( 'moderate_comments' ) ) {
    418418                        return new WP_Error( 'rest_comment_invalid_author',
    419419                                /* translators: %s: request parameter */
    420                                 sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author' ),
     420                                sprintf( _l( "Sorry, you are not allowed to edit '%s' for comments." ), 'author' ),
    421421                                array( 'status' => rest_authorization_required_code() )
    422422                        );
    423423                }
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    426426                        if ( empty( $_SERVER['REMOTE_ADDR'] ) || $request['author_ip'] !== $_SERVER['REMOTE_ADDR'] ) {
    427427                                return new WP_Error( 'rest_comment_invalid_author_ip',
    428428                                        /* translators: %s: request parameter */
    429                                         sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author_ip' ),
     429                                        sprintf( _l( "Sorry, you are not allowed to edit '%s' for comments." ), 'author_ip' ),
    430430                                        array( 'status' => rest_authorization_required_code() )
    431431                                );
    432432                        }
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    435435                if ( isset( $request['status'] ) && ! current_user_can( 'moderate_comments' ) ) {
    436436                        return new WP_Error( 'rest_comment_invalid_status',
    437437                                /* translators: %s: request parameter */
    438                                 sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'status' ),
     438                                sprintf( _l( "Sorry, you are not allowed to edit '%s' for comments." ), 'status' ),
    439439                                array( 'status' => rest_authorization_required_code() )
    440440                        );
    441441                }
    442442
    443443                if ( empty( $request['post'] ) ) {
    444                         return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) );
     444                        return new WP_Error( 'rest_comment_invalid_post_id', _l( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) );
    445445                }
    446446
    447447                $post = get_post( (int) $request['post'] );
    448448                if ( ! $post ) {
    449                         return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) );
     449                        return new WP_Error( 'rest_comment_invalid_post_id', _l( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) );
    450450                }
    451451
    452452                if ( 'draft' === $post->post_status ) {
    453                         return new WP_Error( 'rest_comment_draft_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
     453                        return new WP_Error( 'rest_comment_draft_post', _l( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
    454454                }
    455455
    456456                if ( 'trash' === $post->post_status ) {
    457                         return new WP_Error( 'rest_comment_trash_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
     457                        return new WP_Error( 'rest_comment_trash_post', _l( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
    458458                }
    459459
    460460                if ( ! $this->check_read_post_permission( $post, $request ) ) {
    461                         return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     461                        return new WP_Error( 'rest_cannot_read_post', _l( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    462462                }
    463463
    464464                if ( ! comments_open( $post->ID ) ) {
    465                         return new WP_Error( 'rest_comment_closed', __( 'Sorry, comments are closed for this item.' ), array( 'status' => 403 ) );
     465                        return new WP_Error( 'rest_comment_closed', _l( 'Sorry, comments are closed for this item.' ), array( 'status' => 403 ) );
    466466                }
    467467
    468468                return true;
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    478478         */
    479479        public function create_item( $request ) {
    480480                if ( ! empty( $request['id'] ) ) {
    481                         return new WP_Error( 'rest_comment_exists', __( 'Cannot create existing comment.' ), array( 'status' => 400 ) );
     481                        return new WP_Error( 'rest_comment_exists', _l( 'Cannot create existing comment.' ), array( 'status' => 400 ) );
    482482                }
    483483
    484484                // Do not allow comments to be created with a non-default type.
    485485                if ( ! empty( $request['type'] ) && 'comment' !== $request['type'] ) {
    486                         return new WP_Error( 'rest_invalid_comment_type', __( 'Cannot create a comment with that type.' ), array( 'status' => 400 ) );
     486                        return new WP_Error( 'rest_invalid_comment_type', _l( 'Cannot create a comment with that type.' ), array( 'status' => 400 ) );
    487487                }
    488488
    489489                $prepared_comment = $this->prepare_item_for_database( $request );
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    498498                 * comment_content. See wp_handle_comment_submission().
    499499                 */
    500500                if ( empty( $prepared_comment['comment_content'] ) ) {
    501                         return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) );
     501                        return new WP_Error( 'rest_comment_content_invalid', _l( 'Invalid comment content.' ), array( 'status' => 400 ) );
    502502                }
    503503
    504504                // Setting remaining values before wp_insert_comment so we can use wp_allow_comment().
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    524524                // Honor the discussion setting that requires a name and email address of the comment author.
    525525                if ( get_option( 'require_name_email' ) ) {
    526526                        if ( empty( $prepared_comment['comment_author'] ) || empty( $prepared_comment['comment_author_email'] ) ) {
    527                                 return new WP_Error( 'rest_comment_author_data_required', __( 'Creating a comment requires valid author name and email values.' ), array( 'status' => 400 ) );
     527                                return new WP_Error( 'rest_comment_author_data_required', _l( 'Creating a comment requires valid author name and email values.' ), array( 'status' => 400 ) );
    528528                        }
    529529                }
    530530
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    543543                $check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_comment );
    544544                if ( is_wp_error( $check_comment_lengths ) ) {
    545545                        $error_code = $check_comment_lengths->get_error_code();
    546                         return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
     546                        return new WP_Error( $error_code, _l( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
    547547                }
    548548
    549549                $prepared_comment['comment_approved'] = wp_allow_comment( $prepared_comment, true );
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    584584                $comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) );
    585585
    586586                if ( ! $comment_id ) {
    587                         return new WP_Error( 'rest_comment_failed_create', __( 'Creating comment failed.' ), array( 'status' => 500 ) );
     587                        return new WP_Error( 'rest_comment_failed_create', _l( 'Creating comment failed.' ), array( 'status' => 500 ) );
    588588                }
    589589
    590590                if ( isset( $request['status'] ) ) {
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    650650                }
    651651
    652652                if ( ! $this->check_edit_permission( $comment ) ) {
    653                         return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     653                        return new WP_Error( 'rest_cannot_edit', _l( 'Sorry, you are not allowed to edit this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    654654                }
    655655
    656656                return true;
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    673673                $id = $comment->comment_ID;
    674674
    675675                if ( isset( $request['type'] ) && get_comment_type( $id ) !== $request['type'] ) {
    676                         return new WP_Error( 'rest_comment_invalid_type', __( 'Sorry, you are not allowed to change the comment type.' ), array( 'status' => 404 ) );
     676                        return new WP_Error( 'rest_comment_invalid_type', _l( 'Sorry, you are not allowed to change the comment type.' ), array( 'status' => 404 ) );
    677677                }
    678678
    679679                $prepared_args = $this->prepare_item_for_database( $request );
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    685685                if ( ! empty( $prepared_args['comment_post_ID'] ) ) {
    686686                        $post = get_post( $prepared_args['comment_post_ID'] );
    687687                        if ( empty( $post ) ) {
    688                                 return new WP_Error( 'rest_comment_invalid_post_id', __( 'Invalid post ID.' ), array( 'status' => 403 ) );
     688                                return new WP_Error( 'rest_comment_invalid_post_id', _l( 'Invalid post ID.' ), array( 'status' => 403 ) );
    689689                        }
    690690                }
    691691
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    694694                        $change = $this->handle_status_param( $request['status'], $id );
    695695
    696696                        if ( ! $change ) {
    697                                 return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment status failed.' ), array( 'status' => 500 ) );
     697                                return new WP_Error( 'rest_comment_failed_edit', _l( 'Updating comment status failed.' ), array( 'status' => 500 ) );
    698698                        }
    699699                } elseif ( ! empty( $prepared_args ) ) {
    700700                        if ( is_wp_error( $prepared_args ) ) {
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    702702                        }
    703703
    704704                        if ( isset( $prepared_args['comment_content'] ) && empty( $prepared_args['comment_content'] ) ) {
    705                                 return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) );
     705                                return new WP_Error( 'rest_comment_content_invalid', _l( 'Invalid comment content.' ), array( 'status' => 400 ) );
    706706                        }
    707707
    708708                        $prepared_args['comment_ID'] = $id;
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    710710                        $check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_args );
    711711                        if ( is_wp_error( $check_comment_lengths ) ) {
    712712                                $error_code = $check_comment_lengths->get_error_code();
    713                                 return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
     713                                return new WP_Error( $error_code, _l( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
    714714                        }
    715715
    716716                        $updated = wp_update_comment( wp_slash( (array) $prepared_args ) );
    717717
    718718                        if ( false === $updated ) {
    719                                 return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment failed.' ), array( 'status' => 500 ) );
     719                                return new WP_Error( 'rest_comment_failed_edit', _l( 'Updating comment failed.' ), array( 'status' => 500 ) );
    720720                        }
    721721
    722722                        if ( isset( $request['status'] ) ) {
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    767767                }
    768768
    769769                if ( ! $this->check_edit_permission( $comment ) ) {
    770                         return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     770                        return new WP_Error( 'rest_cannot_delete', _l( 'Sorry, you are not allowed to delete this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    771771                }
    772772                return true;
    773773        }
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    811811                        // If this type doesn't support trashing, error out.
    812812                        if ( ! $supports_trash ) {
    813813                                /* translators: %s: force=true */
    814                                 return new WP_Error( 'rest_trash_not_supported', sprintf( __( "The comment does not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
     814                                return new WP_Error( 'rest_trash_not_supported', sprintf( _l( "The comment does not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
    815815                        }
    816816
    817817                        if ( 'trash' === $comment->comment_approved ) {
    818                                 return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.' ), array( 'status' => 410 ) );
     818                                return new WP_Error( 'rest_already_trashed', _l( 'The comment has already been trashed.' ), array( 'status' => 410 ) );
    819819                        }
    820820
    821821                        $result = wp_trash_comment( $comment->comment_ID );
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    824824                }
    825825
    826826                if ( ! $result ) {
    827                         return new WP_Error( 'rest_cannot_delete', __( 'The comment cannot be deleted.' ), array( 'status' => 500 ) );
     827                        return new WP_Error( 'rest_cannot_delete', _l( 'The comment cannot be deleted.' ), array( 'status' => 500 ) );
    828828                }
    829829
    830830                /**
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    10751075                                $prepared_comment['comment_author_email'] = $user->user_email;
    10761076                                $prepared_comment['comment_author_url'] = $user->user_url;
    10771077                        } else {
    1078                                 return new WP_Error( 'rest_comment_author_invalid', __( 'Invalid comment author ID.' ), array( 'status' => 400 ) );
     1078                                return new WP_Error( 'rest_comment_author_invalid', _l( 'Invalid comment author ID.' ), array( 'status' => 400 ) );
    10791079                        }
    10801080                }
    10811081
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11461146                        'type'                 => 'object',
    11471147                        'properties'           => array(
    11481148                                'id'               => array(
    1149                                         'description'  => __( 'Unique identifier for the object.' ),
     1149                                        'description'  => _l( 'Unique identifier for the object.' ),
    11501150                                        'type'         => 'integer',
    11511151                                        'context'      => array( 'view', 'edit', 'embed' ),
    11521152                                        'readonly'     => true,
    11531153                                ),
    11541154                                'author'           => array(
    1155                                         'description'  => __( 'The ID of the user object, if author was a user.' ),
     1155                                        'description'  => _l( 'The ID of the user object, if author was a user.' ),
    11561156                                        'type'         => 'integer',
    11571157                                        'context'      => array( 'view', 'edit', 'embed' ),
    11581158                                ),
    11591159                                'author_email'     => array(
    1160                                         'description'  => __( 'Email address for the object author.' ),
     1160                                        'description'  => _l( 'Email address for the object author.' ),
    11611161                                        'type'         => 'string',
    11621162                                        'format'       => 'email',
    11631163                                        'context'      => array( 'edit' ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11671167                                        ),
    11681168                                ),
    11691169                                'author_ip'     => array(
    1170                                         'description'  => __( 'IP address for the object author.' ),
     1170                                        'description'  => _l( 'IP address for the object author.' ),
    11711171                                        'type'         => 'string',
    11721172                                        'format'       => 'ip',
    11731173                                        'context'      => array( 'edit' ),
    11741174                                ),
    11751175                                'author_name'     => array(
    1176                                         'description'  => __( 'Display name for the object author.' ),
     1176                                        'description'  => _l( 'Display name for the object author.' ),
    11771177                                        'type'         => 'string',
    11781178                                        'context'      => array( 'view', 'edit', 'embed' ),
    11791179                                        'arg_options'  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11811181                                        ),
    11821182                                ),
    11831183                                'author_url'       => array(
    1184                                         'description'  => __( 'URL for the object author.' ),
     1184                                        'description'  => _l( 'URL for the object author.' ),
    11851185                                        'type'         => 'string',
    11861186                                        'format'       => 'uri',
    11871187                                        'context'      => array( 'view', 'edit', 'embed' ),
    11881188                                ),
    11891189                                'author_user_agent'     => array(
    1190                                         'description'  => __( 'User agent for the object author.' ),
     1190                                        'description'  => _l( 'User agent for the object author.' ),
    11911191                                        'type'         => 'string',
    11921192                                        'context'      => array( 'edit' ),
    11931193                                        'arg_options'  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11951195                                        ),
    11961196                                ),
    11971197                                'content'          => array(
    1198                                         'description'     => __( 'The content for the object.' ),
     1198                                        'description'     => _l( 'The content for the object.' ),
    11991199                                        'type'            => 'object',
    12001200                                        'context'         => array( 'view', 'edit', 'embed' ),
    12011201                                        'arg_options'     => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12041204                                        ),
    12051205                                        'properties'      => array(
    12061206                                                'raw'         => array(
    1207                                                         'description'     => __( 'Content for the object, as it exists in the database.' ),
     1207                                                        'description'     => _l( 'Content for the object, as it exists in the database.' ),
    12081208                                                        'type'            => 'string',
    12091209                                                        'context'         => array( 'edit' ),
    12101210                                                ),
    12111211                                                'rendered'    => array(
    1212                                                         'description'     => __( 'HTML content for the object, transformed for display.' ),
     1212                                                        'description'     => _l( 'HTML content for the object, transformed for display.' ),
    12131213                                                        'type'            => 'string',
    12141214                                                        'context'         => array( 'view', 'edit', 'embed' ),
    12151215                                                        'readonly'        => true,
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12171217                                        ),
    12181218                                ),
    12191219                                'date'             => array(
    1220                                         'description'  => __( "The date the object was published, in the site's timezone." ),
     1220                                        'description'  => _l( "The date the object was published, in the site's timezone." ),
    12211221                                        'type'         => 'string',
    12221222                                        'format'       => 'date-time',
    12231223                                        'context'      => array( 'view', 'edit', 'embed' ),
    12241224                                ),
    12251225                                'date_gmt'         => array(
    1226                                         'description'  => __( 'The date the object was published, as GMT.' ),
     1226                                        'description'  => _l( 'The date the object was published, as GMT.' ),
    12271227                                        'type'         => 'string',
    12281228                                        'format'       => 'date-time',
    12291229                                        'context'      => array( 'view', 'edit' ),
    12301230                                ),
    12311231                                'link'             => array(
    1232                                         'description'  => __( 'URL to the object.' ),
     1232                                        'description'  => _l( 'URL to the object.' ),
    12331233                                        'type'         => 'string',
    12341234                                        'format'       => 'uri',
    12351235                                        'context'      => array( 'view', 'edit', 'embed' ),
    12361236                                        'readonly'     => true,
    12371237                                ),
    12381238                                'parent'           => array(
    1239                                         'description'  => __( 'The ID for the parent of the object.' ),
     1239                                        'description'  => _l( 'The ID for the parent of the object.' ),
    12401240                                        'type'         => 'integer',
    12411241                                        'context'      => array( 'view', 'edit', 'embed' ),
    12421242                                        'default'      => 0,
    12431243                                ),
    12441244                                'post'             => array(
    1245                                         'description'  => __( 'The ID of the associated post object.' ),
     1245                                        'description'  => _l( 'The ID of the associated post object.' ),
    12461246                                        'type'         => 'integer',
    12471247                                        'context'      => array( 'view', 'edit' ),
    12481248                                        'default'      => 0,
    12491249                                ),
    12501250                                'status'           => array(
    1251                                         'description'  => __( 'State of the object.' ),
     1251                                        'description'  => _l( 'State of the object.' ),
    12521252                                        'type'         => 'string',
    12531253                                        'context'      => array( 'view', 'edit' ),
    12541254                                        'arg_options'  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12561256                                        ),
    12571257                                ),
    12581258                                'type'             => array(
    1259                                         'description'  => __( 'Type of Comment for the object.' ),
     1259                                        'description'  => _l( 'Type of Comment for the object.' ),
    12601260                                        'type'         => 'string',
    12611261                                        'context'      => array( 'view', 'edit', 'embed' ),
    12621262                                        'readonly'     => true,
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12711271                        foreach ( $avatar_sizes as $size ) {
    12721272                                $avatar_properties[ $size ] = array(
    12731273                                        /* translators: %d: avatar image size in pixels */
    1274                                         'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' ), $size ),
     1274                                        'description' => sprintf( _l( 'Avatar URL with image size of %d pixels.' ), $size ),
    12751275                                        'type'        => 'string',
    12761276                                        'format'      => 'uri',
    12771277                                        'context'     => array( 'embed', 'view', 'edit' ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12791279                        }
    12801280
    12811281                        $schema['properties']['author_avatar_urls'] = array(
    1282                                 'description'   => __( 'Avatar URLs for the object author.' ),
     1282                                'description'   => _l( 'Avatar URLs for the object author.' ),
    12831283                                'type'          => 'object',
    12841284                                'context'       => array( 'view', 'edit', 'embed' ),
    12851285                                'readonly'      => true,
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13051305                $query_params['context']['default'] = 'view';
    13061306
    13071307                $query_params['after'] = array(
    1308                         'description'       => __( 'Limit response to comments published after a given ISO8601 compliant date.' ),
     1308                        'description'       => _l( 'Limit response to comments published after a given ISO8601 compliant date.' ),
    13091309                        'type'              => 'string',
    13101310                        'format'            => 'date-time',
    13111311                );
    13121312
    13131313                $query_params['author'] = array(
    1314                         'description'       => __( 'Limit result set to comments assigned to specific user IDs. Requires authorization.' ),
     1314                        'description'       => _l( 'Limit result set to comments assigned to specific user IDs. Requires authorization.' ),
    13151315                        'type'              => 'array',
    13161316                        'items'             => array(
    13171317                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13191319                );
    13201320
    13211321                $query_params['author_exclude'] = array(
    1322                         'description'       => __( 'Ensure result set excludes comments assigned to specific user IDs. Requires authorization.' ),
     1322                        'description'       => _l( 'Ensure result set excludes comments assigned to specific user IDs. Requires authorization.' ),
    13231323                        'type'              => 'array',
    13241324                        'items'             => array(
    13251325                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13281328
    13291329                $query_params['author_email'] = array(
    13301330                        'default'           => null,
    1331                         'description'       => __( 'Limit result set to that from a specific author email. Requires authorization.' ),
     1331                        'description'       => _l( 'Limit result set to that from a specific author email. Requires authorization.' ),
    13321332                        'format'            => 'email',
    13331333                        'type'              => 'string',
    13341334                );
    13351335
    13361336                $query_params['before'] = array(
    1337                         'description'       => __( 'Limit response to comments published before a given ISO8601 compliant date.' ),
     1337                        'description'       => _l( 'Limit response to comments published before a given ISO8601 compliant date.' ),
    13381338                        'type'              => 'string',
    13391339                        'format'            => 'date-time',
    13401340                );
    13411341
    13421342                $query_params['exclude'] = array(
    1343                         'description'        => __( 'Ensure result set excludes specific IDs.' ),
     1343                        'description'        => _l( 'Ensure result set excludes specific IDs.' ),
    13441344                        'type'               => 'array',
    13451345                        'items'              => array(
    13461346                                'type'           => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13491349                );
    13501350
    13511351                $query_params['include'] = array(
    1352                         'description'        => __( 'Limit result set to specific IDs.' ),
     1352                        'description'        => _l( 'Limit result set to specific IDs.' ),
    13531353                        'type'               => 'array',
    13541354                        'items'              => array(
    13551355                                'type'           => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13581358                );
    13591359
    13601360                $query_params['offset'] = array(
    1361                         'description'        => __( 'Offset the result set by a specific number of items.' ),
     1361                        'description'        => _l( 'Offset the result set by a specific number of items.' ),
    13621362                        'type'               => 'integer',
    13631363                );
    13641364
    13651365                $query_params['order']      = array(
    1366                         'description'           => __( 'Order sort attribute ascending or descending.' ),
     1366                        'description'           => _l( 'Order sort attribute ascending or descending.' ),
    13671367                        'type'                  => 'string',
    13681368                        'default'               => 'desc',
    13691369                        'enum'                  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13731373                );
    13741374
    13751375                $query_params['orderby']    = array(
    1376                         'description'           => __( 'Sort collection by object attribute.' ),
     1376                        'description'           => _l( 'Sort collection by object attribute.' ),
    13771377                        'type'                  => 'string',
    13781378                        'default'               => 'date_gmt',
    13791379                        'enum'                  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13891389
    13901390                $query_params['parent'] = array(
    13911391                        'default'           => array(),
    1392                         'description'       => __( 'Limit result set to comments of specific parent IDs.' ),
     1392                        'description'       => _l( 'Limit result set to comments of specific parent IDs.' ),
    13931393                        'type'              => 'array',
    13941394                        'items'             => array(
    13951395                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13981398
    13991399                $query_params['parent_exclude'] = array(
    14001400                        'default'           => array(),
    1401                         'description'       => __( 'Ensure result set excludes specific parent IDs.' ),
     1401                        'description'       => _l( 'Ensure result set excludes specific parent IDs.' ),
    14021402                        'type'              => 'array',
    14031403                        'items'             => array(
    14041404                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    14071407
    14081408                $query_params['post']   = array(
    14091409                        'default'           => array(),
    1410                         'description'       => __( 'Limit result set to comments assigned to specific post IDs.' ),
     1410                        'description'       => _l( 'Limit result set to comments assigned to specific post IDs.' ),
    14111411                        'type'              => 'array',
    14121412                        'items'             => array(
    14131413                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    14161416
    14171417                $query_params['status'] = array(
    14181418                        'default'           => 'approve',
    1419                         'description'       => __( 'Limit result set to comments assigned a specific status. Requires authorization.' ),
     1419                        'description'       => _l( 'Limit result set to comments assigned a specific status. Requires authorization.' ),
    14201420                        'sanitize_callback' => 'sanitize_key',
    14211421                        'type'              => 'string',
    14221422                        'validate_callback' => 'rest_validate_request_arg',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    14241424
    14251425                $query_params['type'] = array(
    14261426                        'default'           => 'comment',
    1427                         'description'       => __( 'Limit result set to comments assigned a specific type. Requires authorization.' ),
     1427                        'description'       => _l( 'Limit result set to comments assigned a specific type. Requires authorization.' ),
    14281428                        'sanitize_callback' => 'sanitize_key',
    14291429                        'type'              => 'string',
    14301430                        'validate_callback' => 'rest_validate_request_arg',
    14311431                );
    14321432
    14331433                $query_params['password'] = array(
    1434                         'description' => __( 'The password for the post if it is password protected.' ),
     1434                        'description' => _l( 'The password for the post if it is password protected.' ),
    14351435                        'type'        => 'string',
    14361436                );
    14371437
  • src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
    index 78c3567147..c93b2b53b3 100644
    abstract class WP_REST_Controller { 
    3737         */
    3838        public function register_routes() {
    3939                /* translators: %s: register_routes() */
    40                 _doing_it_wrong( 'WP_REST_Controller::register_routes', sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ), '4.7' );
     40                _doing_it_wrong( 'WP_REST_Controller::register_routes', sprintf( _l( "Method '%s' must be overridden." ), __METHOD__ ), '4.7' );
    4141        }
    4242
    4343        /**
    abstract class WP_REST_Controller { 
    5050         */
    5151        public function get_items_permissions_check( $request ) {
    5252                /* translators: %s: method name */
    53                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     53                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    5454        }
    5555
    5656        /**
    abstract class WP_REST_Controller { 
    6363         */
    6464        public function get_items( $request ) {
    6565                /* translators: %s: method name */
    66                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     66                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    6767        }
    6868
    6969        /**
    abstract class WP_REST_Controller { 
    7676         */
    7777        public function get_item_permissions_check( $request ) {
    7878                /* translators: %s: method name */
    79                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     79                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    8080        }
    8181
    8282        /**
    abstract class WP_REST_Controller { 
    8989         */
    9090        public function get_item( $request ) {
    9191                /* translators: %s: method name */
    92                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     92                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    9393        }
    9494
    9595        /**
    abstract class WP_REST_Controller { 
    102102         */
    103103        public function create_item_permissions_check( $request ) {
    104104                /* translators: %s: method name */
    105                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     105                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    106106        }
    107107
    108108        /**
    abstract class WP_REST_Controller { 
    115115         */
    116116        public function create_item( $request ) {
    117117                /* translators: %s: method name */
    118                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     118                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    119119        }
    120120
    121121        /**
    abstract class WP_REST_Controller { 
    128128         */
    129129        public function update_item_permissions_check( $request ) {
    130130                /* translators: %s: method name */
    131                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     131                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    132132        }
    133133
    134134        /**
    abstract class WP_REST_Controller { 
    141141         */
    142142        public function update_item( $request ) {
    143143                /* translators: %s: method name */
    144                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     144                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    145145        }
    146146
    147147        /**
    abstract class WP_REST_Controller { 
    154154         */
    155155        public function delete_item_permissions_check( $request ) {
    156156                /* translators: %s: method name */
    157                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     157                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    158158        }
    159159
    160160        /**
    abstract class WP_REST_Controller { 
    167167         */
    168168        public function delete_item( $request ) {
    169169                /* translators: %s: method name */
    170                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     170                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    171171        }
    172172
    173173        /**
    abstract class WP_REST_Controller { 
    180180         */
    181181        protected function prepare_item_for_database( $request ) {
    182182                /* translators: %s: method name */
    183                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     183                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    184184        }
    185185
    186186        /**
    abstract class WP_REST_Controller { 
    194194         */
    195195        public function prepare_item_for_response( $item, $request ) {
    196196                /* translators: %s: method name */
    197                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     197                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    198198        }
    199199
    200200        /**
    abstract class WP_REST_Controller { 
    307307                return array(
    308308                        'context'                => $this->get_context_param(),
    309309                        'page'                   => array(
    310                                 'description'        => __( 'Current page of the collection.' ),
     310                                'description'        => _l( 'Current page of the collection.' ),
    311311                                'type'               => 'integer',
    312312                                'default'            => 1,
    313313                                'sanitize_callback'  => 'absint',
    abstract class WP_REST_Controller { 
    315315                                'minimum'            => 1,
    316316                        ),
    317317                        'per_page'               => array(
    318                                 'description'        => __( 'Maximum number of items to be returned in result set.' ),
     318                                'description'        => _l( 'Maximum number of items to be returned in result set.' ),
    319319                                'type'               => 'integer',
    320320                                'default'            => 10,
    321321                                'minimum'            => 1,
    abstract class WP_REST_Controller { 
    324324                                'validate_callback'  => 'rest_validate_request_arg',
    325325                        ),
    326326                        'search'                 => array(
    327                                 'description'        => __( 'Limit results to those matching a string.' ),
     327                                'description'        => _l( 'Limit results to those matching a string.' ),
    328328                                'type'               => 'string',
    329329                                'sanitize_callback'  => 'sanitize_text_field',
    330330                                'validate_callback'  => 'rest_validate_request_arg',
    abstract class WP_REST_Controller { 
    344344         */
    345345        public function get_context_param( $args = array() ) {
    346346                $param_details = array(
    347                         'description'        => __( 'Scope under which the request is made; determines fields present in response.' ),
     347                        'description'        => _l( 'Scope under which the request is made; determines fields present in response.' ),
    348348                        'type'               => 'string',
    349349                        'sanitize_callback'  => 'sanitize_key',
    350350                        'validate_callback'  => 'rest_validate_request_arg',
  • src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php
    index 369cf3c757..27afb7c703 100644
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    4848                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<status>[\w-]+)', array(
    4949                        'args' => array(
    5050                                'status' => array(
    51                                         'description' => __( 'An alphanumeric identifier for the status.' ),
     51                                        'description' => _l( 'An alphanumeric identifier for the status.' ),
    5252                                        'type'        => 'string',
    5353                                ),
    5454                        ),
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    8181                                        return true;
    8282                                }
    8383                        }
    84                         return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
     84                        return new WP_Error( 'rest_cannot_view', _l( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
    8585                }
    8686
    8787                return true;
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    126126                $status = get_post_status_object( $request['status'] );
    127127
    128128                if ( empty( $status ) ) {
    129                         return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) );
     129                        return new WP_Error( 'rest_status_invalid', _l( 'Invalid status.' ), array( 'status' => 404 ) );
    130130                }
    131131
    132132                $check = $this->check_read_permission( $status );
    133133
    134134                if ( ! $check ) {
    135                         return new WP_Error( 'rest_cannot_read_status', __( 'Cannot view status.' ), array( 'status' => rest_authorization_required_code() ) );
     135                        return new WP_Error( 'rest_cannot_read_status', _l( 'Cannot view status.' ), array( 'status' => rest_authorization_required_code() ) );
    136136                }
    137137
    138138                return true;
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    176176                $obj = get_post_status_object( $request['status'] );
    177177
    178178                if ( empty( $obj ) ) {
    179                         return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) );
     179                        return new WP_Error( 'rest_status_invalid', _l( 'Invalid status.' ), array( 'status' => 404 ) );
    180180                }
    181181
    182182                $data = $this->prepare_item_for_response( $obj, $request );
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    245245                        'type'                 => 'object',
    246246                        'properties'           => array(
    247247                                'name'             => array(
    248                                         'description'  => __( 'The title for the status.' ),
     248                                        'description'  => _l( 'The title for the status.' ),
    249249                                        'type'         => 'string',
    250250                                        'context'      => array( 'embed', 'view', 'edit' ),
    251251                                        'readonly'     => true,
    252252                                ),
    253253                                'private'          => array(
    254                                         'description'  => __( 'Whether posts with this status should be private.' ),
     254                                        'description'  => _l( 'Whether posts with this status should be private.' ),
    255255                                        'type'         => 'boolean',
    256256                                        'context'      => array( 'edit' ),
    257257                                        'readonly'     => true,
    258258                                ),
    259259                                'protected'        => array(
    260                                         'description'  => __( 'Whether posts with this status should be protected.' ),
     260                                        'description'  => _l( 'Whether posts with this status should be protected.' ),
    261261                                        'type'         => 'boolean',
    262262                                        'context'      => array( 'edit' ),
    263263                                        'readonly'     => true,
    264264                                ),
    265265                                'public'           => array(
    266                                         'description'  => __( 'Whether posts of this status should be shown in the front end of the site.' ),
     266                                        'description'  => _l( 'Whether posts of this status should be shown in the front end of the site.' ),
    267267                                        'type'         => 'boolean',
    268268                                        'context'      => array( 'view', 'edit' ),
    269269                                        'readonly'     => true,
    270270                                ),
    271271                                'queryable'        => array(
    272                                         'description'  => __( 'Whether posts with this status should be publicly-queryable.' ),
     272                                        'description'  => _l( 'Whether posts with this status should be publicly-queryable.' ),
    273273                                        'type'         => 'boolean',
    274274                                        'context'      => array( 'view', 'edit' ),
    275275                                        'readonly'     => true,
    276276                                ),
    277277                                'show_in_list'     => array(
    278                                         'description'  => __( 'Whether to include posts in the edit listing for their post type.' ),
     278                                        'description'  => _l( 'Whether to include posts in the edit listing for their post type.' ),
    279279                                        'type'         => 'boolean',
    280280                                        'context'      => array( 'edit' ),
    281281                                        'readonly'     => true,
    282282                                ),
    283283                                'slug'             => array(
    284                                         'description'  => __( 'An alphanumeric identifier for the status.' ),
     284                                        'description'  => _l( 'An alphanumeric identifier for the status.' ),
    285285                                        'type'         => 'string',
    286286                                        'context'      => array( 'embed', 'view', 'edit' ),
    287287                                        'readonly'     => true,
  • src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
    index c4571d9721..6840fd1de7 100644
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    4848                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<type>[\w-]+)', array(
    4949                        'args' => array(
    5050                                'type' => array(
    51                                         'description' => __( 'An alphanumeric identifier for the post type.' ),
     51                                        'description' => _l( 'An alphanumeric identifier for the post type.' ),
    5252                                        'type'        => 'string',
    5353                                ),
    5454                        ),
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    7979                                }
    8080                        }
    8181
    82                         return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
     82                        return new WP_Error( 'rest_cannot_view', _l( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
    8383                }
    8484
    8585                return true;
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    120120                $obj = get_post_type_object( $request['type'] );
    121121
    122122                if ( empty( $obj ) ) {
    123                         return new WP_Error( 'rest_type_invalid', __( 'Invalid post type.' ), array( 'status' => 404 ) );
     123                        return new WP_Error( 'rest_type_invalid', _l( 'Invalid post type.' ), array( 'status' => 404 ) );
    124124                }
    125125
    126126                if ( empty( $obj->show_in_rest ) ) {
    127                         return new WP_Error( 'rest_cannot_read_type', __( 'Cannot view post type.' ), array( 'status' => rest_authorization_required_code() ) );
     127                        return new WP_Error( 'rest_cannot_read_type', _l( 'Cannot view post type.' ), array( 'status' => rest_authorization_required_code() ) );
    128128                }
    129129
    130130                if ( 'edit' === $request['context'] && ! current_user_can( $obj->cap->edit_posts ) ) {
    131                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
     131                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
    132132                }
    133133
    134134                $data = $this->prepare_item_for_response( $obj, $request );
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    206206                        'type'                 => 'object',
    207207                        'properties'           => array(
    208208                                'capabilities'     => array(
    209                                         'description'  => __( 'All capabilities used by the post type.' ),
     209                                        'description'  => _l( 'All capabilities used by the post type.' ),
    210210                                        'type'         => 'object',
    211211                                        'context'      => array( 'edit' ),
    212212                                        'readonly'     => true,
    213213                                ),
    214214                                'description'      => array(
    215                                         'description'  => __( 'A human-readable description of the post type.' ),
     215                                        'description'  => _l( 'A human-readable description of the post type.' ),
    216216                                        'type'         => 'string',
    217217                                        'context'      => array( 'view', 'edit' ),
    218218                                        'readonly'     => true,
    219219                                ),
    220220                                'hierarchical'     => array(
    221                                         'description'  => __( 'Whether or not the post type should have children.' ),
     221                                        'description'  => _l( 'Whether or not the post type should have children.' ),
    222222                                        'type'         => 'boolean',
    223223                                        'context'      => array( 'view', 'edit' ),
    224224                                        'readonly'     => true,
    225225                                ),
    226226                                'labels'           => array(
    227                                         'description'  => __( 'Human-readable labels for the post type for various contexts.' ),
     227                                        'description'  => _l( 'Human-readable labels for the post type for various contexts.' ),
    228228                                        'type'         => 'object',
    229229                                        'context'      => array( 'edit' ),
    230230                                        'readonly'     => true,
    231231                                ),
    232232                                'name'             => array(
    233                                         'description'  => __( 'The title for the post type.' ),
     233                                        'description'  => _l( 'The title for the post type.' ),
    234234                                        'type'         => 'string',
    235235                                        'context'      => array( 'view', 'edit', 'embed' ),
    236236                                        'readonly'     => true,
    237237                                ),
    238238                                'slug'             => array(
    239                                         'description'  => __( 'An alphanumeric identifier for the post type.' ),
     239                                        'description'  => _l( 'An alphanumeric identifier for the post type.' ),
    240240                                        'type'         => 'string',
    241241                                        'context'      => array( 'view', 'edit', 'embed' ),
    242242                                        'readonly'     => true,
    243243                                ),
    244244                                'supports'         => array(
    245                                         'description'  => __( 'All features, supported by the post type.' ),
     245                                        'description'  => _l( 'All features, supported by the post type.' ),
    246246                                        'type'         => 'object',
    247247                                        'context'      => array( 'edit' ),
    248248                                        'readonly'     => true,
    249249                                ),
    250250                                'taxonomies'       => array(
    251                                         'description'  => __( 'Taxonomies associated with post type.' ),
     251                                        'description'  => _l( 'Taxonomies associated with post type.' ),
    252252                                        'type'         => 'array',
    253253                                        'items'        => array(
    254254                                                'type' => 'string',
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    257257                                        'readonly'     => true,
    258258                                ),
    259259                                'rest_base'            => array(
    260                                         'description'  => __( 'REST base route for the post type.' ),
     260                                        'description'  => _l( 'REST base route for the post type.' ),
    261261                                        'type'         => 'string',
    262262                                        'context'      => array( 'view', 'edit', 'embed' ),
    263263                                        'readonly'     => true,
  • src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
    index 80027cfea8..4522ef4bf8 100644
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    7979                );
    8080                if ( isset( $schema['properties']['password'] ) ) {
    8181                        $get_item_args['password'] = array(
    82                                 'description' => __( 'The password for the post if it is password protected.' ),
     82                                'description' => _l( 'The password for the post if it is password protected.' ),
    8383                                'type'        => 'string',
    8484                        );
    8585                }
    8686                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    8787                        'args' => array(
    8888                                'id' => array(
    89                                         'description' => __( 'Unique identifier for the object.' ),
     89                                        'description' => _l( 'Unique identifier for the object.' ),
    9090                                        'type'        => 'integer',
    9191                                ),
    9292                        ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    110110                                        'force' => array(
    111111                                                'type'        => 'boolean',
    112112                                                'default'     => false,
    113                                                 'description' => __( 'Whether to bypass trash and force deletion.' ),
     113                                                'description' => _l( 'Whether to bypass trash and force deletion.' ),
    114114                                        ),
    115115                                ),
    116116                        ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    131131                $post_type = get_post_type_object( $this->post_type );
    132132
    133133                if ( 'edit' === $request['context'] && ! current_user_can( $post_type->cap->edit_posts ) ) {
    134                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
     134                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
    135135                }
    136136
    137137                return true;
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    149149
    150150                // Ensure a search string is set in case the orderby is set to 'relevance'.
    151151                if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) ) {
    152                         return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) );
     152                        return new WP_Error( 'rest_no_search_term_defined', _l( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) );
    153153                }
    154154
    155155                // Ensure an include parameter is set in case the orderby is set to 'include'.
    156156                if ( ! empty( $request['orderby'] ) && 'include' === $request['orderby'] && empty( $request['include'] ) ) {
    157                         return new WP_Error( 'rest_orderby_include_missing_include', __( 'You need to define an include parameter to order by include.' ), array( 'status' => 400 ) );
     157                        return new WP_Error( 'rest_orderby_include_missing_include', _l( 'You need to define an include parameter to order by include.' ), array( 'status' => 400 ) );
    158158                }
    159159
    160160                // Retrieve the list of registered collection query parameters.
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    326326                $max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] );
    327327
    328328                if ( $page > $max_pages && $total_posts > 0 ) {
    329                         return new WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) );
     329                        return new WP_Error( 'rest_post_invalid_page_number', _l( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) );
    330330                }
    331331
    332332                $response  = rest_ensure_response( $posts );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    366366         * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.
    367367         */
    368368        protected function get_post( $id ) {
    369                 $error = new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
     369                $error = new WP_Error( 'rest_post_invalid_id', _l( 'Invalid post ID.' ), array( 'status' => 404 ) );
    370370                if ( (int) $id <= 0 ) {
    371371                        return $error;
    372372                }
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    394394                }
    395395
    396396                if ( 'edit' === $request['context'] && $post && ! $this->check_update_permission( $post ) ) {
    397                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
     397                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
    398398                }
    399399
    400400                if ( $post && ! empty( $request['password'] ) ) {
    401401                        // Check post password, and return error if invalid.
    402402                        if ( ! hash_equals( $post->post_password, $request['password'] ) ) {
    403                                 return new WP_Error( 'rest_post_incorrect_password', __( 'Incorrect post password.' ), array( 'status' => 403 ) );
     403                                return new WP_Error( 'rest_post_incorrect_password', _l( 'Incorrect post password.' ), array( 'status' => 403 ) );
    404404                        }
    405405                }
    406406
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    482482         */
    483483        public function create_item_permissions_check( $request ) {
    484484                if ( ! empty( $request['id'] ) ) {
    485                         return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) );
     485                        return new WP_Error( 'rest_post_exists', _l( 'Cannot create existing post.' ), array( 'status' => 400 ) );
    486486                }
    487487
    488488                $post_type = get_post_type_object( $this->post_type );
    489489
    490490                if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
    491                         return new WP_Error( 'rest_cannot_edit_others', __( 'Sorry, you are not allowed to create posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
     491                        return new WP_Error( 'rest_cannot_edit_others', _l( 'Sorry, you are not allowed to create posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
    492492                }
    493493
    494494                if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
    495                         return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
     495                        return new WP_Error( 'rest_cannot_assign_sticky', _l( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
    496496                }
    497497
    498498                if ( ! current_user_can( $post_type->cap->create_posts ) ) {
    499                         return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
     499                        return new WP_Error( 'rest_cannot_create', _l( 'Sorry, you are not allowed to create posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
    500500                }
    501501
    502502                if ( ! $this->check_assign_terms_permission( $request ) ) {
    503                         return new WP_Error( 'rest_cannot_assign_term', __( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) );
     503                        return new WP_Error( 'rest_cannot_assign_term', _l( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) );
    504504                }
    505505
    506506                return true;
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    516516         */
    517517        public function create_item( $request ) {
    518518                if ( ! empty( $request['id'] ) ) {
    519                         return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) );
     519                        return new WP_Error( 'rest_post_exists', _l( 'Cannot create existing post.' ), array( 'status' => 400 ) );
    520520                }
    521521
    522522                $prepared_post = $this->prepare_item_for_database( $request );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    626626                $post_type = get_post_type_object( $this->post_type );
    627627
    628628                if ( $post && ! $this->check_update_permission( $post ) ) {
    629                         return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
     629                        return new WP_Error( 'rest_cannot_edit', _l( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
    630630                }
    631631
    632632                if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
    633                         return new WP_Error( 'rest_cannot_edit_others', __( 'Sorry, you are not allowed to update posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
     633                        return new WP_Error( 'rest_cannot_edit_others', _l( 'Sorry, you are not allowed to update posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
    634634                }
    635635
    636636                if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
    637                         return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
     637                        return new WP_Error( 'rest_cannot_assign_sticky', _l( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
    638638                }
    639639
    640640                if ( ! $this->check_assign_terms_permission( $request ) ) {
    641                         return new WP_Error( 'rest_cannot_assign_term', __( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) );
     641                        return new WP_Error( 'rest_cannot_assign_term', _l( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) );
    642642                }
    643643
    644644                return true;
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    746746                }
    747747
    748748                if ( $post && ! $this->check_delete_permission( $post ) ) {
    749                         return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
     749                        return new WP_Error( 'rest_cannot_delete', _l( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
    750750                }
    751751
    752752                return true;
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    790790                $supports_trash = apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post );
    791791
    792792                if ( ! $this->check_delete_permission( $post ) ) {
    793                         return new WP_Error( 'rest_user_cannot_delete_post', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
     793                        return new WP_Error( 'rest_user_cannot_delete_post', _l( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
    794794                }
    795795
    796796                $request->set_param( 'context', 'edit' );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    806806                        // If we don't support trashing for this type, error out.
    807807                        if ( ! $supports_trash ) {
    808808                                /* translators: %s: force=true */
    809                                 return new WP_Error( 'rest_trash_not_supported', sprintf( __( "The post does not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
     809                                return new WP_Error( 'rest_trash_not_supported', sprintf( _l( "The post does not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
    810810                        }
    811811
    812812                        // Otherwise, only trash if we haven't already.
    813813                        if ( 'trash' === $post->post_status ) {
    814                                 return new WP_Error( 'rest_already_trashed', __( 'The post has already been deleted.' ), array( 'status' => 410 ) );
     814                                return new WP_Error( 'rest_already_trashed', _l( 'The post has already been deleted.' ), array( 'status' => 410 ) );
    815815                        }
    816816
    817817                        // (Note that internally this falls through to `wp_delete_post` if
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    822822                }
    823823
    824824                if ( ! $result ) {
    825                         return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
     825                        return new WP_Error( 'rest_cannot_delete', _l( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
    826826                }
    827827
    828828                /**
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    10141014                                $user_obj = get_userdata( $post_author );
    10151015
    10161016                                if ( ! $user_obj ) {
    1017                                         return new WP_Error( 'rest_invalid_author', __( 'Invalid author ID.' ), array( 'status' => 400 ) );
     1017                                        return new WP_Error( 'rest_invalid_author', _l( 'Invalid author ID.' ), array( 'status' => 400 ) );
    10181018                                }
    10191019                        }
    10201020
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    10271027
    10281028                        if ( '' !== $request['password'] ) {
    10291029                                if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) {
    1030                                         return new WP_Error( 'rest_invalid_field', __( 'A post can not be sticky and have a password.' ), array( 'status' => 400 ) );
     1030                                        return new WP_Error( 'rest_invalid_field', _l( 'A post can not be sticky and have a password.' ), array( 'status' => 400 ) );
    10311031                                }
    10321032
    10331033                                if ( ! empty( $prepared_post->ID ) && is_sticky( $prepared_post->ID ) ) {
    1034                                         return new WP_Error( 'rest_invalid_field', __( 'A sticky post can not be password protected.' ), array( 'status' => 400 ) );
     1034                                        return new WP_Error( 'rest_invalid_field', _l( 'A sticky post can not be password protected.' ), array( 'status' => 400 ) );
    10351035                                }
    10361036                        }
    10371037                }
    10381038
    10391039                if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) {
    10401040                        if ( ! empty( $prepared_post->ID ) && post_password_required( $prepared_post->ID ) ) {
    1041                                 return new WP_Error( 'rest_invalid_field', __( 'A password protected post can not be set to sticky.' ), array( 'status' => 400 ) );
     1041                                return new WP_Error( 'rest_invalid_field', _l( 'A password protected post can not be set to sticky.' ), array( 'status' => 400 ) );
    10421042                        }
    10431043                }
    10441044
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    10491049                        } else {
    10501050                                $parent = get_post( (int) $request['parent'] );
    10511051                                if ( empty( $parent ) ) {
    1052                                         return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent ID.' ), array( 'status' => 400 ) );
     1052                                        return new WP_Error( 'rest_post_invalid_id', _l( 'Invalid post parent ID.' ), array( 'status' => 400 ) );
    10531053                                }
    10541054                                $prepared_post->post_parent = (int) $parent->ID;
    10551055                        }
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    11021102                                break;
    11031103                        case 'private':
    11041104                                if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
    1105                                         return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to create private posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
     1105                                        return new WP_Error( 'rest_cannot_publish', _l( 'Sorry, you are not allowed to create private posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
    11061106                                }
    11071107                                break;
    11081108                        case 'publish':
    11091109                        case 'future':
    11101110                                if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
    1111                                         return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to publish posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
     1111                                        return new WP_Error( 'rest_cannot_publish', _l( 'Sorry, you are not allowed to publish posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
    11121112                                }
    11131113                                break;
    11141114                        default:
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    11381138                        if ( $result ) {
    11391139                                return true;
    11401140                        } else {
    1141                                 return new WP_Error( 'rest_invalid_featured_media', __( 'Invalid featured media ID.' ), array( 'status' => 400 ) );
     1141                                return new WP_Error( 'rest_invalid_featured_media', _l( 'Invalid featured media ID.' ), array( 'status' => 400 ) );
    11421142                        }
    11431143                } else {
    11441144                        return delete_post_thumbnail( $post_id );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    16911691                        // Base properties for every Post.
    16921692                        'properties' => array(
    16931693                                'date'            => array(
    1694                                         'description' => __( "The date the object was published, in the site's timezone." ),
     1694                                        'description' => _l( "The date the object was published, in the site's timezone." ),
    16951695                                        'type'        => 'string',
    16961696                                        'format'      => 'date-time',
    16971697                                        'context'     => array( 'view', 'edit', 'embed' ),
    16981698                                ),
    16991699                                'date_gmt'        => array(
    1700                                         'description' => __( 'The date the object was published, as GMT.' ),
     1700                                        'description' => _l( 'The date the object was published, as GMT.' ),
    17011701                                        'type'        => 'string',
    17021702                                        'format'      => 'date-time',
    17031703                                        'context'     => array( 'view', 'edit' ),
    17041704                                ),
    17051705                                'guid'            => array(
    1706                                         'description' => __( 'The globally unique identifier for the object.' ),
     1706                                        'description' => _l( 'The globally unique identifier for the object.' ),
    17071707                                        'type'        => 'object',
    17081708                                        'context'     => array( 'view', 'edit' ),
    17091709                                        'readonly'    => true,
    17101710                                        'properties'  => array(
    17111711                                                'raw'      => array(
    1712                                                         'description' => __( 'GUID for the object, as it exists in the database.' ),
     1712                                                        'description' => _l( 'GUID for the object, as it exists in the database.' ),
    17131713                                                        'type'        => 'string',
    17141714                                                        'context'     => array( 'edit' ),
    17151715                                                        'readonly'    => true,
    17161716                                                ),
    17171717                                                'rendered' => array(
    1718                                                         'description' => __( 'GUID for the object, transformed for display.' ),
     1718                                                        'description' => _l( 'GUID for the object, transformed for display.' ),
    17191719                                                        'type'        => 'string',
    17201720                                                        'context'     => array( 'view', 'edit' ),
    17211721                                                        'readonly'    => true,
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    17231723                                        ),
    17241724                                ),
    17251725                                'id'              => array(
    1726                                         'description' => __( 'Unique identifier for the object.' ),
     1726                                        'description' => _l( 'Unique identifier for the object.' ),
    17271727                                        'type'        => 'integer',
    17281728                                        'context'     => array( 'view', 'edit', 'embed' ),
    17291729                                        'readonly'    => true,
    17301730                                ),
    17311731                                'link'            => array(
    1732                                         'description' => __( 'URL to the object.' ),
     1732                                        'description' => _l( 'URL to the object.' ),
    17331733                                        'type'        => 'string',
    17341734                                        'format'      => 'uri',
    17351735                                        'context'     => array( 'view', 'edit', 'embed' ),
    17361736                                        'readonly'    => true,
    17371737                                ),
    17381738                                'modified'        => array(
    1739                                         'description' => __( "The date the object was last modified, in the site's timezone." ),
     1739                                        'description' => _l( "The date the object was last modified, in the site's timezone." ),
    17401740                                        'type'        => 'string',
    17411741                                        'format'      => 'date-time',
    17421742                                        'context'     => array( 'view', 'edit' ),
    17431743                                        'readonly'    => true,
    17441744                                ),
    17451745                                'modified_gmt'    => array(
    1746                                         'description' => __( 'The date the object was last modified, as GMT.' ),
     1746                                        'description' => _l( 'The date the object was last modified, as GMT.' ),
    17471747                                        'type'        => 'string',
    17481748                                        'format'      => 'date-time',
    17491749                                        'context'     => array( 'view', 'edit' ),
    17501750                                        'readonly'    => true,
    17511751                                ),
    17521752                                'slug'            => array(
    1753                                         'description' => __( 'An alphanumeric identifier for the object unique to its type.' ),
     1753                                        'description' => _l( 'An alphanumeric identifier for the object unique to its type.' ),
    17541754                                        'type'        => 'string',
    17551755                                        'context'     => array( 'view', 'edit', 'embed' ),
    17561756                                        'arg_options' => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    17581758                                        ),
    17591759                                ),
    17601760                                'status'          => array(
    1761                                         'description' => __( 'A named status for the object.' ),
     1761                                        'description' => _l( 'A named status for the object.' ),
    17621762                                        'type'        => 'string',
    17631763                                        'enum'        => array_keys( get_post_stati( array( 'internal' => false ) ) ),
    17641764                                        'context'     => array( 'view', 'edit' ),
    17651765                                ),
    17661766                                'type'            => array(
    1767                                         'description' => __( 'Type of Post for the object.' ),
     1767                                        'description' => _l( 'Type of Post for the object.' ),
    17681768                                        'type'        => 'string',
    17691769                                        'context'     => array( 'view', 'edit', 'embed' ),
    17701770                                        'readonly'    => true,
    17711771                                ),
    17721772                                'password'        => array(
    1773                                         'description' => __( 'A password to protect access to the content and excerpt.' ),
     1773                                        'description' => _l( 'A password to protect access to the content and excerpt.' ),
    17741774                                        'type'        => 'string',
    17751775                                        'context'     => array( 'edit' ),
    17761776                                ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    17811781
    17821782                if ( $post_type_obj->hierarchical ) {
    17831783                        $schema['properties']['parent'] = array(
    1784                                 'description' => __( 'The ID for the parent of the object.' ),
     1784                                'description' => _l( 'The ID for the parent of the object.' ),
    17851785                                'type'        => 'integer',
    17861786                                'context'     => array( 'view', 'edit' ),
    17871787                        );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18411841
    18421842                                case 'title':
    18431843                                        $schema['properties']['title'] = array(
    1844                                                 'description' => __( 'The title for the object.' ),
     1844                                                'description' => _l( 'The title for the object.' ),
    18451845                                                'type'        => 'object',
    18461846                                                'context'     => array( 'view', 'edit', 'embed' ),
    18471847                                                'arg_options' => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18501850                                                ),
    18511851                                                'properties'  => array(
    18521852                                                        'raw' => array(
    1853                                                                 'description' => __( 'Title for the object, as it exists in the database.' ),
     1853                                                                'description' => _l( 'Title for the object, as it exists in the database.' ),
    18541854                                                                'type'        => 'string',
    18551855                                                                'context'     => array( 'edit' ),
    18561856                                                        ),
    18571857                                                        'rendered' => array(
    1858                                                                 'description' => __( 'HTML title for the object, transformed for display.' ),
     1858                                                                'description' => _l( 'HTML title for the object, transformed for display.' ),
    18591859                                                                'type'        => 'string',
    18601860                                                                'context'     => array( 'view', 'edit', 'embed' ),
    18611861                                                                'readonly'    => true,
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18661866
    18671867                                case 'editor':
    18681868                                        $schema['properties']['content'] = array(
    1869                                                 'description' => __( 'The content for the object.' ),
     1869                                                'description' => _l( 'The content for the object.' ),
    18701870                                                'type'        => 'object',
    18711871                                                'context'     => array( 'view', 'edit' ),
    18721872                                                'arg_options' => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18751875                                                ),
    18761876                                                'properties'  => array(
    18771877                                                        'raw' => array(
    1878                                                                 'description' => __( 'Content for the object, as it exists in the database.' ),
     1878                                                                'description' => _l( 'Content for the object, as it exists in the database.' ),
    18791879                                                                'type'        => 'string',
    18801880                                                                'context'     => array( 'edit' ),
    18811881                                                        ),
    18821882                                                        'rendered' => array(
    1883                                                                 'description' => __( 'HTML content for the object, transformed for display.' ),
     1883                                                                'description' => _l( 'HTML content for the object, transformed for display.' ),
    18841884                                                                'type'        => 'string',
    18851885                                                                'context'     => array( 'view', 'edit' ),
    18861886                                                                'readonly'    => true,
    18871887                                                        ),
    18881888                                                        'protected'       => array(
    1889                                                                 'description' => __( 'Whether the content is protected with a password.' ),
     1889                                                                'description' => _l( 'Whether the content is protected with a password.' ),
    18901890                                                                'type'        => 'boolean',
    18911891                                                                'context'     => array( 'view', 'edit', 'embed' ),
    18921892                                                                'readonly'    => true,
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18971897
    18981898                                case 'author':
    18991899                                        $schema['properties']['author'] = array(
    1900                                                 'description' => __( 'The ID for the author of the object.' ),
     1900                                                'description' => _l( 'The ID for the author of the object.' ),
    19011901                                                'type'        => 'integer',
    19021902                                                'context'     => array( 'view', 'edit', 'embed' ),
    19031903                                        );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19051905
    19061906                                case 'excerpt':
    19071907                                        $schema['properties']['excerpt'] = array(
    1908                                                 'description' => __( 'The excerpt for the object.' ),
     1908                                                'description' => _l( 'The excerpt for the object.' ),
    19091909                                                'type'        => 'object',
    19101910                                                'context'     => array( 'view', 'edit', 'embed' ),
    19111911                                                'arg_options' => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19141914                                                ),
    19151915                                                'properties'  => array(
    19161916                                                        'raw' => array(
    1917                                                                 'description' => __( 'Excerpt for the object, as it exists in the database.' ),
     1917                                                                'description' => _l( 'Excerpt for the object, as it exists in the database.' ),
    19181918                                                                'type'        => 'string',
    19191919                                                                'context'     => array( 'edit' ),
    19201920                                                        ),
    19211921                                                        'rendered' => array(
    1922                                                                 'description' => __( 'HTML excerpt for the object, transformed for display.' ),
     1922                                                                'description' => _l( 'HTML excerpt for the object, transformed for display.' ),
    19231923                                                                'type'        => 'string',
    19241924                                                                'context'     => array( 'view', 'edit', 'embed' ),
    19251925                                                                'readonly'    => true,
    19261926                                                        ),
    19271927                                                        'protected'       => array(
    1928                                                                 'description' => __( 'Whether the excerpt is protected with a password.' ),
     1928                                                                'description' => _l( 'Whether the excerpt is protected with a password.' ),
    19291929                                                                'type'        => 'boolean',
    19301930                                                                'context'     => array( 'view', 'edit', 'embed' ),
    19311931                                                                'readonly'    => true,
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19361936
    19371937                                case 'thumbnail':
    19381938                                        $schema['properties']['featured_media'] = array(
    1939                                                 'description' => __( 'The ID of the featured media for the object.' ),
     1939                                                'description' => _l( 'The ID of the featured media for the object.' ),
    19401940                                                'type'        => 'integer',
    19411941                                                'context'     => array( 'view', 'edit', 'embed' ),
    19421942                                        );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19441944
    19451945                                case 'comments':
    19461946                                        $schema['properties']['comment_status'] = array(
    1947                                                 'description' => __( 'Whether or not comments are open on the object.' ),
     1947                                                'description' => _l( 'Whether or not comments are open on the object.' ),
    19481948                                                'type'        => 'string',
    19491949                                                'enum'        => array( 'open', 'closed' ),
    19501950                                                'context'     => array( 'view', 'edit' ),
    19511951                                        );
    19521952                                        $schema['properties']['ping_status'] = array(
    1953                                                 'description' => __( 'Whether or not the object can be pinged.' ),
     1953                                                'description' => _l( 'Whether or not the object can be pinged.' ),
    19541954                                                'type'        => 'string',
    19551955                                                'enum'        => array( 'open', 'closed' ),
    19561956                                                'context'     => array( 'view', 'edit' ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19591959
    19601960                                case 'page-attributes':
    19611961                                        $schema['properties']['menu_order'] = array(
    1962                                                 'description' => __( 'The order of the object in relation to other object of its type.' ),
     1962                                                'description' => _l( 'The order of the object in relation to other object of its type.' ),
    19631963                                                'type'        => 'integer',
    19641964                                                'context'     => array( 'view', 'edit' ),
    19651965                                        );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19701970                                        $formats = array_values( get_post_format_slugs() );
    19711971
    19721972                                        $schema['properties']['format'] = array(
    1973                                                 'description' => __( 'The format for the object.' ),
     1973                                                'description' => _l( 'The format for the object.' ),
    19741974                                                'type'        => 'string',
    19751975                                                'enum'        => $formats,
    19761976                                                'context'     => array( 'view', 'edit' ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19861986
    19871987                if ( 'post' === $this->post_type ) {
    19881988                        $schema['properties']['sticky'] = array(
    1989                                 'description' => __( 'Whether or not the object should be treated as sticky.' ),
     1989                                'description' => _l( 'Whether or not the object should be treated as sticky.' ),
    19901990                                'type'        => 'boolean',
    19911991                                'context'     => array( 'view', 'edit' ),
    19921992                        );
    19931993                }
    19941994
    19951995                $schema['properties']['template'] = array(
    1996                         'description' => __( 'The theme file to use to display the object.' ),
     1996                        'description' => _l( 'The theme file to use to display the object.' ),
    19971997                        'type'        => 'string',
    19981998                        'enum'        => array_merge( array_keys( wp_get_theme()->get_page_templates( null, $this->post_type ) ), array( '' ) ),
    19991999                        'context'     => array( 'view', 'edit' ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20042004                        $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
    20052005                        $schema['properties'][ $base ] = array(
    20062006                                /* translators: %s: taxonomy name */
    2007                                 'description' => sprintf( __( 'The terms assigned to the object in the %s taxonomy.' ), $taxonomy->name ),
     2007                                'description' => sprintf( _l( 'The terms assigned to the object in the %s taxonomy.' ), $taxonomy->name ),
    20082008                                'type'        => 'array',
    20092009                                'items'       => array(
    20102010                                        'type'    => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20292029                $query_params['context']['default'] = 'view';
    20302030
    20312031                $query_params['after'] = array(
    2032                         'description'        => __( 'Limit response to posts published after a given ISO8601 compliant date.' ),
     2032                        'description'        => _l( 'Limit response to posts published after a given ISO8601 compliant date.' ),
    20332033                        'type'               => 'string',
    20342034                        'format'             => 'date-time',
    20352035                );
    20362036
    20372037                if ( post_type_supports( $this->post_type, 'author' ) ) {
    20382038                        $query_params['author'] = array(
    2039                                 'description'         => __( 'Limit result set to posts assigned to specific authors.' ),
     2039                                'description'         => _l( 'Limit result set to posts assigned to specific authors.' ),
    20402040                                'type'                => 'array',
    20412041                                'items'               => array(
    20422042                                        'type'            => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20442044                                'default'             => array(),
    20452045                        );
    20462046                        $query_params['author_exclude'] = array(
    2047                                 'description'         => __( 'Ensure result set excludes posts assigned to specific authors.' ),
     2047                                'description'         => _l( 'Ensure result set excludes posts assigned to specific authors.' ),
    20482048                                'type'                => 'array',
    20492049                                'items'               => array(
    20502050                                        'type'            => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20542054                }
    20552055
    20562056                $query_params['before'] = array(
    2057                         'description'        => __( 'Limit response to posts published before a given ISO8601 compliant date.' ),
     2057                        'description'        => _l( 'Limit response to posts published before a given ISO8601 compliant date.' ),
    20582058                        'type'               => 'string',
    20592059                        'format'             => 'date-time',
    20602060                );
    20612061
    20622062                $query_params['exclude'] = array(
    2063                         'description'        => __( 'Ensure result set excludes specific IDs.' ),
     2063                        'description'        => _l( 'Ensure result set excludes specific IDs.' ),
    20642064                        'type'               => 'array',
    20652065                        'items'              => array(
    20662066                                'type'           => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20692069                );
    20702070
    20712071                $query_params['include'] = array(
    2072                         'description'        => __( 'Limit result set to specific IDs.' ),
     2072                        'description'        => _l( 'Limit result set to specific IDs.' ),
    20732073                        'type'               => 'array',
    20742074                        'items'              => array(
    20752075                                'type'           => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20792079
    20802080                if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
    20812081                        $query_params['menu_order'] = array(
    2082                                 'description'        => __( 'Limit result set to posts with a specific menu_order value.' ),
     2082                                'description'        => _l( 'Limit result set to posts with a specific menu_order value.' ),
    20832083                                'type'               => 'integer',
    20842084                        );
    20852085                }
    20862086
    20872087                $query_params['offset'] = array(
    2088                         'description'        => __( 'Offset the result set by a specific number of items.' ),
     2088                        'description'        => _l( 'Offset the result set by a specific number of items.' ),
    20892089                        'type'               => 'integer',
    20902090                );
    20912091
    20922092                $query_params['order'] = array(
    2093                         'description'        => __( 'Order sort attribute ascending or descending.' ),
     2093                        'description'        => _l( 'Order sort attribute ascending or descending.' ),
    20942094                        'type'               => 'string',
    20952095                        'default'            => 'desc',
    20962096                        'enum'               => array( 'asc', 'desc' ),
    20972097                );
    20982098
    20992099                $query_params['orderby'] = array(
    2100                         'description'        => __( 'Sort collection by object attribute.' ),
     2100                        'description'        => _l( 'Sort collection by object attribute.' ),
    21012101                        'type'               => 'string',
    21022102                        'default'            => 'date',
    21032103                        'enum'               => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21212121
    21222122                if ( $post_type->hierarchical || 'attachment' === $this->post_type ) {
    21232123                        $query_params['parent'] = array(
    2124                                 'description'       => __( 'Limit result set to items with particular parent IDs.' ),
     2124                                'description'       => _l( 'Limit result set to items with particular parent IDs.' ),
    21252125                                'type'              => 'array',
    21262126                                'items'             => array(
    21272127                                        'type'          => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21292129                                'default'           => array(),
    21302130                        );
    21312131                        $query_params['parent_exclude'] = array(
    2132                                 'description'       => __( 'Limit result set to all items except those of a particular parent ID.' ),
     2132                                'description'       => _l( 'Limit result set to all items except those of a particular parent ID.' ),
    21332133                                'type'              => 'array',
    21342134                                'items'             => array(
    21352135                                        'type'          => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21392139                }
    21402140
    21412141                $query_params['slug'] = array(
    2142                         'description'       => __( 'Limit result set to posts with one or more specific slugs.' ),
     2142                        'description'       => _l( 'Limit result set to posts with one or more specific slugs.' ),
    21432143                        'type'              => 'array',
    21442144                        'items'             => array(
    21452145                                'type'          => 'string',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21492149
    21502150                $query_params['status'] = array(
    21512151                        'default'           => 'publish',
    2152                         'description'       => __( 'Limit result set to posts assigned one or more statuses.' ),
     2152                        'description'       => _l( 'Limit result set to posts assigned one or more statuses.' ),
    21532153                        'type'              => 'array',
    21542154                        'items'             => array(
    21552155                                'enum'          => array_merge( array_keys( get_post_stati() ), array( 'any' ) ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21652165
    21662166                        $query_params[ $base ] = array(
    21672167                                /* translators: %s: taxonomy name */
    2168                                 'description'       => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
     2168                                'description'       => sprintf( _l( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
    21692169                                'type'              => 'array',
    21702170                                'items'             => array(
    21712171                                        'type'          => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21752175
    21762176                        $query_params[ $base . '_exclude' ] = array(
    21772177                                /* translators: %s: taxonomy name */
    2178                                 'description' => sprintf( __( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
     2178                                'description' => sprintf( _l( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
    21792179                                'type'        => 'array',
    21802180                                'items'       => array(
    21812181                                        'type'    => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21862186
    21872187                if ( 'post' === $this->post_type ) {
    21882188                        $query_params['sticky'] = array(
    2189                                 'description'       => __( 'Limit result set to items that are sticky.' ),
     2189                                'description'       => _l( 'Limit result set to items that are sticky.' ),
    21902190                                'type'              => 'boolean',
    21912191                        );
    21922192                }
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    22402240                                        return $result;
    22412241                                }
    22422242                        } else {
    2243                                 return new WP_Error( 'rest_forbidden_status', __( 'Status is forbidden.' ), array( 'status' => rest_authorization_required_code() ) );
     2243                                return new WP_Error( 'rest_forbidden_status', _l( 'Status is forbidden.' ), array( 'status' => rest_authorization_required_code() ) );
    22442244                        }
    22452245                }
    22462246
  • src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
    index a648fa2de5..8cc7d94ab9 100644
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    6868                register_rest_route( $this->namespace, '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base, array(
    6969                        'args' => array(
    7070                                'parent' => array(
    71                                         'description' => __( 'The ID for the parent of the object.' ),
     71                                        'description' => _l( 'The ID for the parent of the object.' ),
    7272                                        'type'        => 'integer',
    7373                                ),
    7474                        ),
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    8484                register_rest_route( $this->namespace, '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    8585                        'args' => array(
    8686                                'parent' => array(
    87                                         'description' => __( 'The ID for the parent of the object.' ),
     87                                        'description' => _l( 'The ID for the parent of the object.' ),
    8888                                        'type'        => 'integer',
    8989                                ),
    9090                                'id' => array(
    91                                         'description' => __( 'Unique identifier for the object.' ),
     91                                        'description' => _l( 'Unique identifier for the object.' ),
    9292                                        'type'        => 'integer',
    9393                                ),
    9494                        ),
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    108108                                        'force' => array(
    109109                                                'type'        => 'boolean',
    110110                                                'default'     => false,
    111                                                 'description' => __( 'Required to be true, as revisions do not support trashing.' ),
     111                                                'description' => _l( 'Required to be true, as revisions do not support trashing.' ),
    112112                                        ),
    113113                                ),
    114114                        ),
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    126126         * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.
    127127         */
    128128        protected function get_parent( $parent ) {
    129                 $error = new WP_Error( 'rest_post_invalid_parent', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) );
     129                $error = new WP_Error( 'rest_post_invalid_parent', _l( 'Invalid post parent ID.' ), array( 'status' => 404 ) );
    130130                if ( (int) $parent <= 0 ) {
    131131                        return $error;
    132132                }
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    155155
    156156                $parent_post_type_obj = get_post_type_object( $parent->post_type );
    157157                if ( ! current_user_can( $parent_post_type_obj->cap->edit_post, $parent->ID ) ) {
    158                         return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to view revisions of this post.' ), array( 'status' => rest_authorization_required_code() ) );
     158                        return new WP_Error( 'rest_cannot_read', _l( 'Sorry, you are not allowed to view revisions of this post.' ), array( 'status' => rest_authorization_required_code() ) );
    159159                }
    160160
    161161                return true;
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    170170         * @return WP_Post|WP_Error Revision post object if ID is valid, WP_Error otherwise.
    171171         */
    172172        protected function get_revision( $id ) {
    173                 $error = new WP_Error( 'rest_post_invalid_id', __( 'Invalid revision ID.' ), array( 'status' => 404 ) );
     173                $error = new WP_Error( 'rest_post_invalid_id', _l( 'Invalid revision ID.' ), array( 'status' => 404 ) );
    174174                if ( (int) $id <= 0 ) {
    175175                        return $error;
    176176                }
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    289289                // We don't support trashing for revisions.
    290290                if ( ! $force ) {
    291291                        /* translators: %s: force=true */
    292                         return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Revisions do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
     292                        return new WP_Error( 'rest_trash_not_supported', sprintf( _l( "Revisions do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
    293293                }
    294294
    295295                $previous = $this->prepare_item_for_response( $revision, $request );
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    309309                do_action( 'rest_delete_revision', $result, $request );
    310310
    311311                if ( ! $result ) {
    312                         return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
     312                        return new WP_Error( 'rest_cannot_delete', _l( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
    313313                }
    314314
    315315                $response = new WP_REST_Response();
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    458458                        // Base properties for every Revision.
    459459                        'properties' => array(
    460460                                'author'          => array(
    461                                         'description' => __( 'The ID for the author of the object.' ),
     461                                        'description' => _l( 'The ID for the author of the object.' ),
    462462                                        'type'        => 'integer',
    463463                                        'context'     => array( 'view', 'edit', 'embed' ),
    464464                                ),
    465465                                'date'            => array(
    466                                         'description' => __( "The date the object was published, in the site's timezone." ),
     466                                        'description' => _l( "The date the object was published, in the site's timezone." ),
    467467                                        'type'        => 'string',
    468468                                        'format'      => 'date-time',
    469469                                        'context'     => array( 'view', 'edit', 'embed' ),
    470470                                ),
    471471                                'date_gmt'        => array(
    472                                         'description' => __( 'The date the object was published, as GMT.' ),
     472                                        'description' => _l( 'The date the object was published, as GMT.' ),
    473473                                        'type'        => 'string',
    474474                                        'format'      => 'date-time',
    475475                                        'context'     => array( 'view', 'edit' ),
    476476                                ),
    477477                                'guid'            => array(
    478                                         'description' => __( 'GUID for the object, as it exists in the database.' ),
     478                                        'description' => _l( 'GUID for the object, as it exists in the database.' ),
    479479                                        'type'        => 'string',
    480480                                        'context'     => array( 'view', 'edit' ),
    481481                                ),
    482482                                'id'              => array(
    483                                         'description' => __( 'Unique identifier for the object.' ),
     483                                        'description' => _l( 'Unique identifier for the object.' ),
    484484                                        'type'        => 'integer',
    485485                                        'context'     => array( 'view', 'edit', 'embed' ),
    486486                                ),
    487487                                'modified'        => array(
    488                                         'description' => __( "The date the object was last modified, in the site's timezone." ),
     488                                        'description' => _l( "The date the object was last modified, in the site's timezone." ),
    489489                                        'type'        => 'string',
    490490                                        'format'      => 'date-time',
    491491                                        'context'     => array( 'view', 'edit' ),
    492492                                ),
    493493                                'modified_gmt'    => array(
    494                                         'description' => __( 'The date the object was last modified, as GMT.' ),
     494                                        'description' => _l( 'The date the object was last modified, as GMT.' ),
    495495                                        'type'        => 'string',
    496496                                        'format'      => 'date-time',
    497497                                        'context'     => array( 'view', 'edit' ),
    498498                                ),
    499499                                'parent'          => array(
    500                                         'description' => __( 'The ID for the parent of the object.' ),
     500                                        'description' => _l( 'The ID for the parent of the object.' ),
    501501                                        'type'        => 'integer',
    502502                                        'context'     => array( 'view', 'edit', 'embed' ),
    503503                                        ),
    504504                                'slug'            => array(
    505                                         'description' => __( 'An alphanumeric identifier for the object unique to its type.' ),
     505                                        'description' => _l( 'An alphanumeric identifier for the object unique to its type.' ),
    506506                                        'type'        => 'string',
    507507                                        'context'     => array( 'view', 'edit', 'embed' ),
    508508                                ),
  • src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php
    index 17a01b8ba6..82bf524395 100644
    class WP_REST_Settings_Controller extends WP_REST_Controller { 
    194194                                 */
    195195                                if ( ! is_scalar( get_option( $args['option_name'], false ) ) ) {
    196196                                        return new WP_Error(
    197                                                 'rest_invalid_stored_value', sprintf( __( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ), array( 'status' => 500 )
     197                                                'rest_invalid_stored_value', sprintf( _l( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ), array( 'status' => 500 )
    198198                                        );
    199199                                }
    200200
  • src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php
    index ea97135677..e3c8d99cd3 100644
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    4848                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<taxonomy>[\w-]+)', array(
    4949                        'args' => array(
    5050                                'taxonomy' => array(
    51                                         'description'  => __( 'An alphanumeric identifier for the taxonomy.' ),
     51                                        'description'  => _l( 'An alphanumeric identifier for the taxonomy.' ),
    5252                                        'type'         => 'string',
    5353                                ),
    5454                        ),
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    8484                                        return true;
    8585                                }
    8686                        }
    87                         return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
     87                        return new WP_Error( 'rest_cannot_view', _l( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
    8888                }
    8989                return true;
    9090        }
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    142142                                return false;
    143143                        }
    144144                        if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->manage_terms ) ) {
    145                                 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
     145                                return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
    146146                        }
    147147                }
    148148
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    160160        public function get_item( $request ) {
    161161                $tax_obj = get_taxonomy( $request['taxonomy'] );
    162162                if ( empty( $tax_obj ) ) {
    163                         return new WP_Error( 'rest_taxonomy_invalid', __( 'Invalid taxonomy.' ), array( 'status' => 404 ) );
     163                        return new WP_Error( 'rest_taxonomy_invalid', _l( 'Invalid taxonomy.' ), array( 'status' => 404 ) );
    164164                }
    165165                $data = $this->prepare_item_for_response( $tax_obj, $request );
    166166                return rest_ensure_response( $data );
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    233233                        'type'                 => 'object',
    234234                        'properties'           => array(
    235235                                'capabilities'     => array(
    236                                         'description'  => __( 'All capabilities used by the taxonomy.' ),
     236                                        'description'  => _l( 'All capabilities used by the taxonomy.' ),
    237237                                        'type'         => 'object',
    238238                                        'context'      => array( 'edit' ),
    239239                                        'readonly'     => true,
    240240                                ),
    241241                                'description'      => array(
    242                                         'description'  => __( 'A human-readable description of the taxonomy.' ),
     242                                        'description'  => _l( 'A human-readable description of the taxonomy.' ),
    243243                                        'type'         => 'string',
    244244                                        'context'      => array( 'view', 'edit' ),
    245245                                        'readonly'     => true,
    246246                                ),
    247247                                'hierarchical'     => array(
    248                                         'description'  => __( 'Whether or not the taxonomy should have children.' ),
     248                                        'description'  => _l( 'Whether or not the taxonomy should have children.' ),
    249249                                        'type'         => 'boolean',
    250250                                        'context'      => array( 'view', 'edit' ),
    251251                                        'readonly'     => true,
    252252                                ),
    253253                                'labels'           => array(
    254                                         'description'  => __( 'Human-readable labels for the taxonomy for various contexts.' ),
     254                                        'description'  => _l( 'Human-readable labels for the taxonomy for various contexts.' ),
    255255                                        'type'         => 'object',
    256256                                        'context'      => array( 'edit' ),
    257257                                        'readonly'     => true,
    258258                                ),
    259259                                'name'             => array(
    260                                         'description'  => __( 'The title for the taxonomy.' ),
     260                                        'description'  => _l( 'The title for the taxonomy.' ),
    261261                                        'type'         => 'string',
    262262                                        'context'      => array( 'view', 'edit', 'embed' ),
    263263                                        'readonly'     => true,
    264264                                ),
    265265                                'slug'             => array(
    266                                         'description'  => __( 'An alphanumeric identifier for the taxonomy.' ),
     266                                        'description'  => _l( 'An alphanumeric identifier for the taxonomy.' ),
    267267                                        'type'         => 'string',
    268268                                        'context'      => array( 'view', 'edit', 'embed' ),
    269269                                        'readonly'     => true,
    270270                                ),
    271271                                'show_cloud'       => array(
    272                                         'description'  => __( 'Whether or not the term cloud should be displayed.' ),
     272                                        'description'  => _l( 'Whether or not the term cloud should be displayed.' ),
    273273                                        'type'         => 'boolean',
    274274                                        'context'      => array( 'edit' ),
    275275                                        'readonly'     => true,
    276276                                ),
    277277                                'types'            => array(
    278                                         'description'  => __( 'Types associated with the taxonomy.' ),
     278                                        'description'  => _l( 'Types associated with the taxonomy.' ),
    279279                                        'type'         => 'array',
    280280                                        'items'        => array(
    281281                                                'type' => 'string',
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    284284                                        'readonly'     => true,
    285285                                ),
    286286                                'rest_base'            => array(
    287                                         'description'  => __( 'REST base route for the taxonomy.' ),
     287                                        'description'  => _l( 'REST base route for the taxonomy.' ),
    288288                                        'type'         => 'string',
    289289                                        'context'      => array( 'view', 'edit', 'embed' ),
    290290                                        'readonly'     => true,
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    305305                $new_params = array();
    306306                $new_params['context'] = $this->get_context_param( array( 'default' => 'view' ) );
    307307                $new_params['type'] = array(
    308                         'description'  => __( 'Limit results to taxonomies associated with a specific post type.' ),
     308                        'description'  => _l( 'Limit results to taxonomies associated with a specific post type.' ),
    309309                        'type'         => 'string',
    310310                );
    311311                return $new_params;
  • src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
    index ca0f53263a..f6f81b3e15 100644
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    9292                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    9393                        'args' => array(
    9494                                'id' => array(
    95                                         'description' => __( 'Unique identifier for the term.' ),
     95                                        'description' => _l( 'Unique identifier for the term.' ),
    9696                                        'type'        => 'integer',
    9797                                ),
    9898                        ),
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    118118                                        'force' => array(
    119119                                                'type'        => 'boolean',
    120120                                                'default'     => false,
    121                                                 'description' => __( 'Required to be true, as terms do not support trashing.' ),
     121                                                'description' => _l( 'Required to be true, as terms do not support trashing.' ),
    122122                                        ),
    123123                                ),
    124124                        ),
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    140140                        return false;
    141141                }
    142142                if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->edit_terms ) ) {
    143                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
     143                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
    144144                }
    145145                return true;
    146146        }
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    294294         * @return WP_Term|WP_Error Term object if ID is valid, WP_Error otherwise.
    295295         */
    296296        protected function get_term( $id ) {
    297                 $error = new WP_Error( 'rest_term_invalid', __( 'Term does not exist.' ), array( 'status' => 404 ) );
     297                $error = new WP_Error( 'rest_term_invalid', _l( 'Term does not exist.' ), array( 'status' => 404 ) );
    298298
    299299                if ( ! $this->check_is_taxonomy_allowed( $this->taxonomy ) ) {
    300300                        return $error;
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    327327                }
    328328
    329329                if ( 'edit' === $request['context'] && ! current_user_can( 'edit_term', $term->term_id ) ) {
    330                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) );
     330                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) );
    331331                }
    332332                return true;
    333333        }
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    367367
    368368                $taxonomy_obj = get_taxonomy( $this->taxonomy );
    369369                if ( ! current_user_can( $taxonomy_obj->cap->edit_terms ) ) {
    370                         return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create new terms.' ), array( 'status' => rest_authorization_required_code() ) );
     370                        return new WP_Error( 'rest_cannot_create', _l( 'Sorry, you are not allowed to create new terms.' ), array( 'status' => rest_authorization_required_code() ) );
    371371                }
    372372
    373373                return true;
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    384384        public function create_item( $request ) {
    385385                if ( isset( $request['parent'] ) ) {
    386386                        if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) {
    387                                 return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );
     387                                return new WP_Error( 'rest_taxonomy_not_hierarchical', _l( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );
    388388                        }
    389389
    390390                        $parent = get_term( (int) $request['parent'], $this->taxonomy );
    391391
    392392                        if ( ! $parent ) {
    393                                 return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) );
     393                                return new WP_Error( 'rest_term_invalid', _l( 'Parent term does not exist.' ), array( 'status' => 400 ) );
    394394                        }
    395395                }
    396396
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    466466                }
    467467
    468468                if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
    469                         return new WP_Error( 'rest_cannot_update', __( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) );
     469                        return new WP_Error( 'rest_cannot_update', _l( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) );
    470470                }
    471471
    472472                return true;
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    488488
    489489                if ( isset( $request['parent'] ) ) {
    490490                        if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) {
    491                                 return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );
     491                                return new WP_Error( 'rest_taxonomy_not_hierarchical', _l( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );
    492492                        }
    493493
    494494                        $parent = get_term( (int) $request['parent'], $this->taxonomy );
    495495
    496496                        if ( ! $parent ) {
    497                                 return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) );
     497                                return new WP_Error( 'rest_term_invalid', _l( 'Parent term does not exist.' ), array( 'status' => 400 ) );
    498498                        }
    499499                }
    500500
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    551551                }
    552552
    553553                if ( ! current_user_can( 'delete_term', $term->term_id ) ) {
    554                         return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this term.' ), array( 'status' => rest_authorization_required_code() ) );
     554                        return new WP_Error( 'rest_cannot_delete', _l( 'Sorry, you are not allowed to delete this term.' ), array( 'status' => rest_authorization_required_code() ) );
    555555                }
    556556
    557557                return true;
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    576576                // We don't support trashing for terms.
    577577                if ( ! $force ) {
    578578                        /* translators: %s: force=true */
    579                         return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Terms do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
     579                        return new WP_Error( 'rest_trash_not_supported', sprintf( _l( "Terms do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
    580580                }
    581581
    582582                $request->set_param( 'context', 'view' );
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    586586                $retval = wp_delete_term( $term->term_id, $term->taxonomy );
    587587
    588588                if ( ! $retval ) {
    589                         return new WP_Error( 'rest_cannot_delete', __( 'The term cannot be deleted.' ), array( 'status' => 500 ) );
     589                        return new WP_Error( 'rest_cannot_delete', _l( 'The term cannot be deleted.' ), array( 'status' => 500 ) );
    590590                }
    591591
    592592                $response = new WP_REST_Response();
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    809809                        'type'       => 'object',
    810810                        'properties' => array(
    811811                                'id'          => array(
    812                                         'description'  => __( 'Unique identifier for the term.' ),
     812                                        'description'  => _l( 'Unique identifier for the term.' ),
    813813                                        'type'         => 'integer',
    814814                                        'context'      => array( 'view', 'embed', 'edit' ),
    815815                                        'readonly'     => true,
    816816                                ),
    817817                                'count'       => array(
    818                                         'description'  => __( 'Number of published posts for the term.' ),
     818                                        'description'  => _l( 'Number of published posts for the term.' ),
    819819                                        'type'         => 'integer',
    820820                                        'context'      => array( 'view', 'edit' ),
    821821                                        'readonly'     => true,
    822822                                ),
    823823                                'description' => array(
    824                                         'description'  => __( 'HTML description of the term.' ),
     824                                        'description'  => _l( 'HTML description of the term.' ),
    825825                                        'type'         => 'string',
    826826                                        'context'      => array( 'view', 'edit' ),
    827827                                ),
    828828                                'link'        => array(
    829                                         'description'  => __( 'URL of the term.' ),
     829                                        'description'  => _l( 'URL of the term.' ),
    830830                                        'type'         => 'string',
    831831                                        'format'       => 'uri',
    832832                                        'context'      => array( 'view', 'embed', 'edit' ),
    833833                                        'readonly'     => true,
    834834                                ),
    835835                                'name'        => array(
    836                                         'description'  => __( 'HTML title for the term.' ),
     836                                        'description'  => _l( 'HTML title for the term.' ),
    837837                                        'type'         => 'string',
    838838                                        'context'      => array( 'view', 'embed', 'edit' ),
    839839                                        'arg_options'  => array(
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    842842                                        'required'     => true,
    843843                                ),
    844844                                'slug'        => array(
    845                                         'description'  => __( 'An alphanumeric identifier for the term unique to its type.' ),
     845                                        'description'  => _l( 'An alphanumeric identifier for the term unique to its type.' ),
    846846                                        'type'         => 'string',
    847847                                        'context'      => array( 'view', 'embed', 'edit' ),
    848848                                        'arg_options'  => array(
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    850850                                        ),
    851851                                ),
    852852                                'taxonomy'    => array(
    853                                         'description'  => __( 'Type attribution for the term.' ),
     853                                        'description'  => _l( 'Type attribution for the term.' ),
    854854                                        'type'         => 'string',
    855855                                        'enum'         => array_keys( get_taxonomies() ),
    856856                                        'context'      => array( 'view', 'embed', 'edit' ),
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    863863
    864864                if ( $taxonomy->hierarchical ) {
    865865                        $schema['properties']['parent'] = array(
    866                                 'description'  => __( 'The parent term ID.' ),
     866                                'description'  => _l( 'The parent term ID.' ),
    867867                                'type'         => 'integer',
    868868                                'context'      => array( 'view', 'edit' ),
    869869                        );
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    888888                $query_params['context']['default'] = 'view';
    889889
    890890                $query_params['exclude'] = array(
    891                         'description'       => __( 'Ensure result set excludes specific IDs.' ),
     891                        'description'       => _l( 'Ensure result set excludes specific IDs.' ),
    892892                        'type'              => 'array',
    893893                        'items'             => array(
    894894                                'type'          => 'integer',
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    897897                );
    898898
    899899                $query_params['include'] = array(
    900                         'description'       => __( 'Limit result set to specific IDs.' ),
     900                        'description'       => _l( 'Limit result set to specific IDs.' ),
    901901                        'type'              => 'array',
    902902                        'items'             => array(
    903903                                'type'          => 'integer',
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    907907
    908908                if ( ! $taxonomy->hierarchical ) {
    909909                        $query_params['offset'] = array(
    910                                 'description'       => __( 'Offset the result set by a specific number of items.' ),
     910                                'description'       => _l( 'Offset the result set by a specific number of items.' ),
    911911                                'type'              => 'integer',
    912912                        );
    913913                }
    914914
    915915                $query_params['order'] = array(
    916                         'description'       => __( 'Order sort attribute ascending or descending.' ),
     916                        'description'       => _l( 'Order sort attribute ascending or descending.' ),
    917917                        'type'              => 'string',
    918918                        'default'           => 'asc',
    919919                        'enum'              => array(
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    923923                );
    924924
    925925                $query_params['orderby'] = array(
    926                         'description'       => __( 'Sort collection by term attribute.' ),
     926                        'description'       => _l( 'Sort collection by term attribute.' ),
    927927                        'type'              => 'string',
    928928                        'default'           => 'name',
    929929                        'enum'              => array(
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    938938                );
    939939
    940940                $query_params['hide_empty'] = array(
    941                         'description'       => __( 'Whether to hide terms not assigned to any posts.' ),
     941                        'description'       => _l( 'Whether to hide terms not assigned to any posts.' ),
    942942                        'type'              => 'boolean',
    943943                        'default'           => false,
    944944                );
    945945
    946946                if ( $taxonomy->hierarchical ) {
    947947                        $query_params['parent'] = array(
    948                                 'description'       => __( 'Limit result set to terms assigned to a specific parent.' ),
     948                                'description'       => _l( 'Limit result set to terms assigned to a specific parent.' ),
    949949                                'type'              => 'integer',
    950950                        );
    951951                }
    952952
    953953                $query_params['post'] = array(
    954                         'description'       => __( 'Limit result set to terms assigned to a specific post.' ),
     954                        'description'       => _l( 'Limit result set to terms assigned to a specific post.' ),
    955955                        'type'              => 'integer',
    956956                        'default'           => null,
    957957                );
    958958
    959959                $query_params['slug'] = array(
    960                         'description'       => __( 'Limit result set to terms with one or more specific slugs.' ),
     960                        'description'       => _l( 'Limit result set to terms with one or more specific slugs.' ),
    961961                        'type'              => 'array',
    962962                        'items'             => array(
    963963                                'type'          => 'string'
  • src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
    index 372c9654de..e2ade568df 100644
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    6464                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    6565                        'args' => array(
    6666                                'id' => array(
    67                                         'description' => __( 'Unique identifier for the user.' ),
     67                                        'description' => _l( 'Unique identifier for the user.' ),
    6868                                        'type'        => 'integer',
    6969                                ),
    7070                        ),
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    9090                                        'force'    => array(
    9191                                                'type'        => 'boolean',
    9292                                                'default'     => false,
    93                                                 'description' => __( 'Required to be true, as users do not support trashing.' ),
     93                                                'description' => _l( 'Required to be true, as users do not support trashing.' ),
    9494                                        ),
    9595                                        'reassign' => array(
    9696                                                'type'        => 'integer',
    97                                                 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ),
     97                                                'description' => _l( 'Reassign the deleted user\'s posts and links to this user ID.' ),
    9898                                                'required'    => true,
    9999                                                'sanitize_callback' => array( $this, 'check_reassign' ),
    100100                                        ),
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    125125                                        'force'    => array(
    126126                                                'type'        => 'boolean',
    127127                                                'default'     => false,
    128                                                 'description' => __( 'Required to be true, as users do not support trashing.' ),
     128                                                'description' => _l( 'Required to be true, as users do not support trashing.' ),
    129129                                        ),
    130130                                        'reassign' => array(
    131131                                                'type'        => 'integer',
    132                                                 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ),
     132                                                'description' => _l( 'Reassign the deleted user\'s posts and links to this user ID.' ),
    133133                                                'required'    => true,
    134134                                                'sanitize_callback' => array( $this, 'check_reassign' ),
    135135                                        ),
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    161161                        return false;
    162162                }
    163163
    164                 return new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
     164                return new WP_Error( 'rest_invalid_param', _l( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
    165165        }
    166166
    167167        /**
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    175175        public function get_items_permissions_check( $request ) {
    176176                // Check if roles is specified in GET request and if user can list users.
    177177                if ( ! empty( $request['roles'] ) && ! current_user_can( 'list_users' ) ) {
    178                         return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to filter users by role.' ), array( 'status' => rest_authorization_required_code() ) );
     178                        return new WP_Error( 'rest_user_cannot_view', _l( 'Sorry, you are not allowed to filter users by role.' ), array( 'status' => rest_authorization_required_code() ) );
    179179                }
    180180
    181181                if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) {
    182                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
     182                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
    183183                }
    184184
    185185                if ( in_array( $request['orderby'], array( 'email', 'registered_date' ), true ) && ! current_user_can( 'list_users' ) ) {
    186                         return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you are not allowed to order users by this parameter.' ), array( 'status' => rest_authorization_required_code() ) );
     186                        return new WP_Error( 'rest_forbidden_orderby', _l( 'Sorry, you are not allowed to order users by this parameter.' ), array( 'status' => rest_authorization_required_code() ) );
    187187                }
    188188
    189189                return true;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    330330         * @return WP_User|WP_Error True if ID is valid, WP_Error otherwise.
    331331         */
    332332        protected function get_user( $id ) {
    333                 $error = new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
     333                $error = new WP_Error( 'rest_user_invalid_id', _l( 'Invalid user ID.' ), array( 'status' => 404 ) );
    334334                if ( (int) $id <= 0 ) {
    335335                        return $error;
    336336                }
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    368368                }
    369369
    370370                if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) {
    371                         return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
     371                        return new WP_Error( 'rest_user_cannot_view', _l( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
    372372                } elseif ( ! count_user_posts( $user->ID, $types ) && ! current_user_can( 'edit_user', $user->ID ) && ! current_user_can( 'list_users' ) ) {
    373                         return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
     373                        return new WP_Error( 'rest_user_cannot_view', _l( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
    374374                }
    375375
    376376                return true;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    408408                $current_user_id = get_current_user_id();
    409409
    410410                if ( empty( $current_user_id ) ) {
    411                         return new WP_Error( 'rest_not_logged_in', __( 'You are not currently logged in.' ), array( 'status' => 401 ) );
     411                        return new WP_Error( 'rest_not_logged_in', _l( 'You are not currently logged in.' ), array( 'status' => 401 ) );
    412412                }
    413413
    414414                $user     = wp_get_current_user();
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    430430        public function create_item_permissions_check( $request ) {
    431431
    432432                if ( ! current_user_can( 'create_users' ) ) {
    433                         return new WP_Error( 'rest_cannot_create_user', __( 'Sorry, you are not allowed to create new users.' ), array( 'status' => rest_authorization_required_code() ) );
     433                        return new WP_Error( 'rest_cannot_create_user', _l( 'Sorry, you are not allowed to create new users.' ), array( 'status' => rest_authorization_required_code() ) );
    434434                }
    435435
    436436                return true;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    446446         */
    447447        public function create_item( $request ) {
    448448                if ( ! empty( $request['id'] ) ) {
    449                         return new WP_Error( 'rest_user_exists', __( 'Cannot create existing user.' ), array( 'status' => 400 ) );
     449                        return new WP_Error( 'rest_user_exists', _l( 'Cannot create existing user.' ), array( 'status' => 400 ) );
    450450                }
    451451
    452452                $schema = $this->get_item_schema();
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    465465                        $ret = wpmu_validate_user_signup( $user->user_login, $user->user_email );
    466466
    467467                        if ( is_wp_error( $ret['errors'] ) && ! empty( $ret['errors']->errors ) ) {
    468                                 $error = new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
     468                                $error = new WP_Error( 'rest_invalid_param', _l( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
    469469                                foreach ( $ret['errors']->errors as $code => $messages ) {
    470470                                        foreach ( $messages as $message ) {
    471471                                                $error->add( $code, $message );
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    482482                        $user_id = wpmu_create_user( $user->user_login, $user->user_pass, $user->user_email );
    483483
    484484                        if ( ! $user_id ) {
    485                                 return new WP_Error( 'rest_user_create', __( 'Error creating new user.' ), array( 'status' => 500 ) );
     485                                return new WP_Error( 'rest_user_create', _l( 'Error creating new user.' ), array( 'status' => 500 ) );
    486486                        }
    487487
    488488                        $user->ID = $user_id;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    563563
    564564                if ( ! empty( $request['roles'] ) ) {
    565565                        if ( ! current_user_can( 'promote_user', $user->ID ) ) {
    566                                 return new WP_Error( 'rest_cannot_edit_roles', __( 'Sorry, you are not allowed to edit roles of this user.' ), array( 'status' => rest_authorization_required_code() ) );
     566                                return new WP_Error( 'rest_cannot_edit_roles', _l( 'Sorry, you are not allowed to edit roles of this user.' ), array( 'status' => rest_authorization_required_code() ) );
    567567                        }
    568568
    569569                        $request_params = array_keys( $request->get_params() );
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    576576                }
    577577
    578578                if ( ! current_user_can( 'edit_user', $user->ID ) ) {
    579                         return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this user.' ), array( 'status' => rest_authorization_required_code() ) );
     579                        return new WP_Error( 'rest_cannot_edit', _l( 'Sorry, you are not allowed to edit this user.' ), array( 'status' => rest_authorization_required_code() ) );
    580580                }
    581581
    582582                return true;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    599599                $id = $user->ID;
    600600
    601601                if ( ! $user ) {
    602                         return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
     602                        return new WP_Error( 'rest_user_invalid_id', _l( 'Invalid user ID.' ), array( 'status' => 404 ) );
    603603                }
    604604
    605605                if ( email_exists( $request['email'] ) && $request['email'] !== $user->user_email ) {
    606                         return new WP_Error( 'rest_user_invalid_email', __( 'Invalid email address.' ), array( 'status' => 400 ) );
     606                        return new WP_Error( 'rest_user_invalid_email', _l( 'Invalid email address.' ), array( 'status' => 400 ) );
    607607                }
    608608
    609609                if ( ! empty( $request['username'] ) && $request['username'] !== $user->user_login ) {
    610                         return new WP_Error( 'rest_user_invalid_argument', __( "Username isn't editable." ), array( 'status' => 400 ) );
     610                        return new WP_Error( 'rest_user_invalid_argument', _l( "Username isn't editable." ), array( 'status' => 400 ) );
    611611                }
    612612
    613613                if ( ! empty( $request['slug'] ) && $request['slug'] !== $user->user_nicename && get_user_by( 'slug', $request['slug'] ) ) {
    614                         return new WP_Error( 'rest_user_invalid_slug', __( 'Invalid slug.' ), array( 'status' => 400 ) );
     614                        return new WP_Error( 'rest_user_invalid_slug', _l( 'Invalid slug.' ), array( 'status' => 400 ) );
    615615                }
    616616
    617617                if ( ! empty( $request['roles'] ) ) {
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    710710                }
    711711
    712712                if ( ! current_user_can( 'delete_user', $user->ID ) ) {
    713                         return new WP_Error( 'rest_user_cannot_delete', __( 'Sorry, you are not allowed to delete this user.' ), array( 'status' => rest_authorization_required_code() ) );
     713                        return new WP_Error( 'rest_user_cannot_delete', _l( 'Sorry, you are not allowed to delete this user.' ), array( 'status' => rest_authorization_required_code() ) );
    714714                }
    715715
    716716                return true;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    727727        public function delete_item( $request ) {
    728728                // We don't support delete requests in multisite.
    729729                if ( is_multisite() ) {
    730                         return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 501 ) );
     730                        return new WP_Error( 'rest_cannot_delete', _l( 'The user cannot be deleted.' ), array( 'status' => 501 ) );
    731731                }
    732732                $user = $this->get_user( $request['id'] );
    733733                if ( is_wp_error( $user ) ) {
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    741741                // We don't support trashing for users.
    742742                if ( ! $force ) {
    743743                        /* translators: %s: force=true */
    744                         return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Users do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
     744                        return new WP_Error( 'rest_trash_not_supported', sprintf( _l( "Users do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) );
    745745                }
    746746
    747747                if ( ! empty( $reassign ) ) {
    748748                        if ( $reassign === $id || ! get_userdata( $reassign ) ) {
    749                                 return new WP_Error( 'rest_user_invalid_reassign', __( 'Invalid user ID for reassignment.' ), array( 'status' => 400 ) );
     749                                return new WP_Error( 'rest_user_invalid_reassign', _l( 'Invalid user ID for reassignment.' ), array( 'status' => 400 ) );
    750750                        }
    751751                }
    752752
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    760760                $result = wp_delete_user( $id, $reassign );
    761761
    762762                if ( ! $result ) {
    763                         return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 500 ) );
     763                        return new WP_Error( 'rest_cannot_delete', _l( 'The user cannot be deleted.' ), array( 'status' => 500 ) );
    764764                }
    765765
    766766                $response = new WP_REST_Response();
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    10341034
    10351035                        if ( ! isset( $wp_roles->role_objects[ $role ] ) ) {
    10361036                                /* translators: %s: role key */
    1037                                 return new WP_Error( 'rest_user_invalid_role', sprintf( __( 'The role %s does not exist.' ), $role ), array( 'status' => 400 ) );
     1037                                return new WP_Error( 'rest_user_invalid_role', sprintf( _l( 'The role %s does not exist.' ), $role ), array( 'status' => 400 ) );
    10381038                        }
    10391039
    10401040                        $potential_role = $wp_roles->role_objects[ $role ];
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    10481048                                && get_current_user_id() === $user_id
    10491049                                && ! $potential_role->has_cap( 'edit_users' )
    10501050                        ) {
    1051                                 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => rest_authorization_required_code() ) );
     1051                                return new WP_Error( 'rest_user_invalid_role', _l( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => rest_authorization_required_code() ) );
    10521052                        }
    10531053
    10541054                        /** Include admin functions to get access to get_editable_roles() */
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    10581058                        $editable_roles = get_editable_roles();
    10591059
    10601060                        if ( empty( $editable_roles[ $role ] ) ) {
    1061                                 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => 403 ) );
     1061                                return new WP_Error( 'rest_user_invalid_role', _l( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => 403 ) );
    10621062                        }
    10631063                }
    10641064
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    10811081                $username = (string) $value;
    10821082
    10831083                if ( ! validate_username( $username ) ) {
    1084                         return new WP_Error( 'rest_user_invalid_username', __( 'Username contains invalid characters.' ), array( 'status' => 400 ) );
     1084                        return new WP_Error( 'rest_user_invalid_username', _l( 'Username contains invalid characters.' ), array( 'status' => 400 ) );
    10851085                }
    10861086
    10871087                /** This filter is documented in wp-includes/user.php */
    10881088                $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
    10891089
    10901090                if ( in_array( strtolower( $username ), array_map( 'strtolower', $illegal_logins ) ) ) {
    1091                         return new WP_Error( 'rest_user_invalid_username', __( 'Sorry, that username is not allowed.' ), array( 'status' => 400 ) );
     1091                        return new WP_Error( 'rest_user_invalid_username', _l( 'Sorry, that username is not allowed.' ), array( 'status' => 400 ) );
    10921092                }
    10931093
    10941094                return $username;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11101110                $password = (string) $value;
    11111111
    11121112                if ( empty( $password ) ) {
    1113                         return new WP_Error( 'rest_user_invalid_password', __( 'Passwords cannot be empty.' ), array( 'status' => 400 ) );
     1113                        return new WP_Error( 'rest_user_invalid_password', _l( 'Passwords cannot be empty.' ), array( 'status' => 400 ) );
    11141114                }
    11151115
    11161116                if ( false !== strpos( $password, "\\" ) ) {
    1117                         return new WP_Error( 'rest_user_invalid_password', __( 'Passwords cannot contain the "\\" character.' ), array( 'status' => 400 ) );
     1117                        return new WP_Error( 'rest_user_invalid_password', _l( 'Passwords cannot contain the "\\" character.' ), array( 'status' => 400 ) );
    11181118                }
    11191119
    11201120                return $password;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11341134                        'type'       => 'object',
    11351135                        'properties' => array(
    11361136                                'id'          => array(
    1137                                         'description' => __( 'Unique identifier for the user.' ),
     1137                                        'description' => _l( 'Unique identifier for the user.' ),
    11381138                                        'type'        => 'integer',
    11391139                                        'context'     => array( 'embed', 'view', 'edit' ),
    11401140                                        'readonly'    => true,
    11411141                                ),
    11421142                                'username'    => array(
    1143                                         'description' => __( 'Login name for the user.' ),
     1143                                        'description' => _l( 'Login name for the user.' ),
    11441144                                        'type'        => 'string',
    11451145                                        'context'     => array( 'edit' ),
    11461146                                        'required'    => true,
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11491149                                        ),
    11501150                                ),
    11511151                                'name'        => array(
    1152                                         'description' => __( 'Display name for the user.' ),
     1152                                        'description' => _l( 'Display name for the user.' ),
    11531153                                        'type'        => 'string',
    11541154                                        'context'     => array( 'embed', 'view', 'edit' ),
    11551155                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11571157                                        ),
    11581158                                ),
    11591159                                'first_name'  => array(
    1160                                         'description' => __( 'First name for the user.' ),
     1160                                        'description' => _l( 'First name for the user.' ),
    11611161                                        'type'        => 'string',
    11621162                                        'context'     => array( 'edit' ),
    11631163                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11651165                                        ),
    11661166                                ),
    11671167                                'last_name'   => array(
    1168                                         'description' => __( 'Last name for the user.' ),
     1168                                        'description' => _l( 'Last name for the user.' ),
    11691169                                        'type'        => 'string',
    11701170                                        'context'     => array( 'edit' ),
    11711171                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11731173                                        ),
    11741174                                ),
    11751175                                'email'       => array(
    1176                                         'description' => __( 'The email address for the user.' ),
     1176                                        'description' => _l( 'The email address for the user.' ),
    11771177                                        'type'        => 'string',
    11781178                                        'format'      => 'email',
    11791179                                        'context'     => array( 'edit' ),
    11801180                                        'required'    => true,
    11811181                                ),
    11821182                                'url'         => array(
    1183                                         'description' => __( 'URL of the user.' ),
     1183                                        'description' => _l( 'URL of the user.' ),
    11841184                                        'type'        => 'string',
    11851185                                        'format'      => 'uri',
    11861186                                        'context'     => array( 'embed', 'view', 'edit' ),
    11871187                                ),
    11881188                                'description' => array(
    1189                                         'description' => __( 'Description of the user.' ),
     1189                                        'description' => _l( 'Description of the user.' ),
    11901190                                        'type'        => 'string',
    11911191                                        'context'     => array( 'embed', 'view', 'edit' ),
    11921192                                ),
    11931193                                'link'        => array(
    1194                                         'description' => __( 'Author URL of the user.' ),
     1194                                        'description' => _l( 'Author URL of the user.' ),
    11951195                                        'type'        => 'string',
    11961196                                        'format'      => 'uri',
    11971197                                        'context'     => array( 'embed', 'view', 'edit' ),
    11981198                                        'readonly'    => true,
    11991199                                ),
    12001200                                'locale'    => array(
    1201                                         'description' => __( 'Locale for the user.' ),
     1201                                        'description' => _l( 'Locale for the user.' ),
    12021202                                        'type'        => 'string',
    12031203                                        'enum'        => array_merge( array( '', 'en_US' ), get_available_languages() ),
    12041204                                        'context'     => array( 'edit' ),
    12051205                                ),
    12061206                                'nickname'    => array(
    1207                                         'description' => __( 'The nickname for the user.' ),
     1207                                        'description' => _l( 'The nickname for the user.' ),
    12081208                                        'type'        => 'string',
    12091209                                        'context'     => array( 'edit' ),
    12101210                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12121212                                        ),
    12131213                                ),
    12141214                                'slug'        => array(
    1215                                         'description' => __( 'An alphanumeric identifier for the user.' ),
     1215                                        'description' => _l( 'An alphanumeric identifier for the user.' ),
    12161216                                        'type'        => 'string',
    12171217                                        'context'     => array( 'embed', 'view', 'edit' ),
    12181218                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12201220                                        ),
    12211221                                ),
    12221222                                'registered_date' => array(
    1223                                         'description' => __( 'Registration date for the user.' ),
     1223                                        'description' => _l( 'Registration date for the user.' ),
    12241224                                        'type'        => 'string',
    12251225                                        'format'      => 'date-time',
    12261226                                        'context'     => array( 'edit' ),
    12271227                                        'readonly'    => true,
    12281228                                ),
    12291229                                'roles'           => array(
    1230                                         'description' => __( 'Roles assigned to the user.' ),
     1230                                        'description' => _l( 'Roles assigned to the user.' ),
    12311231                                        'type'        => 'array',
    12321232                                        'items'       => array(
    12331233                                                'type'    => 'string',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12351235                                        'context'     => array( 'edit' ),
    12361236                                ),
    12371237                                'password'        => array(
    1238                                         'description' => __( 'Password for the user (never included).' ),
     1238                                        'description' => _l( 'Password for the user (never included).' ),
    12391239                                        'type'        => 'string',
    12401240                                        'context'     => array(), // Password is never displayed.
    12411241                                        'required'    => true,
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12441244                                        ),
    12451245                                ),
    12461246                                'capabilities'    => array(
    1247                                         'description' => __( 'All capabilities assigned to the user.' ),
     1247                                        'description' => _l( 'All capabilities assigned to the user.' ),
    12481248                                        'type'        => 'object',
    12491249                                        'context'     => array( 'edit' ),
    12501250                                        'readonly'    => true,
    12511251                                ),
    12521252                                'extra_capabilities' => array(
    1253                                         'description' => __( 'Any extra capabilities assigned to the user.' ),
     1253                                        'description' => _l( 'Any extra capabilities assigned to the user.' ),
    12541254                                        'type'        => 'object',
    12551255                                        'context'     => array( 'edit' ),
    12561256                                        'readonly'    => true,
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12661266                        foreach ( $avatar_sizes as $size ) {
    12671267                                $avatar_properties[ $size ] = array(
    12681268                                        /* translators: %d: avatar image size in pixels */
    1269                                         'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' ), $size ),
     1269                                        'description' => sprintf( _l( 'Avatar URL with image size of %d pixels.' ), $size ),
    12701270                                        'type'        => 'string',
    12711271                                        'format'      => 'uri',
    12721272                                        'context'     => array( 'embed', 'view', 'edit' ),
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12741274                        }
    12751275
    12761276                        $schema['properties']['avatar_urls']  = array(
    1277                                 'description' => __( 'Avatar URLs for the user.' ),
     1277                                'description' => _l( 'Avatar URLs for the user.' ),
    12781278                                'type'        => 'object',
    12791279                                'context'     => array( 'embed', 'view', 'edit' ),
    12801280                                'readonly'    => true,
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13001300                $query_params['context']['default'] = 'view';
    13011301
    13021302                $query_params['exclude'] = array(
    1303                         'description'        => __( 'Ensure result set excludes specific IDs.' ),
     1303                        'description'        => _l( 'Ensure result set excludes specific IDs.' ),
    13041304                        'type'               => 'array',
    13051305                        'items'              => array(
    13061306                                'type'           => 'integer',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13091309                );
    13101310
    13111311                $query_params['include'] = array(
    1312                         'description'        => __( 'Limit result set to specific IDs.' ),
     1312                        'description'        => _l( 'Limit result set to specific IDs.' ),
    13131313                        'type'               => 'array',
    13141314                        'items'              => array(
    13151315                                'type'           => 'integer',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13181318                );
    13191319
    13201320                $query_params['offset'] = array(
    1321                         'description'        => __( 'Offset the result set by a specific number of items.' ),
     1321                        'description'        => _l( 'Offset the result set by a specific number of items.' ),
    13221322                        'type'               => 'integer',
    13231323                );
    13241324
    13251325                $query_params['order'] = array(
    13261326                        'default'            => 'asc',
    1327                         'description'        => __( 'Order sort attribute ascending or descending.' ),
     1327                        'description'        => _l( 'Order sort attribute ascending or descending.' ),
    13281328                        'enum'               => array( 'asc', 'desc' ),
    13291329                        'type'               => 'string',
    13301330                );
    13311331
    13321332                $query_params['orderby'] = array(
    13331333                        'default'            => 'name',
    1334                         'description'        => __( 'Sort collection by object attribute.' ),
     1334                        'description'        => _l( 'Sort collection by object attribute.' ),
    13351335                        'enum'               => array(
    13361336                                'id',
    13371337                                'include',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13451345                );
    13461346
    13471347                $query_params['slug']    = array(
    1348                         'description'        => __( 'Limit result set to users with one or more specific slugs.' ),
     1348                        'description'        => _l( 'Limit result set to users with one or more specific slugs.' ),
    13491349                        'type'               => 'array',
    13501350                        'items'              => array(
    13511351                                'type'               => 'string',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13531353                );
    13541354
    13551355                $query_params['roles']   = array(
    1356                         'description'        => __( 'Limit result set to users matching at least one specific role provided. Accepts csv list or single role.' ),
     1356                        'description'        => _l( 'Limit result set to users matching at least one specific role provided. Accepts csv list or single role.' ),
    13571357                        'type'               => 'array',
    13581358                        'items'              => array(
    13591359                                'type'           => 'string',
  • src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php

    diff --git src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
    index 9288c0a284..519fcd4850 100644
    abstract class WP_REST_Meta_Fields { 
    173173                        return new WP_Error(
    174174                                'rest_cannot_delete',
    175175                                /* translators: %s: custom field key */
    176                                 sprintf( __( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
     176                                sprintf( _l( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
    177177                                array( 'key' => $name, 'status' => rest_authorization_required_code() )
    178178                        );
    179179                }
    abstract class WP_REST_Meta_Fields { 
    181181                if ( ! delete_metadata( $meta_type, $object_id, wp_slash( $meta_key ) ) ) {
    182182                        return new WP_Error(
    183183                                'rest_meta_database_error',
    184                                 __( 'Could not delete meta value from database.' ),
     184                                _l( 'Could not delete meta value from database.' ),
    185185                                array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
    186186                        );
    187187                }
    abstract class WP_REST_Meta_Fields { 
    208208                        return new WP_Error(
    209209                                'rest_cannot_update',
    210210                                /* translators: %s: custom field key */
    211                                 sprintf( __( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
     211                                sprintf( _l( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
    212212                                array( 'key' => $name, 'status' => rest_authorization_required_code() )
    213213                        );
    214214                }
    abstract class WP_REST_Meta_Fields { 
    243243                        if ( ! delete_metadata( $meta_type, $object_id, wp_slash( $meta_key ), wp_slash( $value ) ) ) {
    244244                                return new WP_Error(
    245245                                        'rest_meta_database_error',
    246                                         __( 'Could not update meta value in database.' ),
     246                                        _l( 'Could not update meta value in database.' ),
    247247                                        array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
    248248                                );
    249249                        }
    abstract class WP_REST_Meta_Fields { 
    253253                        if ( ! add_metadata( $meta_type, $object_id, wp_slash( $meta_key ), wp_slash( $value ) ) ) {
    254254                                return new WP_Error(
    255255                                        'rest_meta_database_error',
    256                                         __( 'Could not update meta value in database.' ),
     256                                        _l( 'Could not update meta value in database.' ),
    257257                                        array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
    258258                                );
    259259                        }
    abstract class WP_REST_Meta_Fields { 
    279279                        return new WP_Error(
    280280                                'rest_cannot_update',
    281281                                /* translators: %s: custom field key */
    282                                 sprintf( __( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
     282                                sprintf( _l( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
    283283                                array( 'key' => $name, 'status' => rest_authorization_required_code() )
    284284                        );
    285285                }
    abstract class WP_REST_Meta_Fields { 
    299299                if ( ! update_metadata( $meta_type, $object_id, $meta_key, $meta_value ) ) {
    300300                        return new WP_Error(
    301301                                'rest_meta_database_error',
    302                                 __( 'Could not update meta value in database.' ),
     302                                _l( 'Could not update meta value in database.' ),
    303303                                array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
    304304                        );
    305305                }
    abstract class WP_REST_Meta_Fields { 
    376376                $fields = $this->get_registered_fields();
    377377
    378378                $schema = array(
    379                         'description' => __( 'Meta fields.' ),
     379                        'description' => _l( 'Meta fields.' ),
    380380                        'type'        => 'object',
    381381                        'context'     => array( 'view', 'edit' ),
    382382                        'properties'  => array(),
  • tests/phpunit/tests/rest-api/rest-users-controller.php

    diff --git tests/phpunit/tests/rest-api/rest-users-controller.php tests/phpunit/tests/rest-api/rest-users-controller.php
    index d04cbcb7f7..e6476e14c2 100644
    class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { 
    948948                } else {
    949949                        $this->assertInternalType( 'array', $data['data']['params'] );
    950950                        $errors = $data['data']['params'];
    951                         $this->assertInternalType( 'string', $errors['username'] );
    952951                        $this->assertEquals( 'Username contains invalid characters.', $errors['username'] );
    953952                }
    954953        }
    class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { 
    988987                $data = $response->get_data();
    989988                $this->assertInternalType( 'array', $data['data']['params'] );
    990989                $errors = $data['data']['params'];
    991                 $this->assertInternalType( 'string', $errors['username'] );
    992990                $this->assertEquals( 'Sorry, that username is not allowed.', $errors['username'] );
    993991        }
    994992