Skip to content

Instantly share code, notes, and snippets.

@chrisvanpatten
Created March 3, 2012 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisvanpatten/1967719 to your computer and use it in GitHub Desktop.
Save chrisvanpatten/1967719 to your computer and use it in GitHub Desktop.
admin_enqueue_scripts
<?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