【发布时间】:2021-10-24 09:55:00
【问题描述】:
在 WordPress 中,如何删除插件类中的以下操作?
插件包括这个(我只是引用它的几行):
class WC_Product_Vendors_Vendor_Admin {
public static function init() {
self::$self = new self();
add_action( 'pre_get_users', array( self::$self, 'filter_users' ) );
}
}
WC_Product_Vendors_Vendor_Admin::init();
在我自己的自定义插件中,我尝试了:
function remove_my_class_action() {
remove_action ( 'pre_get_users', array( WC_Product_Vendors_Vendor_Admin::$instance , 'filter_users') );
}
add_action( 'plugins_loaded', 'remove_my_class_action' );
但是 Wordpress 甚至不允许我保存它——它说找不到该类。
我也试过getInstance()而不是$instance。
我还尝试了'wp_head' 和'init',而不是'plugins_loaded'。
还在 add_action 和 remove_action 上尝试了不同的优先级,但这并没有什么不同。 (虽然可能是我错过了上述的一些组合。)
【问题讨论】:
-
不幸的是,没有,我尝试按照那里的答案实例化该类,但它仍然告诉我
Uncaught Error: Class 'WC_Product_Vendors_Vendor_Admin' not found in wp-content/plugins/mycustomplugin/custom-roles.php:107 -
你可以检查
class_exisits...我会假设供应商管理类是一个管理功能? -
单独
class_exists返回 false ...如果我将remove_action放在带有if (class_exists(...)的条件中,我至少可以保存文件,但随后网站显示错误:@ 987654334@
标签: wordpress woocommerce