Add limit to wc_load_webhooks

This commit is contained in:
Mike Jolley 2019-02-18 13:15:32 +00:00
parent 0c53145f2b
commit d0438264ff
1 changed files with 7 additions and 3 deletions

View File

@ -136,15 +136,19 @@ function wc_get_webhook_statuses() {
function wc_load_webhooks( $status = '', $limit = null ) {
$data_store = WC_Data_Store::load( 'webhook' );
$webhooks = $data_store->get_webhooks_ids( $status );
$loaded = false;
$loaded = 0;
foreach ( $webhooks as $webhook_id ) {
$webhook = new WC_Webhook( $webhook_id );
$webhook->enqueue();
$loaded = true;
$loaded ++;
if ( $loaded >= $limit ) {
break;
}
}
return $loaded;
return 0 < $loaded;
}
/**