i want to remove an menu item from admin bar , tried the following code
add_action( 'admin_menu', 'remove_admin_menu_items', 999 );
function remove_admin_menu_items() {
remove_menu_page('admin.php?page=litespeed&LSCWP_CTRL=purge&LSCWP_NONCE=ccd23d492e&litespeed_type=purge_all_lscache' );
}
unfortunately it doesn't work ! I have attached a screenshot of menu I want to remove
I like to hide the menu using the child theme function.php code.
Plugin author posts the following:
The best way to hide our menu is by CSS. For top icon in adminbar, use
.litespeed-top-toolbar {display:none}. It can be done by using 3rd party plugin like https://wordpress.org/plugins/add-admin-css/ or
add_action('admin_head', 'hide_litespeed_icon');
function hide_litespeed_icon() {
echo '<style>.litespeed-top-toolbar {display:none}</style>';
}
into your theme’s functions.php
Alternatively, try adding the following code to functions.php:
function remove_lscwp_admin_menu($wp_admin_bar) {
$wp_admin_bar->remove_node('litespeed-menu');
}
add_action('admin_bar_menu', 'remove_lscwp_admin_menu', 999);
Related
I created an ACF option menu item with sub-menu items, but I'd like to hide a specific sub-menu item (translations).
I've tried a few thing like for example:
add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_submenu_page( 'admin.php', 'acf-options-translations' );
}
But that doesn't work. Is it possible to achieve what I need via action, or I need to go with some sketchy CSS ?
Tks
I added a custom logout link to my WP admin menu, but instead of appearing as a top-level menu item, it is displayed as a submenu item (smaller font size, left padding). The link itself works perfectly though. Any ideas how the code can be changed? Thanks!
current admin menu
The code I use is from this thread.
add_action('admin_init', 'text_domain_logout_link');
function text_domain_logout_link() {
global $menu;
$menu[9999] = array(__('Logout'), 'manage_options', wp_logout_url());
}
Can you try this?:
add_action('admin_menu', 'text_domain_logout_link');
function text_domain_logout_link() {
global $menu;
$menu[9999] = array(__('Logout'), 'manage_options', wp_logout_url());
}
Tested and works on my wordpress
Updated:
If you want to show it to top-level then use this code:
add_action('admin_menu', 'text_domain_logout_link');
function text_domain_logout_link() {
global $menu;
$menu[9999] = array(__('Logout'), 'manage_options', wp_logout_url());
// add class
$menu[9999][4] = "menu-top toplevel_page_menu";
// Add Icon
$menu[9999][6] = "dashicons-update";
}
So it will look like this:
I wanted to remove the cart icon from my nav bar using woocommerce. There did not seem to be a setting in the admin to do that.
I used this code
function remove_nav_cart_link () {
remove_action( 'woo_nav_inside', 'woo_add_nav_cart_link', 20);
}
add_action( 'after_setup_theme', 'remove_nav_cart_link' );
The setting is under WooThemes -> WooCommerce -> Header Cart Link
for me the following solution worked but nothing else
Just added the following code in Theme's custom css
Appearance>Themes>Your theme>Custom CSS
#top .wc-nav li.cart {
display: none !important;}
#top .wc-nav li.checkout{
display: none !important;}
I don't use WooTheme, just the WooCommerce plugin and the header cart still appeared in my premium theme, so instead of disabling it by a function I just used the following CSS code in my child theme..
#Top_bar a#header_cart { display:none }
Go to \wamp64\www\....\wp-content\themes\yourtheme\includes\header-top-bar-right
Find line WooCommerce Cart
Comment the line out:
echo '<a id="header_cart" href="'. $woocommerce->cart->get_cart_url() .'"><i class="'. $show_cart .'"></i><span>'. $woocommerce->cart->cart_contents_count .'</span></a>';
Go to wp-content/themes/yourtheme/inc/woocommerce/yourthemename-woocommerce-template-hook
search for
add_action( 'storefront_header', 'storefront_product_search', 40 );
add_action( 'storefront_header', 'storefront_header_cart', 60 );
comment these 2 lines..!!
I integrated option tree in my template.
I want to hide OptionTree menu item from users. How to remove Option Tree menu item in admin page?
Add this code to your theme's functions.php:
// Remove Option Tree Settings Menu
add_filter( 'ot_show_pages', '__return_false' );
That will remove the Option Tree admin menu.
Here is another solution.
function remove_ot_menu () {
remove_menu_page( "ot-settings" ); } add_action( 'admin_menu', 'remove_ot_menu' );
I know i'm late to the party but since i got to find
a solution (for an old website i restructering) i tought
i might share "a softer" solution.
2 steps
1. We ad the current user id to the admin body class
2. We add a css to hide the menu except for the intended user.
User id in the body class
/*********************************************
** CUSTOM BODY CLASS
*********************************************/
add_filter('admin_body_class', 'custom_admin_body_class');
function custom_admin_body_class($classes){
$cuserid = get_current_user_id();
return $classes. 'user-'.$cuserid;
}
Add the desired css to anytype of css loaded to wp-admin
** replace user-[number] with yours*
.wp-admin:not(.user-1) #toplevel_page_ot-settings {display: none;}
If your not loading any css to wp-admin you can use this
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>.wp-admin:not(.user-1) #toplevel_page_ot-settings {display: none;}</style>';
}
I have an elegant theme installed in my Wordpress website, and I am wondering how i can hide or remove the shortcode buttons in the tinymce (thing) that are generated by the Elegant Theme (admin area WP). I have been trying to look up the action hook and remove it and also play with the CSS of the buttons, but nothing helped. any idea's on how to remove these small buttons from the backend of my WP website?
This is the related code I've found:
add_filter('mce_buttons', 'et_filter_mce_button');
add_filter('mce_external_plugins', 'et_filter_mce_plugin');
function et_filter_mce_button($buttons) {
array_push( $buttons, '|', 'et_learn_more', 'et_box', 'et_button', 'et_tabs', 'et_author' );
return $buttons;
}
Create a plugin and remove the filters:
<?php
/**
* Plugin Name: Remove ET MCE Buttons
*/
add_action( 'admin_init', 'remove_et_so_19084867' );
function remove_et_so_19084867() {
remove_filter( 'mce_buttons', 'et_filter_mce_button' );
remove_filter( 'mce_external_plugins', 'et_filter_mce_plugin' );
}
A user from the Elegant Themes forum referenced this post: https://wordpress.stackexchange.com/questions/103347/removing-buttons-from-the-editor and said:
Place the following code in your child theme functions.php:
// HIDE TINYMCE CUSTOM BUTTONS
function tinymce_editor_buttons($buttons) {
return array();
}
function tinymce_editor_buttons_second_row($buttons) {
return array();
}
add_filter("mce_buttons", "tinymce_editor_buttons", 99);
add_filter("mce_buttons_2", "tinymce_editor_buttons_second_row", 99);
This removes all buttons inserted by Divi and other plugins. If you need to keep any buttons you can include the corresponding ID inside of return array();. Also, if you're using the plugin TinyMCE Advanced, the standard buttons stay in place anyway.