remove_menu_page breaks “Add media”
It’s because you’ve hooked it to the wrong action, it should be admin_menu, not admin_init.
It’s because you’ve hooked it to the wrong action, it should be admin_menu, not admin_init.
I think you’re using the wrong approach. Rather than removing the submenu item, alter how the post type was registered, and change the show_in_menu argument. Hook into init way late and change the argument. <?php add_action(‘init’, ‘wpse99123_post_type_switcher’, 999); function wpse99123_post_type_switcher() { global $wp_post_types; $wp_post_types[‘contact’]->show_in_menu = true; // put it back in the menu } Then, … Read more
Remove ‘admin.php?page=” from those values. “admin.php?page=custom_settings_page’ should be ‘custom_settings_page’ ‘admin.php?page=gf_edit_forms’ should be ‘gf_edit_forms’ Values that start with admin.php only have their parameter set in the global default menu order array (global $default_menu_order). So when the sort occurs between your custom menu order array and the global default menu menu order array, it won’t correctly match … Read more
Solution – add_action( ‘admin_menu’, ‘wpse_admin_menu’, 100 ); function wpse_admin_menu() { global $menu, $submenu; $parent=”gf_edit_forms”; if( !isset($submenu[$parent]) ) return; foreach( $submenu[$parent] as $k => $d ){ if( $d[‘2’] == ‘gf_entries’ ) { $submenu[$parent][$k][‘2’] = ‘admin.php?page=gf_entries&id=2’; break; } } }
You can use the awesome WP_Admin_Bar & hook in with admin_bar_menu: /** * Add a “Log out” link directly to the admin bar. * * @link http://wordpress.stackexchange.com/q/141446/1685 * * @param WP_Admin_Bar $wp_admin_bar */ function wpse_141446_admin_bar_logout( $wp_admin_bar ) { if ( is_user_logged_in() ) { $wp_admin_bar->add_menu( array( ‘id’ => ‘my-log-out’, ‘parent’ => ‘top-secondary’, ‘title’ => __( ‘Log … Read more
Not tested, but it might work, use wp_logout_url() wordpress in built function to get logout url. // Add a Login hyperlink to the secondary navigation menu if the user is logged-out function wpa_remove_menu_item( $items, $menu, $args ) { if( is_admin() || ! is_user_logged_in() ) return $items; foreach ( $items as $key => $item ) { … Read more
You can use the remove_submenu_page function after registering the taxonomy. This is how it works by default, it has 2 required parameters, the $menu_slug (these are the parent menus e.g. posts, media, pages, comments and so on), and the $submenu_slug (these are the children of those menus) which is what you’re removing because your custom … Read more
Assuming you are trying to remove the default nav_menus panel, you have the id wrong. Also, you’ll need to add a priority of at least 20 to the customize_register hook, assuming you’re using that hook. function remove_customizer_settings( $wp_customize ){ $wp_customize->remove_panel(‘nav_menus’); } add_action( ‘customize_register’, ‘remove_customizer_settings’, 20 );
If you install WordPress using the GoDaddy cPanel then GoDaddy will automatically install a number of Must Use Plugins in your installation. These plugins are invisible and you can’t disable them by normal means. One of these plugins is enabling the Link Manager. Aside: If you haven’t worked on your site yet I recommend installing … Read more
For your particular situation, where you need to have a menu registered, but not shown unless you click on it from a link on another page you can add a conditional check to see if you’re on the editing page. If so, then change replace null with book per the add_submenu_page() parameters. add_action( ‘admin_menu’, ‘add_the_menus’ … Read more