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-friends/classes/class-bp-core-friends-widget.php

    r10529 r10553  
    3737     */
    3838    function widget( $args, $instance ) {
     39        global $members_template;
     40
    3941        extract( $args );
    4042
     
    7880            'populate_extras' => 1,
    7981        );
     82
     83        // Back up the global.
     84        $old_members_template = $members_template;
    8085
    8186        ?>
     
    125130        <?php endif; ?>
    126131
    127         <?php echo $after_widget; ?>
    128     <?php
     132        <?php echo $after_widget;
     133
     134        // Restore the global.
     135        $members_template = $old_members_template;
    129136    }
    130137
Note: See TracChangeset for help on using the changeset viewer.