| 1 |
<?php |
| 2 |
/** |
| 3 |
* GamiPress 1.8.0 compatibility functions |
| 4 |
* |
| 5 |
* @package GamiPress\1.8.0 |
| 6 |
* @author GamiPress <[email protected]>, Ruben Garcia <[email protected]> |
| 7 |
* @since 1.8.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Returns array of achievement types a user has earned across a multisite network |
| 14 |
* |
| 15 |
* @deprecated Deprecated since is an unused function |
| 16 |
* |
| 17 |
* @since 1.0.0 |
| 18 |
* @param integer $user_id The user's ID |
| 19 |
* @return array An array of post types |
| 20 |
*/ |
| 21 |
function gamipress_get_network_achievement_types_for_user( $user_id ) { |
| 22 |
|
| 23 |
$blog_id = get_current_blog_id(); |
| 24 |
|
| 25 |
// Assume we have no achievement types |
| 26 |
$all_achievement_types = array(); |
| 27 |
|
| 28 |
// Loop through all active sites |
| 29 |
$sites = gamipress_get_network_site_ids(); |
| 30 |
|
| 31 |
foreach( $sites as $site_blog_id ) { |
| 32 |
|
| 33 |
// If we're polling a different blog, switch to it |
| 34 |
if ( $blog_id != $site_blog_id ) { |
| 35 |
switch_to_blog( $site_blog_id ); |
| 36 |
} |
| 37 |
|
| 38 |
// Merge earned achievements to our achievement type array |
| 39 |
$achievement_types = gamipress_get_user_earned_achievement_types( $user_id ); |
| 40 |
|
| 41 |
if ( is_array( $achievement_types ) ) { |
| 42 |
$all_achievement_types = array_merge( $achievement_types, $all_achievement_types ); |
| 43 |
} |
| 44 |
|
| 45 |
// If switched to blog, return back to que current blog |
| 46 |
if ( $blog_id != $site_blog_id && is_multisite() ) { |
| 47 |
restore_current_blog(); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
// Restore the original blog so the sky doesn't fall |
| 52 |
if ( $blog_id != get_current_blog_id() && is_multisite() ) { |
| 53 |
restore_current_blog(); |
| 54 |
} |
| 55 |
|
| 56 |
// Pare down achievement type list so we return no duplicates |
| 57 |
$achievement_types = array_unique( $all_achievement_types ); |
| 58 |
|
| 59 |
// Return all found achievements |
| 60 |
return $achievement_types; |
| 61 |
|
| 62 |
} |