ActionScheduler_wpPostStore::release_claim
Release pending actions from a claim.
Метод класса: ActionScheduler_wpPostStore{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$ActionScheduler_wpPostStore = new ActionScheduler_wpPostStore(); $ActionScheduler_wpPostStore->release_claim( $claim );
- $claim(ActionScheduler_ActionClaim) (обязательный)
- Claim object to release.
Код ActionScheduler_wpPostStore::release_claim() ActionScheduler wpPostStore::release claim WC 10.4.0
public function release_claim( ActionScheduler_ActionClaim $claim ) {
/**
* Global wpdb object.
*
* @var wpdb $wpdb
*/
global $wpdb;
$claim_id = $claim->get_id();
if ( trim( $claim_id ) === '' ) {
// Verify that the claim_id is valid before attempting to release it.
return;
}
// Only attempt to release pending actions to be claimed again. Running and complete actions are no longer relevant outside of admin/analytics.
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$action_ids = $wpdb->get_col(
$wpdb->prepare(
"SELECT ID, post_date_gmt FROM {$wpdb->posts} WHERE post_type = %s AND post_password = %s AND post_status = %s",
self::POST_TYPE,
$claim_id,
self::STATUS_PENDING
)
);
if ( empty( $action_ids ) ) {
return; // nothing to do.
}
$action_id_string = implode( ',', array_map( 'intval', $action_ids ) );
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$result = $wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->posts} SET post_password = '' WHERE ID IN ($action_id_string) AND post_password = %s", //phpcs:ignore
array(
$claim->get_id(),
)
)
);
if ( false === $result ) {
/* translators: %s: claim ID */
throw new RuntimeException( sprintf( __( 'Unable to unlock claim %s. Database error.', 'woocommerce' ), $claim->get_id() ) );
}
}