Automattic\WooCommerce\StoreApi\Utilities
RateLimits::get_rate_limit_row()
Get current rate limit row from DB and normalize types. This query is not cached, and returns a new rate limit row if none exists.
Method of the class: RateLimits{}
No Hooks.
Return
Object
. Object containing reset and remaining.
Usage
$result = RateLimits::get_rate_limit_row( $action_id );
- $action_id(string) (required)
- Identifier of the action.
RateLimits::get_rate_limit_row() RateLimits::get rate limit row code WC 7.7.0
protected static function get_rate_limit_row( $action_id ) { global $wpdb; $row = $wpdb->get_row( $wpdb->prepare( " SELECT rate_limit_expiry as reset, rate_limit_remaining as remaining FROM {$wpdb->prefix}wc_rate_limits WHERE rate_limit_key = %s AND rate_limit_expiry > %s ", $action_id, time() ), 'OBJECT' ); if ( empty( $row ) ) { $options = self::get_options(); return (object) [ 'reset' => (int) $options->seconds + time(), 'remaining' => (int) $options->limit, ]; } return (object) [ 'reset' => (int) $row->reset, 'remaining' => (int) $row->remaining, ]; }