--- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php Tue Sep 27 16:37:53 2022 +0200
@@ -200,13 +200,16 @@
* Prepares a taxonomy object for serialization.
*
* @since 4.7.0
+ * @since 5.9.0 Renamed `$taxonomy` to `$item` to match parent class for PHP 8 named parameter support.
*
- * @param WP_Taxonomy $taxonomy Taxonomy data.
- * @param WP_REST_Request $request Full details about the request.
+ * @param WP_Taxonomy $item Taxonomy data.
+ * @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response Response object.
*/
- public function prepare_item_for_response( $taxonomy, $request ) {
- $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
+ public function prepare_item_for_response( $item, $request ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $taxonomy = $item;
+ $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
$fields = $this->get_fields_for_response( $request );
$data = array();
@@ -247,6 +250,10 @@
$data['rest_base'] = $base;
}
+ if ( in_array( 'rest_namespace', $fields, true ) ) {
+ $data['rest_namespace'] = $taxonomy->rest_namespace;
+ }
+
if ( in_array( 'visibility', $fields, true ) ) {
$data['visibility'] = array(
'public' => (bool) $taxonomy->public,
@@ -271,7 +278,7 @@
'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
),
'https://api.w.org/items' => array(
- 'href' => rest_url( sprintf( 'wp/v2/%s', $base ) ),
+ 'href' => rest_url( rest_get_route_for_taxonomy_items( $taxonomy->name ) ),
),
)
);
@@ -294,6 +301,8 @@
* Retrieves the taxonomy's schema, conforming to JSON Schema.
*
* @since 4.7.0
+ * @since 5.0.0 The `visibility` property was added.
+ * @since 5.9.0 The `rest_namespace` property was added.
*
* @return array Item schema data.
*/
@@ -307,49 +316,49 @@
'title' => 'taxonomy',
'type' => 'object',
'properties' => array(
- 'capabilities' => array(
+ 'capabilities' => array(
'description' => __( 'All capabilities used by the taxonomy.' ),
'type' => 'object',
'context' => array( 'edit' ),
'readonly' => true,
),
- 'description' => array(
+ 'description' => array(
'description' => __( 'A human-readable description of the taxonomy.' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
- 'hierarchical' => array(
+ 'hierarchical' => array(
'description' => __( 'Whether or not the taxonomy should have children.' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
- 'labels' => array(
+ 'labels' => array(
'description' => __( 'Human-readable labels for the taxonomy for various contexts.' ),
'type' => 'object',
'context' => array( 'edit' ),
'readonly' => true,
),
- 'name' => array(
+ 'name' => array(
'description' => __( 'The title for the taxonomy.' ),
'type' => 'string',
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
- 'slug' => array(
+ 'slug' => array(
'description' => __( 'An alphanumeric identifier for the taxonomy.' ),
'type' => 'string',
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
- 'show_cloud' => array(
+ 'show_cloud' => array(
'description' => __( 'Whether or not the term cloud should be displayed.' ),
'type' => 'boolean',
'context' => array( 'edit' ),
'readonly' => true,
),
- 'types' => array(
+ 'types' => array(
'description' => __( 'Types associated with the taxonomy.' ),
'type' => 'array',
'items' => array(
@@ -358,13 +367,19 @@
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
- 'rest_base' => array(
+ 'rest_base' => array(
'description' => __( 'REST base route for the taxonomy.' ),
'type' => 'string',
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
- 'visibility' => array(
+ 'rest_namespace' => array(
+ 'description' => __( 'REST namespace route for the taxonomy.' ),
+ 'type' => 'string',
+ 'context' => array( 'view', 'edit', 'embed' ),
+ 'readonly' => true,
+ ),
+ 'visibility' => array(
'description' => __( 'The visibility settings for the taxonomy.' ),
'type' => 'object',
'context' => array( 'edit' ),