Skip to main content

benecaster_rest_rate_limit_skip

Filter Free Since v1.0.0

Return true to bypass rate limiting for a single REST request. Evaluated before any bucket is consulted, so a skipped request neither counts against a limit nor is blocked by one.

Intended for trusted internal callers — a monitoring probe, a server-side integration on a known IP, or automated tests. Be conservative: a filter that returns true broadly removes the protection entirely, and rate limiting is what keeps a public endpoint from being used to generate load or enumerate data.

Parameters

Name Type Default Description
$skip bool Whether to skip rate limiting. Default `false`.
$request object The `WP_REST_Request` being evaluated.

Returns: bool

Examples

Exempt a monitoring probe by shared secret

add_filter( 'benecaster_rest_rate_limit_skip', function ( bool $skip, $request ): bool {
    $secret = $request->get_header( 'x-my-monitor-key' );
    if ( is_string( $secret ) && hash_equals( MY_MONITOR_KEY, $secret ) ) {
        return true;
    }
    return $skip;
}, 10, 2 );

Notes

Prefer matching on a secret header over an IP allowlist — source IPs are spoofable and change behind proxies and CDNs.