To preface this, I am well aware there are multiple questions on SO that cover this issue. However, after going through many of them and attempting their solutions, I still haven't been successful in removing the action. Some of the SO questions that I have tried are:
need help removing action from plugin file
remove_action() not working in WordPress plugin
How to remove a WordPress action which uses the current object - $this?
I am working on creating a child theme in Wordpress that is utilizing a third party plugin for adding software license capabilities to WooCommerce. In trying to customize this plugin, I am looking at removing a action added by the plugin, and replacing it with a modified version.
The add_action call that I am trying to remove is:
add_action( 'woocommerce_order_item_meta_end', array($this->functions, 'woocommerce_order_item_meta_end'), 99, 3 );
This add_action is called in the class WOO_SL_front
, which defines $this->functions = new WOO_SL_functions();
In my attempt to remove this action, I have used the following function:
//Remove WOO_SL email and order action...
//Add customized version of email and order action
function swsint_remove_actions(){
global $wp_filter, $WOO_SL_functions;
remove_action( 'woocommerce_order_item_meta_end', array($WOO_SL_functions, 'woocommerce_order_item_meta_end'), 99);
error_log(print_R($wp_filter, true));
}
add_action('init', 'swsint_remove_actions');
add_action('woocommerce_order_item_meta_end', 'swsint_woocommerce_order_item_meta_end', 98, 3);
With this attempt, I have not been able to remove the action. The function still executes. As you can see, I print the list of registered Wordpress actions to the error_log. Through this, I know the action has been added prior to me attempting to remove it, and I believe I have confirmed I have the correct class listed in the remove_action function. The pertinent output is here:
[woocommerce_order_item_meta_end] => Array
(
[99] => Array
(
[000000005807010900000000491e34d0woocommerce_order_item_meta_end] => Array
(
[function] => Array
(
[0] => WOO_SL_functions Object
(
[query_vars] => Array
(
[software_license] => view-license
)
)
[1] => woocommerce_order_item_meta_end
)
[accepted_args] => 3
)
)
[98] => Array
(
[swsint_woocommerce_order_item_meta_end] => Array
(
[function] => swsint_woocommerce_order_item_meta_end
[accepted_args] => 3
)
)
)
From this output, I am unsure what to make of the 000000005807010900000000491e34d0woocommerce_order_item_meta_end
. It clearly shows the class which the function is from is WOO_SL_functions
, and the function name is woocommerce_order_item_meta_end
. However, I have tried all variations I can think of for calling the remove_action function:
remove_action( 'woocommerce_order_item_meta_end', array($WOO_SL_functions, 'woocommerce_order_item_meta_end'), 99);
remove_action( 'woocommerce_order_item_meta_end', array('WOO_SL_functions', 'woocommerce_order_item_meta_end'), 99);
remove_action( 'woocommerce_order_item_meta_end', array($WOO_SL_front->functions, 'woocommerce_order_item_meta_end'), 99);
remove_action( 'woocommerce_order_item_meta_end', array('WOO_SL_front->functions', 'woocommerce_order_item_meta_end'), 99);
remove_action( 'woocommerce_order_item_meta_end', array('WOO_SL_functions::woocommerce_order_item_meta_end'), 99);
Any insight anyone can provide is much appreciated!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire