Make WordPress Core


Ignore:
Timestamp:
07/19/2022 04:20:54 PM (2 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-taxonomies-controller.php

    r53722 r53724  
    290290
    291291    /**
     292     * Prepares links for the request.
     293     *
     294     * @since 6.1.0
     295     *
     296     * @param @param WP_Taxonomy $taxonomy The taxonomy.
     297     * @return array Links for the given taxonomy.
     298     */
     299    protected function prepare_links( $taxonomy ) {
     300        return array(
     301            'collection'              => array(
     302                'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
     303            ),
     304            'https://api.w.org/items' => array(
     305                'href' => rest_url( rest_get_route_for_taxonomy_items( $taxonomy->name ) ),
     306            ),
     307        );
     308    }
     309
     310    /**
    292311     * Retrieves the taxonomy's schema, conforming to JSON Schema.
    293312     *
     
    428447        return $new_params;
    429448    }
    430 
    431     /**
    432      * Prepares links for the request.
    433      *
    434      * @since 6.1.0
    435      *
    436      * @param @param WP_Taxonomy $taxonomy The taxonomy.
    437      * @return array Links for the given taxonomy.
    438      */
    439     protected function prepare_links( $taxonomy ) {
    440         return array(
    441             'collection'              => array(
    442                 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
    443             ),
    444             'https://api.w.org/items' => array(
    445                 'href' => rest_url( rest_get_route_for_taxonomy_items( $taxonomy->name ) ),
    446             ),
    447         );
    448     }
    449 
    450449}
Note: See TracChangeset for help on using the changeset viewer.