/**
 * Allow Heartbeat to refresh activity stream.
 *
 * @since 2.0.0
 */
function bp_admin_setting_callback_heartbeat()
{
    ?>

	<input id="_bp_enable_heartbeat_refresh" name="_bp_enable_heartbeat_refresh" type="checkbox" value="1" <?php 
    checked(bp_is_activity_heartbeat_active(true));
    ?>
 />
	<label for="_bp_enable_heartbeat_refresh"><?php 
    _e('Automatically check for new items while viewing the activity stream', 'buddypress');
    ?>
</label>

<?php 
}
/**
 * Should we use Heartbeat to refresh activities?
 *
 * @since 2.0.0
 *
 * @uses bp_is_activity_heartbeat_active() to check if heartbeat setting is on.
 * @uses bp_is_activity_directory() to check if the current page is the activity
 *       directory.
 * @uses bp_is_group_activity() to check if on a single group, the current page
 *       is the group activities.
 *
 * @return bool True if activity heartbeat is enabled, otherwise false.
 */
function bp_activity_do_heartbeat()
{
    $retval = false;
    if (!bp_is_activity_heartbeat_active()) {
        return $retval;
    }
    if (bp_is_activity_directory() || bp_is_group_activity()) {
        $retval = true;
    }
    return $retval;
}
Пример #3
0
/**
 * Should we use Heartbeat to refresh activities?
 *
 * @since BuddyPress (2.0.0)
 *
 * @uses bp_is_activity_heartbeat_active() to check if heatbeat setting is on.
 * @uses bp_is_activity_directory() to check if the current page is the activity
 *       directory.
 * @uses bp_is_active() to check if the group component is active.
 * @uses bp_is_group_activity() to check if on a single group, the current page
 *       is the group activities.
 * @uses bp_is_group_home() to check if the current page is a single group home
 *       page.
 *
 * @return bool True if activity heartbeat is enabled, otherwise false.
 */
function bp_activity_do_heartbeat()
{
    $retval = false;
    if (!bp_is_activity_heartbeat_active()) {
        return $retval;
    }
    if (bp_is_activity_directory()) {
        $retval = true;
    }
    if (bp_is_active('groups')) {
        // If no custom front, then activities are loaded in group's home
        $has_custom_front = bp_locate_template(array('groups/single/front.php'), false, true);
        if (bp_is_group_activity() || !$has_custom_front && bp_is_group_home()) {
            $retval = true;
        }
    }
    return $retval;
}
/**
 * Should we use Heartbeat to refresh activities?
 *
 * @since 2.0.0
 *
 * @return bool True if activity heartbeat is enabled, otherwise false.
 */
function bp_activity_do_heartbeat()
{
    $retval = false;
    if (bp_is_activity_heartbeat_active() && (bp_is_activity_directory() || bp_is_group_activity())) {
        $retval = true;
    }
    /**
     * Filters whether the heartbeat feature in the activity stream should be active.
     *
     * @since 2.8.0
     *
     * @param bool $retval Whether or not activity heartbeat is active.
     */
    return (bool) apply_filters('bp_activity_do_heartbeat', $retval);
}