Skip to content

Instantly share code, notes, and snippets.

@kmwalsh
Forked from mehrshaddarzi/admin-menu.php
Created April 29, 2025 19:31
Show Gist options
  • Save kmwalsh/2b9cb22b6dca9657374b0c309c121c2e to your computer and use it in GitHub Desktop.
Save kmwalsh/2b9cb22b6dca9657374b0c309c121c2e to your computer and use it in GitHub Desktop.
debug get all list menu in admin wordpress
<?php
/*
Check class Adctie Menu Admin
//is_open => wp-has-current-submenu wp-menu-open
//is_open for menu who not submenu => current
//is_close => wp-not-current-submenu menu-top
//if for post Type li => id="menu-posts-{post_type_name}"
//if for taxonomy => id="toplevel_page_edit-tags-taxonomy-{taxonomy}-post_type-{posttype}"
*/
//add menu parent file
https://stackoverflow.com/questions/2308569/manually-highlight-wordpress-admin-menu-item
//change url of menu
https://wordpress.stackexchange.com/questions/83768/add-menu-and-submenu-in-admin-with-a-url-instead-of-slug
add_action( 'admin_init', 'wpse_136058_remove_menu_pages' );
function wpse_136058_remove_menu_pages() {
remove_menu_page( 'edit.php?post_type=acf' );
remove_menu_page( 'wpcf7' );
}
add_action( 'admin_init', 'wpse_136058_debug_admin_menu' );
function wpse_136058_debug_admin_menu() {
echo '<pre>' . print_r( $GLOBALS[ 'menu' ], TRUE) . '</pre>';
}
[27] => Array
(
[0] => Formular
[1] => wpcf7_read_contact_forms
[2] => wpcf7
[3] => Contact Form 7
[4] => menu-top menu-icon-generic toplevel_page_wpcf7 menu-top-last
[5] => toplevel_page_wpcf7
[6] => none
)
add_filter( 'parent_file', 'test_taxonomy_highlight' );
add_filter( 'submenu_file', 'test_taxonomy_highlight' );
function test_taxonomy_highlight( $parent_file ){
global $submenu_file, $pagenow;
echo '<pre>', var_dump( $submenu_file, htmlentities( $submenu_file ) ), '</pre>';
echo '<pre>', var_dump( $parent_file, htmlentities( $parent_file ) ), '</pre>';
if($pagenow =="post-new.php" and isset($_GET['post_type']) and $_GET['post_type'] =="wp-pattern") {
return "edit.php?post_type=wp-pattern";
}
return $parent_file;
}
https://wordpress.stackexchange.com/questions/136058/how-to-remove-admin-menu-pages-inserted-by-plugins
http://www.kvcodes.com/2014/07/add-font-awesome-icons-wordpress-menus/
https://stackoverflow.com/questions/30620226/custom-svg-admin-menu-icon-in-wordpress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment