WC_Rate_Limiter::retried_too_soon()
Returns true if the action is not allowed to be run by the rate limiter yet, false otherwise.
Method of the class: WC_Rate_Limiter{}
No Hooks.
Return
true|false
.
Usage
$result = WC_Rate_Limiter::retried_too_soon( $action_id );
- $action_id(string) (required)
- Identifier of the action.
WC_Rate_Limiter::retried_too_soon() WC Rate Limiter::retried too soon code WC 7.7.0
public static function retried_too_soon( $action_id ) { global $wpdb; $next_try_allowed_at = self::get_cached( $action_id ); if ( false === $next_try_allowed_at ) { $next_try_allowed_at = $wpdb->get_var( $wpdb->prepare( " SELECT rate_limit_expiry FROM {$wpdb->prefix}wc_rate_limits WHERE rate_limit_key = %s ", $action_id ) ); self::set_cache( $action_id, $next_try_allowed_at ); } // No record of action running, so action is allowed to run. if ( null === $next_try_allowed_at ) { return false; } // Before the next run is allowed, retry forbidden. if ( time() <= $next_try_allowed_at ) { return true; } // After the next run is allowed, retry allowed. return false; }