PluginProbe ʕ •ᴥ•ʔ
OttoKit: All-in-One Automation Platform / trunk
OttoKit: All-in-One Automation Platform vtrunk
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 2 months ago SureDash 4 weeks ago academylms 9 months ago advanced-ads 2 years ago advanced-coupons 5 months ago advanced-custom-fields 9 months ago advanced-forms 1 month ago affiliatewp 9 months ago amelia 2 weeks ago appointment-hour-booking 1 month ago asgaros 2 years ago badgeos 3 years ago bbpress 9 months ago beaver-builder 11 months ago better-messages 9 months ago bookingpress 4 weeks ago bookly 1 month ago bricks-builder 11 months ago bricksforge 4 weeks ago buddyboss 4 weeks ago buddypress 9 months ago cartflows 1 year ago clickwhale 9 months ago code-snippets 2 months ago contact-form7 10 months ago convertpro 1 year ago divi-builder 1 year ago easy-affiliate 9 months ago edd 4 weeks ago elementor-pro 11 months ago event-calendar 3 months ago event-espresso 1 month ago eventon 1 month ago eventprime 2 months ago events-manager 2 months ago everest-forms 2 months ago fluent-boards 1 month ago fluent-booking 8 months ago fluent-form 2 months ago fluent-support 9 months ago fluentaffiliate 5 months ago fluentcart 6 months ago fluentcommunity 5 months ago fluentcrm 1 month ago fluentsmtp 1 year ago formidable-forms 1 month ago forminator 3 years ago funnel-kit-automations 9 months ago gamipress 9 months ago geo-directory 9 months ago givewp 9 months ago gravity-form 9 months ago gravity-kit 2 years ago groundhogg 7 months ago groups-itthinx 1 month ago happyforms 3 years ago jet-appointments-booking 5 months ago jetengine 3 years ago jetformbuilder 1 year ago jetpack-crm 5 months ago kadence-forms 3 months ago late-point 1 month ago learndash 3 months ago learndash-achievements 9 months ago learnpress 9 months ago lifterlms 9 months ago mail-mint 9 months ago mailerpress 6 months ago mailpoet 9 months ago masteriyo 2 years ago masterstudy-lms 9 months ago memberpress 2 weeks ago memberpress-course 2 months ago metabox 9 months ago metform 3 years ago modern-events-calendar 9 months ago mycred 9 months ago new-user-approve 4 months ago newsletter 5 months ago ninja-forms 3 years ago ninja-tables 1 month ago paid-memberships-pro 9 months ago paymattic 9 months ago peepso 9 months ago pie-forms 3 years ago powerful-docs 1 year ago presto-player 9 months ago pretty-links 8 months ago profilegrid 1 year ago profilepress 9 months ago projecthuddle 9 months ago raffle-press 9 months ago redirection 2 months ago restrict-content 9 months ago secure-custom-fields 1 month ago sensei-lms 9 months ago services-for-surecart 1 year ago simply-schedule-appointments 2 years ago slice-wp 9 months ago spaces-engine 1 month ago storeengine 2 months ago support-genix 1 month ago support-portal-for-surecart 1 year ago suredash 3 months ago sureforms 3 months ago suremail 1 year ago suremembers 3 weeks ago teams-for-woocommerce-memberships 2 months ago thrive-apprentice 6 months ago thrive-leads 1 year ago thrive-ovation 5 months ago triggerbutton 1 year ago tutorlms 4 months ago ultimate-addons-for-gutenberg 3 years ago ultimate-member 9 months ago voxel 4 months ago wishlistmember 8 months ago woocommerce 3 months ago woocommerce-bookings 2 years ago woocommerce-memberships 9 months ago woocommerce-shipstation 2 years ago woocommerce-subscriptions 5 months ago wordpress 3 months ago wp-all-import 2 years ago wp-courseware 9 months ago wp-fusion 9 months ago wp-job-manager 3 years ago wp-polls 2 months ago wp-simple-pay 2 years ago wp-travel-engine 1 month ago wp-user-manager 2 years ago wpadverts 2 months ago wpcafe 4 months ago wpforms 8 months ago wpforo 9 months ago wpfunnels 2 months ago wplms 11 months ago wployalty 9 months ago wpsubscription 9 months ago ws-form 1 year ago AutomateAction.php 11 months ago Integrations.php 11 months 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