wp/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php
--- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php Fri Sep 05 18:40:08 2025 +0200
@@ -1,6 +1,6 @@
<?php
/**
- * REST API: WP_REST_Block_Pattern_Catergories_Controller class
+ * REST API: WP_REST_Block_Pattern_Categories_Controller class
*
* @package WordPress
* @subpackage REST_API
@@ -102,10 +102,10 @@
*/
public function prepare_item_for_response( $item, $request ) {
$fields = $this->get_fields_for_response( $request );
- $keys = array( 'name', 'label' );
+ $keys = array( 'name', 'label', 'description' );
$data = array();
foreach ( $keys as $key ) {
- if ( rest_is_field_included( $key, $fields ) ) {
+ if ( isset( $item[ $key ] ) && rest_is_field_included( $key, $fields ) ) {
$data[ $key ] = $item[ $key ];
}
}
@@ -125,26 +125,38 @@
* @return array Item schema data.
*/
public function get_item_schema() {
+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'block-pattern-category',
'type' => 'object',
'properties' => array(
- 'name' => array(
+ 'name' => array(
'description' => __( 'The category name.' ),
'type' => 'string',
'readonly' => true,
'context' => array( 'view', 'edit', 'embed' ),
),
- 'label' => array(
+ 'label' => array(
'description' => __( 'The category label, in human readable format.' ),
'type' => 'string',
'readonly' => true,
'context' => array( 'view', 'edit', 'embed' ),
),
+ 'description' => array(
+ 'description' => __( 'The category description, in human readable format.' ),
+ 'type' => 'string',
+ 'readonly' => true,
+ 'context' => array( 'view', 'edit', 'embed' ),
+ ),
),
);
- return $this->add_additional_fields_schema( $schema );
+ $this->schema = $schema;
+
+ return $this->add_additional_fields_schema( $this->schema );
}
}