Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
function orbis_timesheets_admin_menu() {
add_menu_page(
__( 'Orbis Timesheets', 'orbis_timesheets' ),
__( 'Timesheets', 'orbis_timesheets' ),
'manage_options',
'orbis_timesheets',
'__return_false',
'dashicons-clock',
40
);
add_submenu_page(
'orbis_timesheets', // parent_slug
__( 'Orbis Timesheets Settings', 'orbis_timesheets' ), // page_title
__( 'Settings', 'orbis_timesheets' ), // menu_title
'manage_options', // capability
'orbis_timesheets_settings', // menu_slug
'__return_false' // function
);
global $submenu;
/*
* Add taxonomy 'orbis_timesheets_activity' to sub menu
* @see https://github.com/WordPress/WordPress/blob/3.9.1/wp-admin/menu.php#L59
*/
if ( isset( $submenu['orbis_timesheets'] ) ) {
$tax = get_taxonomy( 'orbis_timesheets_activity' );
$submenu['orbis_timesheets'][] = array(
esc_attr( $tax->labels->menu_name ),
$tax->cap->manage_terms,
add_query_arg( 'taxonomy', $tax->name, 'edit-tags.php' )
);
}
}
add_action( 'admin_menu', 'orbis_timesheets_admin_menu' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment