add logout button on admin side menu

I’m using this as a custom logout button, it also displays a random quote before logout the user. I think you can adapt it to your needs by removing what you don’t need. Instructions: Copy the code below and save as users-logout.php Create a folder called users-logout, upload the file and the images below to … Read more

Highlighting a Menu Item by Post Name

Attention to the use of get_page_by_title parameters. And also to the use of the Heredoc PHP syntax. $the_post_title=”The Portfolio”; add_action( ‘admin_menu’, ‘wpse_59050_add_menu’ ); add_action( ‘admin_head-post.php’, ‘wpse_59050_highlight_menu_item’ ); function wpse_59050_add_menu() { global $the_post_title; $our_page = get_page_by_title( $the_post_title ); $settings_page = add_menu_page( ‘Edit ‘.$our_page->post_title, ‘Edit ‘.$our_page->post_title, ‘add_users’, ‘/post.php?post=”.$our_page->ID.”&action=edit’, ”, ”, 2); } function wpse_59050_highlight_menu_item() { global $the_post_title, … Read more

Remove menus and submenus

Try this: add_action(‘_admin_menu’, ‘remove_editor_submenu’, 1); function remove_editor_submenu() { remove_action(‘admin_menu’, ‘_add_themes_utility_last’, 101); } add_action(‘admin_init’, ‘remove_theme_submenus’); function remove_theme_submenus() { global $submenu; unset($submenu[‘themes.php’][5]); unset($submenu[‘themes.php’][7]); unset($submenu[‘themes.php’][15]); } To disable other submenu names, go to ./wp-admin/menu.php and search for the item(s) you want to disable. EDIT: As far as disabling by username, I would instead add a new capability to … Read more

Add highlighting to new Admin Dashboard Menu Item

The probability is high that no hook will exist for that… But it can be solved with jQuery: add_action( ‘admin_head-post.php’, ‘wpse_58567_highlight_menu_item’ ); function wpse_58567_highlight_menu_item() { global $post; if( 69 != $post->ID ) return; ?> <script type=”text/javascript”> jQuery(document).ready( function($) { $(‘#toplevel_page_post-post-69-action-edit’).removeClass(‘wp-not-current-submenu’).addClass(‘current’); $(‘#toplevel_page_post-post-69-action-edit’).find(‘a:last’).addClass(‘current’); }); </script> <?php }

How to hide menu on WordPress admin

You can do this with remove_menu_page. Add the appropriate menu slug in your functions.php of your theme or your plugin. <?php remove_menu_page( $menu_slug ) ?> Note that users can still access these menus using a direct link. If you intend to block a user from accessing a menu, you will have to set up a … Read more

How to check if an admin (sub)menu already exists?

Something like this should work. $handle should be the menu’s slug; set $sub to true to search submenus (defaults to top level menus): function find_my_menu_item( $handle, $sub = false; ){ if( !is_admin() || (defined(‘DOING_AJAX’) && DOING_AJAX) ) return false; global $menu, $submenu; $check_menu = $sub ? $submenu : $menu; if( empty( $check_menu ) ) return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)