【发布时间】:2019-03-06 00:24:53
【问题描述】:
我继承了以下 PHP 问题的设置,我希望能有想法:我们使用 ivole 的 Customer Reviews for WooCommerce 插件和 Automattic 的 WooCommerce Bookings。
WooCommerce 的 Customer Revierws 包含以下类构造函数,该构造函数设置一个操作以在订单完成(即在这种情况下已付款)时向客户发送电子邮件:
class Ivole_Sender {
public function __construct() {
:
add_action( 'woocommerce_order_status_completed_notification', array( $this, 'sender_trigger' ) );
:
}
:
}
问题是,由于在预订附加日期过去之前预订尚未完成,它实际上需要附加到不同的操作:
add_action( 'woocommerce_booking_complete', array( $this, 'sender_trigger' ) );
通常,在 function.php(或类似文件)中使用 remove_action,然后重新添加操作就可以了,但在这种情况下,由于 add_action 发生在类中,我该如何 remove_action无需物理修改插件中的类?
插件加载顺序如下所示:
ivole.php(插件加载器):
require_once( 'class-ivole.php' );
class-ivole.php:
require_once('class-ivole-sender.php');
class-ivole-sender.php:
class Ivole_Sender {
public function __construct() {
:
add_action( 'woocommerce_order_status_completed_notification', array( $this, 'sender_trigger' ) );
:
}
:
}
【问题讨论】:
标签: wordpress