-
-
Save videlais/61e53ffc31944509433abcfb6394b575 to your computer and use it in GitHub Desktop.
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 | |
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