Skip to content

Commit 011962f

Browse files
Posts, Post Types: Add default menu_icon values for built-in post types.
This allows the icons to be retrieved via `get_post_type_object()`. Props m.usama.masood, michael.ecklund, SergeyBiryukov. Fixes #38844. git-svn-id: https://develop.svn.wordpress.org/trunk@47196 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 56e4630 commit 011962f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/wp-includes/post.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function create_initial_post_types() {
3030
'capability_type' => 'post',
3131
'map_meta_cap' => true,
3232
'menu_position' => 5,
33+
'menu_icon' => 'dashicons-admin-post',
3334
'hierarchical' => false,
3435
'rewrite' => false,
3536
'query_var' => false,
@@ -54,6 +55,7 @@ function create_initial_post_types() {
5455
'capability_type' => 'page',
5556
'map_meta_cap' => true,
5657
'menu_position' => 20,
58+
'menu_icon' => 'dashicons-admin-page',
5759
'hierarchical' => true,
5860
'rewrite' => false,
5961
'query_var' => false,
@@ -85,6 +87,7 @@ function create_initial_post_types() {
8587
'create_posts' => 'upload_files',
8688
),
8789
'map_meta_cap' => true,
90+
'menu_icon' => 'dashicons-admin-media',
8891
'hierarchical' => false,
8992
'rewrite' => false,
9093
'query_var' => false,

tests/phpunit/tests/post/types.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ public function test_get_post_type_object_casting() {
263263
_unregister_post_type( 'foo' );
264264
}
265265

266+
/**
267+
* @ticket 38844
268+
*/
269+
public function test_get_post_type_object_includes_menu_icon_for_builtin_post_types() {
270+
$this->assertEquals( 'dashicons-admin-post', get_post_type_object( 'post' )->menu_icon );
271+
$this->assertEquals( 'dashicons-admin-page', get_post_type_object( 'page' )->menu_icon );
272+
$this->assertEquals( 'dashicons-admin-media', get_post_type_object( 'attachment' )->menu_icon );
273+
}
274+
266275
/**
267276
* @ticket 14761
268277
*/

0 commit comments

Comments
 (0)