PluginProbe ʕ •ᴥ•ʔ
OttoKit: All-in-One Automation Platform / 1.1.33
OttoKit: All-in-One Automation Platform v1.1.33
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
CluevoLms 1 month ago JetEngineCCT 3 months ago Mailster 3 days ago SureDash 1 month ago SureDonation 2 weeks ago academylms 10 months ago advanced-ads 2 years ago advanced-coupons 5 months ago advanced-custom-fields 10 months ago advanced-forms 1 month ago affiliatewp 10 months ago amelia 1 month ago appointment-hour-booking 1 month ago asgaros 2 years ago badgeos 3 years ago bbpress 10 months ago beaver-builder 1 year ago better-messages 10 months ago bookingpress 1 month ago bookly 2 months ago bricks-builder 2 weeks ago bricksforge 1 month ago buddyboss 3 days ago buddypress 10 months ago cartflows 1 year ago clickwhale 10 months ago code-snippets 3 months ago contact-form7 10 months ago convertpro 1 year ago divi-builder 1 year ago easy-affiliate 10 months ago edd 1 month ago elementor-pro 1 year ago event-calendar 3 months ago event-espresso 2 months ago eventon 2 months ago eventprime 3 months ago events-manager 2 months ago everest-forms 3 months ago fluent-boards 1 month ago fluent-booking 8 months ago fluent-form 3 months ago fluent-support 10 months ago fluentaffiliate 5 months ago fluentcart 7 months ago fluentcommunity 6 months ago fluentcrm 2 weeks ago fluentsmtp 2 weeks ago formidable-forms 1 month ago forminator 3 years ago funnel-kit-automations 10 months ago gamipress 10 months ago geo-directory 10 months ago givewp 10 months ago gravity-form 10 months ago gravity-kit 2 years ago groundhogg 8 months ago groups-itthinx 1 month ago happyforms 3 years ago jet-appointments-booking 6 months ago jetengine 3 years ago jetformbuilder 2 years ago jetpack-crm 6 months ago kadence-forms 4 months ago late-point 2 months ago learndash 4 months ago learndash-achievements 10 months ago learnpress 10 months ago lifterlms 10 months ago mail-mint 2 weeks ago mailerpress 7 months ago mailpoet 10 months ago masteriyo 2 years ago masterstudy-lms 10 months ago memberpress 1 month ago memberpress-course 3 months ago metabox 10 months ago metform 3 years ago modern-events-calendar 10 months ago mycred 10 months ago new-user-approve 5 months ago newsletter 5 months ago ninja-forms 3 years ago ninja-tables 2 months ago paid-memberships-pro 10 months ago paymattic 10 months ago peepso 10 months ago pie-forms 3 years ago powerful-docs 1 year ago presto-player 10 months ago pretty-links 8 months ago profilegrid 1 year ago profilepress 10 months ago projecthuddle 10 months ago raffle-press 10 months ago redirection 3 months ago restrict-content 10 months ago secure-custom-fields 1 month ago sensei-lms 10 months ago services-for-surecart 1 year ago simply-schedule-appointments 2 years ago slice-wp 10 months ago spaces-engine 1 month ago storeengine 3 months ago support-genix 2 months ago support-portal-for-surecart 1 year ago suredash 4 months ago sureforms 4 months ago suremail 1 year ago suremembers 1 month ago teams-for-woocommerce-memberships 3 months ago thrive-apprentice 6 months ago thrive-leads 1 year ago thrive-ovation 6 months ago triggerbutton 2 years ago tutorlms 5 months ago ultimate-addons-for-gutenberg 3 years ago ultimate-member 10 months ago voxel 5 months ago wishlistmember 9 months ago woocommerce 4 months ago woocommerce-bookings 2 years ago woocommerce-memberships 10 months ago woocommerce-shipstation 2 years ago woocommerce-subscriptions 3 days ago wordpress 3 months ago wp-all-import 2 years ago wp-courseware 10 months ago wp-fusion 10 months ago wp-job-manager 3 years ago wp-polls 3 months ago wp-simple-pay 2 years ago wp-travel-engine 1 month ago wp-user-manager 2 years ago wpadverts 3 months ago wpcafe 5 months ago wpforms 8 months ago wpforo 10 months ago wpfunnels 3 months ago wplms 1 year ago wployalty 10 months ago wpsubscription 10 months ago ws-form 1 year ago AutomateAction.php 1 year ago Integrations.php 1 year ago
AutomateAction.php
172 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 use Throwable;
18
19 /**
20 * AutomateAction
21 *
22 * @category AutomateAction
23 * @package SureTriggers
24 * @author BSF <username@example.com>
25 * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3
26 * @link https://www.brainstormforce.com/
27 * @since 1.0.0
28 */
29 abstract class AutomateAction {
30
31 /**
32 * Error data.
33 *
34 * @var null
35 */
36 public $data = null;
37
38 /**
39 * Action name.
40 *
41 * @var null|string
42 */
43 public $action = null;
44
45 /**
46 * Constructor
47 *
48 * @since 1.0.0
49 */
50 public function __construct() {
51
52 add_filter( 'sure_trigger_register_action', [ $this, 'register' ] );
53 add_action( 'sure_trigger_action_' . $this->action, [ $this, 'action_listener' ], 10, 4 );
54
55 }
56
57 /**
58 * Register action.
59 *
60 * @param array $actions action data.
61 * @return array
62 */
63 abstract public function register( $actions ); //phpcs:ignore WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.AbstractMethod
64
65 /**
66 * Action listener.
67 *
68 * @param int $user_id user_id.
69 * @param int $automation_id automation_id.
70 * @param array $fields fields.
71 * @param array $selected_options selectedOptions.
72 *
73 * @return void
74 */
75 abstract public function _action_listener( $user_id, $automation_id, $fields, $selected_options);
76
77 /**
78 * Failed function callback.
79 *
80 * @param string $method method name.
81 * @param array $args method arguments.
82 * @return false|void
83 * @throws Exception Excepotion.
84 */
85 public function __call( $method, $args ) {
86 // Allow support for only action_listener callback.
87 if ( 'action_listener' !== $method ) {
88 return;
89 }
90
91 // Copy and remove the context from function parameters.
92 $context = isset( $args[4] ) ? $args[4] : '';
93 unset( $args[4] );
94 // Convert select field array values in to single value array.
95 $temp_arr = [];
96 if ( is_array( $args[3] ) ) {
97 foreach ( $args[3] as $key => $val ) {
98 if ( is_array( $val ) ) {
99 $temp_arr[ $key ] = isset( $val['value'] ) ? $val['value'] : $val;
100 } else {
101 $temp_arr[ $key ] = $val;
102 }
103 }
104
105 $args[3] = $temp_arr;
106 }
107
108 if ( isset( $args[3]['wp_user_email'] ) ) {
109 $args[0] = ap_get_user_id_from_email( $args[3]['wp_user_email'] );
110
111 if ( empty( $args[0] ) ) {
112 $args[0] = 0;
113 }
114 }
115
116 $method = '_' . $method;
117 try {
118 $status = $this->$method( ...$args );
119 if ( is_null( $status ) && ! is_null( $this->data ) ) {
120 // If status is null but we have error data, throw an exception with the error message.
121 $error_msg = is_array( $this->data ) && isset( $this->data['msg'] ) ? $this->data['msg'] : 'Action failed';
122 throw new Exception( $error_msg );
123 }
124 return $status;
125 } catch ( Exception $e ) {
126 throw new Exception( $e->getMessage() );
127 } catch ( \Throwable $php_error ) {
128 throw new Exception( 'PHP Error: ' . $php_error->getMessage() );
129 }
130 }
131
132 /**
133 * Check required fields.
134 *
135 * @param array $fields template field array.
136 * @param array $selected_options admin selected option fields.
137 * @return bool
138 */
139 public function check_required_fields( $fields, $selected_options ) {
140 foreach ( $fields as $field ) {
141 if ( 'test-action' === $field['type'] ) {
142 continue;
143 }
144
145 $fieldname = isset( $selected_options[ $field['name'] ] ) ? $selected_options[ $field['name'] ] : false;
146
147 if ( isset( $field['validationProps'] ) && ( empty( $fieldname ) && '0' !== $fieldname ) ) {
148 $this->set_error(
149 [
150 'msg' => __( 'Required field is missing: ', 'suretriggers' ) . $field['name'],
151 ]
152 );
153 return false;
154 }
155 }
156 return true;
157 }
158
159 /**
160 * Set the error before returning the false.
161 *
162 * @param array|object|null $data error data.
163 *
164 * @return void
165 */
166 public function set_error( $data ) {
167 $this->data = $data;
168 }
169 }
170
171
172