Remove license message in Wordpress - 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.

Related

How to dequeue or deregister specific woocoomerce script in wordpress admin panel

I need to remove Woocommerce script: wc-admin-order-meta-boxes-js (woocommerce/assets/js/admin/meta-boxes-order.min.js) from the edit-order page or all admin pages in woocommerce. I tried everything but nothing works. Can anyone help me? Thanks.
For example, I tried this:
add_action( 'admin_print_script', 'remove_admin_scripts', 1 );
function remove_admin_scripts() {
// Dequeue
wp_dequeue_script( 'wc-admin-order-meta-boxes-js' );
// Deregister
wp_deregister_script( 'wc-admin-order-meta-boxes-js' );
}
You are calling the wrong name of the script. You can just dequeue as it is enqueued, but with a higher priority.
add_action( 'admin_enqueue_scripts', 'remove_admin_scripts', 99 );
function remove_admin_scripts() {
// Dequeue.
wp_dequeue_script( 'wc-admin-order-meta-boxes' );
// Deregister.
wp_deregister_script( 'wc-admin-order-meta-boxes' );
}
This is tested and works.

Wordpress remove or override action "template_redirect" from another plugin

The Woocommerce Subscriptions plugin is using a function called with action:
add_action( 'template_redirect', array( &$this, 'maybe_setup_cart' ), 100 );
I need to remove this action in my plugin, as it is causing unwanted effects.
I have tried creating an action before it in plugin construct, to override it:
add_action('template_redirect', array( &$this, 'maybe_setup_cart' ), 98);
In it i am also trying to remove the action:
remove_action( 'template_redirect', 'maybe_setup_cart', 100 );
This is also not working.
How can i disable the action from another plugin?
You can copy function shared here:
https://github.com/herewithme/wp-filters-extras/blob/master/wp-filters-extras.php
Next simply do
remove_filters_with_method_name( 'template_redirect', 'maybe_setup_cart', 100 );
I tried and It works :)
Thanks

How to Unhook actions/filters in within Class in plugin

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!

wc_print_notices is not displaying any messages in woocommerce pages?

I have used default woocommerce templates for shop, cart and single page.
I have not removed any hooks either but also I am not getting any message.
Any Idea?
add_action( 'woocommerce_before_single_product', 'Cusotm_wc_print_notices', 10 );
function Cusotm_wc_print_notices()
{
echo 'Hook is working fine';
}
I am getting this message 'Hook is working fine' but not wc_print_notices();.
I'm not really sure what is the problem. Your question needs further details. With that said, can you try adding this code to your functions.php of your current theme.
add_action( 'template_redirect', 'test' );
function test() {
wc_add_notice( __( 'Sorry there was a problem.', 'woocommerce' ), 'error' );
}
Let me know if it does something.
UPDATE
If you have something like this:
add_action( 'woocommerce_before_single_product', 'Cusotm_wc_print_notices', 10 );
function Cusotm_wc_print_notices()
{
$notices = WC()->session->get('wc_notices');
print_r($notices);
}
it will not work because $notices will be empty once wc_print_notices() is called.
try changing priority and you will get something. Should be something like this:
add_action( 'woocommerce_before_single_product', 'Cusotm_wc_print_notices', 9 );
use priority below 10. Because WooCommerce is using 10.
add_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );

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