time() ? $state : array( 'until' => time() + 60, 'count' => 0, ); if ( $state['count'] >= $limit ) { return false; } ++$state['count']; set_transient( $key, $state, max( 1, $state['until'] - time() ) ); return true; } /** * Reset a connection's limit for operational recovery. * * @param string $ip Direct connection address. * @param string $scope Separate endpoint budget. */ public static function clear( string $ip, string $scope = 'gate' ): void { delete_transient( self::key( $ip, $scope ) ); } /** * Derive an opaque site-scoped transient name. * * @param string $ip Address. * @param string $scope Separate endpoint budget. * @return string */ private static function key( string $ip, string $scope ): string { return 'pixelpair_' . $scope . '_' . hash_hmac( 'sha256', $ip, wp_salt( 'nonce' ) ); } }