Load webhooks on each page load

Part of #5564
This commit is contained in:
Max Rice 2014-07-30 16:27:50 -04:00
parent a7538da23b
commit 51f71cfade
1 changed files with 28 additions and 1 deletions

View File

@ -402,6 +402,9 @@ final class WooCommerce {
add_action( $action, array( $this, 'send_transactional_email' ), 10, 10 ); add_action( $action, array( $this, 'send_transactional_email' ), 10, 10 );
} }
// webhooks
$this->load_webhooks();
// Init action // Init action
do_action( 'woocommerce_init' ); do_action( 'woocommerce_init' );
} }
@ -547,6 +550,30 @@ final class WooCommerce {
do_action_ref_array( current_filter() . '_notification', $args ); do_action_ref_array( current_filter() . '_notification', $args );
} }
/**
* Load & enqueue active webhooks
*
* @since 2.2
*/
public function load_webhooks() {
$args = array(
'fields' => 'ids',
'post_type' => 'shop_webhook',
'post_status' => 'publish',
);
$query = new WP_Query( $args );
if ( ! empty( $query->posts ) ) {
foreach ( $query->posts as $id ) {
$webhook = new WC_Webhook( $id );
$webhook->enqueue();
}
}
}
/** Load Instances on demand **********************************************/ /** Load Instances on demand **********************************************/
/** /**