# wpstream/4.14.0/integrations/integrations.php

WpStream – Live Streaming, Video on Demand, Pay Per View, version 4.14.0. 90 lines.

- Page: https://pluginprobe.com/plugins/wpstream/4.14.0/code/integrations/integrations.php
- Raw: https://pluginprobe.com/plugins/wpstream/4.14.0/raw/integrations/integrations.php
- Modified: 2026-09-08T09:04:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpstream/4.14.0/code/integrations/integrations.php#L10-L20`.

```php
<?php
/**
 * Third-party plugin integration bootstrap and shared helpers.
 *
 * This file is the entry point for WpStream's compatibility layer with other
 * plugins. It detects whether BuddyPress/BuddyBoss is active and conditionally
 * loads the matching integration file, and it exposes small helper functions
 * (live-event lookup with transient caching, and a "LIVE" card badge) that the
 * integrations and theme templates reuse.
 *
 * @package    Wpstream
 * @subpackage Wpstream/integrations
 */


// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Check and load integrations for plugins like BuddyPress or BuddyBoss.
 *
 * This function checks if the BuddyPress or BuddyBoss plugin is active
 * and, if so, includes the necessary integration file for compatibility.
 *
 * @return void
 */
function wpstream_check_integrations() {
    // Check if the BuddyPress or BuddyBoss class exists, indicating the plugin is active.
    if (class_exists('BuddyPress')) {
        // Include the integration file for BuddyBoss compatibility.
        require plugin_dir_path( __FILE__ ) . 'buddyboss/buddyboss.php';
    }
}




/**
 * Get live events for the logged-in user.
 *
 * This function retrieves the live event associated with the current logged-in user.
 * It first checks if the event data is cached in a transient to avoid redundant processing.
 * If no cached data is found, it retrieves the live event data using the wpstream plugin
 * and stores it in a transient for 10 minutes.
 *
 * @return mixed The live event data for the logged-in user.
 */
function wpestream_integrations_get_current_user_live_events() {
    // Check if the live event data is cached in a transient.
    $live_event_for_user = get_transient('wpstream_bb_get_live_event_for_user');
    global $wpstream_plugin;

    // If no cached data is found, fetch the live event data.
    if ($live_event_for_user === false) {
        $live_event_for_user = $wpstream_plugin->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 '<div class="wpstream_featured_image_live_tag">' . esc_html_x('LIVE', 'Card tag', 'wpstream') . '</div>';
			}
		}
		// Not a live post (or no live event matched): render nothing.
		return '';
	}
}

?>
```
