Make WordPress Core


Ignore:
Timestamp:
07/19/2022 04:20:54 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use consistent placement for ::prepare_links() methods.

This moves the ::prepare_links() methods in REST API classes next to ::prepare_item_for_response() where they are used, to bring some consistency across the classes and make code navigation easier.

Includes wrapping some long lines for better readability.

Follow-up to [52079], [52051], [52342], [53721], [53722].

See #55647.

File:
1 edited

Legend:

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

    r53721 r53724  
    262262
    263263    /**
     264     * Prepares links for the request.
     265     *
     266     * @since 6.1.0
     267     *
     268     * @param WP_Post_Type $post_type The post type.
     269     * @return array Links for the given post type.
     270     */
     271    protected function prepare_links( $post_type ) {
     272        return array(
     273            'collection'              => array(
     274                'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
     275            ),
     276            'https://api.w.org/items' => array(
     277                'href' => rest_url( rest_get_route_for_post_type_items( $post_type->name ) ),
     278            ),
     279        );
     280    }
     281
     282    /**
    264283     * Retrieves the post type's schema, conforming to JSON Schema.
    265284     *
     
    385404        );
    386405    }
    387 
    388     /**
    389      * Prepares links for the request.
    390      *
    391      * @since 6.1.0
    392      *
    393      * @param WP_Post_Type $post_type The post type.
    394      * @return array Links for the given post type.
    395      */
    396     protected function prepare_links( $post_type ) {
    397         return array(
    398             'collection'              => array(
    399                 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
    400             ),
    401             'https://api.w.org/items' => array(
    402                 'href' => rest_url( rest_get_route_for_post_type_items( $post_type->name ) ),
    403             ),
    404         );
    405     }
    406406}
Note: See TracChangeset for help on using the changeset viewer.