如何从单一实例类中删除操作


How to remove action from within a singleton class

我正在尝试通过我的子主题函数从插件中删除操作.php。该函数包装在单例类中。我试过这个

function remove_wc_monarch(){
    global $ET_Monarch;
    $ET_Monarch = new ET_Monarch();
remove_action( 'woocommerce_after_single_product_summary', array( $ET_Monarch, 'display_on_wc_page' ), 999 );
}
add_action('init', 'remove_wc_monarch');

但是,这会呈现一个带有此消息的死页,ET_Monarch是一个单一实例类,您无法创建第二个实例。

这就是课程的启动方式

class ET_Monarch {
    var $plugin_version = '1.2.7.2';
    var $db_version = '1.2';
    var $monarch_options;
    var $_options_pagename = 'et_monarch_options';
    var $menu_page;
    var $protocol;
    public static $shortcodes_count = 0;
    public static $total_follows_count = '';
    public static $follow_counts_array = '';
    private static $_this;
    function __construct() {
        // Don't allow more than one instance of the class
        if ( isset( self::$_this ) ) {
            wp_die( sprintf( esc_html__( '%s is a singleton class and you cannot create a second instance.', 'Monarch' ),
                get_class( $this ) )
            );
        }
        self::$_this = $this;

Monarch插件具有静态函数get_this()。

我在创世纪中将其与我的钩子一起使用并且工作正常。

问候