PluginProbe ʕ •ᴥ•ʔ
OttoKit: All-in-One Automation Platform / 1.0.25
OttoKit: All-in-One Automation Platform v1.0.25
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
advanced-ads 2 years ago advanced-coupons 2 years ago advanced-custom-fields 2 years ago affiliatewp 3 years ago amelia 2 years ago badgeos 3 years ago bbpress 3 years ago beaver-builder 3 years ago bricks-builder 3 years ago buddyboss 3 years ago buddypress 3 years ago cartflows 3 years ago contact-form7 2 years ago convertpro 3 years ago divi-builder 3 years ago edd 2 years ago elementor-pro 3 years ago event-calendar 3 years ago events-manager 3 years ago fluent-form 3 years ago fluent-support 3 years ago fluentcrm 3 years ago formidable-forms 3 years ago forminator 3 years ago funnel-kit-automations 3 years ago gamipress 2 years ago givewp 3 years ago gravity-form 3 years ago gravity-kit 3 years ago happyforms 3 years ago jetengine 3 years ago jetformbuilder 3 years ago jetpack-crm 3 years ago kadence-forms 3 years ago learndash 3 years ago learndash-achievements 2 years ago learnpress 3 years ago lifterlms 3 years ago mailpoet 3 years ago masterstudy-lms 3 years ago memberpress 3 years ago memberpress-course 3 years ago metabox 2 years ago metform 3 years ago modern-events-calendar 2 years ago mycred 3 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 presto-player 3 years ago projecthuddle 3 years ago raffle-press 2 years ago restrict-content 3 years ago suremembers 3 years ago thrive-leads 2 years ago triggerbutton 3 years ago tutorlms 3 years ago ultimate-addons-for-gutenberg 3 years ago ultimate-member 3 years ago wishlistmember 3 years ago woocommerce 2 years ago woocommerce-memberships 3 years ago woocommerce-shipstation 2 years ago woocommerce-subscriptions 2 years ago wordpress 2 years ago wp-all-import 3 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 3 years ago Integrations.php 3 years ago
AutomateAction.php
170 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
94 if ( ! $this->check_required_fields( $args[2], $args[3] ) ) {
95 $status = false;
96 } else {
97 // Convert select field array values in to single value array.
98 $temp_arr = [];
99 if ( is_array( $args[3] ) ) {
100 foreach ( $args[3] as $key => $val ) {
101 if ( is_array( $val ) ) {
102 $temp_arr[ $key ] = isset( $val['value'] ) ? $val['value'] : $val;
103 } else {
104 $temp_arr[ $key ] = $val;
105 }
106 }
107
108 $args[3] = $temp_arr;
109 }
110
111 if ( isset( $args[3]['wp_user_email'] ) ) {
112 $args[0] = ap_get_user_id_from_email( $args[3]['wp_user_email'] );
113
114 if ( empty( $args[0] ) ) {
115 $args[0] = 0;
116 }
117 }
118
119 $method = '_' . $method;
120 try {
121 $status = $this->$method( ...$args );
122 } catch ( Exception $e ) {
123 throw new Exception( $e->getMessage() );
124 }
125 }
126
127 return $status;
128 }
129
130 /**
131 * Check required fields.
132 *
133 * @param array $fields template field array.
134 * @param array $selected_options admin selected option fields.
135 * @return bool
136 */
137 public function check_required_fields( $fields, $selected_options ) {
138 foreach ( $fields as $field ) {
139 if ( 'test-action' === $field['type'] ) {
140 continue;
141 }
142
143 $fieldname = isset( $selected_options[ $field['name'] ] ) ? $selected_options[ $field['name'] ] : false;
144
145 if ( isset( $field['validationProps'] ) && ( empty( $fieldname ) && '0' !== $fieldname ) ) {
146 $this->set_error(
147 [
148 'msg' => __( 'Required field is missing: ', 'suretriggers' ) . $field['name'],
149 ]
150 );
151 return false;
152 }
153 }
154 return true;
155 }
156
157 /**
158 * Set the error before returning the false.
159 *
160 * @param array|object|null $data error data.
161 *
162 * @return void
163 */
164 public function set_error( $data ) {
165 $this->data = $data;
166 }
167 }
168
169
170