| 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 |
|
| 50 |
?> |