Changeset 12744
- Timestamp:
- 10/09/2020 01:25:47 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-template.php
r12647 r12744 294 294 * @since 2.6.0 Added `$group_type`, `$group_type__in`, and `$group_type__not_in` parameters. 295 295 * @since 2.7.0 Added `$update_admin_cache` parameter. 296 * @since 7.0.0 Added `$status` parameter. 296 297 * 297 298 * @param array|string $args { … … 320 321 * @type array|string $group_type__not_in Array or comma-separated list of group types that will be 321 322 * excluded from results. 323 * @type array|string $status Array or comma-separated list of group statuses to limit results to. 322 324 * @type array $meta_query An array of meta_query conditions. 323 325 * See {@link WP_Meta_Query::queries} for description. … … 370 372 // Can be a comma-separated list. 371 373 $group_type = explode( ',', $_GET['group_type'] ); 374 } 375 } 376 377 $status = array(); 378 if ( ! empty( $_GET['status'] ) ) { 379 if ( is_array( $_GET['status'] ) ) { 380 $status = $_GET['status']; 381 } else { 382 // Can be a comma-separated list. 383 $status = explode( ',', $_GET['status'] ); 372 384 } 373 385 } … … 399 411 'group_type__in' => '', 400 412 'group_type__not_in' => '', 413 'status' => $status, 401 414 'meta_query' => false, 402 415 'include' => false, … … 423 436 'group_type__in' => $r['group_type__in'], 424 437 'group_type__not_in' => $r['group_type__not_in'], 438 'status' => $r['status'], 425 439 'meta_query' => $r['meta_query'], 426 440 'include' => $r['include'], -
trunk/src/bp-groups/classes/class-bp-groups-template.php
r12426 r12744 172 172 'group_type__in' => '', 173 173 'group_type__not_in' => '', 174 'status' => array(), 174 175 'meta_query' => false, 175 176 'update_meta_cache' => true, … … 225 226 'group_type__in' => $group_type__in, 226 227 'group_type__not_in' => $group_type__not_in, 228 'status' => $status, 227 229 'include' => $include, 228 230 'exclude' => $exclude, -
trunk/tests/phpunit/testcases/groups/template.php
r12516 r12744 116 116 $ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) ); 117 117 $this->assertEquals( array( $g1 ), $ids ); 118 119 $this->assertEquals( 1, $groups_template->group_count ); 120 } 121 122 /** 123 * Test using the 'status' parameter in bp_has_groups() 124 * 125 * @group bp_has_groups 126 */ 127 public function test_bp_has_groups_status() { 128 $g1 = self::factory()->group->create( array( 129 'status' => 'public', 130 ) ); 131 $g2 = self::factory()->group->create( array( 132 'status' => 'private', 133 ) ); 134 $g3 = self::factory()->group->create( array( 135 'status' => 'hidden', 136 ) ); 137 138 global $groups_template; 139 bp_has_groups( array( 140 'status' => 'private', 141 ) ); 142 143 $ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) ); 144 $this->assertEqualSets( array( $g2 ), $ids ); 118 145 119 146 $this->assertEquals( 1, $groups_template->group_count );
Note: See TracChangeset
for help on using the changeset viewer.