PluginProbe ʕ •ᴥ•ʔ
OttoKit: All-in-One Automation Platform / 1.0.42
OttoKit: All-in-One Automation Platform v1.0.42
1.1.38 1.1.37 1.1.36 1.1.35 1.1.34 1.1.33 1.1.32 1.1.31 1.1.30 1.1.29 1.1.28 1.1.27 1.1.9 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.47 1.0.48 1.0.49 1.0.50 1.0.51 1.0.52 1.0.53 1.0.54 1.0.55 1.0.56 1.0.57 1.0.58 1.0.59 1.0.60 1.0.61 1.0.62 1.0.63 1.0.64 1.0.65 1.0.66 1.0.67 1.0.68 1.0.69 1.0.7 1.0.70 1.0.71 1.0.72 1.0.73 1.0.74 1.0.75 1.0.76 1.0.77 1.0.78 1.0.79 1.0.8 1.0.80 1.0.81 1.0.82 1.0.83 1.0.84 1.0.85 1.0.86 1.0.87 1.0.88 1.0.89 1.0.9 1.0.90 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.20 1.1.21 1.1.22 1.1.23 1.1.24 1.1.25 1.1.26 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
suretriggers / src / Integrations / AutomateAction.php
suretriggers / src / Integrations Last commit date
academylms 2 years ago advanced-ads 2 years ago advanced-coupons 2 years ago advanced-custom-fields 2 years ago affiliatewp 2 years ago amelia 2 years ago asgaros 2 years ago badgeos 3 years ago bbpress 3 years ago beaver-builder 3 years ago bricks-builder 2 years ago buddyboss 2 years ago buddypress 3 years ago cartflows 3 years ago contact-form7 2 years ago convertpro 3 years ago divi-builder 3 years ago easy-affiliate 2 years ago edd 2 years ago elementor-pro 2 years ago event-calendar 2 years ago events-manager 2 years ago fluent-booking 2 years ago fluent-form 2 years ago fluent-support 2 years ago fluentcrm 2 years ago formidable-forms 3 years ago forminator 3 years ago funnel-kit-automations 3 years ago gamipress 2 years ago geo-directory 2 years ago givewp 2 years ago gravity-form 2 years ago gravity-kit 3 years ago groundhogg 2 years ago happyforms 3 years ago jetengine 3 years ago jetformbuilder 2 years ago jetpack-crm 3 years ago kadence-forms 3 years ago late-point 2 years ago learndash 2 years ago learndash-achievements 2 years ago learnpress 2 years ago lifterlms 2 years ago mailpoet 3 years ago masteriyo 2 years ago masterstudy-lms 3 years ago memberpress 2 years ago memberpress-course 3 years ago metabox 2 years ago metform 3 years ago modern-events-calendar 2 years ago mycred 2 years ago newsletter 2 years ago ninja-forms 3 years ago paid-memberships-pro 2 years ago peepso 3 years ago pie-forms 3 years ago powerful-docs 2 years ago presto-player 3 years ago projecthuddle 3 years ago raffle-press 2 years ago restrict-content 2 years ago sureforms 2 years ago suremembers 3 years ago thrive-leads 2 years ago triggerbutton 3 years ago tutorlms 2 years ago ultimate-addons-for-gutenberg 3 years ago ultimate-member 3 years ago wishlistmember 2 years ago woocommerce 2 years ago woocommerce-bookings 2 years ago woocommerce-memberships 2 years ago woocommerce-shipstation 2 years ago woocommerce-subscriptions 2 years ago wordpress 2 years ago wp-all-import 3 years ago wp-courseware 2 years ago wp-fusion 2 years ago wp-job-manager 3 years ago wp-polls 2 years ago wp-simple-pay 3 years ago wp-user-manager 3 years ago wpforms 3 years ago wpforo 2 years ago wplms 3 years ago ws-form 2 years ago AutomateAction.php 2 years ago Integrations.php 3 years ago
AutomateAction.php
166 lines
1 <?php
2 /**
3 * AutomateAction.
4 * php version 5.6
5 *
6 * @category AutomateAction
7 * @package SureTriggers
8 * @author BSF <username@example.com>
9 * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3
10 * @link https://www.brainstormforce.com/
11 * @since 1.0.0
12 */
13
14 namespace SureTriggers\Integrations;
15
16 use Exception;
17
18 /**
19 * AutomateAction
20 *
21 * @category AutomateAction
22 * @package SureTriggers
23 * @author BSF <username@example.com>
24 * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3
25 * @link https://www.brainstormforce.com/
26 * @since 1.0.0
27 */
28 abstract class AutomateAction {
29
30 /**
31 * Error data.
32 *
33 * @var null
34 */
35 public $data = null;
36
37 /**
38 * Action name.
39 *
40 * @var null|string
41 */
42 public $action = null;
43
44 /**
45 * Constructor
46 *
47 * @since 1.0.0
48 */
49 public function __construct() {
50
51 add_filter( 'sure_trigger_register_action', [ $this, 'register' ] );
52 add_action( 'sure_trigger_action_' . $this->action, [ $this, 'action_listener' ], 10, 4 );
53
54 }
55
56 /**
57 * Register action.
58 *
59 * @param array $actions action data.
60 * @return array
61 */
62 abstract public function register( $actions ); //phpcs:ignore WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.AbstractMethod
63
64 /**
65 * Action listener.
66 *
67 * @param int $user_id user_id.
68 * @param int $automation_id automation_id.
69 * @param array $fields fields.
70 * @param array $selected_options selectedOptions.
71 *
72 * @return void
73 */
74 abstract public function _action_listener( $user_id, $automation_id, $fields, $selected_options);
75
76 /**
77 * Failed function callback.
78 *
79 * @param string $method method name.
80 * @param array $args method arguments.
81 * @return false|void
82 * @throws Exception Excepotion.
83 */
84 public function __call( $method, $args ) {
85 // Allow support for only action_listener callback.
86 if ( 'action_listener' !== $method ) {
87 return;
88 }
89
90 // Copy and remove the context from function parameters.
91 $context = isset( $args[4] ) ? $args[4] : '';
92 unset( $args[4] );
93 // Convert select field array values in to single value array.
94 $temp_arr = [];
95 if ( is_array( $args[3] ) ) {
96 foreach ( $args[3] as $key => $val ) {
97 if ( is_array( $val ) ) {
98 $temp_arr[ $key ] = isset( $val['value'] ) ? $val['value'] : $val;
99 } else {
100 $temp_arr[ $key ] = $val;
101 }
102 }
103
104 $args[3] = $temp_arr;
105 }
106
107 if ( isset( $args[3]['wp_user_email'] ) ) {
108 $args[0] = ap_get_user_id_from_email( $args[3]['wp_user_email'] );
109
110 if ( empty( $args[0] ) ) {
111 $args[0] = 0;
112 }
113 }
114
115 $method = '_' . $method;
116 try {
117 $status = $this->$method( ...$args );
118 } catch ( Exception $e ) {
119 throw new Exception( $e->getMessage() );
120 }
121
122
123 return $status;
124 }
125
126 /**
127 * Check required fields.
128 *
129 * @param array $fields template field array.
130 * @param array $selected_options admin selected option fields.
131 * @return bool
132 */
133 public function check_required_fields( $fields, $selected_options ) {
134 foreach ( $fields as $field ) {
135 if ( 'test-action' === $field['type'] ) {
136 continue;
137 }
138
139 $fieldname = isset( $selected_options[ $field['name'] ] ) ? $selected_options[ $field['name'] ] : false;
140
141 if ( isset( $field['validationProps'] ) && ( empty( $fieldname ) && '0' !== $fieldname ) ) {
142 $this->set_error(
143 [
144 'msg' => __( 'Required field is missing: ', 'suretriggers' ) . $field['name'],
145 ]
146 );
147 return false;
148 }
149 }
150 return true;
151 }
152
153 /**
154 * Set the error before returning the false.
155 *
156 * @param array|object|null $data error data.
157 *
158 * @return void
159 */
160 public function set_error( $data ) {
161 $this->data = $data;
162 }
163 }
164
165
166