当我把我的代码functions.php
从...开始
add_action( 'woocommerce_order_status_completed', 'do_something' );
here is my code
有用!但是当我把它放进去plugin
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
if ( ! class_exists( 'WC_Some_class' ) ) {
class WC_Some_class {
public function __construct() {
add_action( 'woocommerce_order_status_completed', 'do_something' );
}
script ...
}
}
// finally instantiate our plugin class and add it to the set of globals
$WC_Some_class = new WC_Some_class();
}
}
这不起作用。为什么?