2016-03-07 49 views
0

我想通過我的孩子主題functions.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; 
+0

有沒有辦法獲得對單例實例的引用?也許像'ET_Monarch :: getInstance()'或者其他一些對象可以給你實例。 – Halcyon

回答

1

君主插件具有靜態函數get_this()。

我用這與我在創世紀的鉤子和正常工作。

關於