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

Add Admin Menu Inside Construct or Init

The callback you have given in add_menu_page() is a static function, not a class method. It should be: add_menu_page( ‘School Manager Settings’, ‘School Manager’, ‘administrator’, ‘school-manager-settings’, array ( $this, ‘show_admin_settings_page’ ) ); And please don’t use &$this anymore, that’s PHP 4. 🙂 My demo plugin T5 Admin Menu Demo might help understanding how that works.

How do I remove the entire Media section from the main WordPress navigation without just hiding it?

You are indeed correct, before the admin update(i imagine the UI redesign, etc), unsetting items from the menus would in effect prevent access to those pages, that’s clearly changed now and requires additional cap checking. This isn’t something i’ve looked into myself(as i’ve just found out this moment), so i can’t speak about methods for … Read more

Remove Custom Post Type menu for non-administrator users.

Codex – Register Post Type See the capability_type and capabilities arguments for register_post_type. You can pass the capabilities argument an array of capabilities to map to the necessary caps, here’s an example of the args array with custom capabilities. $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘query_var’ … Read more

How to remove/hide elements from the admin menu?

If you just want to hide the menu items, you can do it like shown below. Don’t forget about the entries inside the admin bar. Code: //hide in admin menu add_action( ‘admin_menu’, ‘wpse121406_hide_pages_comments_m’ ); function wpse121406_hide_pages_comments_m() { remove_menu_page(‘edit.php?post_type=page’); remove_menu_page( ‘edit-comments.php’ ); } //hide in admin bar add_action( ‘wp_before_admin_bar_render’, ‘wpse121406_hide_pages_comments_b’ ); function wpse121406_hide_pages_comments_b() { global $wp_admin_bar; … Read more

Current class on admin menu using add_submenu_page()

Try this: add_menu_page(__(‘My Plugin’, ‘myplugin’),__(‘My Plugin’, ‘myplugin’), ‘edit_posts’,’my-plugin-dashboard’,’my_plugin_dashboard’,’icon’); // dashboard submenu – this fails to highlight with current add_submenu_page(‘my-plugin-dashboard’, __(‘Dashboard’,’myplugin’), __(‘Dashboard’,’myplugin’), ‘edit_posts’, ‘my-plugin-dashboard’, ‘my_plugin_dashboard’ ); // settings submenu – this fails to highlight with current add_submenu_page(‘my-plugin-dashboard’, __(‘Settings’,’myplugin’), __(‘Settings’,’myplugin’), ‘manage_options’, ‘my-plugin-settings’, ‘my_plugin_settings’ ); Essentially: don’t use full page links with admin.php?… as the page slug. Especially … 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

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