Make WordPress Core


Ignore:
Timestamp:
05/25/2021 01:11:55 PM (5 years ago)
Author:
SergeyBiryukov
Message:

REST API: Update “object” strings to use the appropriate nouns.

This updates route arguments and schema descriptions to use more specific object types for clarity.

Follow-up to [39342].

Props lephleg, jnylen0.
Fixes #40720.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r50717 r51000  
    5757
    5858        /**
    59          * Registers the routes for the objects of the controller.
     59         * Registers the routes for posts.
    6060         *
    6161         * @since 4.7.0
     
    101101                                'args'   => array(
    102102                                        'id' => array(
    103                                                 'description' => __( 'Unique identifier for the object.' ),
     103                                                'description' => __( 'Unique identifier for the post.' ),
    104104                                                'type'        => 'integer',
    105105                                        ),
     
    21542154                        'properties' => array(
    21552155                                'date'         => array(
    2156                                         'description' => __( "The date the object was published, in the site's timezone." ),
     2156                                        'description' => __( "The date the post was published, in the site's timezone." ),
    21572157                                        'type'        => array( 'string', 'null' ),
    21582158                                        'format'      => 'date-time',
     
    21602160                                ),
    21612161                                'date_gmt'     => array(
    2162                                         'description' => __( 'The date the object was published, as GMT.' ),
     2162                                        'description' => __( 'The date the post was published, as GMT.' ),
    21632163                                        'type'        => array( 'string', 'null' ),
    21642164                                        'format'      => 'date-time',
     
    21662166                                ),
    21672167                                'guid'         => array(
    2168                                         'description' => __( 'The globally unique identifier for the object.' ),
     2168                                        'description' => __( 'The globally unique identifier for the post.' ),
    21692169                                        'type'        => 'object',
    21702170                                        'context'     => array( 'view', 'edit' ),
     
    21722172                                        'properties'  => array(
    21732173                                                'raw'      => array(
    2174                                                         'description' => __( 'GUID for the object, as it exists in the database.' ),
     2174                                                        'description' => __( 'GUID for the post, as it exists in the database.' ),
    21752175                                                        'type'        => 'string',
    21762176                                                        'context'     => array( 'edit' ),
     
    21782178                                                ),
    21792179                                                'rendered' => array(
    2180                                                         'description' => __( 'GUID for the object, transformed for display.' ),
     2180                                                        'description' => __( 'GUID for the post, transformed for display.' ),
    21812181                                                        'type'        => 'string',
    21822182                                                        'context'     => array( 'view', 'edit' ),
     
    21862186                                ),
    21872187                                'id'           => array(
    2188                                         'description' => __( 'Unique identifier for the object.' ),
     2188                                        'description' => __( 'Unique identifier for the post.' ),
    21892189                                        'type'        => 'integer',
    21902190                                        'context'     => array( 'view', 'edit', 'embed' ),
     
    21922192                                ),
    21932193                                'link'         => array(
    2194                                         'description' => __( 'URL to the object.' ),
     2194                                        'description' => __( 'URL to the post.' ),
    21952195                                        'type'        => 'string',
    21962196                                        'format'      => 'uri',
     
    21992199                                ),
    22002200                                'modified'     => array(
    2201                                         'description' => __( "The date the object was last modified, in the site's timezone." ),
     2201                                        'description' => __( "The date the post was last modified, in the site's timezone." ),
    22022202                                        'type'        => 'string',
    22032203                                        'format'      => 'date-time',
     
    22062206                                ),
    22072207                                'modified_gmt' => array(
    2208                                         'description' => __( 'The date the object was last modified, as GMT.' ),
     2208                                        'description' => __( 'The date the post was last modified, as GMT.' ),
    22092209                                        'type'        => 'string',
    22102210                                        'format'      => 'date-time',
     
    22132213                                ),
    22142214                                'slug'         => array(
    2215                                         'description' => __( 'An alphanumeric identifier for the object unique to its type.' ),
     2215                                        'description' => __( 'An alphanumeric identifier for the post unique to its type.' ),
    22162216                                        'type'        => 'string',
    22172217                                        'context'     => array( 'view', 'edit', 'embed' ),
     
    22212221                                ),
    22222222                                'status'       => array(
    2223                                         'description' => __( 'A named status for the object.' ),
     2223                                        'description' => __( 'A named status for the post.' ),
    22242224                                        'type'        => 'string',
    22252225                                        'enum'        => array_keys( get_post_stati( array( 'internal' => false ) ) ),
     
    22302230                                ),
    22312231                                'type'         => array(
    2232                                         'description' => __( 'Type of Post for the object.' ),
     2232                                        'description' => __( 'Type of post.' ),
    22332233                                        'type'        => 'string',
    22342234                                        'context'     => array( 'view', 'edit', 'embed' ),
     
    22462246                if ( is_post_type_viewable( $post_type_obj ) && $post_type_obj->public ) {
    22472247                        $schema['properties']['permalink_template'] = array(
    2248                                 'description' => __( 'Permalink template for the object.' ),
     2248                                'description' => __( 'Permalink template for the post.' ),
    22492249                                'type'        => 'string',
    22502250                                'context'     => array( 'edit' ),
     
    22532253
    22542254                        $schema['properties']['generated_slug'] = array(
    2255                                 'description' => __( 'Slug automatically generated from the object title.' ),
     2255                                'description' => __( 'Slug automatically generated from the post title.' ),
    22562256                                'type'        => 'string',
    22572257                                'context'     => array( 'edit' ),
     
    22622262                if ( $post_type_obj->hierarchical ) {
    22632263                        $schema['properties']['parent'] = array(
    2264                                 'description' => __( 'The ID for the parent of the object.' ),
     2264                                'description' => __( 'The ID for the parent of the post.' ),
    22652265                                'type'        => 'integer',
    22662266                                'context'     => array( 'view', 'edit' ),
     
    23232323                                case 'title':
    23242324                                        $schema['properties']['title'] = array(
    2325                                                 'description' => __( 'The title for the object.' ),
     2325                                                'description' => __( 'The title for the post.' ),
    23262326                                                'type'        => 'object',
    23272327                                                'context'     => array( 'view', 'edit', 'embed' ),
     
    23322332                                                'properties'  => array(
    23332333                                                        'raw'      => array(
    2334                                                                 'description' => __( 'Title for the object, as it exists in the database.' ),
     2334                                                                'description' => __( 'Title for the post, as it exists in the database.' ),
    23352335                                                                'type'        => 'string',
    23362336                                                                'context'     => array( 'edit' ),
    23372337                                                        ),
    23382338                                                        'rendered' => array(
    2339                                                                 'description' => __( 'HTML title for the object, transformed for display.' ),
     2339                                                                'description' => __( 'HTML title for the post, transformed for display.' ),
    23402340                                                                'type'        => 'string',
    23412341                                                                'context'     => array( 'view', 'edit', 'embed' ),
     
    23482348                                case 'editor':
    23492349                                        $schema['properties']['content'] = array(
    2350                                                 'description' => __( 'The content for the object.' ),
     2350                                                'description' => __( 'The content for the post.' ),
    23512351                                                'type'        => 'object',
    23522352                                                'context'     => array( 'view', 'edit' ),
     
    23572357                                                'properties'  => array(
    23582358                                                        'raw'           => array(
    2359                                                                 'description' => __( 'Content for the object, as it exists in the database.' ),
     2359                                                                'description' => __( 'Content for the post, as it exists in the database.' ),
    23602360                                                                'type'        => 'string',
    23612361                                                                'context'     => array( 'edit' ),
    23622362                                                        ),
    23632363                                                        'rendered'      => array(
    2364                                                                 'description' => __( 'HTML content for the object, transformed for display.' ),
     2364                                                                'description' => __( 'HTML content for the post, transformed for display.' ),
    23652365                                                                'type'        => 'string',
    23662366                                                                'context'     => array( 'view', 'edit' ),
     
    23682368                                                        ),
    23692369                                                        'block_version' => array(
    2370                                                                 'description' => __( 'Version of the content block format used by the object.' ),
     2370                                                                'description' => __( 'Version of the content block format used by the post.' ),
    23712371                                                                'type'        => 'integer',
    23722372                                                                'context'     => array( 'edit' ),
     
    23852385                                case 'author':
    23862386                                        $schema['properties']['author'] = array(
    2387                                                 'description' => __( 'The ID for the author of the object.' ),
     2387                                                'description' => __( 'The ID for the author of the post.' ),
    23882388                                                'type'        => 'integer',
    23892389                                                'context'     => array( 'view', 'edit', 'embed' ),
     
    23932393                                case 'excerpt':
    23942394                                        $schema['properties']['excerpt'] = array(
    2395                                                 'description' => __( 'The excerpt for the object.' ),
     2395                                                'description' => __( 'The excerpt for the post.' ),
    23962396                                                'type'        => 'object',
    23972397                                                'context'     => array( 'view', 'edit', 'embed' ),
     
    24022402                                                'properties'  => array(
    24032403                                                        'raw'       => array(
    2404                                                                 'description' => __( 'Excerpt for the object, as it exists in the database.' ),
     2404                                                                'description' => __( 'Excerpt for the post, as it exists in the database.' ),
    24052405                                                                'type'        => 'string',
    24062406                                                                'context'     => array( 'edit' ),
    24072407                                                        ),
    24082408                                                        'rendered'  => array(
    2409                                                                 'description' => __( 'HTML excerpt for the object, transformed for display.' ),
     2409                                                                'description' => __( 'HTML excerpt for the post, transformed for display.' ),
    24102410                                                                'type'        => 'string',
    24112411                                                                'context'     => array( 'view', 'edit', 'embed' ),
     
    24242424                                case 'thumbnail':
    24252425                                        $schema['properties']['featured_media'] = array(
    2426                                                 'description' => __( 'The ID of the featured media for the object.' ),
     2426                                                'description' => __( 'The ID of the featured media for the post.' ),
    24272427                                                'type'        => 'integer',
    24282428                                                'context'     => array( 'view', 'edit', 'embed' ),
     
    24322432                                case 'comments':
    24332433                                        $schema['properties']['comment_status'] = array(
    2434                                                 'description' => __( 'Whether or not comments are open on the object.' ),
     2434                                                'description' => __( 'Whether or not comments are open on the post.' ),
    24352435                                                'type'        => 'string',
    24362436                                                'enum'        => array( 'open', 'closed' ),
     
    24382438                                        );
    24392439                                        $schema['properties']['ping_status']    = array(
    2440                                                 'description' => __( 'Whether or not the object can be pinged.' ),
     2440                                                'description' => __( 'Whether or not the post can be pinged.' ),
    24412441                                                'type'        => 'string',
    24422442                                                'enum'        => array( 'open', 'closed' ),
     
    24472447                                case 'page-attributes':
    24482448                                        $schema['properties']['menu_order'] = array(
    2449                                                 'description' => __( 'The order of the object in relation to other object of its type.' ),
     2449                                                'description' => __( 'The order of the post in relation to other posts.' ),
    24502450                                                'type'        => 'integer',
    24512451                                                'context'     => array( 'view', 'edit' ),
     
    24582458
    24592459                                        $schema['properties']['format'] = array(
    2460                                                 'description' => __( 'The format for the object.' ),
     2460                                                'description' => __( 'The format for the post.' ),
    24612461                                                'type'        => 'string',
    24622462                                                'enum'        => $formats,
     
    24742474                if ( 'post' === $this->post_type ) {
    24752475                        $schema['properties']['sticky'] = array(
    2476                                 'description' => __( 'Whether or not the object should be treated as sticky.' ),
     2476                                'description' => __( 'Whether or not the post should be treated as sticky.' ),
    24772477                                'type'        => 'boolean',
    24782478                                'context'     => array( 'view', 'edit' ),
     
    24812481
    24822482                $schema['properties']['template'] = array(
    2483                         'description' => __( 'The theme file to use to display the object.' ),
     2483                        'description' => __( 'The theme file to use to display the post.' ),
    24842484                        'type'        => 'string',
    24852485                        'context'     => array( 'view', 'edit' ),
     
    25112511                        $schema['properties'][ $base ] = array(
    25122512                                /* translators: %s: Taxonomy name. */
    2513                                 'description' => sprintf( __( 'The terms assigned to the object in the %s taxonomy.' ), $taxonomy->name ),
     2513                                'description' => sprintf( __( 'The terms assigned to the post in the %s taxonomy.' ), $taxonomy->name ),
    25142514                                'type'        => 'array',
    25152515                                'items'       => array(
     
    27812781
    27822782                $query_params['orderby'] = array(
    2783                         'description' => __( 'Sort collection by object attribute.' ),
     2783                        'description' => __( 'Sort collection by post attribute.' ),
    27842784                        'type'        => 'string',
    27852785                        'default'     => 'date',
Note: See TracChangeset for help on using the changeset viewer.