Make WordPress Core

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

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

No changes, just added .diff extension for syntax highlighting.

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

    diff --git src/wp-includes/rest-api.php src/wp-includes/rest-api.php
    index fd6dc3e5f9..a06d94f7bd 100644
    function register_rest_route( $namespace, $route, $args = array(), $override = f 
    3939                 * and namespace indexes. If you really need to register a
    4040                 * non-namespaced route, call `WP_REST_Server::register_route` directly.
    4141                 */
    42                 _doing_it_wrong( 'register_rest_route', __( 'Routes must be namespaced with plugin or theme name and version.' ), '4.4.0' );
     42                _doing_it_wrong( 'register_rest_route', _l( 'Routes must be namespaced with plugin or theme name and version.' ), '4.4.0' );
    4343                return false;
    4444        } else if ( empty( $route ) ) {
    45                 _doing_it_wrong( 'register_rest_route', __( 'Route must be specified.' ), '4.4.0' );
     45                _doing_it_wrong( 'register_rest_route', _l( 'Route must be specified.' ), '4.4.0' );
    4646                return false;
    4747        }
    4848
    function rest_handle_deprecated_function( $function, $replacement, $version ) { 
    494494        }
    495495        if ( ! empty( $replacement ) ) {
    496496                /* translators: 1: function name, 2: WordPress version number, 3: new function name */
    497                 $string = sprintf( __( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement );
     497                $string = sprintf( _l( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement );
    498498        } else {
    499499                /* translators: 1: function name, 2: WordPress version number */
    500                 $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version );
     500                $string = sprintf( _l( '%1$s (since %2$s; no alternative available)' ), $function, $version );
    501501        }
    502502
    503503        header( sprintf( 'X-WP-DeprecatedFunction: %s', $string ) );
    function rest_handle_deprecated_argument( $function, $message, $version ) { 
    518518        }
    519519        if ( ! empty( $message ) ) {
    520520                /* translators: 1: function name, 2: WordPress version number, 3: error message */
    521                 $string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function, $version, $message );
     521                $string = sprintf( _l( '%1$s (since %2$s; %3$s)' ), $function, $version, $message );
    522522        } else {
    523523                /* translators: 1: function name, 2: WordPress version number */
    524                 $string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version );
     524                $string = sprintf( _l( '%1$s (since %2$s; no alternative available)' ), $function, $version );
    525525        }
    526526
    527527        header( sprintf( 'X-WP-DeprecatedParam: %s', $string ) );
    function rest_cookie_check_errors( $result ) { 
    741741        $result = wp_verify_nonce( $nonce, 'wp_rest' );
    742742
    743743        if ( ! $result ) {
    744                 return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) );
     744                return new WP_Error( 'rest_cookie_invalid_nonce', _l( 'Cookie nonce is invalid' ), array( 'status' => 403 ) );
    745745        }
    746746
    747747        // Send a refreshed nonce in header.
    function rest_validate_value_from_schema( $value, $args, $param = '' ) { 
    10461046                }
    10471047                if ( ! wp_is_numeric_array( $value ) ) {
    10481048                        /* translators: 1: parameter, 2: type name */
    1049                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'array' ) );
     1049                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $param, 'array' ) );
    10501050                }
    10511051                foreach ( $value as $index => $v ) {
    10521052                        $is_valid = rest_validate_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' );
    function rest_validate_value_from_schema( $value, $args, $param = '' ) { 
    10581058        if ( ! empty( $args['enum'] ) ) {
    10591059                if ( ! in_array( $value, $args['enum'], true ) ) {
    10601060                        /* translators: 1: parameter, 2: list of valid values */
    1061                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not one of %2$s.' ), $param, implode( ', ', $args['enum'] ) ) );
     1061                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not one of %2$s.' ), $param, implode( ', ', $args['enum'] ) ) );
    10621062                }
    10631063        }
    10641064
    10651065        if ( in_array( $args['type'], array( 'integer', 'number' ) ) && ! is_numeric( $value ) ) {
    10661066                /* translators: 1: parameter, 2: type name */
    1067                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, $args['type'] ) );
     1067                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $param, $args['type'] ) );
    10681068        }
    10691069
    10701070        if ( 'integer' === $args['type'] && round( floatval( $value ) ) !== floatval( $value ) ) {
    10711071                /* translators: 1: parameter, 2: type name */
    1072                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'integer' ) );
     1072                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $param, 'integer' ) );
    10731073        }
    10741074
    10751075        if ( 'boolean' === $args['type'] && ! rest_is_boolean( $value ) ) {
    10761076                /* translators: 1: parameter, 2: type name */
    1077                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $value, 'boolean' ) );
     1077                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $value, 'boolean' ) );
    10781078        }
    10791079
    10801080        if ( 'string' === $args['type'] && ! is_string( $value ) ) {
    10811081                /* translators: 1: parameter, 2: type name */
    1082                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'string' ) );
     1082                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s is not of type %2$s.' ), $param, 'string' ) );
    10831083        }
    10841084
    10851085        if ( isset( $args['format'] ) ) {
    10861086                switch ( $args['format'] ) {
    10871087                        case 'date-time' :
    10881088                                if ( ! rest_parse_date( $value ) ) {
    1089                                         return new WP_Error( 'rest_invalid_date', __( 'Invalid date.' ) );
     1089                                        return new WP_Error( 'rest_invalid_date', _l( 'Invalid date.' ) );
    10901090                                }
    10911091                                break;
    10921092
    10931093                        case 'email' :
    10941094                                if ( ! is_email( $value ) ) {
    1095                                         return new WP_Error( 'rest_invalid_email', __( 'Invalid email address.' ) );
     1095                                        return new WP_Error( 'rest_invalid_email', _l( 'Invalid email address.' ) );
    10961096                                }
    10971097                                break;
    10981098                        case 'ip' :
    10991099                                if ( ! rest_is_ip_address( $value ) ) {
    11001100                                        /* translators: %s: IP address */
    1101                                         return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not a valid IP address.' ), $value ) );
     1101                                        return new WP_Error( 'rest_invalid_param', sprintf( _l( '%s is not a valid IP address.' ), $value ) );
    11021102                                }
    11031103                                break;
    11041104                }
    function rest_validate_value_from_schema( $value, $args, $param = '' ) { 
    11081108                if ( isset( $args['minimum'] ) && ! isset( $args['maximum'] ) ) {
    11091109                        if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) {
    11101110                                /* translators: 1: parameter, 2: minimum number */
    1111                                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) );
     1111                                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) );
    11121112                        } elseif ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) {
    11131113                                /* translators: 1: parameter, 2: minimum number */
    1114                                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) );
     1114                                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) );
    11151115                        }
    11161116                } elseif ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) {
    11171117                        if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) {
    11181118                                /* translators: 1: parameter, 2: maximum number */
    1119                                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) );
     1119                                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) );
    11201120                        } elseif ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) {
    11211121                                /* translators: 1: parameter, 2: maximum number */
    1122                                 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) );
     1122                                return new WP_Error( 'rest_invalid_param', sprintf( _l( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) );
    11231123                        }
    11241124                } elseif ( isset( $args['maximum'] ) && isset( $args['minimum'] ) ) {
    11251125                        if ( ! empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
    11261126                                if ( $value >= $args['maximum'] || $value <= $args['minimum'] ) {
    11271127                                        /* translators: 1: parameter, 2: minimum number, 3: maximum number */
    1128                                         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'] ) );
     1128                                        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'] ) );
    11291129                                }
    11301130                        } elseif ( empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
    11311131                                if ( $value >= $args['maximum'] || $value < $args['minimum'] ) {
    11321132                                        /* translators: 1: parameter, 2: minimum number, 3: maximum number */
    1133                                         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'] ) );
     1133                                        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'] ) );
    11341134                                }
    11351135                        } elseif ( ! empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
    11361136                                if ( $value > $args['maximum'] || $value <= $args['minimum'] ) {
    11371137                                        /* translators: 1: parameter, 2: minimum number, 3: maximum number */
    1138                                         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'] ) );
     1138                                        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'] ) );
    11391139                                }
    11401140                        } elseif ( empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
    11411141                                if ( $value > $args['maximum'] || $value < $args['minimum'] ) {
    11421142                                        /* translators: 1: parameter, 2: minimum number, 3: maximum number */
    1143                                         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'] ) );
     1143                                        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'] ) );
    11441144                                }
    11451145                        }
    11461146                }
  • 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 e41c014557..83a7c2458c 100644
    class WP_REST_Request implements ArrayAccess { 
    692692                                $error_data['json_error_message'] = json_last_error_msg();
    693693                        }
    694694
    695                         return new WP_Error( 'rest_invalid_json', __( 'Invalid JSON body passed.' ), $error_data );
     695                        return new WP_Error( 'rest_invalid_json', _l( 'Invalid JSON body passed.' ), $error_data );
    696696                }
    697697
    698698                $this->params['JSON'] = $params;
    class WP_REST_Request implements ArrayAccess { 
    846846                }
    847847
    848848                if ( $invalid_params ) {
    849                         return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
     849                        return new WP_Error( 'rest_invalid_param', sprintf( _l( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
    850850                }
    851851
    852852                return true;
    class WP_REST_Request implements ArrayAccess { 
    885885                }
    886886
    887887                if ( ! empty( $required ) ) {
    888                         return new WP_Error( 'rest_missing_callback_param', sprintf( __( 'Missing parameter(s): %s' ), implode( ', ', $required ) ), array( 'status' => 400, 'params' => $required ) );
     888                        return new WP_Error( 'rest_missing_callback_param', sprintf( _l( 'Missing parameter(s): %s' ), implode( ', ', $required ) ), array( 'status' => 400, 'params' => $required ) );
    889889                }
    890890
    891891                /*
    class WP_REST_Request implements ArrayAccess { 
    903903                                $valid_check = call_user_func( $arg['validate_callback'], $param, $this, $key );
    904904
    905905                                if ( false === $valid_check ) {
    906                                         $invalid_params[ $key ] = __( 'Invalid parameter.' );
     906                                        $invalid_params[ $key ] = _l( 'Invalid parameter.' );
    907907                                }
    908908
    909909                                if ( is_wp_error( $valid_check ) ) {
    class WP_REST_Request implements ArrayAccess { 
    913913                }
    914914
    915915                if ( $invalid_params ) {
    916                         return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
     916                        return new WP_Error( 'rest_invalid_param', sprintf( _l( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
    917917                }
    918918
    919919                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 2ec8ccde23..2c1427d22b 100644
    class WP_REST_Server { 
    269269                 * @param bool $rest_enabled Whether the REST API is enabled. Default true.
    270270                 */
    271271                apply_filters_deprecated( 'rest_enabled', array( true ), '4.7.0', 'rest_authentication_errors',
    272                         __( 'The REST API can no longer be completely disabled, the rest_authentication_errors filter can be used to restrict access to the API, instead.' )
     272                        _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.' )
    273273                );
    274274
    275275                /**
    class WP_REST_Server { 
    285285
    286286                if ( isset( $_GET['_jsonp'] ) ) {
    287287                        if ( ! $jsonp_enabled ) {
    288                                 echo $this->json_error( 'rest_callback_disabled', __( 'JSONP support is disabled on this site.' ), 400 );
     288                                echo $this->json_error( 'rest_callback_disabled', _l( 'JSONP support is disabled on this site.' ), 400 );
    289289                                return false;
    290290                        }
    291291
    292292                        $jsonp_callback = $_GET['_jsonp'];
    293293                        if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) {
    294                                 echo $this->json_error( 'rest_callback_invalid', __( 'Invalid JSONP callback function.' ), 400 );
     294                                echo $this->json_error( 'rest_callback_invalid', _l( 'Invalid JSONP callback function.' ), 400 );
    295295                                return false;
    296296                        }
    297297                }
    class WP_REST_Server { 
    862862                                }
    863863
    864864                                if ( ! is_callable( $callback ) ) {
    865                                         $response = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) );
     865                                        $response = new WP_Error( 'rest_invalid_handler', _l( 'The handler for the route is invalid' ), array( 'status' => 500 ) );
    866866                                }
    867867
    868868                                if ( ! is_wp_error( $response ) ) {
    class WP_REST_Server { 
    919919                                                if ( is_wp_error( $permission ) ) {
    920920                                                        $response = $permission;
    921921                                                } elseif ( false === $permission || null === $permission ) {
    922                                                         $response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => 403 ) );
     922                                                        $response = new WP_Error( 'rest_forbidden', _l( 'Sorry, you are not allowed to do that.' ), array( 'status' => 403 ) );
    923923                                                }
    924924                                        }
    925925                                }
    class WP_REST_Server { 
    983983                        }
    984984                }
    985985
    986                 return $this->error_to_response( new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method' ), array( 'status' => 404 ) ) );
     986                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 ) ) );
    987987        }
    988988
    989989        /**
    class WP_REST_Server { 
    10731073                $namespace = $request['namespace'];
    10741074
    10751075                if ( ! isset( $this->namespaces[ $namespace ] ) ) {
    1076                         return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) );
     1076                        return new WP_Error( 'rest_invalid_namespace', _l( 'The specified namespace could not be found.' ), array( 'status' => 404 ) );
    10771077                }
    10781078
    10791079                $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 43d057e167..d00bff397b 100644
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    7272                }
    7373
    7474                if ( ! current_user_can( 'upload_files' ) ) {
    75                         return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to upload media on this site.' ), array( 'status' => 400 ) );
     75                        return new WP_Error( 'rest_cannot_create', _l( 'Sorry, you are not allowed to upload media on this site.' ), array( 'status' => 400 ) );
    7676                }
    7777
    7878                // Attaching media to a post requires ability to edit said post.
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    8181                        $post_parent_type = get_post_type_object( $parent->post_type );
    8282
    8383                        if ( ! current_user_can( $post_parent_type->cap->edit_post, $request['post'] ) ) {
    84                                 return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to upload media to this post.' ), array( 'status' => rest_authorization_required_code() ) );
     84                                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() ) );
    8585                        }
    8686                }
    8787
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    100100        public function create_item( $request ) {
    101101
    102102                if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) {
    103                         return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) );
     103                        return new WP_Error( 'rest_invalid_param', _l( 'Invalid parent type.' ), array( 'status' => 400 ) );
    104104                }
    105105
    106106                // Get the file via $_FILES or raw data.
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    207207         */
    208208        public function update_item( $request ) {
    209209                if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) {
    210                         return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) );
     210                        return new WP_Error( 'rest_invalid_param', _l( 'Invalid parent type.' ), array( 'status' => 400 ) );
    211211                }
    212212
    213213                $response = parent::update_item( $request );
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    384384                $schema = parent::get_item_schema();
    385385
    386386                $schema['properties']['alt_text'] = array(
    387                         'description'     => __( 'Alternative text to display when attachment is not displayed.' ),
     387                        'description'     => _l( 'Alternative text to display when attachment is not displayed.' ),
    388388                        'type'            => 'string',
    389389                        'context'         => array( 'view', 'edit', 'embed' ),
    390390                        'arg_options'     => array(
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    393393                );
    394394
    395395                $schema['properties']['caption'] = array(
    396                         'description' => __( 'The attachment caption.' ),
     396                        'description' => _l( 'The attachment caption.' ),
    397397                        'type'        => 'object',
    398398                        'context'     => array( 'view', 'edit', 'embed' ),
    399399                        'arg_options' => array(
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    401401                        ),
    402402                        'properties'  => array(
    403403                                'raw' => array(
    404                                         'description' => __( 'Caption for the attachment, as it exists in the database.' ),
     404                                        'description' => _l( 'Caption for the attachment, as it exists in the database.' ),
    405405                                        'type'        => 'string',
    406406                                        'context'     => array( 'edit' ),
    407407                                ),
    408408                                'rendered' => array(
    409                                         'description' => __( 'HTML caption for the attachment, transformed for display.' ),
     409                                        'description' => _l( 'HTML caption for the attachment, transformed for display.' ),
    410410                                        'type'        => 'string',
    411411                                        'context'     => array( 'view', 'edit', 'embed' ),
    412412                                        'readonly'    => true,
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    415415                );
    416416
    417417                $schema['properties']['description'] = array(
    418                         'description' => __( 'The attachment description.' ),
     418                        'description' => _l( 'The attachment description.' ),
    419419                        'type'        => 'object',
    420420                        'context'     => array( 'view', 'edit' ),
    421421                        'arg_options' => array(
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    423423                        ),
    424424                        'properties'  => array(
    425425                                'raw' => array(
    426                                         'description' => __( 'Description for the object, as it exists in the database.' ),
     426                                        'description' => _l( 'Description for the object, as it exists in the database.' ),
    427427                                        'type'        => 'string',
    428428                                        'context'     => array( 'edit' ),
    429429                                ),
    430430                                'rendered' => array(
    431                                         'description' => __( 'HTML description for the object, transformed for display.' ),
     431                                        'description' => _l( 'HTML description for the object, transformed for display.' ),
    432432                                        'type'        => 'string',
    433433                                        'context'     => array( 'view', 'edit' ),
    434434                                        'readonly'    => true,
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    437437                );
    438438
    439439                $schema['properties']['media_type'] = array(
    440                         'description'     => __( 'Attachment type.' ),
     440                        'description'     => _l( 'Attachment type.' ),
    441441                        'type'            => 'string',
    442442                        'enum'            => array( 'image', 'file' ),
    443443                        'context'         => array( 'view', 'edit', 'embed' ),
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    445445                );
    446446
    447447                $schema['properties']['mime_type'] = array(
    448                         'description'     => __( 'The attachment MIME type.' ),
     448                        'description'     => _l( 'The attachment MIME type.' ),
    449449                        'type'            => 'string',
    450450                        'context'         => array( 'view', 'edit', 'embed' ),
    451451                        'readonly'        => true,
    452452                );
    453453
    454454                $schema['properties']['media_details'] = array(
    455                         'description'     => __( 'Details about the media file, specific to its type.' ),
     455                        'description'     => _l( 'Details about the media file, specific to its type.' ),
    456456                        'type'            => 'object',
    457457                        'context'         => array( 'view', 'edit', 'embed' ),
    458458                        'readonly'        => true,
    459459                );
    460460
    461461                $schema['properties']['post'] = array(
    462                         'description'     => __( 'The ID for the associated post of the attachment.' ),
     462                        'description'     => _l( 'The ID for the associated post of the attachment.' ),
    463463                        'type'            => 'integer',
    464464                        'context'         => array( 'view', 'edit' ),
    465465                );
    466466
    467467                $schema['properties']['source_url'] = array(
    468                         'description'     => __( 'URL to the original attachment file.' ),
     468                        'description'     => _l( 'URL to the original attachment file.' ),
    469469                        'type'            => 'string',
    470470                        'format'          => 'uri',
    471471                        'context'         => array( 'view', 'edit', 'embed' ),
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    489489         */
    490490        protected function upload_from_data( $data, $headers ) {
    491491                if ( empty( $data ) ) {
    492                         return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) );
     492                        return new WP_Error( 'rest_upload_no_data', _l( 'No data supplied.' ), array( 'status' => 400 ) );
    493493                }
    494494
    495495                if ( empty( $headers['content_type'] ) ) {
    496                         return new WP_Error( 'rest_upload_no_content_type', __( 'No Content-Type supplied.' ), array( 'status' => 400 ) );
     496                        return new WP_Error( 'rest_upload_no_content_type', _l( 'No Content-Type supplied.' ), array( 'status' => 400 ) );
    497497                }
    498498
    499499                if ( empty( $headers['content_disposition'] ) ) {
    500                         return new WP_Error( 'rest_upload_no_content_disposition', __( 'No Content-Disposition supplied.' ), array( 'status' => 400 ) );
     500                        return new WP_Error( 'rest_upload_no_content_disposition', _l( 'No Content-Disposition supplied.' ), array( 'status' => 400 ) );
    501501                }
    502502
    503503                $filename = self::get_filename_from_disposition( $headers['content_disposition'] );
    504504
    505505                if ( empty( $filename ) ) {
    506                         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 ) );
     506                        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 ) );
    507507                }
    508508
    509509                if ( ! empty( $headers['content_md5'] ) ) {
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    512512                        $actual      = md5( $data );
    513513
    514514                        if ( $expected !== $actual ) {
    515                                 return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
     515                                return new WP_Error( 'rest_upload_hash_mismatch', _l( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
    516516                        }
    517517                }
    518518
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    528528                $fp = fopen( $tmpfname, 'w+' );
    529529
    530530                if ( ! $fp ) {
    531                         return new WP_Error( 'rest_upload_file_error', __( 'Could not open file handle.' ), array( 'status' => 500 ) );
     531                        return new WP_Error( 'rest_upload_file_error', _l( 'Could not open file handle.' ), array( 'status' => 500 ) );
    532532                }
    533533
    534534                fwrite( $fp, $data );
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    644644
    645645                $params['media_type'] = array(
    646646                        'default'           => null,
    647                         'description'       => __( 'Limit result set to attachments of a particular media type.' ),
     647                        'description'       => _l( 'Limit result set to attachments of a particular media type.' ),
    648648                        'type'              => 'string',
    649649                        'enum'              => array_keys( $media_types ),
    650650                );
    651651
    652652                $params['mime_type'] = array(
    653653                        'default'     => null,
    654                         'description' => __( 'Limit result set to attachments of a particular MIME type.' ),
     654                        'description' => _l( 'Limit result set to attachments of a particular MIME type.' ),
    655655                        'type'        => 'string',
    656656                );
    657657
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    689689         */
    690690        protected function upload_from_file( $files, $headers ) {
    691691                if ( empty( $files ) ) {
    692                         return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) );
     692                        return new WP_Error( 'rest_upload_no_data', _l( 'No data supplied.' ), array( 'status' => 400 ) );
    693693                }
    694694
    695695                // Verify hash, if given.
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    699699                        $actual      = md5_file( $files['file']['tmp_name'] );
    700700
    701701                        if ( $expected !== $actual ) {
    702                                 return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
     702                                return new WP_Error( 'rest_upload_hash_mismatch', _l( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
    703703                        }
    704704                }
    705705
  • 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 4ed2026dcb..2a2fe5515d 100644
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    6565                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    6666                        'args' => array(
    6767                                'id' => array(
    68                                         'description' => __( 'Unique identifier for the object.' ),
     68                                        'description' => _l( 'Unique identifier for the object.' ),
    6969                                        'type'        => 'integer',
    7070                                ),
    7171                        ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    7676                                'args'     => array(
    7777                                        'context'          => $this->get_context_param( array( 'default' => 'view' ) ),
    7878                                        'password' => array(
    79                                                 'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
     79                                                'description' => _l( 'The password for the parent post of the comment (if the post is password protected).' ),
    8080                                                'type'        => 'string',
    8181                                        ),
    8282                                ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    9595                                        'force'    => array(
    9696                                                'type'        => 'boolean',
    9797                                                'default'     => false,
    98                                                 'description' => __( 'Whether to bypass trash and force deletion.' ),
     98                                                'description' => _l( 'Whether to bypass trash and force deletion.' ),
    9999                                        ),
    100100                                        'password' => array(
    101                                                 'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
     101                                                'description' => _l( 'The password for the parent post of the comment (if the post is password protected).' ),
    102102                                                'type'        => 'string',
    103103                                        ),
    104104                                ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    123123                                $post = get_post( $post_id );
    124124
    125125                                if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post, $request ) ) {
    126                                         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() ) );
     126                                        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() ) );
    127127                                } elseif ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) {
    128                                         return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) );
     128                                        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() ) );
    129129                                }
    130130                        }
    131131                }
    132132
    133133                if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
    134                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
     134                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
    135135                }
    136136
    137137                if ( ! current_user_can( 'edit_posts' ) ) {
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    153153                        }
    154154
    155155                        if ( ! empty( $forbidden_params ) ) {
    156                                 return new WP_Error( 'rest_forbidden_param', sprintf( __( 'Query parameter not permitted: %s' ), implode( ', ', $forbidden_params ) ), array( 'status' => rest_authorization_required_code() ) );
     156                                return new WP_Error( 'rest_forbidden_param', sprintf( _l( 'Query parameter not permitted: %s' ), implode( ', ', $forbidden_params ) ), array( 'status' => rest_authorization_required_code() ) );
    157157                        }
    158158                }
    159159
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    314314         * @return WP_Comment|WP_Error Comment object if ID is valid, WP_Error otherwise.
    315315         */
    316316        protected function get_comment( $id ) {
    317                 $error = new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment ID.' ), array( 'status' => 404 ) );
     317                $error = new WP_Error( 'rest_comment_invalid_id', _l( 'Invalid comment ID.' ), array( 'status' => 404 ) );
    318318                if ( (int) $id <= 0 ) {
    319319                        return $error;
    320320                }
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    328328                if ( ! empty( $comment->comment_post_ID ) ) {
    329329                        $post = get_post( (int) $comment->comment_post_ID );
    330330                        if ( empty( $post ) ) {
    331                                 return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
     331                                return new WP_Error( 'rest_post_invalid_id', _l( 'Invalid post ID.' ), array( 'status' => 404 ) );
    332332                        }
    333333                }
    334334
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    351351                }
    352352
    353353                if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
    354                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
     354                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
    355355                }
    356356
    357357                $post = get_post( $comment->comment_post_ID );
    358358
    359359                if ( ! $this->check_read_permission( $comment, $request ) ) {
    360                         return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     360                        return new WP_Error( 'rest_cannot_read', _l( 'Sorry, you are not allowed to read this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    361361                }
    362362
    363363                if ( $post && ! $this->check_read_post_permission( $post, $request ) ) {
    364                         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() ) );
     364                        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() ) );
    365365                }
    366366
    367367                return true;
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    400400        public function create_item_permissions_check( $request ) {
    401401                if ( ! is_user_logged_in() ) {
    402402                        if ( get_option( 'comment_registration' ) ) {
    403                                 return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
     403                                return new WP_Error( 'rest_comment_login_required', _l( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
    404404                        }
    405405
    406406                        /**
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    417417                         */
    418418                        $allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request );
    419419                        if ( ! $allow_anonymous ) {
    420                                 return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
     420                                return new WP_Error( 'rest_comment_login_required', _l( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
    421421                        }
    422422                }
    423423
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    425425                if ( isset( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( 'moderate_comments' ) ) {
    426426                        return new WP_Error( 'rest_comment_invalid_author',
    427427                                /* translators: %s: request parameter */
    428                                 sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author' ),
     428                                sprintf( _l( "Sorry, you are not allowed to edit '%s' for comments." ), 'author' ),
    429429                                array( 'status' => rest_authorization_required_code() )
    430430                        );
    431431                }
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    434434                        if ( empty( $_SERVER['REMOTE_ADDR'] ) || $request['author_ip'] !== $_SERVER['REMOTE_ADDR'] ) {
    435435                                return new WP_Error( 'rest_comment_invalid_author_ip',
    436436                                        /* translators: %s: request parameter */
    437                                         sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author_ip' ),
     437                                        sprintf( _l( "Sorry, you are not allowed to edit '%s' for comments." ), 'author_ip' ),
    438438                                        array( 'status' => rest_authorization_required_code() )
    439439                                );
    440440                        }
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    443443                if ( isset( $request['status'] ) && ! current_user_can( 'moderate_comments' ) ) {
    444444                        return new WP_Error( 'rest_comment_invalid_status',
    445445                                /* translators: %s: request parameter */
    446                                 sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'status' ),
     446                                sprintf( _l( "Sorry, you are not allowed to edit '%s' for comments." ), 'status' ),
    447447                                array( 'status' => rest_authorization_required_code() )
    448448                        );
    449449                }
    450450
    451451                if ( empty( $request['post'] ) ) {
    452                         return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) );
     452                        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 ) );
    453453                }
    454454
    455455                $post = get_post( (int) $request['post'] );
    456456                if ( ! $post ) {
    457                         return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) );
     457                        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 ) );
    458458                }
    459459
    460460                if ( 'draft' === $post->post_status ) {
    461                         return new WP_Error( 'rest_comment_draft_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
     461                        return new WP_Error( 'rest_comment_draft_post', _l( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
    462462                }
    463463
    464464                if ( 'trash' === $post->post_status ) {
    465                         return new WP_Error( 'rest_comment_trash_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
     465                        return new WP_Error( 'rest_comment_trash_post', _l( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
    466466                }
    467467
    468468                if ( ! $this->check_read_post_permission( $post, $request ) ) {
    469                         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() ) );
     469                        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() ) );
    470470                }
    471471
    472472                if ( ! comments_open( $post->ID ) ) {
    473                         return new WP_Error( 'rest_comment_closed', __( 'Sorry, comments are closed for this item.' ), array( 'status' => 403 ) );
     473                        return new WP_Error( 'rest_comment_closed', _l( 'Sorry, comments are closed for this item.' ), array( 'status' => 403 ) );
    474474                }
    475475
    476476                return true;
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    487487         */
    488488        public function create_item( $request ) {
    489489                if ( ! empty( $request['id'] ) ) {
    490                         return new WP_Error( 'rest_comment_exists', __( 'Cannot create existing comment.' ), array( 'status' => 400 ) );
     490                        return new WP_Error( 'rest_comment_exists', _l( 'Cannot create existing comment.' ), array( 'status' => 400 ) );
    491491                }
    492492
    493493                // Do not allow comments to be created with a non-default type.
    494494                if ( ! empty( $request['type'] ) && 'comment' !== $request['type'] ) {
    495                         return new WP_Error( 'rest_invalid_comment_type', __( 'Cannot create a comment with that type.' ), array( 'status' => 400 ) );
     495                        return new WP_Error( 'rest_invalid_comment_type', _l( 'Cannot create a comment with that type.' ), array( 'status' => 400 ) );
    496496                }
    497497
    498498                $prepared_comment = $this->prepare_item_for_database( $request );
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    507507                 * comment_content. See wp_handle_comment_submission().
    508508                 */
    509509                if ( empty( $prepared_comment['comment_content'] ) ) {
    510                         return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) );
     510                        return new WP_Error( 'rest_comment_content_invalid', _l( 'Invalid comment content.' ), array( 'status' => 400 ) );
    511511                }
    512512
    513513                // Setting remaining values before wp_insert_comment so we can use wp_allow_comment().
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    533533                // Honor the discussion setting that requires a name and email address of the comment author.
    534534                if ( get_option( 'require_name_email' ) ) {
    535535                        if ( empty( $prepared_comment['comment_author'] ) || empty( $prepared_comment['comment_author_email'] ) ) {
    536                                 return new WP_Error( 'rest_comment_author_data_required', __( 'Creating a comment requires valid author name and email values.' ), array( 'status' => 400 ) );
     536                                return new WP_Error( 'rest_comment_author_data_required', _l( 'Creating a comment requires valid author name and email values.' ), array( 'status' => 400 ) );
    537537                        }
    538538                }
    539539
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    552552                $check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_comment );
    553553                if ( is_wp_error( $check_comment_lengths ) ) {
    554554                        $error_code = $check_comment_lengths->get_error_code();
    555                         return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
     555                        return new WP_Error( $error_code, _l( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
    556556                }
    557557
    558558                $prepared_comment['comment_approved'] = wp_allow_comment( $prepared_comment, true );
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    593593                $comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) );
    594594
    595595                if ( ! $comment_id ) {
    596                         return new WP_Error( 'rest_comment_failed_create', __( 'Creating comment failed.' ), array( 'status' => 500 ) );
     596                        return new WP_Error( 'rest_comment_failed_create', _l( 'Creating comment failed.' ), array( 'status' => 500 ) );
    597597                }
    598598
    599599                if ( isset( $request['status'] ) ) {
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    660660                }
    661661
    662662                if ( ! $this->check_edit_permission( $comment ) ) {
    663                         return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     663                        return new WP_Error( 'rest_cannot_edit', _l( 'Sorry, you are not allowed to edit this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    664664                }
    665665
    666666                return true;
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    684684                $id = $comment->comment_ID;
    685685
    686686                if ( isset( $request['type'] ) && get_comment_type( $id ) !== $request['type'] ) {
    687                         return new WP_Error( 'rest_comment_invalid_type', __( 'Sorry, you are not allowed to change the comment type.' ), array( 'status' => 404 ) );
     687                        return new WP_Error( 'rest_comment_invalid_type', _l( 'Sorry, you are not allowed to change the comment type.' ), array( 'status' => 404 ) );
    688688                }
    689689
    690690                $prepared_args = $this->prepare_item_for_database( $request );
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    696696                if ( ! empty( $prepared_args['comment_post_ID'] ) ) {
    697697                        $post = get_post( $prepared_args['comment_post_ID'] );
    698698                        if ( empty( $post ) ) {
    699                                 return new WP_Error( 'rest_comment_invalid_post_id', __( 'Invalid post ID.' ), array( 'status' => 403 ) );
     699                                return new WP_Error( 'rest_comment_invalid_post_id', _l( 'Invalid post ID.' ), array( 'status' => 403 ) );
    700700                        }
    701701                }
    702702
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    705705                        $change = $this->handle_status_param( $request['status'], $id );
    706706
    707707                        if ( ! $change ) {
    708                                 return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment status failed.' ), array( 'status' => 500 ) );
     708                                return new WP_Error( 'rest_comment_failed_edit', _l( 'Updating comment status failed.' ), array( 'status' => 500 ) );
    709709                        }
    710710                } elseif ( ! empty( $prepared_args ) ) {
    711711                        if ( is_wp_error( $prepared_args ) ) {
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    713713                        }
    714714
    715715                        if ( isset( $prepared_args['comment_content'] ) && empty( $prepared_args['comment_content'] ) ) {
    716                                 return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) );
     716                                return new WP_Error( 'rest_comment_content_invalid', _l( 'Invalid comment content.' ), array( 'status' => 400 ) );
    717717                        }
    718718
    719719                        $prepared_args['comment_ID'] = $id;
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    721721                        $check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_args );
    722722                        if ( is_wp_error( $check_comment_lengths ) ) {
    723723                                $error_code = $check_comment_lengths->get_error_code();
    724                                 return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
     724                                return new WP_Error( $error_code, _l( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
    725725                        }
    726726
    727727                        $updated = wp_update_comment( wp_slash( (array) $prepared_args ) );
    728728
    729729                        if ( false === $updated ) {
    730                                 return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment failed.' ), array( 'status' => 500 ) );
     730                                return new WP_Error( 'rest_comment_failed_edit', _l( 'Updating comment failed.' ), array( 'status' => 500 ) );
    731731                        }
    732732
    733733                        if ( isset( $request['status'] ) ) {
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    779779                }
    780780
    781781                if ( ! $this->check_edit_permission( $comment ) ) {
    782                         return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this comment.' ), array( 'status' => rest_authorization_required_code() ) );
     782                        return new WP_Error( 'rest_cannot_delete', _l( 'Sorry, you are not allowed to delete this comment.' ), array( 'status' => rest_authorization_required_code() ) );
    783783                }
    784784                return true;
    785785        }
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    823823                } else {
    824824                        // If this type doesn't support trashing, error out.
    825825                        if ( ! $supports_trash ) {
    826                                 return new WP_Error( 'rest_trash_not_supported', __( 'The comment does not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
     826                                return new WP_Error( 'rest_trash_not_supported', _l( 'The comment does not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
    827827                        }
    828828
    829829                        if ( 'trash' === $comment->comment_approved ) {
    830                                 return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.' ), array( 'status' => 410 ) );
     830                                return new WP_Error( 'rest_already_trashed', _l( 'The comment has already been trashed.' ), array( 'status' => 410 ) );
    831831                        }
    832832
    833833                        $result = wp_trash_comment( $comment->comment_ID );
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    836836                }
    837837
    838838                if ( ! $result ) {
    839                         return new WP_Error( 'rest_cannot_delete', __( 'The comment cannot be deleted.' ), array( 'status' => 500 ) );
     839                        return new WP_Error( 'rest_cannot_delete', _l( 'The comment cannot be deleted.' ), array( 'status' => 500 ) );
    840840                }
    841841
    842842                /**
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    10921092                                $prepared_comment['comment_author_email'] = $user->user_email;
    10931093                                $prepared_comment['comment_author_url'] = $user->user_url;
    10941094                        } else {
    1095                                 return new WP_Error( 'rest_comment_author_invalid', __( 'Invalid comment author ID.' ), array( 'status' => 400 ) );
     1095                                return new WP_Error( 'rest_comment_author_invalid', _l( 'Invalid comment author ID.' ), array( 'status' => 400 ) );
    10961096                        }
    10971097                }
    10981098
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11641164                        'type'                 => 'object',
    11651165                        'properties'           => array(
    11661166                                'id'               => array(
    1167                                         'description'  => __( 'Unique identifier for the object.' ),
     1167                                        'description'  => _l( 'Unique identifier for the object.' ),
    11681168                                        'type'         => 'integer',
    11691169                                        'context'      => array( 'view', 'edit', 'embed' ),
    11701170                                        'readonly'     => true,
    11711171                                ),
    11721172                                'author'           => array(
    1173                                         'description'  => __( 'The ID of the user object, if author was a user.' ),
     1173                                        'description'  => _l( 'The ID of the user object, if author was a user.' ),
    11741174                                        'type'         => 'integer',
    11751175                                        'context'      => array( 'view', 'edit', 'embed' ),
    11761176                                ),
    11771177                                'author_email'     => array(
    1178                                         'description'  => __( 'Email address for the object author.' ),
     1178                                        'description'  => _l( 'Email address for the object author.' ),
    11791179                                        'type'         => 'string',
    11801180                                        'format'       => 'email',
    11811181                                        'context'      => array( 'edit' ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11851185                                        ),
    11861186                                ),
    11871187                                'author_ip'     => array(
    1188                                         'description'  => __( 'IP address for the object author.' ),
     1188                                        'description'  => _l( 'IP address for the object author.' ),
    11891189                                        'type'         => 'string',
    11901190                                        'format'       => 'ip',
    11911191                                        'context'      => array( 'edit' ),
    11921192                                ),
    11931193                                'author_name'     => array(
    1194                                         'description'  => __( 'Display name for the object author.' ),
     1194                                        'description'  => _l( 'Display name for the object author.' ),
    11951195                                        'type'         => 'string',
    11961196                                        'context'      => array( 'view', 'edit', 'embed' ),
    11971197                                        'arg_options'  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11991199                                        ),
    12001200                                ),
    12011201                                'author_url'       => array(
    1202                                         'description'  => __( 'URL for the object author.' ),
     1202                                        'description'  => _l( 'URL for the object author.' ),
    12031203                                        'type'         => 'string',
    12041204                                        'format'       => 'uri',
    12051205                                        'context'      => array( 'view', 'edit', 'embed' ),
    12061206                                ),
    12071207                                'author_user_agent'     => array(
    1208                                         'description'  => __( 'User agent for the object author.' ),
     1208                                        'description'  => _l( 'User agent for the object author.' ),
    12091209                                        'type'         => 'string',
    12101210                                        'context'      => array( 'edit' ),
    12111211                                        'arg_options'  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12131213                                        ),
    12141214                                ),
    12151215                                'content'          => array(
    1216                                         'description'     => __( 'The content for the object.' ),
     1216                                        'description'     => _l( 'The content for the object.' ),
    12171217                                        'type'            => 'object',
    12181218                                        'context'         => array( 'view', 'edit', 'embed' ),
    12191219                                        'arg_options'     => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12211221                                        ),
    12221222                                        'properties'      => array(
    12231223                                                'raw'         => array(
    1224                                                         'description'     => __( 'Content for the object, as it exists in the database.' ),
     1224                                                        'description'     => _l( 'Content for the object, as it exists in the database.' ),
    12251225                                                        'type'            => 'string',
    12261226                                                        'context'         => array( 'edit' ),
    12271227                                                ),
    12281228                                                'rendered'    => array(
    1229                                                         'description'     => __( 'HTML content for the object, transformed for display.' ),
     1229                                                        'description'     => _l( 'HTML content for the object, transformed for display.' ),
    12301230                                                        'type'            => 'string',
    12311231                                                        'context'         => array( 'view', 'edit', 'embed' ),
    12321232                                                        'readonly'        => true,
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12341234                                        ),
    12351235                                ),
    12361236                                'date'             => array(
    1237                                         'description'  => __( "The date the object was published, in the site's timezone." ),
     1237                                        'description'  => _l( "The date the object was published, in the site's timezone." ),
    12381238                                        'type'         => 'string',
    12391239                                        'format'       => 'date-time',
    12401240                                        'context'      => array( 'view', 'edit', 'embed' ),
    12411241                                ),
    12421242                                'date_gmt'         => array(
    1243                                         'description'  => __( 'The date the object was published, as GMT.' ),
     1243                                        'description'  => _l( 'The date the object was published, as GMT.' ),
    12441244                                        'type'         => 'string',
    12451245                                        'format'       => 'date-time',
    12461246                                        'context'      => array( 'view', 'edit' ),
    12471247                                ),
    12481248                                'link'             => array(
    1249                                         'description'  => __( 'URL to the object.' ),
     1249                                        'description'  => _l( 'URL to the object.' ),
    12501250                                        'type'         => 'string',
    12511251                                        'format'       => 'uri',
    12521252                                        'context'      => array( 'view', 'edit', 'embed' ),
    12531253                                        'readonly'     => true,
    12541254                                ),
    12551255                                'parent'           => array(
    1256                                         'description'  => __( 'The ID for the parent of the object.' ),
     1256                                        'description'  => _l( 'The ID for the parent of the object.' ),
    12571257                                        'type'         => 'integer',
    12581258                                        'context'      => array( 'view', 'edit', 'embed' ),
    12591259                                        'default'      => 0,
    12601260                                ),
    12611261                                'post'             => array(
    1262                                         'description'  => __( 'The ID of the associated post object.' ),
     1262                                        'description'  => _l( 'The ID of the associated post object.' ),
    12631263                                        'type'         => 'integer',
    12641264                                        'context'      => array( 'view', 'edit' ),
    12651265                                        'default'      => 0,
    12661266                                ),
    12671267                                'status'           => array(
    1268                                         'description'  => __( 'State of the object.' ),
     1268                                        'description'  => _l( 'State of the object.' ),
    12691269                                        'type'         => 'string',
    12701270                                        'context'      => array( 'view', 'edit' ),
    12711271                                        'arg_options'  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12731273                                        ),
    12741274                                ),
    12751275                                'type'             => array(
    1276                                         'description'  => __( 'Type of Comment for the object.' ),
     1276                                        'description'  => _l( 'Type of Comment for the object.' ),
    12771277                                        'type'         => 'string',
    12781278                                        'context'      => array( 'view', 'edit', 'embed' ),
    12791279                                        'readonly'     => true,
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12881288                        foreach ( $avatar_sizes as $size ) {
    12891289                                $avatar_properties[ $size ] = array(
    12901290                                        /* translators: %d: avatar image size in pixels */
    1291                                         'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' ), $size ),
     1291                                        'description' => sprintf( _l( 'Avatar URL with image size of %d pixels.' ), $size ),
    12921292                                        'type'        => 'string',
    12931293                                        'format'      => 'uri',
    12941294                                        'context'     => array( 'embed', 'view', 'edit' ),
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    12961296                        }
    12971297
    12981298                        $schema['properties']['author_avatar_urls'] = array(
    1299                                 'description'   => __( 'Avatar URLs for the object author.' ),
     1299                                'description'   => _l( 'Avatar URLs for the object author.' ),
    13001300                                'type'          => 'object',
    13011301                                'context'       => array( 'view', 'edit', 'embed' ),
    13021302                                'readonly'      => true,
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13231323                $query_params['context']['default'] = 'view';
    13241324
    13251325                $query_params['after'] = array(
    1326                         'description'       => __( 'Limit response to comments published after a given ISO8601 compliant date.' ),
     1326                        'description'       => _l( 'Limit response to comments published after a given ISO8601 compliant date.' ),
    13271327                        'type'              => 'string',
    13281328                        'format'            => 'date-time',
    13291329                );
    13301330
    13311331                $query_params['author'] = array(
    1332                         'description'       => __( 'Limit result set to comments assigned to specific user IDs. Requires authorization.' ),
     1332                        'description'       => _l( 'Limit result set to comments assigned to specific user IDs. Requires authorization.' ),
    13331333                        'type'              => 'array',
    13341334                        'items'             => array(
    13351335                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13371337                );
    13381338
    13391339                $query_params['author_exclude'] = array(
    1340                         'description'       => __( 'Ensure result set excludes comments assigned to specific user IDs. Requires authorization.' ),
     1340                        'description'       => _l( 'Ensure result set excludes comments assigned to specific user IDs. Requires authorization.' ),
    13411341                        'type'              => 'array',
    13421342                        'items'             => array(
    13431343                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13461346
    13471347                $query_params['author_email'] = array(
    13481348                        'default'           => null,
    1349                         'description'       => __( 'Limit result set to that from a specific author email. Requires authorization.' ),
     1349                        'description'       => _l( 'Limit result set to that from a specific author email. Requires authorization.' ),
    13501350                        'format'            => 'email',
    13511351                        'type'              => 'string',
    13521352                );
    13531353
    13541354                $query_params['before'] = array(
    1355                         'description'       => __( 'Limit response to comments published before a given ISO8601 compliant date.' ),
     1355                        'description'       => _l( 'Limit response to comments published before a given ISO8601 compliant date.' ),
    13561356                        'type'              => 'string',
    13571357                        'format'            => 'date-time',
    13581358                );
    13591359
    13601360                $query_params['exclude'] = array(
    1361                         'description'        => __( 'Ensure result set excludes specific IDs.' ),
     1361                        'description'        => _l( 'Ensure result set excludes specific IDs.' ),
    13621362                        'type'               => 'array',
    13631363                        'items'              => array(
    13641364                                'type'           => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13671367                );
    13681368
    13691369                $query_params['include'] = array(
    1370                         'description'        => __( 'Limit result set to specific IDs.' ),
     1370                        'description'        => _l( 'Limit result set to specific IDs.' ),
    13711371                        'type'               => 'array',
    13721372                        'items'              => array(
    13731373                                'type'           => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13761376                );
    13771377
    13781378                $query_params['offset'] = array(
    1379                         'description'        => __( 'Offset the result set by a specific number of items.' ),
     1379                        'description'        => _l( 'Offset the result set by a specific number of items.' ),
    13801380                        'type'               => 'integer',
    13811381                );
    13821382
    13831383                $query_params['order']      = array(
    1384                         'description'           => __( 'Order sort attribute ascending or descending.' ),
     1384                        'description'           => _l( 'Order sort attribute ascending or descending.' ),
    13851385                        'type'                  => 'string',
    13861386                        'default'               => 'desc',
    13871387                        'enum'                  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    13911391                );
    13921392
    13931393                $query_params['orderby']    = array(
    1394                         'description'           => __( 'Sort collection by object attribute.' ),
     1394                        'description'           => _l( 'Sort collection by object attribute.' ),
    13951395                        'type'                  => 'string',
    13961396                        'default'               => 'date_gmt',
    13971397                        'enum'                  => array(
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    14071407
    14081408                $query_params['parent'] = array(
    14091409                        'default'           => array(),
    1410                         'description'       => __( 'Limit result set to comments of specific parent IDs.' ),
     1410                        'description'       => _l( 'Limit result set to comments of specific parent IDs.' ),
    14111411                        'type'              => 'array',
    14121412                        'items'             => array(
    14131413                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    14161416
    14171417                $query_params['parent_exclude'] = array(
    14181418                        'default'           => array(),
    1419                         'description'       => __( 'Ensure result set excludes specific parent IDs.' ),
     1419                        'description'       => _l( 'Ensure result set excludes specific parent IDs.' ),
    14201420                        'type'              => 'array',
    14211421                        'items'             => array(
    14221422                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    14251425
    14261426                $query_params['post']   = array(
    14271427                        'default'           => array(),
    1428                         'description'       => __( 'Limit result set to comments assigned to specific post IDs.' ),
     1428                        'description'       => _l( 'Limit result set to comments assigned to specific post IDs.' ),
    14291429                        'type'              => 'array',
    14301430                        'items'             => array(
    14311431                                'type'          => 'integer',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    14341434
    14351435                $query_params['status'] = array(
    14361436                        'default'           => 'approve',
    1437                         'description'       => __( 'Limit result set to comments assigned a specific status. Requires authorization.' ),
     1437                        'description'       => _l( 'Limit result set to comments assigned a specific status. Requires authorization.' ),
    14381438                        'sanitize_callback' => 'sanitize_key',
    14391439                        'type'              => 'string',
    14401440                        'validate_callback' => 'rest_validate_request_arg',
    class WP_REST_Comments_Controller extends WP_REST_Controller { 
    14421442
    14431443                $query_params['type'] = array(
    14441444                        'default'           => 'comment',
    1445                         'description'       => __( 'Limit result set to comments assigned a specific type. Requires authorization.' ),
     1445                        'description'       => _l( 'Limit result set to comments assigned a specific type. Requires authorization.' ),
    14461446                        'sanitize_callback' => 'sanitize_key',
    14471447                        'type'              => 'string',
    14481448                        'validate_callback' => 'rest_validate_request_arg',
    14491449                );
    14501450
    14511451                $query_params['password'] = array(
    1452                         'description' => __( 'The password for the post if it is password protected.' ),
     1452                        'description' => _l( 'The password for the post if it is password protected.' ),
    14531453                        'type'        => 'string',
    14541454                );
    14551455
  • 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 b6c8ac42ac..8c2afbe1a4 100644
    abstract class WP_REST_Controller { 
    3939         * @access public
    4040         */
    4141        public function register_routes() {
    42                 _doing_it_wrong( 'WP_REST_Controller::register_routes', __( 'The register_routes() method must be overridden' ), '4.7' );
     42                _doing_it_wrong( 'WP_REST_Controller::register_routes', _l( 'The register_routes() method must be overridden' ), '4.7' );
    4343        }
    4444
    4545        /**
    abstract class WP_REST_Controller { 
    5252         * @return WP_Error|bool True if the request has read access, WP_Error object otherwise.
    5353         */
    5454        public function get_items_permissions_check( $request ) {
    55                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     55                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    5656        }
    5757
    5858        /**
    abstract class WP_REST_Controller { 
    6565         * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
    6666         */
    6767        public function get_items( $request ) {
    68                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     68                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    6969        }
    7070
    7171        /**
    abstract class WP_REST_Controller { 
    7878         * @return WP_Error|bool True if the request has read access for the item, WP_Error object otherwise.
    7979         */
    8080        public function get_item_permissions_check( $request ) {
    81                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     81                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    8282        }
    8383
    8484        /**
    abstract class WP_REST_Controller { 
    9191         * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
    9292         */
    9393        public function get_item( $request ) {
    94                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     94                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    9595        }
    9696
    9797        /**
    abstract class WP_REST_Controller { 
    104104         * @return WP_Error|bool True if the request has access to create items, WP_Error object otherwise.
    105105         */
    106106        public function create_item_permissions_check( $request ) {
    107                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     107                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    108108        }
    109109
    110110        /**
    abstract class WP_REST_Controller { 
    117117         * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
    118118         */
    119119        public function create_item( $request ) {
    120                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     120                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    121121        }
    122122
    123123        /**
    abstract class WP_REST_Controller { 
    130130         * @return WP_Error|bool True if the request has access to update the item, WP_Error object otherwise.
    131131         */
    132132        public function update_item_permissions_check( $request ) {
    133                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     133                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    134134        }
    135135
    136136        /**
    abstract class WP_REST_Controller { 
    143143         * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
    144144         */
    145145        public function update_item( $request ) {
    146                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     146                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    147147        }
    148148
    149149        /**
    abstract class WP_REST_Controller { 
    156156         * @return WP_Error|bool True if the request has access to delete the item, WP_Error object otherwise.
    157157         */
    158158        public function delete_item_permissions_check( $request ) {
    159                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     159                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    160160        }
    161161
    162162        /**
    abstract class WP_REST_Controller { 
    169169         * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
    170170         */
    171171        public function delete_item( $request ) {
    172                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     172                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    173173        }
    174174
    175175        /**
    abstract class WP_REST_Controller { 
    182182         * @return WP_Error|object The prepared item, or WP_Error object on failure.
    183183         */
    184184        protected function prepare_item_for_database( $request ) {
    185                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     185                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    186186        }
    187187
    188188        /**
    abstract class WP_REST_Controller { 
    196196         * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
    197197         */
    198198        public function prepare_item_for_response( $item, $request ) {
    199                 return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
     199                return new WP_Error( 'invalid-method', sprintf( _l( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
    200200        }
    201201
    202202        /**
    abstract class WP_REST_Controller { 
    314314                return array(
    315315                        'context'                => $this->get_context_param(),
    316316                        'page'                   => array(
    317                                 'description'        => __( 'Current page of the collection.' ),
     317                                'description'        => _l( 'Current page of the collection.' ),
    318318                                'type'               => 'integer',
    319319                                'default'            => 1,
    320320                                'sanitize_callback'  => 'absint',
    abstract class WP_REST_Controller { 
    322322                                'minimum'            => 1,
    323323                        ),
    324324                        'per_page'               => array(
    325                                 'description'        => __( 'Maximum number of items to be returned in result set.' ),
     325                                'description'        => _l( 'Maximum number of items to be returned in result set.' ),
    326326                                'type'               => 'integer',
    327327                                'default'            => 10,
    328328                                'minimum'            => 1,
    abstract class WP_REST_Controller { 
    331331                                'validate_callback'  => 'rest_validate_request_arg',
    332332                        ),
    333333                        'search'                 => array(
    334                                 'description'        => __( 'Limit results to those matching a string.' ),
     334                                'description'        => _l( 'Limit results to those matching a string.' ),
    335335                                'type'               => 'string',
    336336                                'sanitize_callback'  => 'sanitize_text_field',
    337337                                'validate_callback'  => 'rest_validate_request_arg',
    abstract class WP_REST_Controller { 
    352352         */
    353353        public function get_context_param( $args = array() ) {
    354354                $param_details = array(
    355                         'description'        => __( 'Scope under which the request is made; determines fields present in response.' ),
     355                        'description'        => _l( 'Scope under which the request is made; determines fields present in response.' ),
    356356                        'type'               => 'string',
    357357                        'sanitize_callback'  => 'sanitize_key',
    358358                        '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 59575d566c..89c5013bff 100644
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    5050                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<status>[\w-]+)', array(
    5151                        'args' => array(
    5252                                'status' => array(
    53                                         'description' => __( 'An alphanumeric identifier for the status.' ),
     53                                        'description' => _l( 'An alphanumeric identifier for the status.' ),
    5454                                        'type'        => 'string',
    5555                                ),
    5656                        ),
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    8484                                        return true;
    8585                                }
    8686                        }
    87                         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() ) );
     87                        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() ) );
    8888                }
    8989
    9090                return true;
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    131131                $status = get_post_status_object( $request['status'] );
    132132
    133133                if ( empty( $status ) ) {
    134                         return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) );
     134                        return new WP_Error( 'rest_status_invalid', _l( 'Invalid status.' ), array( 'status' => 404 ) );
    135135                }
    136136
    137137                $check = $this->check_read_permission( $status );
    138138
    139139                if ( ! $check ) {
    140                         return new WP_Error( 'rest_cannot_read_status', __( 'Cannot view status.' ), array( 'status' => rest_authorization_required_code() ) );
     140                        return new WP_Error( 'rest_cannot_read_status', _l( 'Cannot view status.' ), array( 'status' => rest_authorization_required_code() ) );
    141141                }
    142142
    143143                return true;
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    183183                $obj = get_post_status_object( $request['status'] );
    184184
    185185                if ( empty( $obj ) ) {
    186                         return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) );
     186                        return new WP_Error( 'rest_status_invalid', _l( 'Invalid status.' ), array( 'status' => 404 ) );
    187187                }
    188188
    189189                $data = $this->prepare_item_for_response( $obj, $request );
    class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { 
    254254                        'type'                 => 'object',
    255255                        'properties'           => array(
    256256                                'name'             => array(
    257                                         'description'  => __( 'The title for the status.' ),
     257                                        'description'  => _l( 'The title for the status.' ),
    258258                                        'type'         => 'string',
    259259                                        'context'      => array( 'embed', 'view', 'edit' ),
    260260                                        'readonly'     => true,
    261261                                ),
    262262                                'private'          => array(
    263                                         'description'  => __( 'Whether posts with this status should be private.' ),
     263                                        'description'  => _l( 'Whether posts with this status should be private.' ),
    264264                                        'type'         => 'boolean',
    265265                                        'context'      => array( 'edit' ),
    266266                                        'readonly'     => true,
    267267                                ),
    268268                                'protected'        => array(
    269                                         'description'  => __( 'Whether posts with this status should be protected.' ),
     269                                        'description'  => _l( 'Whether posts with this status should be protected.' ),
    270270                                        'type'         => 'boolean',
    271271                                        'context'      => array( 'edit' ),
    272272                                        'readonly'     => true,
    273273                                ),
    274274                                'public'           => array(
    275                                         'description'  => __( 'Whether posts of this status should be shown in the front end of the site.' ),
     275                                        'description'  => _l( 'Whether posts of this status should be shown in the front end of the site.' ),
    276276                                        'type'         => 'boolean',
    277277                                        'context'      => array( 'view', 'edit' ),
    278278                                        'readonly'     => true,
    279279                                ),
    280280                                'queryable'        => array(
    281                                         'description'  => __( 'Whether posts with this status should be publicly-queryable.' ),
     281                                        'description'  => _l( 'Whether posts with this status should be publicly-queryable.' ),
    282282                                        'type'         => 'boolean',
    283283                                        'context'      => array( 'view', 'edit' ),
    284284                                        'readonly'     => true,
    285285                                ),
    286286                                'show_in_list'     => array(
    287                                         'description'  => __( 'Whether to include posts in the edit listing for their post type.' ),
     287                                        'description'  => _l( 'Whether to include posts in the edit listing for their post type.' ),
    288288                                        'type'         => 'boolean',
    289289                                        'context'      => array( 'edit' ),
    290290                                        'readonly'     => true,
    291291                                ),
    292292                                'slug'             => array(
    293                                         'description'  => __( 'An alphanumeric identifier for the status.' ),
     293                                        'description'  => _l( 'An alphanumeric identifier for the status.' ),
    294294                                        'type'         => 'string',
    295295                                        'context'      => array( 'embed', 'view', 'edit' ),
    296296                                        '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 69d221be75..181108221e 100644
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    5050                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<type>[\w-]+)', array(
    5151                        'args' => array(
    5252                                'type' => array(
    53                                         'description' => __( 'An alphanumeric identifier for the post type.' ),
     53                                        'description' => _l( 'An alphanumeric identifier for the post type.' ),
    5454                                        'type'        => 'string',
    5555                                ),
    5656                        ),
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    8282                                }
    8383                        }
    8484
    85                         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() ) );
     85                        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() ) );
    8686                }
    8787
    8888                return true;
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    125125                $obj = get_post_type_object( $request['type'] );
    126126
    127127                if ( empty( $obj ) ) {
    128                         return new WP_Error( 'rest_type_invalid', __( 'Invalid post type.' ), array( 'status' => 404 ) );
     128                        return new WP_Error( 'rest_type_invalid', _l( 'Invalid post type.' ), array( 'status' => 404 ) );
    129129                }
    130130
    131131                if ( empty( $obj->show_in_rest ) ) {
    132                         return new WP_Error( 'rest_cannot_read_type', __( 'Cannot view post type.' ), array( 'status' => rest_authorization_required_code() ) );
     132                        return new WP_Error( 'rest_cannot_read_type', _l( 'Cannot view post type.' ), array( 'status' => rest_authorization_required_code() ) );
    133133                }
    134134
    135135                if ( 'edit' === $request['context'] && ! current_user_can( $obj->cap->edit_posts ) ) {
    136                         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() ) );
     136                        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() ) );
    137137                }
    138138
    139139                $data = $this->prepare_item_for_response( $obj, $request );
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    213213                        'type'                 => 'object',
    214214                        'properties'           => array(
    215215                                'capabilities'     => array(
    216                                         'description'  => __( 'All capabilities used by the post type.' ),
     216                                        'description'  => _l( 'All capabilities used by the post type.' ),
    217217                                        'type'         => 'object',
    218218                                        'context'      => array( 'edit' ),
    219219                                        'readonly'     => true,
    220220                                ),
    221221                                'description'      => array(
    222                                         'description'  => __( 'A human-readable description of the post type.' ),
     222                                        'description'  => _l( 'A human-readable description of the post type.' ),
    223223                                        'type'         => 'string',
    224224                                        'context'      => array( 'view', 'edit' ),
    225225                                        'readonly'     => true,
    226226                                ),
    227227                                'hierarchical'     => array(
    228                                         'description'  => __( 'Whether or not the post type should have children.' ),
     228                                        'description'  => _l( 'Whether or not the post type should have children.' ),
    229229                                        'type'         => 'boolean',
    230230                                        'context'      => array( 'view', 'edit' ),
    231231                                        'readonly'     => true,
    232232                                ),
    233233                                'labels'           => array(
    234                                         'description'  => __( 'Human-readable labels for the post type for various contexts.' ),
     234                                        'description'  => _l( 'Human-readable labels for the post type for various contexts.' ),
    235235                                        'type'         => 'object',
    236236                                        'context'      => array( 'edit' ),
    237237                                        'readonly'     => true,
    238238                                ),
    239239                                'name'             => array(
    240                                         'description'  => __( 'The title for the post type.' ),
     240                                        'description'  => _l( 'The title for the post type.' ),
    241241                                        'type'         => 'string',
    242242                                        'context'      => array( 'view', 'edit', 'embed' ),
    243243                                        'readonly'     => true,
    244244                                ),
    245245                                'slug'             => array(
    246                                         'description'  => __( 'An alphanumeric identifier for the post type.' ),
     246                                        'description'  => _l( 'An alphanumeric identifier for the post type.' ),
    247247                                        'type'         => 'string',
    248248                                        'context'      => array( 'view', 'edit', 'embed' ),
    249249                                        'readonly'     => true,
    250250                                ),
    251251                                'supports'         => array(
    252                                         'description'  => __( 'All features, supported by the post type.' ),
     252                                        'description'  => _l( 'All features, supported by the post type.' ),
    253253                                        'type'         => 'object',
    254254                                        'context'      => array( 'edit' ),
    255255                                        'readonly'     => true,
    256256                                ),
    257257                                'taxonomies'       => array(
    258                                         'description'  => __( 'Taxonomies associated with post type.' ),
     258                                        'description'  => _l( 'Taxonomies associated with post type.' ),
    259259                                        'type'         => 'array',
    260260                                        'items'        => array(
    261261                                                'type' => 'string',
    class WP_REST_Post_Types_Controller extends WP_REST_Controller { 
    264264                                        'readonly'     => true,
    265265                                ),
    266266                                'rest_base'            => array(
    267                                         'description'  => __( 'REST base route for the post type.' ),
     267                                        'description'  => _l( 'REST base route for the post type.' ),
    268268                                        'type'         => 'string',
    269269                                        'context'      => array( 'view', 'edit', 'embed' ),
    270270                                        '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 39593cbe3e..e1f722556c 100644
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    8383                );
    8484                if ( isset( $schema['properties']['password'] ) ) {
    8585                        $get_item_args['password'] = array(
    86                                 'description' => __( 'The password for the post if it is password protected.' ),
     86                                'description' => _l( 'The password for the post if it is password protected.' ),
    8787                                'type'        => 'string',
    8888                        );
    8989                }
    9090                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    9191                        'args' => array(
    9292                                'id' => array(
    93                                         'description' => __( 'Unique identifier for the object.' ),
     93                                        'description' => _l( 'Unique identifier for the object.' ),
    9494                                        'type'        => 'integer',
    9595                                ),
    9696                        ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    114114                                        'force' => array(
    115115                                                'type'        => 'boolean',
    116116                                                'default'     => false,
    117                                                 'description' => __( 'Whether to bypass trash and force deletion.' ),
     117                                                'description' => _l( 'Whether to bypass trash and force deletion.' ),
    118118                                        ),
    119119                                ),
    120120                        ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    136136                $post_type = get_post_type_object( $this->post_type );
    137137
    138138                if ( 'edit' === $request['context'] && ! current_user_can( $post_type->cap->edit_posts ) ) {
    139                         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() ) );
     139                        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() ) );
    140140                }
    141141
    142142                return true;
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    155155
    156156                // Ensure a search string is set in case the orderby is set to 'relevance'.
    157157                if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) ) {
    158                         return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) );
     158                        return new WP_Error( 'rest_no_search_term_defined', _l( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) );
    159159                }
    160160
    161161                // Ensure an include parameter is set in case the orderby is set to 'include'.
    162162                if ( ! empty( $request['orderby'] ) && 'include' === $request['orderby'] && empty( $request['include'] ) ) {
    163                         return new WP_Error( 'rest_orderby_include_missing_include', __( 'You need to define an include parameter to order by include.' ), array( 'status' => 400 ) );
     163                        return new WP_Error( 'rest_orderby_include_missing_include', _l( 'You need to define an include parameter to order by include.' ), array( 'status' => 400 ) );
    164164                }
    165165
    166166                // Retrieve the list of registered collection query parameters.
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    332332                $max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] );
    333333
    334334                if ( $page > $max_pages && $total_posts > 0 ) {
    335                         return new WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) );
     335                        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 ) );
    336336                }
    337337
    338338                $response  = rest_ensure_response( $posts );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    372372         * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.
    373373         */
    374374        protected function get_post( $id ) {
    375                 $error = new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
     375                $error = new WP_Error( 'rest_post_invalid_id', _l( 'Invalid post ID.' ), array( 'status' => 404 ) );
    376376                if ( (int) $id <= 0 ) {
    377377                        return $error;
    378378                }
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    401401                }
    402402
    403403                if ( 'edit' === $request['context'] && $post && ! $this->check_update_permission( $post ) ) {
    404                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
     404                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
    405405                }
    406406
    407407                if ( $post && ! empty( $request['password'] ) ) {
    408408                        // Check post password, and return error if invalid.
    409409                        if ( ! hash_equals( $post->post_password, $request['password'] ) ) {
    410                                 return new WP_Error( 'rest_post_incorrect_password', __( 'Incorrect post password.' ), array( 'status' => 403 ) );
     410                                return new WP_Error( 'rest_post_incorrect_password', _l( 'Incorrect post password.' ), array( 'status' => 403 ) );
    411411                        }
    412412                }
    413413
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    492492         */
    493493        public function create_item_permissions_check( $request ) {
    494494                if ( ! empty( $request['id'] ) ) {
    495                         return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) );
     495                        return new WP_Error( 'rest_post_exists', _l( 'Cannot create existing post.' ), array( 'status' => 400 ) );
    496496                }
    497497
    498498                $post_type = get_post_type_object( $this->post_type );
    499499
    500500                if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
    501                         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() ) );
     501                        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() ) );
    502502                }
    503503
    504504                if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
    505                         return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
     505                        return new WP_Error( 'rest_cannot_assign_sticky', _l( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
    506506                }
    507507
    508508                if ( ! current_user_can( $post_type->cap->create_posts ) ) {
    509                         return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
     509                        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() ) );
    510510                }
    511511
    512512                if ( ! $this->check_assign_terms_permission( $request ) ) {
    513                         return new WP_Error( 'rest_cannot_assign_term', __( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) );
     513                        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() ) );
    514514                }
    515515
    516516                return true;
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    527527         */
    528528        public function create_item( $request ) {
    529529                if ( ! empty( $request['id'] ) ) {
    530                         return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) );
     530                        return new WP_Error( 'rest_post_exists', _l( 'Cannot create existing post.' ), array( 'status' => 400 ) );
    531531                }
    532532
    533533                $prepared_post = $this->prepare_item_for_database( $request );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    638638                $post_type = get_post_type_object( $this->post_type );
    639639
    640640                if ( $post && ! $this->check_update_permission( $post ) ) {
    641                         return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
     641                        return new WP_Error( 'rest_cannot_edit', _l( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
    642642                }
    643643
    644644                if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
    645                         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() ) );
     645                        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() ) );
    646646                }
    647647
    648648                if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
    649                         return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
     649                        return new WP_Error( 'rest_cannot_assign_sticky', _l( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
    650650                }
    651651
    652652                if ( ! $this->check_assign_terms_permission( $request ) ) {
    653                         return new WP_Error( 'rest_cannot_assign_term', __( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) );
     653                        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() ) );
    654654                }
    655655
    656656                return true;
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    760760                }
    761761
    762762                if ( $post && ! $this->check_delete_permission( $post ) ) {
    763                         return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
     763                        return new WP_Error( 'rest_cannot_delete', _l( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
    764764                }
    765765
    766766                return true;
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    805805                $supports_trash = apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post );
    806806
    807807                if ( ! $this->check_delete_permission( $post ) ) {
    808                         return new WP_Error( 'rest_user_cannot_delete_post', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
     808                        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() ) );
    809809                }
    810810
    811811                $request->set_param( 'context', 'edit' );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    820820                } else {
    821821                        // If we don't support trashing for this type, error out.
    822822                        if ( ! $supports_trash ) {
    823                                 return new WP_Error( 'rest_trash_not_supported', __( 'The post does not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
     823                                return new WP_Error( 'rest_trash_not_supported', _l( 'The post does not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
    824824                        }
    825825
    826826                        // Otherwise, only trash if we haven't already.
    827827                        if ( 'trash' === $post->post_status ) {
    828                                 return new WP_Error( 'rest_already_trashed', __( 'The post has already been deleted.' ), array( 'status' => 410 ) );
     828                                return new WP_Error( 'rest_already_trashed', _l( 'The post has already been deleted.' ), array( 'status' => 410 ) );
    829829                        }
    830830
    831831                        // (Note that internally this falls through to `wp_delete_post` if
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    836836                }
    837837
    838838                if ( ! $result ) {
    839                         return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
     839                        return new WP_Error( 'rest_cannot_delete', _l( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
    840840                }
    841841
    842842                /**
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    10311031                                $user_obj = get_userdata( $post_author );
    10321032
    10331033                                if ( ! $user_obj ) {
    1034                                         return new WP_Error( 'rest_invalid_author', __( 'Invalid author ID.' ), array( 'status' => 400 ) );
     1034                                        return new WP_Error( 'rest_invalid_author', _l( 'Invalid author ID.' ), array( 'status' => 400 ) );
    10351035                                }
    10361036                        }
    10371037
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    10441044
    10451045                        if ( '' !== $request['password'] ) {
    10461046                                if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) {
    1047                                         return new WP_Error( 'rest_invalid_field', __( 'A post can not be sticky and have a password.' ), array( 'status' => 400 ) );
     1047                                        return new WP_Error( 'rest_invalid_field', _l( 'A post can not be sticky and have a password.' ), array( 'status' => 400 ) );
    10481048                                }
    10491049
    10501050                                if ( ! empty( $prepared_post->ID ) && is_sticky( $prepared_post->ID ) ) {
    1051                                         return new WP_Error( 'rest_invalid_field', __( 'A sticky post can not be password protected.' ), array( 'status' => 400 ) );
     1051                                        return new WP_Error( 'rest_invalid_field', _l( 'A sticky post can not be password protected.' ), array( 'status' => 400 ) );
    10521052                                }
    10531053                        }
    10541054                }
    10551055
    10561056                if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) {
    10571057                        if ( ! empty( $prepared_post->ID ) && post_password_required( $prepared_post->ID ) ) {
    1058                                 return new WP_Error( 'rest_invalid_field', __( 'A password protected post can not be set to sticky.' ), array( 'status' => 400 ) );
     1058                                return new WP_Error( 'rest_invalid_field', _l( 'A password protected post can not be set to sticky.' ), array( 'status' => 400 ) );
    10591059                        }
    10601060                }
    10611061
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    10661066                        } else {
    10671067                                $parent = get_post( (int) $request['parent'] );
    10681068                                if ( empty( $parent ) ) {
    1069                                         return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent ID.' ), array( 'status' => 400 ) );
     1069                                        return new WP_Error( 'rest_post_invalid_id', _l( 'Invalid post parent ID.' ), array( 'status' => 400 ) );
    10701070                                }
    10711071                                $prepared_post->post_parent = (int) $parent->ID;
    10721072                        }
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    11201120                                break;
    11211121                        case 'private':
    11221122                                if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
    1123                                         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() ) );
     1123                                        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() ) );
    11241124                                }
    11251125                                break;
    11261126                        case 'publish':
    11271127                        case 'future':
    11281128                                if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
    1129                                         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() ) );
     1129                                        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() ) );
    11301130                                }
    11311131                                break;
    11321132                        default:
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    11571157                        if ( $result ) {
    11581158                                return true;
    11591159                        } else {
    1160                                 return new WP_Error( 'rest_invalid_featured_media', __( 'Invalid featured media ID.' ), array( 'status' => 400 ) );
     1160                                return new WP_Error( 'rest_invalid_featured_media', _l( 'Invalid featured media ID.' ), array( 'status' => 400 ) );
    11611161                        }
    11621162                } else {
    11631163                        return delete_post_thumbnail( $post_id );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    17221722                        // Base properties for every Post.
    17231723                        'properties' => array(
    17241724                                'date'            => array(
    1725                                         'description' => __( "The date the object was published, in the site's timezone." ),
     1725                                        'description' => _l( "The date the object was published, in the site's timezone." ),
    17261726                                        'type'        => 'string',
    17271727                                        'format'      => 'date-time',
    17281728                                        'context'     => array( 'view', 'edit', 'embed' ),
    17291729                                ),
    17301730                                'date_gmt'        => array(
    1731                                         'description' => __( 'The date the object was published, as GMT.' ),
     1731                                        'description' => _l( 'The date the object was published, as GMT.' ),
    17321732                                        'type'        => 'string',
    17331733                                        'format'      => 'date-time',
    17341734                                        'context'     => array( 'view', 'edit' ),
    17351735                                ),
    17361736                                'guid'            => array(
    1737                                         'description' => __( 'The globally unique identifier for the object.' ),
     1737                                        'description' => _l( 'The globally unique identifier for the object.' ),
    17381738                                        'type'        => 'object',
    17391739                                        'context'     => array( 'view', 'edit' ),
    17401740                                        'readonly'    => true,
    17411741                                        'properties'  => array(
    17421742                                                'raw'      => array(
    1743                                                         'description' => __( 'GUID for the object, as it exists in the database.' ),
     1743                                                        'description' => _l( 'GUID for the object, as it exists in the database.' ),
    17441744                                                        'type'        => 'string',
    17451745                                                        'context'     => array( 'edit' ),
    17461746                                                        'readonly'    => true,
    17471747                                                ),
    17481748                                                'rendered' => array(
    1749                                                         'description' => __( 'GUID for the object, transformed for display.' ),
     1749                                                        'description' => _l( 'GUID for the object, transformed for display.' ),
    17501750                                                        'type'        => 'string',
    17511751                                                        'context'     => array( 'view', 'edit' ),
    17521752                                                        'readonly'    => true,
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    17541754                                        ),
    17551755                                ),
    17561756                                'id'              => array(
    1757                                         'description' => __( 'Unique identifier for the object.' ),
     1757                                        'description' => _l( 'Unique identifier for the object.' ),
    17581758                                        'type'        => 'integer',
    17591759                                        'context'     => array( 'view', 'edit', 'embed' ),
    17601760                                        'readonly'    => true,
    17611761                                ),
    17621762                                'link'            => array(
    1763                                         'description' => __( 'URL to the object.' ),
     1763                                        'description' => _l( 'URL to the object.' ),
    17641764                                        'type'        => 'string',
    17651765                                        'format'      => 'uri',
    17661766                                        'context'     => array( 'view', 'edit', 'embed' ),
    17671767                                        'readonly'    => true,
    17681768                                ),
    17691769                                'modified'        => array(
    1770                                         'description' => __( "The date the object was last modified, in the site's timezone." ),
     1770                                        'description' => _l( "The date the object was last modified, in the site's timezone." ),
    17711771                                        'type'        => 'string',
    17721772                                        'format'      => 'date-time',
    17731773                                        'context'     => array( 'view', 'edit' ),
    17741774                                        'readonly'    => true,
    17751775                                ),
    17761776                                'modified_gmt'    => array(
    1777                                         'description' => __( 'The date the object was last modified, as GMT.' ),
     1777                                        'description' => _l( 'The date the object was last modified, as GMT.' ),
    17781778                                        'type'        => 'string',
    17791779                                        'format'      => 'date-time',
    17801780                                        'context'     => array( 'view', 'edit' ),
    17811781                                        'readonly'    => true,
    17821782                                ),
    17831783                                'slug'            => array(
    1784                                         'description' => __( 'An alphanumeric identifier for the object unique to its type.' ),
     1784                                        'description' => _l( 'An alphanumeric identifier for the object unique to its type.' ),
    17851785                                        'type'        => 'string',
    17861786                                        'context'     => array( 'view', 'edit', 'embed' ),
    17871787                                        'arg_options' => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    17891789                                        ),
    17901790                                ),
    17911791                                'status'          => array(
    1792                                         'description' => __( 'A named status for the object.' ),
     1792                                        'description' => _l( 'A named status for the object.' ),
    17931793                                        'type'        => 'string',
    17941794                                        'enum'        => array_keys( get_post_stati( array( 'internal' => false ) ) ),
    17951795                                        'context'     => array( 'view', 'edit' ),
    17961796                                ),
    17971797                                'type'            => array(
    1798                                         'description' => __( 'Type of Post for the object.' ),
     1798                                        'description' => _l( 'Type of Post for the object.' ),
    17991799                                        'type'        => 'string',
    18001800                                        'context'     => array( 'view', 'edit', 'embed' ),
    18011801                                        'readonly'    => true,
    18021802                                ),
    18031803                                'password'        => array(
    1804                                         'description' => __( 'A password to protect access to the content and excerpt.' ),
     1804                                        'description' => _l( 'A password to protect access to the content and excerpt.' ),
    18051805                                        'type'        => 'string',
    18061806                                        'context'     => array( 'edit' ),
    18071807                                ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18121812
    18131813                if ( $post_type_obj->hierarchical ) {
    18141814                        $schema['properties']['parent'] = array(
    1815                                 'description' => __( 'The ID for the parent of the object.' ),
     1815                                'description' => _l( 'The ID for the parent of the object.' ),
    18161816                                'type'        => 'integer',
    18171817                                'context'     => array( 'view', 'edit' ),
    18181818                        );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18721872
    18731873                                case 'title':
    18741874                                        $schema['properties']['title'] = array(
    1875                                                 'description' => __( 'The title for the object.' ),
     1875                                                'description' => _l( 'The title for the object.' ),
    18761876                                                'type'        => 'object',
    18771877                                                'context'     => array( 'view', 'edit', 'embed' ),
    18781878                                                'arg_options' => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18801880                                                ),
    18811881                                                'properties'  => array(
    18821882                                                        'raw' => array(
    1883                                                                 'description' => __( 'Title for the object, as it exists in the database.' ),
     1883                                                                'description' => _l( 'Title for the object, as it exists in the database.' ),
    18841884                                                                'type'        => 'string',
    18851885                                                                'context'     => array( 'edit' ),
    18861886                                                        ),
    18871887                                                        'rendered' => array(
    1888                                                                 'description' => __( 'HTML title for the object, transformed for display.' ),
     1888                                                                'description' => _l( 'HTML title for the object, transformed for display.' ),
    18891889                                                                'type'        => 'string',
    18901890                                                                'context'     => array( 'view', 'edit', 'embed' ),
    18911891                                                                'readonly'    => true,
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18961896
    18971897                                case 'editor':
    18981898                                        $schema['properties']['content'] = array(
    1899                                                 'description' => __( 'The content for the object.' ),
     1899                                                'description' => _l( 'The content for the object.' ),
    19001900                                                'type'        => 'object',
    19011901                                                'context'     => array( 'view', 'edit' ),
    19021902                                                'arg_options' => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19041904                                                ),
    19051905                                                'properties'  => array(
    19061906                                                        'raw' => array(
    1907                                                                 'description' => __( 'Content for the object, as it exists in the database.' ),
     1907                                                                'description' => _l( 'Content for the object, as it exists in the database.' ),
    19081908                                                                'type'        => 'string',
    19091909                                                                'context'     => array( 'edit' ),
    19101910                                                        ),
    19111911                                                        'rendered' => array(
    1912                                                                 'description' => __( 'HTML content for the object, transformed for display.' ),
     1912                                                                'description' => _l( 'HTML content for the object, transformed for display.' ),
    19131913                                                                'type'        => 'string',
    19141914                                                                'context'     => array( 'view', 'edit' ),
    19151915                                                                'readonly'    => true,
    19161916                                                        ),
    19171917                                                        'protected'       => array(
    1918                                                                 'description' => __( 'Whether the content is protected with a password.' ),
     1918                                                                'description' => _l( 'Whether the content is protected with a password.' ),
    19191919                                                                'type'        => 'boolean',
    19201920                                                                'context'     => array( 'view', 'edit', 'embed' ),
    19211921                                                                'readonly'    => true,
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19261926
    19271927                                case 'author':
    19281928                                        $schema['properties']['author'] = array(
    1929                                                 'description' => __( 'The ID for the author of the object.' ),
     1929                                                'description' => _l( 'The ID for the author of the object.' ),
    19301930                                                'type'        => 'integer',
    19311931                                                'context'     => array( 'view', 'edit', 'embed' ),
    19321932                                        );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19341934
    19351935                                case 'excerpt':
    19361936                                        $schema['properties']['excerpt'] = array(
    1937                                                 'description' => __( 'The excerpt for the object.' ),
     1937                                                'description' => _l( 'The excerpt for the object.' ),
    19381938                                                'type'        => 'object',
    19391939                                                'context'     => array( 'view', 'edit', 'embed' ),
    19401940                                                'arg_options' => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19421942                                                ),
    19431943                                                'properties'  => array(
    19441944                                                        'raw' => array(
    1945                                                                 'description' => __( 'Excerpt for the object, as it exists in the database.' ),
     1945                                                                'description' => _l( 'Excerpt for the object, as it exists in the database.' ),
    19461946                                                                'type'        => 'string',
    19471947                                                                'context'     => array( 'edit' ),
    19481948                                                        ),
    19491949                                                        'rendered' => array(
    1950                                                                 'description' => __( 'HTML excerpt for the object, transformed for display.' ),
     1950                                                                'description' => _l( 'HTML excerpt for the object, transformed for display.' ),
    19511951                                                                'type'        => 'string',
    19521952                                                                'context'     => array( 'view', 'edit', 'embed' ),
    19531953                                                                'readonly'    => true,
    19541954                                                        ),
    19551955                                                        'protected'       => array(
    1956                                                                 'description' => __( 'Whether the excerpt is protected with a password.' ),
     1956                                                                'description' => _l( 'Whether the excerpt is protected with a password.' ),
    19571957                                                                'type'        => 'boolean',
    19581958                                                                'context'     => array( 'view', 'edit', 'embed' ),
    19591959                                                                'readonly'    => true,
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19641964
    19651965                                case 'thumbnail':
    19661966                                        $schema['properties']['featured_media'] = array(
    1967                                                 'description' => __( 'The ID of the featured media for the object.' ),
     1967                                                'description' => _l( 'The ID of the featured media for the object.' ),
    19681968                                                'type'        => 'integer',
    19691969                                                'context'     => array( 'view', 'edit', 'embed' ),
    19701970                                        );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19721972
    19731973                                case 'comments':
    19741974                                        $schema['properties']['comment_status'] = array(
    1975                                                 'description' => __( 'Whether or not comments are open on the object.' ),
     1975                                                'description' => _l( 'Whether or not comments are open on the object.' ),
    19761976                                                'type'        => 'string',
    19771977                                                'enum'        => array( 'open', 'closed' ),
    19781978                                                'context'     => array( 'view', 'edit' ),
    19791979                                        );
    19801980                                        $schema['properties']['ping_status'] = array(
    1981                                                 'description' => __( 'Whether or not the object can be pinged.' ),
     1981                                                'description' => _l( 'Whether or not the object can be pinged.' ),
    19821982                                                'type'        => 'string',
    19831983                                                'enum'        => array( 'open', 'closed' ),
    19841984                                                'context'     => array( 'view', 'edit' ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19871987
    19881988                                case 'page-attributes':
    19891989                                        $schema['properties']['menu_order'] = array(
    1990                                                 'description' => __( 'The order of the object in relation to other object of its type.' ),
     1990                                                'description' => _l( 'The order of the object in relation to other object of its type.' ),
    19911991                                                'type'        => 'integer',
    19921992                                                'context'     => array( 'view', 'edit' ),
    19931993                                        );
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19981998                                        $formats = array_values( get_post_format_slugs() );
    19991999
    20002000                                        $schema['properties']['format'] = array(
    2001                                                 'description' => __( 'The format for the object.' ),
     2001                                                'description' => _l( 'The format for the object.' ),
    20022002                                                'type'        => 'string',
    20032003                                                'enum'        => $formats,
    20042004                                                'context'     => array( 'view', 'edit' ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20142014
    20152015                if ( 'post' === $this->post_type ) {
    20162016                        $schema['properties']['sticky'] = array(
    2017                                 'description' => __( 'Whether or not the object should be treated as sticky.' ),
     2017                                'description' => _l( 'Whether or not the object should be treated as sticky.' ),
    20182018                                'type'        => 'boolean',
    20192019                                'context'     => array( 'view', 'edit' ),
    20202020                        );
    20212021                }
    20222022
    20232023                $schema['properties']['template'] = array(
    2024                         'description' => __( 'The theme file to use to display the object.' ),
     2024                        'description' => _l( 'The theme file to use to display the object.' ),
    20252025                        'type'        => 'string',
    20262026                        'enum'        => array_merge( array_keys( wp_get_theme()->get_page_templates( null, $this->post_type ) ), array( '' ) ),
    20272027                        'context'     => array( 'view', 'edit' ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20322032                        $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
    20332033                        $schema['properties'][ $base ] = array(
    20342034                                /* translators: %s: taxonomy name */
    2035                                 'description' => sprintf( __( 'The terms assigned to the object in the %s taxonomy.' ), $taxonomy->name ),
     2035                                'description' => sprintf( _l( 'The terms assigned to the object in the %s taxonomy.' ), $taxonomy->name ),
    20362036                                'type'        => 'array',
    20372037                                'items'       => array(
    20382038                                        'type'    => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20582058                $query_params['context']['default'] = 'view';
    20592059
    20602060                $query_params['after'] = array(
    2061                         'description'        => __( 'Limit response to posts published after a given ISO8601 compliant date.' ),
     2061                        'description'        => _l( 'Limit response to posts published after a given ISO8601 compliant date.' ),
    20622062                        'type'               => 'string',
    20632063                        'format'             => 'date-time',
    20642064                );
    20652065
    20662066                if ( post_type_supports( $this->post_type, 'author' ) ) {
    20672067                        $query_params['author'] = array(
    2068                                 'description'         => __( 'Limit result set to posts assigned to specific authors.' ),
     2068                                'description'         => _l( 'Limit result set to posts assigned to specific authors.' ),
    20692069                                'type'                => 'array',
    20702070                                'items'               => array(
    20712071                                        'type'            => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20732073                                'default'             => array(),
    20742074                        );
    20752075                        $query_params['author_exclude'] = array(
    2076                                 'description'         => __( 'Ensure result set excludes posts assigned to specific authors.' ),
     2076                                'description'         => _l( 'Ensure result set excludes posts assigned to specific authors.' ),
    20772077                                'type'                => 'array',
    20782078                                'items'               => array(
    20792079                                        'type'            => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20832083                }
    20842084
    20852085                $query_params['before'] = array(
    2086                         'description'        => __( 'Limit response to posts published before a given ISO8601 compliant date.' ),
     2086                        'description'        => _l( 'Limit response to posts published before a given ISO8601 compliant date.' ),
    20872087                        'type'               => 'string',
    20882088                        'format'             => 'date-time',
    20892089                );
    20902090
    20912091                $query_params['exclude'] = array(
    2092                         'description'        => __( 'Ensure result set excludes specific IDs.' ),
     2092                        'description'        => _l( 'Ensure result set excludes specific IDs.' ),
    20932093                        'type'               => 'array',
    20942094                        'items'              => array(
    20952095                                'type'           => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    20982098                );
    20992099
    21002100                $query_params['include'] = array(
    2101                         'description'        => __( 'Limit result set to specific IDs.' ),
     2101                        'description'        => _l( 'Limit result set to specific IDs.' ),
    21022102                        'type'               => 'array',
    21032103                        'items'              => array(
    21042104                                'type'           => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21082108
    21092109                if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
    21102110                        $query_params['menu_order'] = array(
    2111                                 'description'        => __( 'Limit result set to posts with a specific menu_order value.' ),
     2111                                'description'        => _l( 'Limit result set to posts with a specific menu_order value.' ),
    21122112                                'type'               => 'integer',
    21132113                        );
    21142114                }
    21152115
    21162116                $query_params['offset'] = array(
    2117                         'description'        => __( 'Offset the result set by a specific number of items.' ),
     2117                        'description'        => _l( 'Offset the result set by a specific number of items.' ),
    21182118                        'type'               => 'integer',
    21192119                );
    21202120
    21212121                $query_params['order'] = array(
    2122                         'description'        => __( 'Order sort attribute ascending or descending.' ),
     2122                        'description'        => _l( 'Order sort attribute ascending or descending.' ),
    21232123                        'type'               => 'string',
    21242124                        'default'            => 'desc',
    21252125                        'enum'               => array( 'asc', 'desc' ),
    21262126                );
    21272127
    21282128                $query_params['orderby'] = array(
    2129                         'description'        => __( 'Sort collection by object attribute.' ),
     2129                        'description'        => _l( 'Sort collection by object attribute.' ),
    21302130                        'type'               => 'string',
    21312131                        'default'            => 'date',
    21322132                        'enum'               => array(
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21502150
    21512151                if ( $post_type->hierarchical || 'attachment' === $this->post_type ) {
    21522152                        $query_params['parent'] = array(
    2153                                 'description'       => __( 'Limit result set to items with particular parent IDs.' ),
     2153                                'description'       => _l( 'Limit result set to items with particular parent IDs.' ),
    21542154                                'type'              => 'array',
    21552155                                'items'             => array(
    21562156                                        'type'          => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21582158                                'default'           => array(),
    21592159                        );
    21602160                        $query_params['parent_exclude'] = array(
    2161                                 'description'       => __( 'Limit result set to all items except those of a particular parent ID.' ),
     2161                                'description'       => _l( 'Limit result set to all items except those of a particular parent ID.' ),
    21622162                                'type'              => 'array',
    21632163                                'items'             => array(
    21642164                                        'type'          => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21682168                }
    21692169
    21702170                $query_params['slug'] = array(
    2171                         'description'       => __( 'Limit result set to posts with one or more specific slugs.' ),
     2171                        'description'       => _l( 'Limit result set to posts with one or more specific slugs.' ),
    21722172                        'type'              => 'array',
    21732173                        'items'             => array(
    21742174                                'type'          => 'string',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21782178
    21792179                $query_params['status'] = array(
    21802180                        'default'           => 'publish',
    2181                         'description'       => __( 'Limit result set to posts assigned one or more statuses.' ),
     2181                        'description'       => _l( 'Limit result set to posts assigned one or more statuses.' ),
    21822182                        'type'              => 'array',
    21832183                        'items'             => array(
    21842184                                'enum'          => array_merge( array_keys( get_post_stati() ), array( 'any' ) ),
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    21942194
    21952195                        $query_params[ $base ] = array(
    21962196                                /* translators: %s: taxonomy name */
    2197                                 'description'       => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
     2197                                'description'       => sprintf( _l( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
    21982198                                'type'              => 'array',
    21992199                                'items'             => array(
    22002200                                        'type'          => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    22042204
    22052205                        $query_params[ $base . '_exclude' ] = array(
    22062206                                /* translators: %s: taxonomy name */
    2207                                 'description' => sprintf( __( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
     2207                                'description' => sprintf( _l( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
    22082208                                'type'        => 'array',
    22092209                                'items'       => array(
    22102210                                        'type'    => 'integer',
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    22152215
    22162216                if ( 'post' === $this->post_type ) {
    22172217                        $query_params['sticky'] = array(
    2218                                 'description'       => __( 'Limit result set to items that are sticky.' ),
     2218                                'description'       => _l( 'Limit result set to items that are sticky.' ),
    22192219                                'type'              => 'boolean',
    22202220                        );
    22212221                }
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    22702270                                        return $result;
    22712271                                }
    22722272                        } else {
    2273                                 return new WP_Error( 'rest_forbidden_status', __( 'Status is forbidden.' ), array( 'status' => rest_authorization_required_code() ) );
     2273                                return new WP_Error( 'rest_forbidden_status', _l( 'Status is forbidden.' ), array( 'status' => rest_authorization_required_code() ) );
    22742274                        }
    22752275                }
    22762276
  • 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 8b0efcdf3d..4b46d8296a 100644
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    7373                register_rest_route( $this->namespace, '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base, array(
    7474                        'args' => array(
    7575                                'parent' => array(
    76                                         'description' => __( 'The ID for the parent of the object.' ),
     76                                        'description' => _l( 'The ID for the parent of the object.' ),
    7777                                        'type'        => 'integer',
    7878                                ),
    7979                        ),
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    8989                register_rest_route( $this->namespace, '/' . $this->parent_base . '/(?P<parent>[\d]+)/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    9090                        'args' => array(
    9191                                'parent' => array(
    92                                         'description' => __( 'The ID for the parent of the object.' ),
     92                                        'description' => _l( 'The ID for the parent of the object.' ),
    9393                                        'type'        => 'integer',
    9494                                ),
    9595                                'id' => array(
    96                                         'description' => __( 'Unique identifier for the object.' ),
     96                                        'description' => _l( 'Unique identifier for the object.' ),
    9797                                        'type'        => 'integer',
    9898                                ),
    9999                        ),
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    113113                                        'force' => array(
    114114                                                'type'        => 'boolean',
    115115                                                'default'     => false,
    116                                                 'description' => __( 'Required to be true, as revisions do not support trashing.' ),
     116                                                'description' => _l( 'Required to be true, as revisions do not support trashing.' ),
    117117                                        ),
    118118                                ),
    119119                        ),
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    131131         * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.
    132132         */
    133133        protected function get_parent( $parent ) {
    134                 $error = new WP_Error( 'rest_post_invalid_parent', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) );
     134                $error = new WP_Error( 'rest_post_invalid_parent', _l( 'Invalid post parent ID.' ), array( 'status' => 404 ) );
    135135                if ( (int) $parent <= 0 ) {
    136136                        return $error;
    137137                }
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    161161
    162162                $parent_post_type_obj = get_post_type_object( $parent->post_type );
    163163                if ( ! current_user_can( $parent_post_type_obj->cap->edit_post, $parent->ID ) ) {
    164                         return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to view revisions of this post.' ), array( 'status' => rest_authorization_required_code() ) );
     164                        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() ) );
    165165                }
    166166
    167167                return true;
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    176176         * @return WP_Post|WP_Error Revision post object if ID is valid, WP_Error otherwise.
    177177         */
    178178        protected function get_revision( $id ) {
    179                 $error = new WP_Error( 'rest_post_invalid_id', __( 'Invalid revision ID.' ), array( 'status' => 404 ) );
     179                $error = new WP_Error( 'rest_post_invalid_id', _l( 'Invalid revision ID.' ), array( 'status' => 404 ) );
    180180                if ( (int) $id <= 0 ) {
    181181                        return $error;
    182182                }
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    299299
    300300                // We don't support trashing for revisions.
    301301                if ( ! $force ) {
    302                         return new WP_Error( 'rest_trash_not_supported', __( 'Revisions do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
     302                        return new WP_Error( 'rest_trash_not_supported', _l( 'Revisions do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
    303303                }
    304304
    305305                $previous = $this->prepare_item_for_response( $revision, $request );
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    319319                do_action( 'rest_delete_revision', $result, $request );
    320320
    321321                if ( ! $result ) {
    322                         return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
     322                        return new WP_Error( 'rest_cannot_delete', _l( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
    323323                }
    324324
    325325                $response = new WP_REST_Response();
    class WP_REST_Revisions_Controller extends WP_REST_Controller { 
    471471                        // Base properties for every Revision.
    472472                        'properties' => array(
    473473                                'author'          => array(
    474                                         'description' => __( 'The ID for the author of the object.' ),
     474                                        'description' => _l( 'The ID for the author of the object.' ),
    475475                                        'type'        => 'integer',
    476476                                        'context'     => array( 'view', 'edit', 'embed' ),
    477477                                ),
    478478                                'date'            => array(
    479                                         'description' => __( "The date the object was published, in the site's timezone." ),
     479                                        'description' => _l( "The date the object was published, in the site's timezone." ),
    480480                                        'type'        => 'string',
    481481                                        'format'      => 'date-time',
    482482                                        'context'     => array( 'view', 'edit', 'embed' ),
    483483                                ),
    484484                                'date_gmt'        => array(
    485                                         'description' => __( 'The date the object was published, as GMT.' ),
     485                                        'description' => _l( 'The date the object was published, as GMT.' ),
    486486                                        'type'        => 'string',
    487487                                        'format'      => 'date-time',
    488488                                        'context'     => array( 'view', 'edit' ),
    489489                                ),
    490490                                'guid'            => array(
    491                                         'description' => __( 'GUID for the object, as it exists in the database.' ),
     491                                        'description' => _l( 'GUID for the object, as it exists in the database.' ),
    492492                                        'type'        => 'string',
    493493                                        'context'     => array( 'view', 'edit' ),
    494494                                ),
    495495                                'id'              => array(
    496                                         'description' => __( 'Unique identifier for the object.' ),
     496                                        'description' => _l( 'Unique identifier for the object.' ),
    497497                                        'type'        => 'integer',
    498498                                        'context'     => array( 'view', 'edit', 'embed' ),
    499499                                ),
    500500                                'modified'        => array(
    501                                         'description' => __( "The date the object was last modified, in the site's timezone." ),
     501                                        'description' => _l( "The date the object was last modified, in the site's timezone." ),
    502502                                        'type'        => 'string',
    503503                                        'format'      => 'date-time',
    504504                                        'context'     => array( 'view', 'edit' ),
    505505                                ),
    506506                                'modified_gmt'    => array(
    507                                         'description' => __( 'The date the object was last modified, as GMT.' ),
     507                                        'description' => _l( 'The date the object was last modified, as GMT.' ),
    508508                                        'type'        => 'string',
    509509                                        'format'      => 'date-time',
    510510                                        'context'     => array( 'view', 'edit' ),
    511511                                ),
    512512                                'parent'          => array(
    513                                         'description' => __( 'The ID for the parent of the object.' ),
     513                                        'description' => _l( 'The ID for the parent of the object.' ),
    514514                                        'type'        => 'integer',
    515515                                        'context'     => array( 'view', 'edit', 'embed' ),
    516516                                        ),
    517517                                'slug'            => array(
    518                                         'description' => __( 'An alphanumeric identifier for the object unique to its type.' ),
     518                                        'description' => _l( 'An alphanumeric identifier for the object unique to its type.' ),
    519519                                        'type'        => 'string',
    520520                                        'context'     => array( 'view', 'edit', 'embed' ),
    521521                                ),
  • 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 57954f1b52..52e533a1a7 100644
    class WP_REST_Settings_Controller extends WP_REST_Controller { 
    200200                                 */
    201201                                if ( ! is_scalar( get_option( $args['option_name'], false ) ) ) {
    202202                                        return new WP_Error(
    203                                                 'rest_invalid_stored_value', sprintf( __( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ), array( 'status' => 500 )
     203                                                'rest_invalid_stored_value', sprintf( _l( 'The %s property has an invalid stored value, and cannot be updated to null.' ), $name ), array( 'status' => 500 )
    204204                                        );
    205205                                }
    206206
  • 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 b46562c9c4..b4c23d1d12 100644
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    5050                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<taxonomy>[\w-]+)', array(
    5151                        'args' => array(
    5252                                'taxonomy' => array(
    53                                         'description'  => __( 'An alphanumeric identifier for the taxonomy.' ),
     53                                        'description'  => _l( 'An alphanumeric identifier for the taxonomy.' ),
    5454                                        'type'         => 'string',
    5555                                ),
    5656                        ),
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    8787                                        return true;
    8888                                }
    8989                        }
    90                         return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
     90                        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() ) );
    9191                }
    9292                return true;
    9393        }
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    147147                                return false;
    148148                        }
    149149                        if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->manage_terms ) ) {
    150                                 return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
     150                                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() ) );
    151151                        }
    152152                }
    153153
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    166166        public function get_item( $request ) {
    167167                $tax_obj = get_taxonomy( $request['taxonomy'] );
    168168                if ( empty( $tax_obj ) ) {
    169                         return new WP_Error( 'rest_taxonomy_invalid', __( 'Invalid taxonomy.' ), array( 'status' => 404 ) );
     169                        return new WP_Error( 'rest_taxonomy_invalid', _l( 'Invalid taxonomy.' ), array( 'status' => 404 ) );
    170170                }
    171171                $data = $this->prepare_item_for_response( $tax_obj, $request );
    172172                return rest_ensure_response( $data );
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    241241                        'type'                 => 'object',
    242242                        'properties'           => array(
    243243                                'capabilities'     => array(
    244                                         'description'  => __( 'All capabilities used by the taxonomy.' ),
     244                                        'description'  => _l( 'All capabilities used by the taxonomy.' ),
    245245                                        'type'         => 'object',
    246246                                        'context'      => array( 'edit' ),
    247247                                        'readonly'     => true,
    248248                                ),
    249249                                'description'      => array(
    250                                         'description'  => __( 'A human-readable description of the taxonomy.' ),
     250                                        'description'  => _l( 'A human-readable description of the taxonomy.' ),
    251251                                        'type'         => 'string',
    252252                                        'context'      => array( 'view', 'edit' ),
    253253                                        'readonly'     => true,
    254254                                ),
    255255                                'hierarchical'     => array(
    256                                         'description'  => __( 'Whether or not the taxonomy should have children.' ),
     256                                        'description'  => _l( 'Whether or not the taxonomy should have children.' ),
    257257                                        'type'         => 'boolean',
    258258                                        'context'      => array( 'view', 'edit' ),
    259259                                        'readonly'     => true,
    260260                                ),
    261261                                'labels'           => array(
    262                                         'description'  => __( 'Human-readable labels for the taxonomy for various contexts.' ),
     262                                        'description'  => _l( 'Human-readable labels for the taxonomy for various contexts.' ),
    263263                                        'type'         => 'object',
    264264                                        'context'      => array( 'edit' ),
    265265                                        'readonly'     => true,
    266266                                ),
    267267                                'name'             => array(
    268                                         'description'  => __( 'The title for the taxonomy.' ),
     268                                        'description'  => _l( 'The title for the taxonomy.' ),
    269269                                        'type'         => 'string',
    270270                                        'context'      => array( 'view', 'edit', 'embed' ),
    271271                                        'readonly'     => true,
    272272                                ),
    273273                                'slug'             => array(
    274                                         'description'  => __( 'An alphanumeric identifier for the taxonomy.' ),
     274                                        'description'  => _l( 'An alphanumeric identifier for the taxonomy.' ),
    275275                                        'type'         => 'string',
    276276                                        'context'      => array( 'view', 'edit', 'embed' ),
    277277                                        'readonly'     => true,
    278278                                ),
    279279                                'show_cloud'       => array(
    280                                         'description'  => __( 'Whether or not the term cloud should be displayed.' ),
     280                                        'description'  => _l( 'Whether or not the term cloud should be displayed.' ),
    281281                                        'type'         => 'boolean',
    282282                                        'context'      => array( 'edit' ),
    283283                                        'readonly'     => true,
    284284                                ),
    285285                                'types'            => array(
    286                                         'description'  => __( 'Types associated with the taxonomy.' ),
     286                                        'description'  => _l( 'Types associated with the taxonomy.' ),
    287287                                        'type'         => 'array',
    288288                                        'items'        => array(
    289289                                                'type' => 'string',
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    292292                                        'readonly'     => true,
    293293                                ),
    294294                                'rest_base'            => array(
    295                                         'description'  => __( 'REST base route for the taxonomy.' ),
     295                                        'description'  => _l( 'REST base route for the taxonomy.' ),
    296296                                        'type'         => 'string',
    297297                                        'context'      => array( 'view', 'edit', 'embed' ),
    298298                                        'readonly'     => true,
    class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 
    314314                $new_params = array();
    315315                $new_params['context'] = $this->get_context_param( array( 'default' => 'view' ) );
    316316                $new_params['type'] = array(
    317                         'description'  => __( 'Limit results to taxonomies associated with a specific post type.' ),
     317                        'description'  => _l( 'Limit results to taxonomies associated with a specific post type.' ),
    318318                        'type'         => 'string',
    319319                );
    320320                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 299b034329..f51b36c990 100644
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    9898                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    9999                        'args' => array(
    100100                                'id' => array(
    101                                         'description' => __( 'Unique identifier for the term.' ),
     101                                        'description' => _l( 'Unique identifier for the term.' ),
    102102                                        'type'        => 'integer',
    103103                                ),
    104104                        ),
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    124124                                        'force' => array(
    125125                                                'type'        => 'boolean',
    126126                                                'default'     => false,
    127                                                 'description' => __( 'Required to be true, as terms do not support trashing.' ),
     127                                                'description' => _l( 'Required to be true, as terms do not support trashing.' ),
    128128                                        ),
    129129                                ),
    130130                        ),
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    147147                        return false;
    148148                }
    149149                if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->edit_terms ) ) {
    150                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) );
     150                        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() ) );
    151151                }
    152152                return true;
    153153        }
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    302302         * @return WP_Term|WP_Error Term object if ID is valid, WP_Error otherwise.
    303303         */
    304304        protected function get_term( $id ) {
    305                 $error = new WP_Error( 'rest_term_invalid', __( 'Term does not exist.' ), array( 'status' => 404 ) );
     305                $error = new WP_Error( 'rest_term_invalid', _l( 'Term does not exist.' ), array( 'status' => 404 ) );
    306306
    307307                if ( ! $this->check_is_taxonomy_allowed( $this->taxonomy ) ) {
    308308                        return $error;
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    336336                }
    337337
    338338                if ( 'edit' === $request['context'] && ! current_user_can( 'edit_term', $term->term_id ) ) {
    339                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) );
     339                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) );
    340340                }
    341341                return true;
    342342        }
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    378378
    379379                $taxonomy_obj = get_taxonomy( $this->taxonomy );
    380380                if ( ! current_user_can( $taxonomy_obj->cap->edit_terms ) ) {
    381                         return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create new terms.' ), array( 'status' => rest_authorization_required_code() ) );
     381                        return new WP_Error( 'rest_cannot_create', _l( 'Sorry, you are not allowed to create new terms.' ), array( 'status' => rest_authorization_required_code() ) );
    382382                }
    383383
    384384                return true;
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    396396        public function create_item( $request ) {
    397397                if ( isset( $request['parent'] ) ) {
    398398                        if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) {
    399                                 return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );
     399                                return new WP_Error( 'rest_taxonomy_not_hierarchical', _l( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );
    400400                        }
    401401
    402402                        $parent = get_term( (int) $request['parent'], $this->taxonomy );
    403403
    404404                        if ( ! $parent ) {
    405                                 return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) );
     405                                return new WP_Error( 'rest_term_invalid', _l( 'Parent term does not exist.' ), array( 'status' => 400 ) );
    406406                        }
    407407                }
    408408
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    479479                }
    480480
    481481                if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
    482                         return new WP_Error( 'rest_cannot_update', __( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) );
     482                        return new WP_Error( 'rest_cannot_update', _l( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) );
    483483                }
    484484
    485485                return true;
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    502502
    503503                if ( isset( $request['parent'] ) ) {
    504504                        if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) {
    505                                 return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );
     505                                return new WP_Error( 'rest_taxonomy_not_hierarchical', _l( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) );
    506506                        }
    507507
    508508                        $parent = get_term( (int) $request['parent'], $this->taxonomy );
    509509
    510510                        if ( ! $parent ) {
    511                                 return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) );
     511                                return new WP_Error( 'rest_term_invalid', _l( 'Parent term does not exist.' ), array( 'status' => 400 ) );
    512512                        }
    513513                }
    514514
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    566566                }
    567567
    568568                if ( ! current_user_can( 'delete_term', $term->term_id ) ) {
    569                         return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this term.' ), array( 'status' => rest_authorization_required_code() ) );
     569                        return new WP_Error( 'rest_cannot_delete', _l( 'Sorry, you are not allowed to delete this term.' ), array( 'status' => rest_authorization_required_code() ) );
    570570                }
    571571
    572572                return true;
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    591591
    592592                // We don't support trashing for terms.
    593593                if ( ! $force ) {
    594                         return new WP_Error( 'rest_trash_not_supported', __( 'Terms do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
     594                        return new WP_Error( 'rest_trash_not_supported', _l( 'Terms do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
    595595                }
    596596
    597597                $request->set_param( 'context', 'view' );
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    601601                $retval = wp_delete_term( $term->term_id, $term->taxonomy );
    602602
    603603                if ( ! $retval ) {
    604                         return new WP_Error( 'rest_cannot_delete', __( 'The term cannot be deleted.' ), array( 'status' => 500 ) );
     604                        return new WP_Error( 'rest_cannot_delete', _l( 'The term cannot be deleted.' ), array( 'status' => 500 ) );
    605605                }
    606606
    607607                $response = new WP_REST_Response();
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    828828                        'type'       => 'object',
    829829                        'properties' => array(
    830830                                'id'          => array(
    831                                         'description'  => __( 'Unique identifier for the term.' ),
     831                                        'description'  => _l( 'Unique identifier for the term.' ),
    832832                                        'type'         => 'integer',
    833833                                        'context'      => array( 'view', 'embed', 'edit' ),
    834834                                        'readonly'     => true,
    835835                                ),
    836836                                'count'       => array(
    837                                         'description'  => __( 'Number of published posts for the term.' ),
     837                                        'description'  => _l( 'Number of published posts for the term.' ),
    838838                                        'type'         => 'integer',
    839839                                        'context'      => array( 'view', 'edit' ),
    840840                                        'readonly'     => true,
    841841                                ),
    842842                                'description' => array(
    843                                         'description'  => __( 'HTML description of the term.' ),
     843                                        'description'  => _l( 'HTML description of the term.' ),
    844844                                        'type'         => 'string',
    845845                                        'context'      => array( 'view', 'edit' ),
    846846                                ),
    847847                                'link'        => array(
    848                                         'description'  => __( 'URL of the term.' ),
     848                                        'description'  => _l( 'URL of the term.' ),
    849849                                        'type'         => 'string',
    850850                                        'format'       => 'uri',
    851851                                        'context'      => array( 'view', 'embed', 'edit' ),
    852852                                        'readonly'     => true,
    853853                                ),
    854854                                'name'        => array(
    855                                         'description'  => __( 'HTML title for the term.' ),
     855                                        'description'  => _l( 'HTML title for the term.' ),
    856856                                        'type'         => 'string',
    857857                                        'context'      => array( 'view', 'embed', 'edit' ),
    858858                                        'arg_options'  => array(
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    861861                                        'required'     => true,
    862862                                ),
    863863                                'slug'        => array(
    864                                         'description'  => __( 'An alphanumeric identifier for the term unique to its type.' ),
     864                                        'description'  => _l( 'An alphanumeric identifier for the term unique to its type.' ),
    865865                                        'type'         => 'string',
    866866                                        'context'      => array( 'view', 'embed', 'edit' ),
    867867                                        'arg_options'  => array(
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    869869                                        ),
    870870                                ),
    871871                                'taxonomy'    => array(
    872                                         'description'  => __( 'Type attribution for the term.' ),
     872                                        'description'  => _l( 'Type attribution for the term.' ),
    873873                                        'type'         => 'string',
    874874                                        'enum'         => array_keys( get_taxonomies() ),
    875875                                        'context'      => array( 'view', 'embed', 'edit' ),
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    882882
    883883                if ( $taxonomy->hierarchical ) {
    884884                        $schema['properties']['parent'] = array(
    885                                 'description'  => __( 'The parent term ID.' ),
     885                                'description'  => _l( 'The parent term ID.' ),
    886886                                'type'         => 'integer',
    887887                                'context'      => array( 'view', 'edit' ),
    888888                        );
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    908908                $query_params['context']['default'] = 'view';
    909909
    910910                $query_params['exclude'] = array(
    911                         'description'       => __( 'Ensure result set excludes specific IDs.' ),
     911                        'description'       => _l( 'Ensure result set excludes specific IDs.' ),
    912912                        'type'              => 'array',
    913913                        'items'             => array(
    914914                                'type'          => 'integer',
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    917917                );
    918918
    919919                $query_params['include'] = array(
    920                         'description'       => __( 'Limit result set to specific IDs.' ),
     920                        'description'       => _l( 'Limit result set to specific IDs.' ),
    921921                        'type'              => 'array',
    922922                        'items'             => array(
    923923                                'type'          => 'integer',
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    927927
    928928                if ( ! $taxonomy->hierarchical ) {
    929929                        $query_params['offset'] = array(
    930                                 'description'       => __( 'Offset the result set by a specific number of items.' ),
     930                                'description'       => _l( 'Offset the result set by a specific number of items.' ),
    931931                                'type'              => 'integer',
    932932                        );
    933933                }
    934934
    935935                $query_params['order'] = array(
    936                         'description'       => __( 'Order sort attribute ascending or descending.' ),
     936                        'description'       => _l( 'Order sort attribute ascending or descending.' ),
    937937                        'type'              => 'string',
    938938                        'default'           => 'asc',
    939939                        'enum'              => array(
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    943943                );
    944944
    945945                $query_params['orderby'] = array(
    946                         'description'       => __( 'Sort collection by term attribute.' ),
     946                        'description'       => _l( 'Sort collection by term attribute.' ),
    947947                        'type'              => 'string',
    948948                        'default'           => 'name',
    949949                        'enum'              => array(
    class WP_REST_Terms_Controller extends WP_REST_Controller { 
    958958                );
    959959
    960960                $query_params['hide_empty'] = array(
    961                         'description'       => __( 'Whether to hide terms not assigned to any posts.' ),
     961                        'description'       => _l( 'Whether to hide terms not assigned to any posts.' ),
    962962                        'type'              => 'boolean',
    963963                        'default'           => false,
    964964                );
    965965
    966966                if ( $taxonomy->hierarchical ) {
    967967                        $query_params['parent'] = array(
    968                                 'description'       => __( 'Limit result set to terms assigned to a specific parent.' ),
     968                                'description'       => _l( 'Limit result set to terms assigned to a specific parent.' ),
    969969                                'type'              => 'integer',
    970970                        );
    971971                }
    972972
    973973                $query_params['post'] = array(
    974                         'description'       => __( 'Limit result set to terms assigned to a specific post.' ),
     974                        'description'       => _l( 'Limit result set to terms assigned to a specific post.' ),
    975975                        'type'              => 'integer',
    976976                        'default'           => null,
    977977                );
    978978
    979979                $query_params['slug'] = array(
    980                         'description'       => __( 'Limit result set to terms with one or more specific slugs.' ),
     980                        'description'       => _l( 'Limit result set to terms with one or more specific slugs.' ),
    981981                        'type'              => 'array',
    982982                        'items'             => array(
    983983                                '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 63fb4e9e99..3976effbbd 100644
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    6767                register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
    6868                        'args' => array(
    6969                                'id' => array(
    70                                         'description' => __( 'Unique identifier for the user.' ),
     70                                        'description' => _l( 'Unique identifier for the user.' ),
    7171                                        'type'        => 'integer',
    7272                                ),
    7373                        ),
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    9393                                        'force'    => array(
    9494                                                'type'        => 'boolean',
    9595                                                'default'     => false,
    96                                                 'description' => __( 'Required to be true, as users do not support trashing.' ),
     96                                                'description' => _l( 'Required to be true, as users do not support trashing.' ),
    9797                                        ),
    9898                                        'reassign' => array(
    9999                                                'type'        => 'integer',
    100                                                 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ),
     100                                                'description' => _l( 'Reassign the deleted user\'s posts and links to this user ID.' ),
    101101                                                'required'    => true,
    102102                                                'sanitize_callback' => array( $this, 'check_reassign' ),
    103103                                        ),
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    128128                                        'force'    => array(
    129129                                                'type'        => 'boolean',
    130130                                                'default'     => false,
    131                                                 'description' => __( 'Required to be true, as users do not support trashing.' ),
     131                                                'description' => _l( 'Required to be true, as users do not support trashing.' ),
    132132                                        ),
    133133                                        'reassign' => array(
    134134                                                'type'        => 'integer',
    135                                                 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ),
     135                                                'description' => _l( 'Reassign the deleted user\'s posts and links to this user ID.' ),
    136136                                                'required'    => true,
    137137                                                'sanitize_callback' => array( $this, 'check_reassign' ),
    138138                                        ),
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    165165                        return false;
    166166                }
    167167
    168                 return new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
     168                return new WP_Error( 'rest_invalid_param', _l( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
    169169        }
    170170
    171171        /**
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    180180        public function get_items_permissions_check( $request ) {
    181181                // Check if roles is specified in GET request and if user can list users.
    182182                if ( ! empty( $request['roles'] ) && ! current_user_can( 'list_users' ) ) {
    183                         return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to filter users by role.' ), array( 'status' => rest_authorization_required_code() ) );
     183                        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() ) );
    184184                }
    185185
    186186                if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) {
    187                         return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
     187                        return new WP_Error( 'rest_forbidden_context', _l( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
    188188                }
    189189
    190190                if ( in_array( $request['orderby'], array( 'email', 'registered_date' ), true ) && ! current_user_can( 'list_users' ) ) {
    191                         return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you are not allowed to order users by this parameter.' ), array( 'status' => rest_authorization_required_code() ) );
     191                        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() ) );
    192192                }
    193193
    194194                return true;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    336336         * @return WP_User|WP_Error True if ID is valid, WP_Error otherwise.
    337337         */
    338338        protected function get_user( $id ) {
    339                 $error = new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) );
     339                $error = new WP_Error( 'rest_user_invalid_id', _l( 'Invalid user ID.' ), array( 'status' => 404 ) );
    340340                if ( (int) $id <= 0 ) {
    341341                        return $error;
    342342                }
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    375375                }
    376376
    377377                if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) {
    378                         return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
     378                        return new WP_Error( 'rest_user_cannot_view', _l( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
    379379                } elseif ( ! count_user_posts( $user->ID, $types ) && ! current_user_can( 'edit_user', $user->ID ) && ! current_user_can( 'list_users' ) ) {
    380                         return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
     380                        return new WP_Error( 'rest_user_cannot_view', _l( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) );
    381381                }
    382382
    383383                return true;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    417417                $current_user_id = get_current_user_id();
    418418
    419419                if ( empty( $current_user_id ) ) {
    420                         return new WP_Error( 'rest_not_logged_in', __( 'You are not currently logged in.' ), array( 'status' => 401 ) );
     420                        return new WP_Error( 'rest_not_logged_in', _l( 'You are not currently logged in.' ), array( 'status' => 401 ) );
    421421                }
    422422
    423423                $user     = wp_get_current_user();
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    440440        public function create_item_permissions_check( $request ) {
    441441
    442442                if ( ! current_user_can( 'create_users' ) ) {
    443                         return new WP_Error( 'rest_cannot_create_user', __( 'Sorry, you are not allowed to create new users.' ), array( 'status' => rest_authorization_required_code() ) );
     443                        return new WP_Error( 'rest_cannot_create_user', _l( 'Sorry, you are not allowed to create new users.' ), array( 'status' => rest_authorization_required_code() ) );
    444444                }
    445445
    446446                return true;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    457457         */
    458458        public function create_item( $request ) {
    459459                if ( ! empty( $request['id'] ) ) {
    460                         return new WP_Error( 'rest_user_exists', __( 'Cannot create existing user.' ), array( 'status' => 400 ) );
     460                        return new WP_Error( 'rest_user_exists', _l( 'Cannot create existing user.' ), array( 'status' => 400 ) );
    461461                }
    462462
    463463                $schema = $this->get_item_schema();
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    476476                        $ret = wpmu_validate_user_signup( $user->user_login, $user->user_email );
    477477
    478478                        if ( is_wp_error( $ret['errors'] ) && ! empty( $ret['errors']->errors ) ) {
    479                                 $error = new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
     479                                $error = new WP_Error( 'rest_invalid_param', _l( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
    480480                                foreach ( $ret['errors']->errors as $code => $messages ) {
    481481                                        foreach ( $messages as $message ) {
    482482                                                $error->add( $code, $message );
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    493493                        $user_id = wpmu_create_user( $user->user_login, $user->user_pass, $user->user_email );
    494494
    495495                        if ( ! $user_id ) {
    496                                 return new WP_Error( 'rest_user_create', __( 'Error creating new user.' ), array( 'status' => 500 ) );
     496                                return new WP_Error( 'rest_user_create', _l( 'Error creating new user.' ), array( 'status' => 500 ) );
    497497                        }
    498498
    499499                        $user->ID = $user_id;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    571571                }
    572572
    573573                if ( ! current_user_can( 'edit_user', $user->ID ) ) {
    574                         return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this user.' ), array( 'status' => rest_authorization_required_code() ) );
     574                        return new WP_Error( 'rest_cannot_edit', _l( 'Sorry, you are not allowed to edit this user.' ), array( 'status' => rest_authorization_required_code() ) );
    575575                }
    576576
    577577                if ( ! empty( $request['roles'] ) && ! current_user_can( 'edit_users' ) ) {
    578                         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() ) );
     578                        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() ) );
    579579                }
    580580
    581581                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 { 
    713713                }
    714714
    715715                if ( ! current_user_can( 'delete_user', $user->ID ) ) {
    716                         return new WP_Error( 'rest_user_cannot_delete', __( 'Sorry, you are not allowed to delete this user.' ), array( 'status' => rest_authorization_required_code() ) );
     716                        return new WP_Error( 'rest_user_cannot_delete', _l( 'Sorry, you are not allowed to delete this user.' ), array( 'status' => rest_authorization_required_code() ) );
    717717                }
    718718
    719719                return true;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    731731        public function delete_item( $request ) {
    732732                // We don't support delete requests in multisite.
    733733                if ( is_multisite() ) {
    734                         return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 501 ) );
     734                        return new WP_Error( 'rest_cannot_delete', _l( 'The user cannot be deleted.' ), array( 'status' => 501 ) );
    735735                }
    736736                $user = $this->get_user( $request['id'] );
    737737                if ( is_wp_error( $user ) ) {
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    744744
    745745                // We don't support trashing for users.
    746746                if ( ! $force ) {
    747                         return new WP_Error( 'rest_trash_not_supported', __( 'Users do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
     747                        return new WP_Error( 'rest_trash_not_supported', _l( 'Users do not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
    748748                }
    749749
    750750                if ( ! empty( $reassign ) ) {
    751751                        if ( $reassign === $id || ! get_userdata( $reassign ) ) {
    752                                 return new WP_Error( 'rest_user_invalid_reassign', __( 'Invalid user ID for reassignment.' ), array( 'status' => 400 ) );
     752                                return new WP_Error( 'rest_user_invalid_reassign', _l( 'Invalid user ID for reassignment.' ), array( 'status' => 400 ) );
    753753                        }
    754754                }
    755755
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    763763                $result = wp_delete_user( $id, $reassign );
    764764
    765765                if ( ! $result ) {
    766                         return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 500 ) );
     766                        return new WP_Error( 'rest_cannot_delete', _l( 'The user cannot be deleted.' ), array( 'status' => 500 ) );
    767767                }
    768768
    769769                $response = new WP_REST_Response();
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    10431043
    10441044                        if ( ! isset( $wp_roles->role_objects[ $role ] ) ) {
    10451045                                /* translators: %s: role key */
    1046                                 return new WP_Error( 'rest_user_invalid_role', sprintf( __( 'The role %s does not exist.' ), $role ), array( 'status' => 400 ) );
     1046                                return new WP_Error( 'rest_user_invalid_role', sprintf( _l( 'The role %s does not exist.' ), $role ), array( 'status' => 400 ) );
    10471047                        }
    10481048
    10491049                        $potential_role = $wp_roles->role_objects[ $role ];
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    10571057                                && get_current_user_id() === $user_id
    10581058                                && ! $potential_role->has_cap( 'edit_users' )
    10591059                        ) {
    1060                                 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => rest_authorization_required_code() ) );
     1060                                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() ) );
    10611061                        }
    10621062
    10631063                        /** Include admin functions to get access to get_editable_roles() */
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    10671067                        $editable_roles = get_editable_roles();
    10681068
    10691069                        if ( empty( $editable_roles[ $role ] ) ) {
    1070                                 return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => 403 ) );
     1070                                return new WP_Error( 'rest_user_invalid_role', _l( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => 403 ) );
    10711071                        }
    10721072                }
    10731073
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    10911091                $username = (string) $value;
    10921092
    10931093                if ( ! validate_username( $username ) ) {
    1094                         return new WP_Error( 'rest_user_invalid_username', __( 'Username contains invalid characters.' ), array( 'status' => 400 ) );
     1094                        return new WP_Error( 'rest_user_invalid_username', _l( 'Username contains invalid characters.' ), array( 'status' => 400 ) );
    10951095                }
    10961096
    10971097                /** This filter is documented in wp-includes/user.php */
    10981098                $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
    10991099
    11001100                if ( in_array( strtolower( $username ), array_map( 'strtolower', $illegal_logins ) ) ) {
    1101                         return new WP_Error( 'rest_user_invalid_username', __( 'Sorry, that username is not allowed.' ), array( 'status' => 400 ) );
     1101                        return new WP_Error( 'rest_user_invalid_username', _l( 'Sorry, that username is not allowed.' ), array( 'status' => 400 ) );
    11021102                }
    11031103
    11041104                return $username;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11211121                $password = (string) $value;
    11221122
    11231123                if ( empty( $password ) ) {
    1124                         return new WP_Error( 'rest_user_invalid_password', __( 'Passwords cannot be empty.' ), array( 'status' => 400 ) );
     1124                        return new WP_Error( 'rest_user_invalid_password', _l( 'Passwords cannot be empty.' ), array( 'status' => 400 ) );
    11251125                }
    11261126
    11271127                if ( false !== strpos( $password, "\\" ) ) {
    1128                         return new WP_Error( 'rest_user_invalid_password', __( 'Passwords cannot contain the "\\" character.' ), array( 'status' => 400 ) );
     1128                        return new WP_Error( 'rest_user_invalid_password', _l( 'Passwords cannot contain the "\\" character.' ), array( 'status' => 400 ) );
    11291129                }
    11301130
    11311131                return $password;
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11461146                        'type'       => 'object',
    11471147                        'properties' => array(
    11481148                                'id'          => array(
    1149                                         'description' => __( 'Unique identifier for the user.' ),
     1149                                        'description' => _l( 'Unique identifier for the user.' ),
    11501150                                        'type'        => 'integer',
    11511151                                        'context'     => array( 'embed', 'view', 'edit' ),
    11521152                                        'readonly'    => true,
    11531153                                ),
    11541154                                'username'    => array(
    1155                                         'description' => __( 'Login name for the user.' ),
     1155                                        'description' => _l( 'Login name for the user.' ),
    11561156                                        'type'        => 'string',
    11571157                                        'context'     => array( 'edit' ),
    11581158                                        'required'    => true,
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11611161                                        ),
    11621162                                ),
    11631163                                'name'        => array(
    1164                                         'description' => __( 'Display name for the user.' ),
     1164                                        'description' => _l( 'Display name for the user.' ),
    11651165                                        'type'        => 'string',
    11661166                                        'context'     => array( 'embed', 'view', 'edit' ),
    11671167                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11691169                                        ),
    11701170                                ),
    11711171                                'first_name'  => array(
    1172                                         'description' => __( 'First name for the user.' ),
     1172                                        'description' => _l( 'First name for the user.' ),
    11731173                                        'type'        => 'string',
    11741174                                        'context'     => array( 'edit' ),
    11751175                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11771177                                        ),
    11781178                                ),
    11791179                                'last_name'   => array(
    1180                                         'description' => __( 'Last name for the user.' ),
     1180                                        'description' => _l( 'Last name for the user.' ),
    11811181                                        'type'        => 'string',
    11821182                                        'context'     => array( 'edit' ),
    11831183                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    11851185                                        ),
    11861186                                ),
    11871187                                'email'       => array(
    1188                                         'description' => __( 'The email address for the user.' ),
     1188                                        'description' => _l( 'The email address for the user.' ),
    11891189                                        'type'        => 'string',
    11901190                                        'format'      => 'email',
    11911191                                        'context'     => array( 'edit' ),
    11921192                                        'required'    => true,
    11931193                                ),
    11941194                                'url'         => array(
    1195                                         'description' => __( 'URL of the user.' ),
     1195                                        'description' => _l( 'URL of the user.' ),
    11961196                                        'type'        => 'string',
    11971197                                        'format'      => 'uri',
    11981198                                        'context'     => array( 'embed', 'view', 'edit' ),
    11991199                                ),
    12001200                                'description' => array(
    1201                                         'description' => __( 'Description of the user.' ),
     1201                                        'description' => _l( 'Description of the user.' ),
    12021202                                        'type'        => 'string',
    12031203                                        'context'     => array( 'embed', 'view', 'edit' ),
    12041204                                ),
    12051205                                'link'        => array(
    1206                                         'description' => __( 'Author URL of the user.' ),
     1206                                        'description' => _l( 'Author URL of the user.' ),
    12071207                                        'type'        => 'string',
    12081208                                        'format'      => 'uri',
    12091209                                        'context'     => array( 'embed', 'view', 'edit' ),
    12101210                                        'readonly'    => true,
    12111211                                ),
    12121212                                'locale'    => array(
    1213                                         'description' => __( 'Locale for the user.' ),
     1213                                        'description' => _l( 'Locale for the user.' ),
    12141214                                        'type'        => 'string',
    12151215                                        'enum'        => array_merge( array( '', 'en_US' ), get_available_languages() ),
    12161216                                        'context'     => array( 'edit' ),
    12171217                                ),
    12181218                                'nickname'    => array(
    1219                                         'description' => __( 'The nickname for the user.' ),
     1219                                        'description' => _l( 'The nickname for the user.' ),
    12201220                                        'type'        => 'string',
    12211221                                        'context'     => array( 'edit' ),
    12221222                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12241224                                        ),
    12251225                                ),
    12261226                                'slug'        => array(
    1227                                         'description' => __( 'An alphanumeric identifier for the user.' ),
     1227                                        'description' => _l( 'An alphanumeric identifier for the user.' ),
    12281228                                        'type'        => 'string',
    12291229                                        'context'     => array( 'embed', 'view', 'edit' ),
    12301230                                        'arg_options' => array(
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12321232                                        ),
    12331233                                ),
    12341234                                'registered_date' => array(
    1235                                         'description' => __( 'Registration date for the user.' ),
     1235                                        'description' => _l( 'Registration date for the user.' ),
    12361236                                        'type'        => 'string',
    12371237                                        'format'      => 'date-time',
    12381238                                        'context'     => array( 'edit' ),
    12391239                                        'readonly'    => true,
    12401240                                ),
    12411241                                'roles'           => array(
    1242                                         'description' => __( 'Roles assigned to the user.' ),
     1242                                        'description' => _l( 'Roles assigned to the user.' ),
    12431243                                        'type'        => 'array',
    12441244                                        'items'       => array(
    12451245                                                'type'    => 'string',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12471247                                        'context'     => array( 'edit' ),
    12481248                                ),
    12491249                                'password'        => array(
    1250                                         'description' => __( 'Password for the user (never included).' ),
     1250                                        'description' => _l( 'Password for the user (never included).' ),
    12511251                                        'type'        => 'string',
    12521252                                        'context'     => array(), // Password is never displayed.
    12531253                                        'required'    => true,
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12561256                                        ),
    12571257                                ),
    12581258                                'capabilities'    => array(
    1259                                         'description' => __( 'All capabilities assigned to the user.' ),
     1259                                        'description' => _l( 'All capabilities assigned to the user.' ),
    12601260                                        'type'        => 'object',
    12611261                                        'context'     => array( 'edit' ),
    12621262                                        'readonly'    => true,
    12631263                                ),
    12641264                                'extra_capabilities' => array(
    1265                                         'description' => __( 'Any extra capabilities assigned to the user.' ),
     1265                                        'description' => _l( 'Any extra capabilities assigned to the user.' ),
    12661266                                        'type'        => 'object',
    12671267                                        'context'     => array( 'edit' ),
    12681268                                        'readonly'    => true,
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12781278                        foreach ( $avatar_sizes as $size ) {
    12791279                                $avatar_properties[ $size ] = array(
    12801280                                        /* translators: %d: avatar image size in pixels */
    1281                                         'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' ), $size ),
     1281                                        'description' => sprintf( _l( 'Avatar URL with image size of %d pixels.' ), $size ),
    12821282                                        'type'        => 'string',
    12831283                                        'format'      => 'uri',
    12841284                                        'context'     => array( 'embed', 'view', 'edit' ),
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    12861286                        }
    12871287
    12881288                        $schema['properties']['avatar_urls']  = array(
    1289                                 'description' => __( 'Avatar URLs for the user.' ),
     1289                                'description' => _l( 'Avatar URLs for the user.' ),
    12901290                                'type'        => 'object',
    12911291                                'context'     => array( 'embed', 'view', 'edit' ),
    12921292                                'readonly'    => true,
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13131313                $query_params['context']['default'] = 'view';
    13141314
    13151315                $query_params['exclude'] = array(
    1316                         'description'        => __( 'Ensure result set excludes specific IDs.' ),
     1316                        'description'        => _l( 'Ensure result set excludes specific IDs.' ),
    13171317                        'type'               => 'array',
    13181318                        'items'              => array(
    13191319                                'type'           => 'integer',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13221322                );
    13231323
    13241324                $query_params['include'] = array(
    1325                         'description'        => __( 'Limit result set to specific IDs.' ),
     1325                        'description'        => _l( 'Limit result set to specific IDs.' ),
    13261326                        'type'               => 'array',
    13271327                        'items'              => array(
    13281328                                'type'           => 'integer',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13311331                );
    13321332
    13331333                $query_params['offset'] = array(
    1334                         'description'        => __( 'Offset the result set by a specific number of items.' ),
     1334                        'description'        => _l( 'Offset the result set by a specific number of items.' ),
    13351335                        'type'               => 'integer',
    13361336                );
    13371337
    13381338                $query_params['order'] = array(
    13391339                        'default'            => 'asc',
    1340                         'description'        => __( 'Order sort attribute ascending or descending.' ),
     1340                        'description'        => _l( 'Order sort attribute ascending or descending.' ),
    13411341                        'enum'               => array( 'asc', 'desc' ),
    13421342                        'type'               => 'string',
    13431343                );
    13441344
    13451345                $query_params['orderby'] = array(
    13461346                        'default'            => 'name',
    1347                         'description'        => __( 'Sort collection by object attribute.' ),
     1347                        'description'        => _l( 'Sort collection by object attribute.' ),
    13481348                        'enum'               => array(
    13491349                                'id',
    13501350                                'include',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13581358                );
    13591359
    13601360                $query_params['slug']    = array(
    1361                         'description'        => __( 'Limit result set to users with one or more specific slugs.' ),
     1361                        'description'        => _l( 'Limit result set to users with one or more specific slugs.' ),
    13621362                        'type'               => 'array',
    13631363                        'items'              => array(
    13641364                                'type'               => 'string',
    class WP_REST_Users_Controller extends WP_REST_Controller { 
    13661366                );
    13671367
    13681368                $query_params['roles']   = array(
    1369                         'description'        => __( 'Limit result set to users matching at least one specific role provided. Accepts csv list or single role.' ),
     1369                        'description'        => _l( 'Limit result set to users matching at least one specific role provided. Accepts csv list or single role.' ),
    13701370                        'type'               => 'array',
    13711371                        'items'              => array(
    13721372                                '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 eaf70a5781..2b44d89f71 100644
    abstract class WP_REST_Meta_Fields { 
    180180                        return new WP_Error(
    181181                                'rest_cannot_delete',
    182182                                /* translators: %s: custom field key */
    183                                 sprintf( __( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
     183                                sprintf( _l( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
    184184                                array( 'key' => $name, 'status' => rest_authorization_required_code() )
    185185                        );
    186186                }
    abstract class WP_REST_Meta_Fields { 
    188188                if ( ! delete_metadata( $meta_type, $object_id, wp_slash( $meta_key ) ) ) {
    189189                        return new WP_Error(
    190190                                'rest_meta_database_error',
    191                                 __( 'Could not delete meta value from database.' ),
     191                                _l( 'Could not delete meta value from database.' ),
    192192                                array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
    193193                        );
    194194                }
    abstract class WP_REST_Meta_Fields { 
    216216                        return new WP_Error(
    217217                                'rest_cannot_update',
    218218                                /* translators: %s: custom field key */
    219                                 sprintf( __( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
     219                                sprintf( _l( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
    220220                                array( 'key' => $name, 'status' => rest_authorization_required_code() )
    221221                        );
    222222                }
    abstract class WP_REST_Meta_Fields { 
    251251                        if ( ! delete_metadata( $meta_type, $object_id, wp_slash( $meta_key ), wp_slash( $value ) ) ) {
    252252                                return new WP_Error(
    253253                                        'rest_meta_database_error',
    254                                         __( 'Could not update meta value in database.' ),
     254                                        _l( 'Could not update meta value in database.' ),
    255255                                        array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
    256256                                );
    257257                        }
    abstract class WP_REST_Meta_Fields { 
    261261                        if ( ! add_metadata( $meta_type, $object_id, wp_slash( $meta_key ), wp_slash( $value ) ) ) {
    262262                                return new WP_Error(
    263263                                        'rest_meta_database_error',
    264                                         __( 'Could not update meta value in database.' ),
     264                                        _l( 'Could not update meta value in database.' ),
    265265                                        array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
    266266                                );
    267267                        }
    abstract class WP_REST_Meta_Fields { 
    288288                        return new WP_Error(
    289289                                'rest_cannot_update',
    290290                                /* translators: %s: custom field key */
    291                                 sprintf( __( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
     291                                sprintf( _l( 'Sorry, you are not allowed to edit the %s custom field.' ), $name ),
    292292                                array( 'key' => $name, 'status' => rest_authorization_required_code() )
    293293                        );
    294294                }
    abstract class WP_REST_Meta_Fields { 
    308308                if ( ! update_metadata( $meta_type, $object_id, $meta_key, $meta_value ) ) {
    309309                        return new WP_Error(
    310310                                'rest_meta_database_error',
    311                                 __( 'Could not update meta value in database.' ),
     311                                _l( 'Could not update meta value in database.' ),
    312312                                array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
    313313                        );
    314314                }
    abstract class WP_REST_Meta_Fields { 
    387387                $fields = $this->get_registered_fields();
    388388
    389389                $schema = array(
    390                         'description' => __( 'Meta fields.' ),
     390                        'description' => _l( 'Meta fields.' ),
    391391                        'type'        => 'object',
    392392                        'context'     => array( 'view', 'edit' ),
    393393                        '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 30246932bf..68bca079f6 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