Skip to:
Content

BuddyPress.org

Changeset 8116


Ignore:
Timestamp:
03/12/2014 06:46:44 PM (10 years ago)
Author:
boonebgorges
Message:

Auto-fetch URL search parameters in bp_has_groups() before parsing $args array

Our previous method, of getting the search term out of $_REQUEST, had the
effect of overriding any search terms that were passed to the bp_has_groups()
function. Among other problems, this made it impossible to get an unfiltered
group list when looking at a page that was using an 's' parameter for something
else.

Fixes #5456

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-template.php

    r8093 r8116  
    312312    }
    313313
     314    // Default search string
     315    if ( ! empty( $_REQUEST['group-filter-box'] ) ) {
     316        $search_terms = $_REQUEST['group-filter-box'];
     317    } elseif ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) ) {
     318        $search_terms = $_REQUEST['s'];
     319    } else {
     320        $search_terms = false;
     321    }
     322
    314323    $defaults = array(
    315324        'type'              => $type, // 'type' is an override for 'order' and 'orderby'. See docblock.
     
    325334        'user_id'           => $user_id, // Pass a user ID to limit to groups this user has joined
    326335        'slug'              => $slug,    // Pass a group slug to only return that group
    327         'search_terms'      => '',      // Pass search terms to return only matching groups
     336        'search_terms'      => $search_terms, // Pass search terms to return only matching groups
    328337        'meta_query'        => false,    // Filter by groupmeta. See WP_Meta_Query for format
    329338        'include'           => false,    // Pass comma separated list or array of group ID's to return only these groups
     
    335344
    336345    $r = wp_parse_args( $args, $defaults );
    337 
    338     if ( empty( $r['search_terms'] ) ) {
    339         if ( isset( $_REQUEST['group-filter-box'] ) && !empty( $_REQUEST['group-filter-box'] ) )
    340             $r['search_terms'] = $_REQUEST['group-filter-box'];
    341         elseif ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) )
    342             $r['search_terms'] = $_REQUEST['s'];
    343         else
    344             $r['search_terms'] = false;
    345     }
    346346
    347347    $groups_template = new BP_Groups_Template( array(
Note: See TracChangeset for help on using the changeset viewer.