Created
December 3, 2013 16:56
-
-
Save ryelle/7772839 to your computer and use it in GitHub Desktop.
Set up a fake menu item to test using an icon font.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Admin Icon Example | |
*/ | |
// Add the fake menu item | |
add_action( 'admin_menu', 'admin_fake_menu_item' ); | |
function admin_fake_menu_item() { | |
add_menu_page( 'Icon Test', 'Icon Test', 'edit_posts', 'admin-icon-font', '__return_true' ); | |
} | |
add_action( 'admin_head', 'set_custom_font_icon' ); | |
function set_custom_font_icon() { | |
?> | |
<style type="text/css"> | |
/* for top level menu pages replace `{menu-slug}` with the slug name passed to `add_menu_page()` */ | |
#toplevel_page_admin-icon-font .wp-menu-image:before { | |
font-family: FontAwesome !important; | |
content: '\f00d' !important; | |
} | |
</style> | |
<?php | |
} | |
// enqueue custom icon font | |
add_action( 'admin_enqueue_scripts', 'enqueue_font_awesome' ); | |
function enqueue_font_awesome() { | |
wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css', false, null ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you a lot.
this code is really practical.