Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/25/2024 03:54:32 PM (20 months ago)
Author:
dcavins
Message:

BP Legacy: load newest activities according to displayed context

Make sure the bp_heartbeat property is included into the sent Heartbeat data object & use it to transport the cookies BP Legacy uses to remember logged in user's navigation preferences.

The bp_heartbeat property is needed to be sure the current Heartbeat request is about BuddyPress and needs to be parsed using the BP Rewrite API since [13752]. This parsing job analyses the current URL to define the value of BP URI globals such as the current displayed single item.

Props dreampixel

Fixes #9248. (14.0 branch)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/14.0/src/bp-templates/bp-legacy/buddypress-functions.php

    r14060 r14083  
    712712 */
    713713function bp_legacy_theme_ajax_querystring( $query_string, $object ) {
    714         if ( empty( $object ) )
     714        if ( empty( $object ) ) {
    715715                return '';
     716        }
    716717
    717718        // Set up the cookies passed on this AJAX request. Store a local var to avoid conflicts.
     
    720721                        str_replace( '; ', '&', urldecode( $_POST['cookie'] ) )
    721722                );
     723        } elseif ( ! empty( $_POST['data']['bp_heartbeat'] ) ) {
     724                $_BP_COOKIE = bp_parse_args(
     725                        str_replace( '; ', '&', urldecode( $_POST['data']['bp_heartbeat'] ) )
     726                );
    722727        } else {
    723728                $_BP_COOKIE = &$_COOKIE;
     
    755760
    756761                // Activity stream scope only on activity directory.
    757                 if ( 'all' != $_BP_COOKIE['bp-' . $object . '-scope'] && ! bp_displayed_user_id() && ! bp_is_single_item() )
     762                if ( 'all' != $_BP_COOKIE['bp-' . $object . '-scope'] && ! bp_displayed_user_id() && ! bp_is_single_item() ) {
    758763                        $qs[] = 'scope=' . urlencode( $_BP_COOKIE['bp-' . $object . '-scope'] );
     764                }
    759765        }
    760766
    761767        // If page and search_terms have been passed via the AJAX post request, use those.
    762         if ( ! empty( $_POST['page'] ) && '-1' != $_POST['page'] )
     768        if ( ! empty( $_POST['page'] ) && '-1' != $_POST['page'] ) {
    763769                $qs[] = 'page=' . absint( $_POST['page'] );
     770        }
    764771
    765772        // Excludes activity just posted and avoids duplicate ids.
     
    779786
    780787        $object_search_text = bp_get_search_default_text( $object );
    781         if ( ! empty( $_POST['search_terms'] ) && is_string( $_POST['search_terms'] ) && $object_search_text != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms'] )
     788        if ( ! empty( $_POST['search_terms'] ) && is_string( $_POST['search_terms'] ) && $object_search_text != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms'] ) {
    782789                $qs[] = 'search_terms=' . urlencode( $_POST['search_terms'] );
     790        }
    783791
    784792        // Now pass the querystring to override default values.
     
    786794
    787795        $object_filter = '';
    788         if ( isset( $_BP_COOKIE['bp-' . $object . '-filter'] ) )
     796        if ( isset( $_BP_COOKIE['bp-' . $object . '-filter'] ) ) {
    789797                $object_filter = $_BP_COOKIE['bp-' . $object . '-filter'];
     798        }
    790799
    791800        $object_scope = '';
    792         if ( isset( $_BP_COOKIE['bp-' . $object . '-scope'] ) )
     801        if ( isset( $_BP_COOKIE['bp-' . $object . '-scope'] ) ) {
    793802                $object_scope = $_BP_COOKIE['bp-' . $object . '-scope'];
     803        }
    794804
    795805        $object_page = '';
    796         if ( isset( $_BP_COOKIE['bp-' . $object . '-page'] ) )
     806        if ( isset( $_BP_COOKIE['bp-' . $object . '-page'] ) ) {
    797807                $object_page = $_BP_COOKIE['bp-' . $object . '-page'];
     808        }
    798809
    799810        $object_search_terms = '';
    800         if ( isset( $_BP_COOKIE['bp-' . $object . '-search-terms'] ) )
     811        if ( isset( $_BP_COOKIE['bp-' . $object . '-search-terms'] ) ) {
    801812                $object_search_terms = $_BP_COOKIE['bp-' . $object . '-search-terms'];
     813        }
    802814
    803815        $object_extras = '';
    804         if ( isset( $_BP_COOKIE['bp-' . $object . '-extras'] ) )
     816        if ( isset( $_BP_COOKIE['bp-' . $object . '-extras'] ) ) {
    805817                $object_extras = $_BP_COOKIE['bp-' . $object . '-extras'];
     818        }
    806819
    807820        /**
Note: See TracChangeset for help on using the changeset viewer.