info
addding font-awesome to admin
https://fontawesome.com/cheatsheet?from=io
https://coolestguidesontheplanet.com/hooking-fontawesome-use-wordpress-dashboard-admin-menus/
[code language=”css”]
function fontawesome_dashboard() {
wp_enqueue_style(‘fontawesome’, ‘http:////netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css’, ”, ‘4.0.3’, ‘all’);
}
add_action(‘admin_init’, ‘fontawesome_dashboard’);
[/code]
Declaring and Overriding
To change the icon a new function and action need to be set in functions.php
[code language=”css”]
function fontawesome_icon_dashboard() {
echo "<style type=’text/css’ media=’screen’>
icon16.icon-media:before, #adminmenu .menu-icon-media div.wp-menu-image:before {
font-family: Fontawesome !important;
content: ‘f03e’;
}
</style>";
}
add_action(‘admin_head’, ‘fontawesome_icon_dashboard’);
[/code]
The function is made of echoing the CSS style, with the font-family set to FontAwesome with the !important override set and the new unicode number with the extra to escape the other one. The action then adds to to the ‘admin_head‘ which will just appear in just the head section of the backend admin pages.
fontawesome-icon-before-admin
media icon
The best use of changing the icons might be to add different icons to new custom post types that have been set up, you could also use this method to change any CSS in the back end which may make some styles more friendly for a client.
https://developer.wordpress.org/resource/dashicons/
[code language=”css”][/code]
Admin Menu
Welcome Screen
Post Formats
Media
Image Editing
TinyMCE
Posts Screen
Sorting
Social
WordPress.org Specific: Jobs, Profiles, WordCamps
Buddicons
Products
Taxonomies
Widgets
Notifications
Misc
WordPress Usage
Admin menu items can be added with 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 'dashicons-editor-removeformatting'
.
Examples
In register_post_type()
, set menu_icon
in the arguments array.
<?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 );
The function add_menu_page()
accepts a parameter after the callback function for an icon URL, which can also accept a dashicons class.
<?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' ); }
CSS/HTML Usage
If you want to use dashicons in the admin outside of the menu, there are two helper classes you can use. These are dashicons-before
and dashicons
, and they can be thought of as setting up dashicons (since you still need your icon’s class, too).
Examples
Adding an icon to a header, with the dashicons-before
class. This can be added right to the element with text.
<h2 class="dashicons-before dashicons-smiley">A Cheerful Headline</h2>
Adding an icon to a header, with the dashicons
class. Note that here, you need extra markup specifically for the icon.
<h2><span class="dashicons dashicons-smiley"></span> A Cheerful Headline</h2>
Photoshop Usage
Use the .OTF version of the font for Photoshop mockups, the web-font versions won’t work. For most accurate results, pick the “Sharp” font smoothing.
[display-posts category=”cheatsheetsall” category_display=”true” category_display=”post_tag” category_display=”taxonomy_name” image_size=”medium” wrapper=”div” wrapper_class=”display-posts-listing grid” meta_key=”_thumbnail_id” pagination=”true” pagination=”100″]