0 && (int) get_transient( $key ) >= $limit; } /** * Adds one to a counter. The period starts again with each event. * * @param string $key Transient key, from key(). * @param int $seconds Period of the counter. */ public static function hit( $key, $seconds ) { set_transient( $key, (int) get_transient( $key ) + 1, $seconds ); } /** * Takes one back from a counter, for an attempt that did not count. * * @param string $key Transient key, from key(). * @param int $seconds Period of the counter. */ public static function undo( $key, $seconds ) { $count = (int) get_transient( $key ); if ( $count > 0 ) { set_transient( $key, $count - 1, $seconds ); } } }