remove_action来自不同命名空间的插件类

时间:2017-09-05 16:47:09

标签: wordpress

晚上好,我在从WordPress下载管理器添加的wp_head删除操作时遇到了一些问题。这是插件中的代码:

class WordPressDownloadManager{

    function __construct(){

        register_activation_hook(__FILE__, array($this, 'Install'));

        add_action( 'init', array($this, 'registerPostTypeTaxonomy'), 1 );

        add_action( 'plugins_loaded', array($this, 'loadTextdomain') );
        add_action( 'wp_enqueue_scripts', array($this, 'EnqueueScripts') );

        add_action( 'wp_head', array($this, 'wpHead') );
        add_action( 'wp_footer', array($this, 'wpFooter') );

        spl_autoload_register( array( $this, 'AutoLoad' ) );

        new \WPDM\libs\UserDashboard();
        new \WPDM\libs\Apply();
        new \WPDM\admin\WordPressDownloadManagerAdmin();
        new \WPDM\ShortCodes();

    }

这是我用来删除它的代码:

function remove_wpdm() {
  remove_action('wp_head', array('WordPressDownloadManager', 'wpHead'));
}
add_action('wp_head', 'remove_wpdm');

没有效果..我该如何解决这个问题?此类位于名为WPDM的不同名称空间中。提前感谢您的帮助。

祝你好运, 多梅尼科

1 个答案:

答案 0 :(得分:1)

尝试以下代码

function remove_wpdm() {
  remove_action('wp_head', array('WordPressDownloadManager', 'wpHead'));
}
add_action('init', 'remove_wpdm');