Skip to content

Instantly share code, notes, and snippets.

@vicsimental
Forked from iwek/plugin_admin_page.php
Created June 20, 2020 03:57
Show Gist options
  • Save vicsimental/2c3135b19ba21a6fbe545273c77f0b82 to your computer and use it in GitHub Desktop.
Save vicsimental/2c3135b19ba21a6fbe545273c77f0b82 to your computer and use it in GitHub Desktop.
Building a WordPress Plugin Admin Menu Page
<?php
add_action('admin_menu', 'plugin_admin_add_page');
function plugin_admin_add_page() {
//http://codex.wordpress.org/Function_Reference/add_menu_page
add_menu_page( 'custom menu title', 'custom menu', 'manage_options', 'dbexplorer/adminpage.php');
}
function my_enqueue($hook) {
//only for our special plugin admin page
if( 'dbexplorer/adminpage.php' != $hook )
return;
wp_register_style('dbexplorer', plugins_url('dbexplorer/pluginpage.css'));
wp_enqueue_style('dbexplorer');
wp_enqueue_script('pluginscript', plugins_url('pluginpage.js', __FILE__ ), array('jquery'));
}
add_action( 'admin_enqueue_scripts', 'my_enqueue' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment