| 1 |
<?php |
| 2 |
/** |
| 3 |
* GamiPress 1.3.1 compatibility functions |
| 4 |
* |
| 5 |
* @package GamiPress\1.3.1 |
| 6 |
* @author GamiPress <[email protected]>, Ruben Garcia <[email protected]> |
| 7 |
* @since 1.3.1 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Helper function tests that we're in the main loop |
| 14 |
* |
| 15 |
* @deprecated use gamipress_is_single_achievement() |
| 16 |
* |
| 17 |
* @since 1.0.0 |
| 18 |
* |
| 19 |
* @param bool|integer $id The page id |
| 20 |
* |
| 21 |
* @return boolean A boolean determining if the function is in the main loop |
| 22 |
*/ |
| 23 |
function gamipress_is_main_loop( $id = false ) { |
| 24 |
|
| 25 |
$slugs = gamipress_get_achievement_types_slugs(); |
| 26 |
// only run our filters on the gamipress singular pages |
| 27 |
if ( is_admin() || empty( $slugs ) || ! is_singular( $slugs ) ) |
| 28 |
return false; |
| 29 |
// w/o id, we're only checking template context |
| 30 |
if ( ! $id ) |
| 31 |
return true; |
| 32 |
|
| 33 |
// Checks several variables to be sure we're in the main loop (and won't effect things like post pagination titles) |
| 34 |
return ( ( $GLOBALS['post']->ID == $id ) && in_the_loop() && empty( $GLOBALS['gamipress_reformat_content'] ) ); |
| 35 |
|
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Return a user's points |
| 40 |
* |
| 41 |
* @deprecated use gamipress_get_user_points() |
| 42 |
* |
| 43 |
* @since 1.0.0 |
| 44 |
* @param int $user_id The given user's ID |
| 45 |
* @return integer $user_points The user's current points |
| 46 |
*/ |
| 47 |
function gamipress_get_users_points( $user_id = 0, $points_type = '' ) { |
| 48 |
return gamipress_get_user_points( $user_id, $points_type ); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Posts a log entry when a user earns points |
| 53 |
* |
| 54 |
* @deprecated use gamipress_update_user_points() |
| 55 |
* |
| 56 |
* @since 1.0.0 |
| 57 |
* |
| 58 |
* @param integer $user_id The given user's ID |
| 59 |
* @param integer $new_points The new points the user is being awarded |
| 60 |
* @param integer $admin_id If being awarded by an admin, the admin's user ID |
| 61 |
* @param integer $achievement_id The achievement that generated the points, if applicable |
| 62 |
* @param string $points_type The points type |
| 63 |
* |
| 64 |
* @return integer The user's updated points total |
| 65 |
*/ |
| 66 |
function gamipress_update_users_points( $user_id = 0, $new_points = 0, $admin_id = 0, $achievement_id = null, $points_type = '' ) { |
| 67 |
return gamipress_update_user_points( $user_id, $new_points, $admin_id, $achievement_id, $points_type ); |
| 68 |
} |