Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/08/2016 04:14:59 AM (9 years ago)
Author:
boonebgorges
Message:

Restore template globals after widget loops.

BP template loop functions, like bp_has_members(), are responsible for
populating corresponding template globals. When this happens inside of a
"secondary" loop - such as a sidebar widget - the loop should clean up after
itself by resetting the relevant template global to whatever it previously was
before the secondary loop had run. (This is a rough approximation of WP's
wp_reset_postdata() for BP loops.)

Fixes #5170.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-widget.php

    r10520 r10553  
    4545     */
    4646    public function widget( $args, $instance ) {
     47        global $groups_template;
    4748
    4849        /**
     
    100101            'max'             => $max_groups,
    101102        );
     103
     104        // Back up the global.
     105        $old_groups_template = $groups_template;
    102106
    103107        ?>
     
    150154        <?php endif; ?>
    151155
    152         <?php echo $after_widget; ?>
    153     <?php
     156        <?php echo $after_widget;
     157
     158        // Restore the global.
     159        $groups_template = $old_groups_template;
    154160    }
    155161
Note: See TracChangeset for help on using the changeset viewer.