+
+
+
+
+
+ register_post_type() and add_menu_page()
, which both have an option to set an icon. To show the current icon, you should pass in %3$s.', 'wporg' ),
+ 'https://developer.wordpress.org/reference/functions/register_post_type/',
+ 'https://developer.wordpress.org/reference/functions/add_menu_page/',
+ '\'dashicons-{icon}\'
'
+ ); ?>
register_post_type(), set menu_icon
in the arguments array.', 'wporg' ),
+ 'https://developer.wordpress.org/reference/functions/register_post_type/'
+ ); ?>
<?php +/** +* Register the Product post type with a Dashicon. +* +* @see register_post_type() +*/ +function wpdocs_create_post_type() { + register_post_type( 'acme_product', + array( + 'labels' => array( + 'name' => __( 'Products', 'textdomain' ), + 'singular_name' => __( 'Product', 'textdomain' ) + ), + 'public' => true, + 'has_archive' => true, + 'menu_icon' => 'dashicons-products', + ) + ); +} +add_action( 'init', 'wpdocs_create_post_type', 0 ); ++
+ add_menu_page() accepts a parameter after the callback function for an icon URL, which can also accept a dashicons class.', 'wporg' ), + 'https://developer.wordpress.org/reference/functions/add_menu_page/' + ); ?>
+<?php +/** +* Register a menu page with a Dashicon. +* +* @see add_menu_page() +*/ +function wpdocs_add_my_custom_menu() { + // Add an item to the menu. + add_menu_page( + __( 'My Page', 'textdomain' ), + __( 'My Title', 'textdomain' ), + 'manage_options', + 'my-page', + 'my_admin_page_function', + 'dashicons-admin-media' + ); +}+ +
dashicons-before and dashicons
, and they can be thought of as setting up dashicons (since you still need your icon's class, too).", 'wporg' ); ?>
dashicons-before class. This can be added right to the element with text.', 'wporg' ); ?>
++<h2 class="dashicons-before dashicons-smiley"></h2> ++
dashicons class. Note that here, you need extra markup specifically for the icon.', 'wporg' ); ?>
++<h2><span class="dashicons dashicons-smiley"></span> </h2> ++ + + +
+ registerBlockType function accepts a parameter "icon" which accepts the name of a dashicon. The provided example is truncated. See the full example in the Block Editor Handbook.', 'wporg' ), + 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/writing-your-first-block-type/#registering-the-block' + ); ?>
++registerBlockType( 'gutenberg-examples/example-01-basic-esnext', { + apiVersion: 2, + title: 'Example: Basic (esnext)', + icon: 'universal-access-alt', + category: 'design', + example: {}, + edit() {}, + save() {}, +} ); ++
+ Dashicon component is available. See the related documentation in the Block Editor Handbook.', 'wporg' ), + 'https://developer.wordpress.org/block-editor/reference-guides/components/dashicon/' + ); ?>
++import { Dashicon } from '@wordpress/components'; + +const MyDashicon = () => ( + <div> + <Dashicon icon="admin-home" /> + <Dashicon icon="products" /> + <Dashicon icon="wordpress" /> + </div> +); ++ + +