PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 5.8.6
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v5.8.6
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
automatorwp / integrations / buddypress / includes / functions.php

functions.php in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 5.8.6, at integrations/buddypress/includes/functions.php

93 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Functions
4 *
5 * @package AutomatorWP\BuddyPress\Functions
6 * @since 1.0.0
7 */
8 // Exit if accessed directly
9 if( !defined( 'ABSPATH' ) ) exit;
10
11 /**
12 * Options callback for select2 fields assigned to groups
13 *
14 * @since 1.0.0
15 *
16 * @param stdClass $field
17 *
18 * @return array
19 */
20 function automatorwp_buddypress_options_cb_group( $field ) {
21
22 // Setup vars
23 $value = $field->escaped_value;
24 $none_value = 'any';
25 $none_label = __( 'any group', 'automatorwp' );
26 $options = automatorwp_options_cb_none_option( $field, $none_value, $none_label );
27
28 if( ! empty( $value ) ) {
29 if( ! is_array( $value ) ) {
30 $value = array( $value );
31 }
32
33 foreach( $value as $group_id ) {
34
35 // Skip option none
36 if( $group_id === $none_value ) {
37 continue;
38 }
39
40 $options[$group_id] = automatorwp_buddypress_get_group_title( $group_id );
41 }
42 }
43
44 return $options;
45
46 }
47
48 /**
49 * Get the group title
50 *
51 * @since 1.0.0
52 *
53 * @param int $group_id
54 *
55 * @return string|null
56 */
57 function automatorwp_buddypress_get_group_title( $group_id ) {
58
59 // Empty title if no ID provided
60 if( absint( $group_id ) === 0 ) {
61 return '';
62 }
63
64 $group = groups_get_group( $group_id );
65
66 return $group->name;
67
68 }
69
70 /**
71 * Options callback for select fields assigned to member types
72 *
73 * @since 1.0.0
74 *
75 * @param stdClass $field
76 *
77 * @return array
78 */
79 function automatorwp_buddypress_member_types_options_cb( $field ) {
80
81 $none_value = 'any';
82 $none_label = __( 'any profile type', 'automatorwp' );
83 $options = automatorwp_options_cb_none_option( $field, $none_value, $none_label );
84
85 $member_types = bp_get_member_types( array(), 'objects' );
86
87 foreach( $member_types as $member_type => $member_type_obj ) {
88 $options[$member_type] = $member_type_obj->labels['singular_name'];
89 }
90
91 return $options;
92
93 }