*/ private static $seen = array(); /** * Record one failure. * * @param string $name Condition name. */ public static function record( $name ) { if ( isset( self::$seen[ $name ] ) || ! function_exists( 'get_option' ) ) { return; } self::$seen[ $name ] = true; $today = gmdate( 'Y-m-d', Clock::now() ); $all = get_option( self::OPTION, array() ); if ( ! is_array( $all ) ) { $all = array(); } if ( isset( $all[ $name ]['date'] ) && $all[ $name ]['date'] === $today ) { return; } $count = isset( $all[ $name ]['days'] ) ? (int) $all[ $name ]['days'] : 0; $all[ $name ] = array( 'date' => $today, 'days' => $count + 1, ); update_option( self::OPTION, $all, false ); } /** * Reset the per-request cache (tests). */ public static function reset() { self::$seen = array(); } }