Generally it's not a problem to remove wp-admin menu items, e.g:
add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_submenu_page( 'themes.php', 'theme-editor.php' );
}
However I'm currently struggling with the following page:
admin.php?page=wpml-string-translation/menu/string-translation.php
What's the best method to have this one removed?
I think you're add_action needs a numeric as a 3rd argument (a priority).
https://wordpress.stackexchange.com/questions/55581/how-can-i-remove-the-wp-menu-from-the-admin-bar
Example
If you have this add_action:
add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
To remove it, it needs a higher priority (11):
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Remove WP Menu From Tool Bar
*/
if ( ! function_exists( 't5_remove_wp_menu' ) )
{
// The action is added with a priority of 10, we take one step later.
add_action( 'init', 't5_remove_wp_menu', 11 );
/**
* Remove the WP menu action.
*/
function t5_remove_wp_menu()
{
is_admin_bar_showing() &&
remove_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
}
}
Based on the previous answers, here's the completed solution for both WPML user menus:
function remove_menu_items()
{
//removes the 'String Translation' menu item from editor's admin screen
if (defined('WPML_ST_FOLDER')){
remove_menu_page(WPML_ST_FOLDER.'/menu/string-translation.php');
}
//removes the 'Translation Interface' menu item from editor's admin screen
if (defined('WPML_TM_FOLDER')){
remove_menu_page(WPML_TM_FOLDER . '/menu/translations-queue.php');
}
}
add_action('admin_menu', 'remove_menu_items', 999);
This should work,
add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_submenu_page( 'admin.php?page=wpml-string-translation/menu/string-translation.php', 'admin.php?page=wpml-string-translation/menu/string-translation.php' );
}
The working solution:
function remove_menu_items()
{
//removes the String Translation menu item from editor's admin screen
if (defined('WPML_ST_FOLDER'))
remove_menu_page(WPML_ST_FOLDER.'/menu/string-translation.php');
}
add_action('admin_menu', 'remove_menu_items', 999);
It needs a higher priority from which it was created and to avoid any issues let's use the same WPML constant, which we can find on the file "wpml-string-translation-class.php" at the plugin folder, line 212 as of version 1.6.1 of the WPML String Transtation plugin.
Related
In WooCommerce we want to disable the product image zoom on hover. I've seen multiple options to do it in the child theme, functions.php. But they all are not working.
The child theme function.php is working (has some other code in it that is working). It's also not working when I put it in the main theme function.php file.
I've tried:
add_filter( 'woocommerce_single_product_zoom_enabled', '__return_false' );
and
function remove_image_zoom_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
}
add_action( 'wp', 'remove_image_zoom_support', 100 );
and
add_filter( ‘woocommerce_single_product_zoom_options’, ‘custom_single_product_zoom_options’, 10, 3 );
function custom_single_product_zoom_options( $zoom_options ) {
// Disable zoom magnify:
$zoom_options[‘magnify’] = 0;
return $zoom_options;
}
Any more options?
All the given options don't work. The theme has a (hidden) builtin feature for this.
Thanks for the replies.
I want to remove the Sort by dropdown completely, in my WooCommerce installation.
http://cswpstage.hostworks.net/product-category/memorabilia/signed-photos/
Thanks!
It depends on the theme that you're using. There are two approaches, CSS and PHP.
I see on your theme you have already hidden it via CSS using
.sort-param-order,
.sort-param-sort {
display: none;
}
If you want to hide it with PHP, you need to look for the action which adds it and remove that action. A search for woocommerce_catalog_ordering will generally return the action you're looking for.
Here is how you remove it via standard WooCommerce:
<?php
/**
* Remove sorting from WooCommerce.
*/
function thenga_remove_filtering() {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}
add_action( 'init', 'thenga_remove_filtering' );
And here is how you remove it from the Storefront theme:
<?php
/**
* Remove sorting from Storefront.
*/
function thenga_remove_filtering() {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
}
add_action( 'init', 'thenga_remove_filtering' );
How do I remove a sub-menu with link
http://vagrant.local/wp/wp-admin/admin.php?page=home_settings_page ?
I tried remove_submenu_page( 'admin.php', 'yrc_home_settings_page' );
but that didn't work.
Edit
function remove_menu_pages_for_fuel_surcharge_editor() {
if(current_user_can('fuel-surcharge-editor')) {
remove_menu_page('tools.php');
remove_menu_page('options-general.php');
remove_menu_page('edit.php?post_type=show_event');
remove_menu_page('jetpack');
remove_submenu_page( 'admin.php', 'yrc_home_settings_page' );
}
}
add_action('admin_menu', 'remove_menu_pages_for_fuel_surcharge_editor', 999);
I also tried which didn't work either.
add_action('admin_init', 'remove_menu_pages_for_fuel_surcharge_editor', 999);
Screenshot:
I think you will need to add the function to a hook. Try something like:
function remove_submenu() {
remove_submenu_page( 'admin.php', 'yrc_home_settings_page' );
}
add_action( 'admin_menu', 'remove_submenu', 999 );
I'm not entirely sure if the second parameter in your function is correct.
I don't want the customers to get linked to the myaccount-dashboard with the annoying Hello xy, from here you can blabla, when they click on "My Account".
Is there an endpoint for the my account dashboard? I didn't find it on the backend in woocommerce>Settings>Accounts...
What's working is: I set up a custom link under menu/navigation... called it "My Account" and set the link to /myaccount/downloads for example.
So, when customers are logged in and they click on My Account, they get redirected to Downloads.
I'm wondering, is there another way to get rid of the dashboard?
Or a redirect solution? Thanks.
Remove it using below function. change downloads to your requirement.
function custom_my_account_menu_items( $items ) {
unset($items['downloads']);
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'custom_my_account_menu_items' );
Looking more closely it seems like there are a handful of ways to do this. Take a look at the my-account.php template. You could override this, but I found that if you remove the woocommerce_account_content hook, you get a deprecation notice and WooCommerce thinks you have an outdated template and adds the content anyway.
Looking at the template you will see two hooks. The side menu navigation is added to the woocommerce_account_navigation and the content is added to woocommerce_account_content function. You can remove the defaults from their hooks and add back just the downloads content.
function so_41983566_remove_account_dadshboard(){
remove_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' );
remove_action( 'woocommerce_account_content', 'woocommerce_account_content' );
add_action( 'woocommerce_account_content', 'so_41983566_download_content' );
}
add_action( 'woocommerce_account_navigation', 'so_41983566_remove_account_dadshboard', 1 );
function so_41983566_download_content(){
do_action( 'woocommerce_account_downloads_endpoint' );
}
Or woocommerce_account_content() and woocommerce_account_navigation() are both pluggable functions and you can just define new versions in your theme/plugin.
This link explains everything:
https://github.com/woocommerce/woocommerce/wiki/Customising-account-page-tabs
First you need to create an endpoint:
function my_custom_endpoints() {
add_rewrite_endpoint( 'my-custom-endpoint', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_custom_endpoints' );
function my_custom_query_vars( $vars ) {
$vars[] = 'my-custom-endpoint';
return $vars;
}
add_filter( 'query_vars', 'my_custom_query_vars', 0 );
Then create the menu item:
function my_custom_my_account_menu_items( $items ) {
$logout = $items['customer-logout'];
unset( $items['customer-logout'] );
$items['my-custom-endpoint'] = __( 'My Custom Endpoint', 'woocommerce' );
$items['customer-logout'] = $logout;
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );
Add content to the endpoint
function my_custom_endpoint_content() {
echo '<p>Hello World!</p>';
}
add_action( 'woocommerce_account_my-custom-endpoint_endpoint', 'my_custom_endpoint_content' );
Does anyone knows how to remove the menu link named "Updates", found under the "Dashboard" section of the Wordpress Administration Menu?
I added the following actions & filters, which stop the core, theme & plugins updates, but the menu link is still there, although there is nothing to update:
# Disable WP>3.0 core updates
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
# Disable WP>3.0 plugin updates
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
# Disable WP>3.0 theme updates
remove_action( 'load-update-core.php', 'wp_update_themes' );
add_filter( 'pre_site_transient_update_themes', create_function( '$a', "return null;" ) );
# disable edit plugin and theme files:
define('DISALLOW_FILE_EDIT',true);
# disable core updates:
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
Thank you,
Ciprian
#wunderdojo wasn't "wrong", but WordPress has a bit of a better built in mechanism to handle this.
What you want (or anyone else viewing this these days) is a function called remove_submenu_page
Codex link: https://codex.wordpress.org/Function_Reference/remove_submenu_page
add_action( 'admin_menu', 'control_menu_items_shown' );
function control_menu_items_shown() {
remove_submenu_page( 'index.php', 'update-core.php' );
}
index.php is the name for the "Dashboard" menu item and update-core.php is the name for the "Updates" menu sub item.
Please note the naming mechanisms of these change quite a bit depending on the plugin, theme, etc.
Example from the Mandrill plugin:
remove_submenu_page( 'options-general.php', 'wpmandrill' );
They may not end in .php
It's also worth noting a similiar function remove_menu_page
Codex link: https://codex.wordpress.org/Function_Reference/remove_menu_page
Hope someone finds this useful in the future.
The update options comes in two places in back-end. One as the message on top and second in the 'AT a glance' window in dashboard. Place the below code in your functions.php. This code will hide the update options from these two areas.
add_action('admin_menu','wphidenag');
function wphidenag() {
remove_action( 'admin_notices', 'update_nag', 3 );
}
function admin_style() { ?>
<style>
#wp-version-message a.button{
display:none;
}
</style>
<?php
}
add_action('admin_enqueue_scripts', 'admin_style');
This should do it:
function edit_admin_menus() {
global $submenu;
unset($submenu['index.php'][10]);
return $submenu;
}
add_action( 'admin_menu', 'edit_admin_menus' );
Put that in your theme's functions.php file or in your plugin code.