in_array( $type, self::TYPES, true ) ? $type : 'info', 'message' => (string) $message, ); set_transient( self::key( $user_id ), $notices, MINUTE_IN_SECONDS ); } /** * Take (and forget) the current user's notices. * * @return array */ public static function take() { $user_id = get_current_user_id(); if ( ! $user_id ) { return array(); } $notices = self::peek( $user_id ); delete_transient( self::key( $user_id ) ); return $notices; } /** * The stored notices. * * @param int $user_id User ID. * @return array */ private static function peek( $user_id ) { $notices = get_transient( self::key( $user_id ) ); return is_array( $notices ) ? $notices : array(); } /** * The transient key. * * @param int $user_id User ID. * @return string */ private static function key( $user_id ) { return 'launchlist_notices_' . (int) $user_id; } }