Skip to content

Instantly share code, notes, and snippets.

Created Sep 16, 2016
What would you like to do?
add_action('admin_menu', 'add_manage_sites_menu');
function add_manage_sites_menu(){
// Save the reference to the new menu page
$adminPage = add_menu_page(
'New My Sites',
'New My Sites',
// Load the JS conditionally using the new menu page name
add_action( 'load-' . $adminPage, 'load_admin_js' );
// This function is only called when our plugin's page loads!
function load_admin_js(){
// Unfortunately we can't just enqueue our scripts here - it's too early.
// So register against the proper action hook to do it
add_action( 'admin_enqueue_scripts', 'enqueue_admin_js' );
function enqueue_admin_js(){
// Enqueue our script
wp_enqueue_script( 'some-js', PLUGIN_URL . 'js/some.js', array( 'jquery') );
// Enqueue our CSS
wp_enqueue_style( 'some-css', PLUGIN_URL . 'css/some.css' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment