Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add WordPress admin menu + submenu
<?php
class WeAreWP {
function __construct() {
}
function init() {
add_action( 'admin_menu', array( $this, 'wearewp_plugin_top_menu' ) );
}
function wearewp_plugin_top_menu(){
add_menu_page( 'WeAre[WP]', 'WeAre[WP]', 'manage_options', 'wearewp', array( $this, 'wearewp_render_plugin_page' ) );
add_submenu_page( 'wearewp', 'About', 'About', 'manage_options', 'wearewp-about', array( $this, 'wearewp_render_about_page' ) );
}
function wearewp_render_plugin_page(){
?>
<div class='wrap'>
<h2>Plugin page</h2>
</div>
<?php
}
function wearewp_render_about_page(){
?>
<div class='wrap'>
<h2>About page</h2>
</div>
<?php
}
}
$wearewp = new WeAreWP();
$wearewp->init();
<?php
add_action('admin_menu','wearewp_plugin_top_menu');
function wearewp_plugin_top_menu(){
add_menu_page( 'WeAre[WP]', 'WeAre[WP]', 'manage_options', 'wearewp', 'wearewp_render_plugin_page' );
add_submenu_page( 'wearewp', 'About', 'About', 'manage_options', 'wearewp-about', 'wearewp_render_about_page');
}
function wearewp_render_plugin_page(){
?>
<div class='wrap'>
<h2>Plugin page</h2>
</div>
<?php
}
function wearewp_render_about_page(){
?>
<div class='wrap'>
<h2>About page</h2>
</div>
<?php
}
@Verturin

This comment has been minimized.

Copy link

commented Nov 28, 2017

Cool !
Merci pour la function !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.