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.
Метод класса: RateLimits{}
Хуков нет.
Возвращает
Объект
. Object containing reset and remaining.
Использование
$result = RateLimits::get_rate_limit_row( $action_id ): object;
- $action_id(строка) (обязательный)
- Identifier of the action.
Код RateLimits::get_rate_limit_row() RateLimits::get rate limit row WC 10.0.2
protected static function get_rate_limit_row( string $action_id ): object { global $wpdb; $time = time(); $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, ]; }