Make WordPress Core


Ignore:
Timestamp:
07/02/2020 05:55:04 AM (4 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Link to the REST route for the currently queried resource.

This allows for programatically determining the REST version of the current page. The links also aid human discovery of the REST API in general.

Props dshanske, tfrommen, TimothyBlynJacobs.
Fixes #49116.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php

    r47122 r48273  
    292292    }
    293293
     294    /**
     295     * @ticket 49116
     296     */
     297    public function test_get_for_taxonomy_reuses_same_instance() {
     298        $this->assertSame(
     299            get_taxonomy( 'category' )->get_rest_controller(),
     300            get_taxonomy( 'category' )->get_rest_controller()
     301        );
     302    }
     303
     304    /**
     305     * @ticket 49116
     306     */
     307    public function test_get_for_taxonomy_returns_terms_controller_if_custom_class_not_specified() {
     308        register_taxonomy(
     309            'test',
     310            'post',
     311            array(
     312                'show_in_rest' => true,
     313            )
     314        );
     315
     316        $this->assertInstanceOf(
     317            WP_REST_Terms_Controller::class,
     318            get_taxonomy( 'test' )->get_rest_controller()
     319        );
     320    }
     321
    294322}
Note: See TracChangeset for help on using the changeset viewer.