Php Wordpress删除行动问题
在这篇文章的前言中,我很清楚有多个问题涉及到这个问题。然而,在经历了其中的许多问题并尝试了它们的解决方案之后,我仍然没有成功地删除该操作。我尝试过的一些问题是: 我正在Wordpress中创建一个子主题,该主题利用第三方插件向WooCommerce添加软件许可功能。在尝试自定义这个插件时,我正在考虑删除插件添加的一个操作,并用修改后的版本替换它 我试图删除的add_操作调用是:Php Wordpress删除行动问题,php,wordpress,Php,Wordpress,在这篇文章的前言中,我很清楚有多个问题涉及到这个问题。然而,在经历了其中的许多问题并尝试了它们的解决方案之后,我仍然没有成功地删除该操作。我尝试过的一些问题是: 我正在Wordpress中创建一个子主题,该主题利用第三方插件向WooCommerce添加软件许可功能。在尝试自定义这个插件时,我正在考虑删除插件添加的一个操作,并用修改后的版本替换它 我试图删除的add_操作调用是: add_action( 'woocommerce_order_item_meta_end', array($th
add_action( 'woocommerce_order_item_meta_end', array($this->functions, 'woocommerce_order_item_meta_end'), 99, 3 );
这个add_操作在类WOO_SL_front
中调用,该类定义了$This->functions=new WOO_SL_functions()代码>
在尝试删除此操作时,我使用了以下函数:
//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);
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);
通过此尝试,我无法删除该操作。该函数仍在执行。如您所见,我将已注册Wordpress操作的列表打印到错误日志中。通过这一点,我知道在我尝试删除它之前已经添加了该操作,并且我相信我已经确认我在remove_action函数中列出了正确的类。相关输出如下:
[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
)
)
)
从这个输出中,我不确定如何处理00000000 5807010900000000491E34D00WOOCERMACE\u order\u item\u meta\u end
。它清楚地显示了函数所属的类是WOO\u SL\u functions
,函数名是woocommerce\u order\u item\u meta\u end
。但是,我已经尝试了调用remove_action函数所能想到的所有变体:
//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);
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);
非常感谢任何人提供的任何见解 这是一个匿名函数,请看这里@David-工作得很好。非常感谢!!