From 011962fae08d9eb15b1a7b333a91f8ae5c0191ad Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 5 Feb 2020 22:38:11 +0000 Subject: [PATCH] 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 --- src/wp-includes/post.php | 3 +++ tests/phpunit/tests/post/types.php | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 3b038c1163..9913223e3f 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -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, diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 9632b8d472..053f884fc1 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -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 */