How do we hide upgrade now message in admin panel for wordpress 2.9.2 ? is there's any ? i use
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
but it seem it's not working.
This is the code that worked for me:
add_action('admin_menu','bhhidenag');
function bhhidenag()
{
remove_action( 'admin_notices', 'update_nag', 3 );
}
You can read more about it in the blog-entry where I found this:
http://www.websitesecrets101.com/how-to-hide-wordpresss-update-now-notification
Run an upgrade. The message will go away.
Related
I have a business website for vacation home rentals in which the WordPress theme has its own booking system for house bookings only and it has been great!
I also, have Tour/Services (not Houses) also bookable but for these I use WooCommerce/WooCommerce Bookings plugins, not the House booking system.
Everything has been great!
But recently the theme update introduced a WooCommerce checkout option for the Home booking system which never existed prior to the update. Although I have the themes WooCommerce checkout option turned OFF, the code is still being executed in the theme's core plugin. I have been going back and forth with an open support ticket with the theme provider for a few weeks for them to put a conditional statement to NOT run the new code when the user has the option turned OFF but I do not know when or if it will ever be done. What happens now is that the theme's core plugin is manipulating the WooCommerce checkout and after the final step of placing the order of any Tour/Services in which I had always been previously using WooCommerce separately now times out after placing the order and generates over 1,000 additional "Phantom" Checkout pages in the back-end.
Bottom line:
When 3 lines (lines 27-29) are commented out of the theme's core plugin file, everything works fine. But I do not want to have to comment out these 3 lines after each plugin update.
//add_action( 'woocommerce_thankyou', array($this,'order_attach') );
//add_filter( 'woocommerce_checkout_fields', array($this,'custom_override_checkout_fields') );
//add_filter('woocommerce_create_account_default_checked', '__return_true');
Here is the full code (with lines 27-29 commented out): https://pastebin.com/jqtBpCpA
I have tried the instructions on both pages below without success:
https://mekshq.com/remove-wordpress-action-filter-class
https://github.com/herewithme/wp-filters-extras
I have inserted the following into the functions.php file
METHOD 1:
global $Wpestate_Global_Payments; //get access to the class object instance
remove_action( 'woocommerce_thankyou', array($Wpestate_Global_Payments,'order_attach') );
remove_filter( 'woocommerce_checkout_fields', array($Wpestate_Global_Payments,'custom_override_checkout_fields') );
remove_filter('woocommerce_create_account_default_checked', '__return_true');
Then using the plugin, here: https://github.com/herewithme/wp-filters-extras
I tried both methods:
METHOD 2:
remove_filters_with_method_name( 'woocommerce_thankyou', 'order_attach' );
remove_filters_with_method_name( 'woocommerce_checkout_fields', 'custom_override_checkout_fields' );
remove_filters_with_method_name( 'woocommerce_create_account_default_checked', '__return_true' );
METHOD 3:
remove_filters_for_anonymous_class( 'woocommerce_thankyou', 'Wpestate_Global_Payments', 'order_attach' );
remove_filters_for_anonymous_class( 'woocommerce_checkout_fields', 'Wpestate_Global_Payments', 'custom_override_checkout_fields' );
remove_filters_for_anonymous_class( 'woocommerce_create_account_default_checked', 'Wpestate_Global_Payments', '__return_true' );
class Wpestate_Global_Payments {
public $stripe_payments;
public $is_woo;
public $userID;
public $user_email;
function __construct() {
$this->is_woo = wprentals_get_option('wp_estate_enable_woo','') ;
$current_user = wp_get_current_user();
$this->userID = $current_user->ID;
$this->user_email = $current_user->user_email;
add_filter( 'woocommerce_cart_item_permalink','__return_false');
add_action( 'wp_ajax_wpestate_woo_pay', array( $this, 'wpestate_woo_pay') );
add_action( 'wp_ajax_mopriv_wpestate_woo_pay', array( $this, 'wpestate_woo_pay') );
add_filter( 'woocommerce_thankyou_order_received_text', array($this, 'wpestate_woocommerce_thankyou_order_received_text'),10,2 );
add_action( 'woocommerce_before_single_product', array($this, 'wpestate_product_redirect') );
add_action( 'woocommerce_product_query', array($this, 'wpestate_custom_pre_get_posts_query' ));
add_action( 'woocommerce_order_status_completed', array($this, 'wpestate_payment_complete') );
add_action( 'woocommerce_order_status_processing', array($this, 'wpestate_payment_complete') );
//EVERYTHING WORKS ONLY WHEN THE 3 LINES BELOW ARE COMMENTED OUT
//add_action( 'woocommerce_thankyou', array($this,'order_attach') );
//add_filter( 'woocommerce_checkout_fields', array($this,'custom_override_checkout_fields') );
//add_filter('woocommerce_create_account_default_checked', '__return_true');
Can anyone provide any insight into how I can insert a remove_action & remove_filter for each in the functions.php to remove/unhook the 3 actions/filters that I currently have commented out in the plugin file?
I'm not 100% sure but my guess would be that your attempts to remove the hooks are being called before the class Wpestate_Global_Payments. This basically means they can't be removed because they haven't been added yet.
I would suggest retrying your methods but when the wp_loaded action is fired.
wp_loaded This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
So for example, in your functions.php file...
function remove_my_themes_actions() {
remove_filters_with_method_name( 'woocommerce_thankyou', 'order_attach' );
remove_filters_with_method_name( 'woocommerce_checkout_fields', 'custom_override_checkout_fields' );
remove_filters_with_method_name( 'woocommerce_create_account_default_checked', '__return_true' );
}
add_action( 'wp_loaded', 'remove_my_themes_actions' );
If your running PHP version 5.3.0 or greater you can use an anonymous function...
add_action( 'wp_loaded', function() {
remove_filters_with_method_name( 'woocommerce_thankyou', 'order_attach' );
remove_filters_with_method_name( 'woocommerce_checkout_fields', 'custom_override_checkout_fields' );
remove_filters_with_method_name( 'woocommerce_create_account_default_checked', '__return_true' );
} );
Hope this helps!
I have used create_function in my theme below.
add_action( 'widgets_init', create_function( '', 'register_widget( "Woocommerce_Header_Cart" );' ) );
But for PHP 7.3.0, the create_function() is deprecated.
Any idea, how to fix my codes above on PHP 7.3.0.
Thanks for your help,
Try this code
add_action( 'widgets_init', 'custom_widget_func');
funcation custom_widget_func(){
register_widget( "Woocommerce_Header_Cart" );
}
Replace
add_action( 'widgets_init', create_function( '', 'register_widget( "Woocommerce_Header_Cart" );' ) );
with this, using an anonymous function instead :
add_action( 'widgets_init', function() { return register_widget("Woocommerce_Header_Cart"); } );
I tried to remove User right section but with no luck any help ? WP version 3.8
This code not working ...
add_action( 'init', 'remove_user_account_menu' );
function remove_user_account_menu() {
remove_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 );
remove_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 );
}
The following will do the trick:
add_action( 'wp_before_admin_bar_render', 'so27304117_before_admin_bar_render' );
function so27304117_before_admin_bar_render()
{
global $wp_admin_bar;
$wp_admin_bar->remove_menu('my-account');
}
Dive into the admin toolbar API.
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.
I am developing a plugin for my clients that advises me when Core, Plugin, or Theme updates are available and emails this to me. I would like to change the default update notification text when this plugin is activated to something like "Plugin update is available however, updates are managed by company xyz".
// Disable core updates
# 2.3 to 2.7:
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
# 2.8 to 3.0:
remove_action( 'wp_version_check', 'wp_version_check' );
remove_action( 'admin_init', '_maybe_update_core' );
add_filter( 'pre_transient_update_core', create_function( '$a', "return null;" ) );
# 3.0:
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
// Disable plugin updates
# 2.3 to 2.7:
add_action( 'admin_menu', create_function( '$a', "remove_action( 'load-plugins.php', 'wp_update_plugins' );") );
# Why use the admin_menu hook? It's the only one available between the above hook being added and being applied
add_action( 'admin_init', create_function( '$a', "remove_action( 'admin_init', 'wp_update_plugins' );"), 2 );
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_update_plugins' );"), 2 );
add_filter( 'pre_option_update_plugins', create_function( '$a', "return null;" ) );
# 2.8 to 3.0:
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-update.php', 'wp_update_plugins' );
remove_action( 'admin_init', '_maybe_update_plugins' );
remove_action( 'wp_update_plugins', 'wp_update_plugins' );
add_filter( 'pre_transient_update_plugins', create_function( '$a', "return null;" ) );
# 3.0:
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
This isn't really an answer to the question, but the above code is unfortunately all over the net and it's badly incorrect. While returning null to the pre_site_ filters does suppress the notification messages, it also forces wordpress to check for updates continuously, because it can't tell when the last update check was made.
The code below (5.3+) implements a better version that suppresses the messages without making WP run update checks on every single WP admin request.
$func = function ($a) {
global $wp_version;
return (object) array(
'last_checked' => time(),
'version_checked' => $wp_version,
);
};
add_filter('pre_site_transient_update_core', $func);
add_filter('pre_site_transient_update_plugins', $func);
add_filter('pre_site_transient_update_themes', $func);