<?php defined('ABSPATH') || exit; class WC_Rate_Limiter { public static function storage_id($action_id) { return 'woocommerce_rate_limit_' . $action_id; } public static function retried_too_soon($action_id) { $next_try_allowed_at = get_option(self::storage_id($action_id)); if (false === $next_try_allowed_at) { return false; } if (time() <= $next_try_allowed_at) { return true; } return false; } public static function set_rate_limit($action_id, $delay) { $option_name = self::storage_id($action_id); $next_try_allowed_at = time() + $delay; return update_option($option_name, $next_try_allowed_at); } }