从类wordpress中的函数中删除动作返回false

时间:2015-03-04 09:30:59

标签: php wordpress

我正在尝试从位于类中的init过滤器中删除一个函数,并根据我读过的内容进行尝试。

可湿性粉剂内容/插件/ PLUGIN_NAME /包括/类WPS的交易公开-pages.php

class Wps_Deals_Public_Pages {
   public function wps_deals_register() {
      // some content here
   }
   public function add_hooks() {
     add_action( 'init', array( $this, 'wps_deals_register' ), 100 );
   }
}

插件的主要文件wp-content / plugins / plugin_name / deals-engine.php

require_once( WPS_DEALS_DIR . '/includes/class-wps-deals-public-pages.php' );
$wps_deals_public = new Wps_Deals_Public_Pages();
$wps_deals_public->add_hooks(); // add_hooks is getting called here

可湿性粉剂内容/主题/ my_theme / overriding_template_that_overrides_the_plugin_template / create_account.php

global $wps_deals_message, $wps_deals_public;
var_dump(remove_action( 'init', array( 'Wps_Deals_Public_Pages', 'wps_deals_register' ), 1000 ));

var_dump()返回false而不是true,并经过测试,确实没有从钩子中删除函数,我也试过了

var_dump(remove_action( 'init', array( $wps_deals_public, 'wps_deals_register' ), 1000 ));

$wps_deals_public =>这是指定的实例化类Wps_Deals_Public_Pages中的对象。

0 个答案:

没有答案