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
This commit is contained in:
Sergey Biryukov 2020-02-05 22:38:11 +00:00
parent 56e4630c0e
commit 011962fae0
2 changed files with 12 additions and 0 deletions

View File

@ -30,6 +30,7 @@ function create_initial_post_types() {
'capability_type' => 'post',
'map_meta_cap' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-post',
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,
@ -54,6 +55,7 @@ function create_initial_post_types() {
'capability_type' => 'page',
'map_meta_cap' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-admin-page',
'hierarchical' => true,
'rewrite' => false,
'query_var' => false,
@ -85,6 +87,7 @@ function create_initial_post_types() {
'create_posts' => 'upload_files',
),
'map_meta_cap' => true,
'menu_icon' => 'dashicons-admin-media',
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,

View File

@ -263,6 +263,15 @@ class Tests_Post_Types extends WP_UnitTestCase {
_unregister_post_type( 'foo' );
}
/**
* @ticket 38844
*/
public function test_get_post_type_object_includes_menu_icon_for_builtin_post_types() {
$this->assertEquals( 'dashicons-admin-post', get_post_type_object( 'post' )->menu_icon );
$this->assertEquals( 'dashicons-admin-page', get_post_type_object( 'page' )->menu_icon );
$this->assertEquals( 'dashicons-admin-media', get_post_type_object( 'attachment' )->menu_icon );
}
/**
* @ticket 14761
*/