Skip to content

Instantly share code, notes, and snippets.

@videlais
Created September 16, 2016 01:15
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 videlais/61e53ffc31944509433abcfb6394b575 to your computer and use it in GitHub Desktop.
Save videlais/61e53ffc31944509433abcfb6394b575 to your computer and use it in GitHub Desktop.
<?php
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',
'read',
'manage_sites',
'manage_sites_menu',
'',
3
);
// 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