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 / mycred / includes / functions.php

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

90 lines 1.8 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\Integrations\MyCred\Functions
6 * @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]>
7 * @since 1.0.0
8 */
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Get point types from MyCred
14 *
15 * @since 1.0.0
16 *
17 * @return array
18 */
19 function automatorwp_mycred_get_point_types( ) {
20
21 $options = array();
22
23 $point_types = mycred_get_types();
24
25 foreach ( $point_types as $point_type => $label ){
26
27 $options[] = array(
28 'id' => $point_type,
29 'name' => $label,
30 );
31
32 }
33
34 return $options;
35
36 }
37
38 /**
39 * Get point type from MyCred
40 *
41 * @since 1.0.0
42 *
43 * @param stdClass $field
44 *
45 * @return array
46 */
47 function automatorwp_mycred_options_cb_point_type( $field ) {
48
49 // Setup vars
50 $value = $field->escaped_value;
51 $none_value = 'any';
52 $none_label = __( 'any point type', 'automatorwp-pro' );
53 $options = automatorwp_options_cb_none_option( $field, $none_value, $none_label );
54
55 if( ! empty( $value ) ) {
56 if( ! is_array( $value ) ) {
57 $value = array( $value );
58 }
59
60 foreach( $value as $point_type_id ) {
61
62 // Skip option none
63 if( $point_type_id === $none_value ) {
64 continue;
65 }
66
67 $options[$point_type_id] = automatorwp_mycred_get_point_type_name( $point_type_id );
68 }
69 }
70
71 return $options;
72
73 }
74
75 /**
76 * Get the point type name
77 *
78 * @since 1.0.0
79 *
80 * @param string $point_type_id
81 *
82 * @return array
83 */
84 function automatorwp_mycred_get_point_type_name( $point_type_id ) {
85
86 $point_type = mycred_get_point_type( $point_type_id );
87
88 return $point_type->singular;
89
90 }