Created
March 3, 2012 19:32
-
-
Save chrisvanpatten/1967719 to your computer and use it in GitHub Desktop.
admin_enqueue_scripts
This file contains 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 | |
/** | |
* | |
* admin_enqueue_scripts is the preferred hook[1] for adding style to the admin, but | |
* documentation is frankly sparse and a bit confusing, especially for beginners. | |
* | |
* This gist has everything you need to load style for a plugin directly to a hook | |
* of your choice. Enjoy! | |
* | |
* [1] http://bit.ly/vYw3SY | |
* | |
*/ | |
function plugin_load_style($hook) { | |
if ( $hook == 'your_hook_name' ) { | |
wp_register_style('plugin_style', plugins_url('css/style.css', __FILE__)); | |
wp_enqueue_style('plugin_style'); | |
} | |
} | |
add_action('admin_enqueue_scripts', 'plugin_load_style'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment