diff --git src/bp-groups/bp-groups-functions.php src/bp-groups/bp-groups-functions.php
index 11439ba..76d031f 100644
|
|
|
function groups_get_groups( $args = '' ) {
|
| 708 | 708 | 'include' => false, // Only include these specific groups (group_ids). |
| 709 | 709 | 'exclude' => false, // Do not include these specific groups (group_ids). |
| 710 | 710 | 'parent_id' => null, // Get groups that are children of the specified group(s). |
| | 711 | 'slug' => false, // Find a group by slug. |
| 711 | 712 | 'search_terms' => false, // Limit to groups that match these search terms. |
| 712 | 713 | 'search_columns' => array(), // Select which columns to search. |
| 713 | 714 | 'group_type' => '', // Array or comma-separated list of group types to limit results to. |
| … |
… |
function groups_get_groups( $args = '' ) {
|
| 728 | 729 | 'user_id' => $r['user_id'], |
| 729 | 730 | 'include' => $r['include'], |
| 730 | 731 | 'exclude' => $r['exclude'], |
| | 732 | 'slug' => $r['slug'], |
| 731 | 733 | 'parent_id' => $r['parent_id'], |
| 732 | 734 | 'search_terms' => $r['search_terms'], |
| 733 | 735 | 'search_columns' => $r['search_columns'], |
diff --git src/bp-groups/classes/class-bp-groups-group.php src/bp-groups/classes/class-bp-groups-group.php
index a851750..6b35cb3 100644
|
|
|
class BP_Groups_Group {
|
| 876 | 876 | * Default: null (no limit). |
| 877 | 877 | * @type int $user_id Optional. If provided, results will be limited to groups |
| 878 | 878 | * of which the specified user is a member. Default: null. |
| 879 | | * @type string $search_terms Optional. If provided, only groups whose names or descriptions |
| | 879 | * @type string $slug Optional. If provided, only the group whose slug matches |
| | 880 | * the provided slug will be returned. |
| | 881 | * Default: false. |
| | 882 | * @type string $search_terms Optional. If provided, only groups whose names or descriptions |
| 880 | 883 | * match the search terms will be returned. Allows specifying the |
| 881 | 884 | * wildcard position using a '*' character before or after the |
| 882 | 885 | * string or both. Works in concert with $search_columns. |
| … |
… |
class BP_Groups_Group {
|
| 938 | 941 | 'per_page' => null, |
| 939 | 942 | 'page' => null, |
| 940 | 943 | 'user_id' => 0, |
| | 944 | 'slug' => false, |
| 941 | 945 | 'search_terms' => false, |
| 942 | 946 | 'search_columns' => array(), |
| 943 | 947 | 'group_type' => '', |
| … |
… |
class BP_Groups_Group {
|
| 974 | 978 | $where_conditions['hidden'] = "g.status != 'hidden'"; |
| 975 | 979 | } |
| 976 | 980 | |
| | 981 | if ( ! empty( $r['slug'] ) ) { |
| | 982 | $where_conditions['slug'] = $wpdb->prepare( "g.slug LIKE %s", $r['slug'] ); |
| | 983 | } |
| | 984 | |
| 977 | 985 | $search = ''; |
| 978 | 986 | if ( isset( $r['search_terms'] ) ) { |
| 979 | 987 | $search = trim( $r['search_terms'] ); |
diff --git tests/phpunit/testcases/groups/class-bp-groups-group.php tests/phpunit/testcases/groups/class-bp-groups-group.php
index 6f6d625..de30d48 100644
|
|
|
class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase {
|
| 2011 | 2011 | $found = wp_list_pluck( $groups['groups'], 'id' ); |
| 2012 | 2012 | $this->assertEqualSets( array( $g1, $g4 ), $found ); |
| 2013 | 2013 | } |
| | 2014 | |
| | 2015 | /** |
| | 2016 | * @group group_exists |
| | 2017 | */ |
| | 2018 | public function test_group_exists_expected_behavior() { |
| | 2019 | $g1 = $this->factory->group->create( array( |
| | 2020 | 'slug' => 'sam', |
| | 2021 | ) ); |
| | 2022 | $g2 = $this->factory->group->create( array( |
| | 2023 | 'slug' => 'sam-e', |
| | 2024 | ) ); |
| | 2025 | |
| | 2026 | $group_id = BP_Groups_Group::group_exists( 'sam' ); |
| | 2027 | |
| | 2028 | $this->assertSame( $g1, $group_id ); |
| | 2029 | } |
| | 2030 | |
| | 2031 | /** |
| | 2032 | * @group group_exists |
| | 2033 | */ |
| | 2034 | public function test_group_exists_expected_behavior_no_match() { |
| | 2035 | $group_id = BP_Groups_Group::group_exists( 'brandywine-river' ); |
| | 2036 | |
| | 2037 | $this->assertNull( $group_id ); |
| | 2038 | } |
| 2014 | 2039 | } |
| 2015 | 2040 | |
| 2016 | 2041 | /** |