diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php index cb2daa4b292c6..6ca4b855b06af 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php @@ -221,6 +221,10 @@ public function prepare_item_for_response( $item, $request ) { $data['slug'] = $post_type->name; } + if ( in_array( 'icon', $fields, true ) ) { + $data['icon'] = $post_type->menu_icon; + } + if ( in_array( 'supports', $fields, true ) ) { $data['supports'] = $supports; } @@ -287,6 +291,7 @@ protected function prepare_links( $post_type ) { * @since 4.7.0 * @since 4.8.0 The `supports` property was added. * @since 5.9.0 The `visibility` and `rest_namespace` properties were added. + * @since 6.1.0 The `icon` property was added. * * @return array Item schema data. */ @@ -385,6 +390,12 @@ public function get_item_schema() { ), ), ), + 'icon' => array( + 'description' => __( 'The icon for the post type.' ), + 'type' => 'string', + 'context' => array( 'view', 'edit', 'embed' ), + 'readonly' => true, + ), ), );