Make WordPress Core


Ignore:
Timestamp:
11/01/2021 03:26:06 AM (3 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Support custom namespaces for taxonomies.

While a taxonomy can define a custom route by using the rest_base argument, a namespace of wp/v2 was assumed. This commit introduces support for a rest_namespace argument.

A new rest_get_route_for_taxonomy_items function has been introduced and the rest_get_route_for_term function updated to facilitate getting the correct route for taxonomies.

For maximum compatibility sticking with the default wp/v2 namespace is recommended until the API functions see wider use.

Props spacedmonkey.
Fixes #54267.
See [51962].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r51885 r51964  
    388388 *                                                for the taxonomy to be available in the block editor.
    389389 *     @type string        $rest_base             To change the base url of REST API route. Default is $taxonomy.
     390 *     @type string        $rest_namespace        To change the namespace URL of REST API route. Default is wp/v2.
    390391 *     @type string        $rest_controller_class REST API Controller class name. Default is 'WP_REST_Terms_Controller'.
    391392 *     @type bool          $show_tagcloud         Whether to list the taxonomy in the Tag Cloud Widget controls. If not set,
Note: See TracChangeset for help on using the changeset viewer.