Skip to content

Commit

Permalink
add icon to types controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Sep 9, 2022
1 parent 343b845 commit 3692d4d
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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,
),
),
);

Expand Down

0 comments on commit 3692d4d

Please sign in to comment.