Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/20/2017 12:19:36 AM (9 years ago)
Author:
dcavins
Message:

Add 'status' parameter to BP_Groups_Group::get().

Add $status parameter to groups_get_groups()` and its underlying
function BP_Groups_Group::get(). Find groups by passing a single
status, a comma-separated list of statuses, or any array of statuses.

Fixes #7501.

File:
1 edited

Legend:

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

    r11530 r11532  
    920920         *                                            groups. Default: false.
    921921         *     @type bool         $show_hidden        Whether to include hidden groups in results. Default: false.
     922         *     @type array|string $status             Optional. Array or comma-separated list of group statuses to limit
     923         *                                            results to. If specified, $show_hidden is ignored.
     924         *                                            Default: empty array.
    922925         * }
    923926         * @return array {
     
    970973                        'exclude'            => false,
    971974                        'show_hidden'        => false,
     975                        'status'             => array()
    972976                );
    973977
     
    990994                $where_conditions = array();
    991995
    992                 if ( empty( $r['show_hidden'] ) ) {
     996
     997                if ( ! empty( $r['status'] ) ) {
     998                        if ( ! is_array( $r['status'] ) ) {
     999                                $r['status'] = preg_split( '/[\s,]+/', $r['status'] );
     1000                        }
     1001                        $r['status'] = array_map( 'sanitize_title', $r['status'] );
     1002                        $status_in = "'" . implode( "','", $r['status'] ) . "'";
     1003                        $where_conditions['status'] = "g.status IN ({$status_in})";
     1004                } elseif ( empty( $r['show_hidden'] ) ) {
    9931005                        $where_conditions['hidden'] = "g.status != 'hidden'";
    9941006                }
Note: See TracChangeset for help on using the changeset viewer.