PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.13
WpStream – Live Streaming, Video on Demand, Pay Per View v4.13
4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 4.5.12 All 180 releases
wpstream / integrations / integrations.php

integrations.php in WpStream – Live Streaming, Video on Demand, Pay Per View 4.13, at integrations/integrations.php

68 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Check and load integrations for plugins like BuddyPress or BuddyBoss.
4 *
5 * This function checks if the BuddyPress or BuddyBoss plugin is active
6 * and, if so, includes the necessary integration file for compatibility.
7 *
8 * @return void
9 */
10 function wpstream_check_integrations() {
11 // Check if the BuddyPress or BuddyBoss class exists, indicating the plugin is active.
12 if (class_exists('BuddyPress')) {
13 // Include the integration file for BuddyBoss compatibility.
14 require plugin_dir_path( __FILE__ ) . 'buddyboss/buddyboss.php';
15 }
16 }
17
18
19
20
21 /**
22 * Get live events for the logged-in user.
23 *
24 * This function retrieves the live event associated with the current logged-in user.
25 * It first checks if the event data is cached in a transient to avoid redundant processing.
26 * If no cached data is found, it retrieves the live event data using the wpstream plugin
27 * and stores it in a transient for 10 minutes. Optionally, it can exit after fetching the data.
28 *
29 * @param string $with_exit Optional. Whether to exit after retrieving live events. Defaults to 'yes'.
30 * @return mixed The live event data for the logged-in user.
31 */
32 function wpestream_integrations_get_current_user_live_events($with_exit = 'yes') {
33 // Check if the live event data is cached in a transient.
34 $live_event_for_user = get_transient('wpstream_bb_get_live_event_for_user');
35 global $wpstream_plugin;
36
37 // If no cached data is found, fetch the live event data.
38 if ($live_event_for_user === false) {
39 $live_event_for_user = $wpstream_plugin->main->wpstream_live_connection->wpstream_get_live_event_for_user($with_exit);
40
41 // Cache the live event data in a transient for 10 minutes.
42 set_transient('wpstream_bb_get_live_event_for_user', $live_event_for_user, 600);
43 }
44
45 // Return the live event data for the logged-in user.
46 return $live_event_for_user;
47 }
48
49 if ( ! function_exists('wpstream_get_live_tag_html' ) ) {
50 /**
51 * Check if a product is live and return the live tag HTML if applicable.
52 *
53 * @param int $post_id The ID of the post.
54 * @return string The HTML for the live tag or an empty string.
55 */
56 function wpstream_get_live_tag_html($post_id)
57 {
58 if ((get_post_type($post_id) === 'product' && has_term('live_stream', 'product_type', $post_id)) || get_post_type($post_id) === 'wpstream_product') {
59 $live_events = wpestream_integrations_get_current_user_live_events('no');
60 if (is_array($live_events) && array_key_exists($post_id, $live_events)) {
61 return '<div class="wpstream_featured_image_live_tag">' . esc_html_x('LIVE', 'Card tag', 'hello-wpstream') . '</div>';
62 }
63 }
64 return '';
65 }
66 }
67
68 ?>