Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/21/2014 02:49:33 PM (11 years ago)
Author:
boonebgorges
Message:

Automatically check for newly created items when viewing the Activity Stream.

Leveraging WP's Heartbeat API, this new functionality performs periodic checks
to see whether new activity items matching the current filter have been posted
since the page was originally loaded. If new items are found, a Load Newest
link is inserted into the top of the stream, which will insert the new items.

A filter is included, bp_activity_heartbeat_pulse, that allows site owners to
set a specific interval for these checks. The default value is 15 seconds, or
whatever your global Heartbeat interval is.

To disable the feature, there is a new setting "Automatically check for new
activity items when viewing the activity stream".

Fixes #5328

Props imath, boonebgorges

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-functions.php

    r7906 r7952  
    18501850    bp_activity_update_meta( $id, $cachekey, $cache );
    18511851}
     1852
     1853/**
     1854 * Should we use Heartbeat to refresh activities?
     1855 *
     1856 * @since BuddyPress (2.0.0)
     1857 *
     1858 * @uses bp_is_activity_heartbeat_active() to check if heatbeat setting is on.
     1859 * @uses bp_is_activity_directory() to check if the current page is the activity
     1860 *       directory.
     1861 * @uses bp_is_active() to check if the group component is active.
     1862 * @uses bp_is_group_activity() to check if on a single group, the current page
     1863 *       is the group activities.
     1864 * @uses bp_is_group_home() to check if the current page is a single group home
     1865 *       page.
     1866 *
     1867 * @return bool True if activity heartbeat is enabled, otherwise false.
     1868 */
     1869function bp_activity_do_heartbeat() {
     1870    $retval = false;
     1871
     1872    if ( ! bp_is_activity_heartbeat_active() ) {
     1873        return $retval;
     1874    }
     1875
     1876    if ( bp_is_activity_directory() ) {
     1877        $retval = true;
     1878    }
     1879
     1880    if ( bp_is_active( 'groups') ) {
     1881        // If no custom front, then activities are loaded in group's home
     1882        $has_custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true );
     1883
     1884        if ( bp_is_group_activity() || ( ! $has_custom_front && bp_is_group_home() ) ) {
     1885            $retval = true;
     1886        }
     1887    }
     1888
     1889    return $retval;
     1890}
Note: See TracChangeset for help on using the changeset viewer.