main->wpstream_live_connection->wpstream_get_live_event_for_user(); // Cache the live event data in a transient for 10 minutes. set_transient('wpstream_bb_get_live_event_for_user', $live_event_for_user, 600); } // Return the live event data for the logged-in user. return $live_event_for_user; } if ( ! function_exists('wpstream_get_live_tag_html' ) ) { /** * Check if a product is live and return the live tag HTML if applicable. * * @param int $post_id The ID of the post. * @return string The HTML for the live tag or an empty string. */ function wpstream_get_live_tag_html($post_id) { // Only WooCommerce live-stream products or native wpstream_product posts can be "live". if ((get_post_type($post_id) === 'product' && has_term('live_stream', 'product_type', $post_id)) || get_post_type($post_id) === 'wpstream_product') { // Pull the current user's live events so we can test membership. $live_events = wpestream_integrations_get_current_user_live_events(); // If this post is among the live events, emit the "LIVE" badge markup. if (is_array($live_events) && array_key_exists($post_id, $live_events)) { return ''; } } // Not a live post (or no live event matched): render nothing. return ''; } } ?>