File "class-wc-rate-limiter.php"

Full path: /home/kosmetik/public_html/wp-content/plugins/woocommerce/includes/class-wc-rate-limiter.php
File size: 744 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?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);
    }
}