Changeset 55097
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php
r53302 r55097 103 103 public function prepare_item_for_response( $item, $request ) { 104 104 $fields = $this->get_fields_for_response( $request ); 105 $keys = array( 'name', 'label' );105 $keys = array( 'name', 'label', 'description' ); 106 106 $data = array(); 107 107 foreach ( $keys as $key ) { 108 if ( rest_is_field_included( $key, $fields ) ) {108 if ( isset( $item[ $key ] ) && rest_is_field_included( $key, $fields ) ) { 109 109 $data[ $key ] = $item[ $key ]; 110 110 } … … 131 131 'type' => 'object', 132 132 'properties' => array( 133 'name' => array(133 'name' => array( 134 134 'description' => __( 'The category name.' ), 135 135 'type' => 'string', … … 137 137 'context' => array( 'view', 'edit', 'embed' ), 138 138 ), 139 'label' => array(139 'label' => array( 140 140 'description' => __( 'The category label, in human readable format.' ), 141 'type' => 'string', 142 'readonly' => true, 143 'context' => array( 'view', 'edit', 'embed' ), 144 ), 145 'description' => array( 146 'description' => __( 'The category description, in human readable format.' ), 141 147 'type' => 'string', 142 148 'readonly' => true, -
trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php
r54088 r55097 75 75 76 76 // Register some categories in the test registry. 77 $test_registry->register( 'test', array( 'label' => 'Test' ) ); 78 $test_registry->register( 'query', array( 'label' => 'Query' ) ); 77 $test_registry->register( 78 'test', 79 array( 80 'label' => 'Test', 81 'description' => 'Test description', 82 ) 83 ); 84 $test_registry->register( 85 'query', 86 array( 87 'label' => 'Query', 88 'description' => 'Query', 89 ) 90 ); 79 91 } 80 92 … … 104 116 105 117 $expected_names = array( 'test', 'query' ); 106 $expected_fields = array( 'name', 'label' );118 $expected_fields = array( 'name', 'label', 'description' ); 107 119 108 120 $request = new WP_REST_Request( 'GET', static::REQUEST_ROUTE ); 109 $request['_fields'] = 'name,label ';121 $request['_fields'] = 'name,label,description'; 110 122 $response = rest_get_server()->dispatch( $request ); 111 123 $data = $response->get_data();
Note: See TracChangeset
for help on using the changeset viewer.