PluginProbe
BuddyPress / trunk
BuddyPress vtrunk
11.6.2 12.7.2 14.5.2 11.6.0 12.7.0 2.5.0-rc1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.0-beta1 2.6.0-rc1 2.6.1 2.6.1.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.0-beta1 2.7.0-rc1 2.7.0-rc2 2.7.1 2.7.2 All 274 releases
buddypress / cli / src / group-fetcher.php

group-fetcher.php in BuddyPress trunk, at cli/src/group-fetcher.php

42 lines 744 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Buddypress\CLI\Command;
4
5 use WP_CLI\Fetchers\Base;
6
7 /**
8 * Fetch a BuddyPress group based on one of its attributes.
9 */
10 class Group_Fetcher extends Base {
11
12 /**
13 * @var string $msg Error message to use when invalid data is provided.
14 */
15 protected $msg = 'Could not find the group with ID %d.';
16
17 /**
18 * Get a group ID from its identifier (ID or slug).
19 *
20 * @param int|string $arg Group ID or slug.
21 * @return BP_Groups_Group|bool
22 */
23 public function get( $arg ) {
24
25 // Group ID or slug.
26 if ( ! is_numeric( $arg ) ) {
27 $arg = groups_get_id( $arg );
28 }
29
30 // Get group object.
31 $group = groups_get_group(
32 [ 'group_id' => $arg ]
33 );
34
35 if ( empty( $group->id ) ) {
36 return false;
37 }
38
39 return $group;
40 }
41 }
42