call_user_func( $callback ), 'computed_at' => time(), ); set_transient( $key, $entry, self::REPORT_TTL ); } self::$report_computed_at = null === self::$report_computed_at ? $entry['computed_at'] : min( self::$report_computed_at, $entry['computed_at'] ); if ( ! headers_sent() ) { header( self::COMPUTED_AT_HEADER . ': ' . self::$report_computed_at ); } return $entry['value']; } /** * Make every Reports-section entry unreachable, for changes that bypass the ticket hooks but * alter report numbers (e.g. the bulk ticket-metrics recalculation). The orphaned transients * are left to expire (REPORT_TTL) and be swept by WordPress's daily expired-transient cleanup. * * @return void */ public static function flush_reports() { update_option( self::REPORT_VERSION_OPTION, (int) get_option( self::REPORT_VERSION_OPTION, 1 ) + 1, false ); } /** * Cache key part identifying the current viewer, for per-viewer entries. * * @return string */ private static function viewer_key_part() { $current_user = WPSC_Current_User::$current_user; return $current_user->is_agent ? 'agent_' . $current_user->agent->id : 'customer_' . $current_user->customer->id; } } endif; WPSC_Stats_Cache::init();