Remove "Updates" link from Wordpress Admin Dashboard - wordpress

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.

Related

WooCommerce: how to disable image zoom?

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.

How to edit Woocommerce style.dev css file?

I am trying to edit the styles of the Woocommerce checkout page that is coming from style.dev.css. I tried to copy the file to my child theme directory and made the changes in the new child file. However, it seems that the page is still loading the original file and not the theme file The reason I am not doing my edits in the style.css child file is that most selectors have !important and don't want to do heavy overwriting. Does anyone know what I am missing, please?
The documentation of WooCommerce could help you acheive what you are looking for.
WooCommerce - Disable the default stylesheet
Disable all stylesheets
WooCommerce enqueues 3 stylesheets by default. You can disable them all with the following snippet:
add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
Disable specific stylesheets
If you want to disable specific stylesheets (i.e, if you do not want to include the handheld stylesheet), you can use the following:
add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
function jk_dequeue_styles( $enqueue_styles ) {
unset( $enqueue_styles['woocommerce-general'] );
unset( $enqueue_styles['woocommerce-layout'] );
unset( $enqueue_styles['woocommerce-smallscreen'] );
return $enqueue_styles;
}
add_filter( 'woocommerce_enqueue_styles', '__return_false' );
Then enqueue your own stylesheet like so:
function wp_enqueue_woocommerce_style(){
wp_register_style( 'mytheme-woocommerce', get_stylesheet_directory_uri() . '/css/woocommerce.css' );
if ( class_exists( 'woocommerce' ) ) {
wp_enqueue_style( 'mytheme-woocommerce' );
}
}
add_action( 'wp_enqueue_scripts', 'wp_enqueue_woocommerce_style' );

Remove license message in Wordpress

I'm trying to disable the license notification for a plugin a bought a few months ago. Now my license for updates is not longer valid but I don't want to receive any updates anymore because I've changed a lot in the plugin. This is the message:
I've tried to remove it this way:
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
function filter_plugin_updates( $value ) {
unset( $value->response['cred-frontend-editor/plugin.php'] );
return $value;
}
But when I refresh the page the notification is still there. How can I remove it?
This depends on the plugin. But the steps I would take.
Search to plugin codebase for variations of add_action( 'admin_notices', 'callback_notice function')
Then try to use remove_action to de-hook that notice.
Keep in mind remove_action has to run after the add_action, So if that add_action is done inside an add_action('admin_init', ...,10) (prio 10) you should run the remove action in an add_action('admin_init', ...,11)
Yes this part is confusing.
Good luck
Edit
Given the code you provided the remove should be:
add_action( 'init', function() {
remove_action( 'admin_notices', array( WP_Installer::instance(), 'setup_plugins_page_notices' ) );
remove_action( 'admin_notices', array( WP_Installer::instance(), 'setup_plugins_renew_warnings' ), 10 );
remove_action( 'admin_notices', array( WP_Installer::instance(), 'queue_plugins_renew_warnings' ), 20 );
}, 100);
The add_actions are run in the init function. the init function is hooked in the , well the init hook, at default priority (10)
So we run the removes after that in the init hook at prio 11.
Probably you don't need to remove the setup_plugins_page_notices hook.

Removing the my account-dashboard and redirect to another endpoint like downloads

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' );

Disable Please visit the Update Network page to update all your sites. Notice from Dashboard

I would like to Hide below message you see on dashboard after wordpress version upgrade in Wordpress MU.
I know for hiding version upgrade notice there is one filter as
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
But I want to disable the following notice
"Thank you for Updating! Please visit the Update Network page to update all your sites."
This message was fired on two hooks.
add_action( 'admin_notices', 'site_admin_notice' );
add_action( 'network_admin_notices', 'site_admin_notice' );
Remove this and you remove the message, use remove_action.
To remove this function use a function, like the follow example.
add_action( 'admin_menu','fb_hide_site_notice' );
function fb_hide_site_notice() {
remove_action( 'admin_notices', 'site_admin_notice' );
}

Resources