【问题标题】:Wordpress remove or override action "template_redirect" from another pluginWordpress 从另一个插件中删除或覆盖操作“template_redirect”
【发布时间】:2020-03-14 13:39:58
【问题描述】:

Woocommerce 订阅插件正在使用一个通过操作调用的函数:

add_action( 'template_redirect', array( &$this, 'maybe_setup_cart' ), 100 );

我需要在我的插件中删除此操作,因为它会导致不必要的影响。

我尝试在插件构造中创建一个动作,以覆盖它:

add_action('template_redirect', array( &$this, 'maybe_setup_cart' ), 98);

在其中我也试图删除该操作:

remove_action( 'template_redirect', 'maybe_setup_cart', 100 );

这也行不通。 如何禁用其他插件的操作?

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    您可以复制此处共享的功能: https://github.com/herewithme/wp-filters-extras/blob/master/wp-filters-extras.php

    接下来干脆做

    remove_filters_with_method_name( 'template_redirect', 'maybe_setup_cart', 100 );
    

    我试过了,效果很好:)

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多