PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 3.06.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v3.06.06
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmFormActionsController.php +195 -381 6.33.06.06 View file →
@@ -1,12 +1,9 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 2
6 3 class FrmFormActionsController {
7 - public static $action_post_type = 'frm_form_actions';
8 - public static $registered_actions;
4 + public static $action_post_type = 'frm_form_actions';
5 + public static $registered_actions;
9 6
10 7 /**
11 8 * Variables saved in the post:
12 9 * post_content: json settings
@@ -12,278 +9,104 @@
12 9 * post_content: json settings
13 10 * menu_order: form id
14 11 * post_excerpt: action type
15 12 */
16 - public static function register_post_types() {
13 + public static function register_post_types() {
17 14 register_post_type(
18 15 self::$action_post_type,
19 16 array(
20 - 'label' => __( 'Form Actions', 'formidable' ),
21 - 'description' => '',
22 - 'public' => false,
23 - 'show_ui' => false,
17 + 'label' => __( 'Form Actions', 'formidable' ),
18 + 'description' => '',
19 + 'public' => false,
20 + 'show_ui' => false,
24 21 'exclude_from_search' => true,
25 - 'show_in_nav_menus' => false,
26 - 'show_in_menu' => true,
27 - 'capability_type' => 'page',
28 - 'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'page-attributes' ),
29 - 'has_archive' => false,
22 + 'show_in_nav_menus' => false,
23 + 'show_in_menu' => true,
24 + 'capability_type' => 'page',
25 + 'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'page-attributes' ),
26 + 'has_archive' => false,
30 27 )
31 28 );
32 29
33 - self::actions_init();
34 - }
30 + self::actions_init();
31 + }
35 32
36 - public static function actions_init() {
37 - self::$registered_actions = new Frm_Form_Action_Factory();
38 - self::register_actions();
39 - do_action( 'frm_form_actions_init' );
40 - }
33 + public static function actions_init() {
34 + self::$registered_actions = new Frm_Form_Action_Factory();
35 + self::register_actions();
36 + do_action( 'frm_form_actions_init' );
37 + }
41 38
42 - /**
43 - * @return void
44 - */
45 - public static function register_actions() {
39 + public static function register_actions() {
46 40 $action_classes = array(
47 - 'on_submit' => 'FrmOnSubmitAction',
48 - 'email' => 'FrmEmailAction',
49 - 'wppost' => 'FrmDefPostAction',
50 - 'register' => 'FrmDefRegAction',
51 - 'paypal' => 'FrmDefPayPalAction',
52 - 'payment' => 'FrmDefHrsAction',
53 - 'quiz' => 'FrmDefQuizAction',
54 - 'quiz_outcome' => 'FrmDefQuizOutcomeAction',
55 - 'mailchimp' => 'FrmDefMlcmpAction',
56 - 'api' => 'FrmDefApiAction',
57 - 'salesforce' => 'FrmDefSalesforceAction',
58 - 'activecampaign' => 'FrmDefActiveCampaignAction',
59 - 'constantcontact' => 'FrmDefConstContactAction',
60 - 'getresponse' => 'FrmDefGetResponseAction',
61 - 'hubspot' => 'FrmDefHubspotAction',
62 - 'zapier' => 'FrmDefZapierAction',
63 - 'twilio' => 'FrmDefTwilioAction',
64 - 'highrise' => 'FrmDefHighriseAction',
65 - 'mailpoet' => 'FrmDefMailpoetAction',
66 - 'aweber' => 'FrmDefAweberAction',
67 - 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction',
68 - );
69 -
41 + 'email' => 'FrmEmailAction',
42 + 'wppost' => 'FrmDefPostAction',
43 + 'register' => 'FrmDefRegAction',
44 + 'paypal' => 'FrmDefPayPalAction',
45 + //'aweber' => 'FrmDefAweberAction',
46 + 'mailchimp' => 'FrmDefMlcmpAction',
47 + 'twilio' => 'FrmDefTwilioAction',
48 + 'payment' => 'FrmDefHrsAction',
49 + 'api' => 'FrmDefApiAction',
50 + );
70 51 $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes );
71 52
72 - include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php';
73 - include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php';
53 + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' );
54 + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' );
74 55
75 - foreach ( $action_classes as $action_class ) {
56 + foreach ( $action_classes as $action_class ) {
76 57 self::$registered_actions->register( $action_class );
77 - }
78 - }
58 + }
59 + }
79 60
80 - /**
81 - * @since 4.0
82 - *
83 - * @param array $values
84 - */
85 - public static function email_settings( $values ) {
86 - $form = FrmForm::getOne( $values['id'] );
87 - $groups = self::form_action_groups();
88 -
89 - $action_controls = self::get_form_actions();
90 - self::maybe_add_action_to_group( $action_controls, $groups );
91 -
92 - $allowed = self::active_actions( $action_controls );
93 -
94 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/settings.php';
95 - }
96 -
97 - /**
98 - * Add unknown actions to a group.
99 - *
100 - * @since 4.0
101 - */
102 - private static function maybe_add_action_to_group( $action_controls, &$groups ) {
103 - $grouped = array();
104 - foreach ( $groups as $group ) {
105 - if ( isset( $group['actions'] ) ) {
106 - $grouped = array_merge( $grouped, $group['actions'] );
107 - }
108 - }
109 -
110 - foreach ( $action_controls as $action ) {
111 - if ( isset( $groups[ $action->id_base ] ) || in_array( $action->id_base, $grouped ) ) {
112 - continue;
113 - }
114 -
115 - $this_group = $action->action_options['group'];
116 - if ( ! isset( $groups[ $this_group ] ) ) {
117 - $this_group = 'misc';
118 - }
119 -
120 - if ( ! isset( $groups[ $this_group ]['actions'] ) ) {
121 - $groups[ $this_group ]['actions'] = array();
122 - }
123 - $groups[ $this_group ]['actions'][] = $action->id_base;
124 -
125 - unset( $action );
126 - }
127 - }
128 -
129 - /**
130 - * @since 4.0
131 - *
132 - * @return array
133 - */
134 - public static function form_action_groups() {
135 - $groups = array(
136 - 'misc' => array(
137 - 'name' => '',
138 - 'icon' => 'frm_icon_font frm_shuffle_icon',
139 - 'actions' => array(
140 - 'email',
141 - 'wppost',
142 - 'register',
143 - 'quiz',
144 - 'quiz_outcome',
145 - 'twilio',
146 - ),
147 - ),
148 - 'payment' => array(
149 - 'name' => __( 'eCommerce', 'formidable' ),
150 - 'icon' => 'frm_icon_font frm_credit_card_alt_icon',
151 - 'actions' => array(
152 - 'paypal',
153 - 'payment',
154 - ),
155 - ),
156 - 'marketing' => array(
157 - 'name' => __( 'Email Marketing', 'formidable' ),
158 - 'icon' => 'frm_icon_font frm_mail_bulk_icon',
159 - 'actions' => array(
160 - 'mailchimp',
161 - 'activecampaign',
162 - 'constantcontact',
163 - 'getresponse',
164 - 'aweber',
165 - 'mailpoet',
166 - ),
167 - ),
168 - 'crm' => array(
169 - 'name' => __( 'CRM', 'formidable' ),
170 - 'icon' => 'frm_icon_font frm_address_card_icon',
171 - 'actions' => array(
172 - 'salesforce',
173 - 'hubspot',
174 - 'highrise',
175 - ),
176 - ),
177 - );
178 -
179 - return apply_filters( 'frm_action_groups', $groups );
180 - }
181 -
182 - /**
183 - * Get the number of currently active form actions.
184 - *
185 - * @since 4.0
186 - *
187 - * @return array
188 - */
189 - private static function active_actions( $action_controls ) {
190 - $allowed = array();
191 - foreach ( $action_controls as $action_control ) {
192 - if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) {
193 - $allowed[] = $action_control->id_base;
194 - }
195 - }
196 - return $allowed;
197 - }
198 -
199 - /**
200 - * For each add-on, add an li, class, and javascript function. If active, add an additional class.
201 - *
202 - * @since 4.0
203 - * @param object $action_control
204 - * @param array $allowed
205 - */
206 - public static function show_action_icon_link( $action_control, $allowed ) {
207 - $data = array();
208 - $classes = ' frm_' . $action_control->id_base . '_action frm_single_action';
209 -
210 - $group_class = ' frm-group-' . $action_control->action_options['group'];
211 -
212 - /* translators: %s: Name of form action */
213 - $upgrade_label = sprintf( esc_html__( '%s form actions', 'formidable' ), $action_control->action_options['tooltip'] );
214 -
215 - $default_shown = array( 'wppost', 'register', 'payment', 'quiz', 'hubspot' );
216 - $default_shown = array_values( array_diff( $default_shown, $allowed ) );
217 - $default_position = array_search( $action_control->id_base, $default_shown );
218 - $allowed_count = count( $allowed );
219 -
220 - if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) {
221 - $classes .= ' frm_active_action';
222 - } else {
223 - $classes .= ' frm_inactive_action';
224 - if ( $default_position !== false && ( $allowed_count + $default_position ) < 6 ) {
225 - $group_class .= ' frm-default-show';
226 - }
227 -
228 - $data['data-upgrade'] = $upgrade_label;
229 - $data['data-medium'] = 'settings-' . $action_control->id_base;
230 -
231 - $upgrading = FrmAddonsController::install_link( $action_control->action_options['plugin'] );
232 - if ( isset( $upgrading['url'] ) ) {
233 - $data['data-oneclick'] = json_encode( $upgrading );
234 - }
235 -
236 - if ( isset( $action_control->action_options['message'] ) ) {
237 - $data['data-message'] = $action_control->action_options['message'];
238 - }
239 -
240 - $requires = FrmFormsHelper::get_plan_required( $upgrading );
241 - if ( $requires && 'free' !== $requires ) {
242 - $data['data-requires'] = $requires;
243 - }
244 - }
245 -
246 - // HTML to include on the icon.
247 - $icon_atts = array();
248 - if ( $action_control->action_options['color'] !== 'var(--primary-700)' ) {
249 - $icon_atts = array(
250 - 'style' => '--primary-700:' . $action_control->action_options['color'],
251 - );
252 - }
253 -
254 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php';
255 - }
256 -
257 61 public static function get_form_actions( $action = 'all' ) {
258 - $temp_actions = self::$registered_actions;
62 + $temp_actions = self::$registered_actions;
259 63 if ( empty( $temp_actions ) ) {
260 - self::actions_init();
261 - $temp_actions = self::$registered_actions->actions;
262 - } else {
263 - $temp_actions = $temp_actions->actions;
264 - }
64 + self::actions_init();
65 + $temp_actions = self::$registered_actions->actions;
66 + } else {
67 + $temp_actions = $temp_actions->actions;
68 + }
265 69
266 - $actions = array();
70 + $actions = array();
267 71
268 - foreach ( $temp_actions as $a ) {
269 - if ( 'all' != $action && $a->id_base == $action ) {
270 - return $a;
271 - }
72 + foreach ( $temp_actions as $a ) {
73 + if ( 'all' != $action && $a->id_base == $action ) {
74 + return $a;
75 + }
272 76
273 77 $actions[ $a->id_base ] = $a;
274 - }
78 + }
79 + unset( $temp_actions, $a );
275 80
276 - return $actions;
277 - }
81 + $action_limit = 10;
82 + if ( count( $actions ) <= $action_limit ) {
83 + return $actions;
84 + }
278 85
86 + // remove the last few inactive icons if there are too many
87 + $temp_actions = $actions;
88 + arsort( $temp_actions );
89 + foreach ( $temp_actions as $type => $a ) {
90 + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) {
91 + unset( $actions[ $type ] );
92 + if ( count( $actions ) <= $action_limit ) {
93 + break;
94 + }
95 + }
96 + unset( $type, $a );
97 + }
98 +
99 + return $actions;
100 + }
101 +
279 102 /**
280 103 * @since 2.0
281 104 */
282 - public static function list_actions( $form, $values ) {
283 - if ( empty( $form ) ) {
284 - return;
285 - }
105 + public static function list_actions( $form, $values ) {
106 + if ( empty( $form ) ) {
107 + return;
108 + }
286 109
287 110 /**
288 111 * Use this hook to migrate old settings into a new action
289 112 *
@@ -290,30 +113,30 @@
290 113 * @since 2.0
291 114 */
292 115 do_action( 'frm_before_list_actions', $form );
293 116
294 - $filters = array(
117 + $filters = array(
295 118 'post_status' => 'all',
296 119 );
297 120 $form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters );
298 121
299 - $action_controls = self::get_form_actions();
122 + $action_controls = self::get_form_actions();
300 123
301 - $action_map = array();
124 + $action_map = array();
302 125
303 126 foreach ( $action_controls as $key => $control ) {
304 - $action_map[ $control->id_base ] = $key;
305 - }
127 + $action_map[ $control->id_base ] = $key;
128 + }
306 129
307 - foreach ( $form_actions as $action ) {
308 - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
309 - // don't try and show settings if action no longer exists
310 - continue;
311 - }
130 + foreach ( $form_actions as $action ) {
131 + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
132 + // don't try and show settings if action no longer exists
133 + continue;
134 + }
312 135
313 - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
314 - }
315 - }
136 + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
137 + }
138 + }
316 139
317 140 public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
318 141 $action_control->_set( $action_key );
319 142
@@ -318,57 +141,57 @@
318 141 $action_control->_set( $action_key );
319 142
320 143 $use_logging = self::should_show_log_message( $form_action->post_excerpt );
321 144
322 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php';
323 - }
145 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
146 + }
324 147
325 - public static function add_form_action() {
148 + public static function add_form_action() {
326 149 FrmAppHelper::permission_check( 'frm_edit_forms' );
327 - check_ajax_referer( 'frm_ajax', 'nonce' );
150 + check_ajax_referer( 'frm_ajax', 'nonce' );
328 151
329 - global $frm_vars;
152 + global $frm_vars;
330 153
331 - $action_key = FrmAppHelper::get_param( 'list_id', '', 'post', 'absint' );
332 - $action_type = FrmAppHelper::get_param( 'type', '', 'post', 'sanitize_text_field' );
154 + $action_key = absint( $_POST['list_id'] );
155 + $action_type = sanitize_text_field( $_POST['type'] );
333 156
334 - $action_control = self::get_form_actions( $action_type );
157 + $action_control = self::get_form_actions( $action_type );
335 158 $action_control->_set( $action_key );
336 159
337 - $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' );
160 + $form_id = absint( $_POST['form_id'] );
338 161
339 162 $form_action = $action_control->prepare_new( $form_id );
340 163 $use_logging = self::should_show_log_message( $action_type );
341 164
342 - $values = array();
343 - $form = self::fields_to_values( $form_id, $values );
165 + $values = array();
166 + $form = self::fields_to_values( $form_id, $values );
344 167
345 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php';
346 - wp_die();
347 - }
168 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
169 + wp_die();
170 + }
348 171
349 - public static function fill_action() {
172 + public static function fill_action() {
350 173 FrmAppHelper::permission_check( 'frm_edit_forms' );
351 - check_ajax_referer( 'frm_ajax', 'nonce' );
174 + check_ajax_referer( 'frm_ajax', 'nonce' );
352 175
353 - $action_key = FrmAppHelper::get_param( 'action_id', '', 'post', 'absint' );
354 - $action_type = FrmAppHelper::get_param( 'action_type', '', 'post', 'sanitize_text_field' );
176 + $action_key = absint( $_POST['action_id'] );
177 + $action_type = sanitize_text_field( $_POST['action_type'] );
355 178
356 - $action_control = self::get_form_actions( $action_type );
179 + $action_control = self::get_form_actions( $action_type );
357 180 if ( empty( $action_control ) ) {
358 - wp_die();
359 - }
181 + wp_die();
182 + }
360 183
361 - $form_action = $action_control->get_single_action( $action_key );
184 + $form_action = $action_control->get_single_action( $action_key );
362 185
363 - $values = array();
364 - $form = self::fields_to_values( $form_action->menu_order, $values );
186 + $values = array();
187 + $form = self::fields_to_values( $form_action->menu_order, $values );
365 188
366 189 $use_logging = self::should_show_log_message( $action_type );
367 190
368 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php';
369 - wp_die();
370 - }
191 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
192 + wp_die();
193 + }
371 194
372 195 /**
373 196 * @since 3.06.04
374 197 * @return bool
@@ -386,37 +209,31 @@
386 209 'id' => $form->id,
387 210 );
388 211
389 212 $fields = FrmField::get_all_for_form( $form->id );
390 - foreach ( $fields as $k => $f ) {
391 - $f = (array) $f;
392 - $opts = (array) $f['field_options'];
393 - $f = array_merge( $opts, $f );
394 - if ( ! isset( $f['post_field'] ) ) {
395 - $f['post_field'] = '';
396 - }
397 - $values['fields'][] = $f;
213 + foreach ( $fields as $k => $f ) {
214 + $f = (array) $f;
215 + $opts = (array) $f['field_options'];
216 + $f = array_merge( $opts, $f );
217 + if ( ! isset( $f['post_field'] ) ) {
218 + $f['post_field'] = '';
219 + }
220 + $values['fields'][] = $f;
398 221 unset( $k, $f );
399 - }
222 + }
400 223
401 - return $form;
402 - }
224 + return $form;
225 + }
403 226
404 - /**
405 - * @param int $form_id
406 - * @return void
407 - */
408 227 public static function update_settings( $form_id ) {
409 - FrmAppHelper::permission_check( 'frm_edit_forms' );
410 228 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
411 229 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
412 - $frm_settings = FrmAppHelper::get_settings();
413 - wp_die( esc_html( $frm_settings->admin_permission ) );
230 + wp_die( esc_html__( 'You do not have permission to do that', 'formidable' ) );
414 231 }
415 232
416 - global $wpdb;
233 + global $wpdb;
417 234
418 - $registered_actions = self::$registered_actions->actions;
235 + $registered_actions = self::$registered_actions->actions;
419 236
420 237 $old_actions = FrmDb::get_col(
421 238 $wpdb->posts,
422 239 array(
@@ -424,28 +241,26 @@
424 241 'menu_order' => $form_id,
425 242 ),
426 243 'ID'
427 244 );
428 - $new_actions = array();
245 + $new_actions = array();
429 246
430 - foreach ( $registered_actions as $registered_action ) {
247 + foreach ( $registered_actions as $registered_action ) {
431 248 $action_ids = $registered_action->update_callback( $form_id );
432 - if ( ! empty( $action_ids ) ) {
433 - $new_actions[] = $action_ids;
434 - }
435 - }
249 + if ( ! empty( $action_ids ) ) {
250 + $new_actions[] = $action_ids;
251 + }
252 + }
436 253
437 - // Only use array_merge if there are new actions.
438 - if ( ! empty( $new_actions ) ) {
439 - $new_actions = call_user_func_array( 'array_merge', $new_actions );
440 - }
441 - $old_actions = array_diff( $old_actions, $new_actions );
254 + //Only use array_merge if there are new actions
255 + if ( ! empty( $new_actions ) ) {
256 + $new_actions = call_user_func_array( 'array_merge', $new_actions );
257 + }
258 + $old_actions = array_diff( $old_actions, $new_actions );
442 259
443 260 self::delete_missing_actions( $old_actions );
261 + }
444 262
445 - FrmOnSubmitHelper::save_on_submit_settings( $form_id );
446 - }
447 -
448 263 public static function delete_missing_actions( $old_actions ) {
449 264 if ( ! empty( $old_actions ) ) {
450 265 foreach ( $old_actions as $old_id ) {
451 266 wp_delete_post( $old_id );
@@ -454,38 +269,37 @@
454 269 }
455 270 }
456 271
457 272 public static function trigger_create_actions( $entry_id, $form_id, $args = array() ) {
458 - $filter_args = $args;
273 + $filter_args = $args;
459 274 $filter_args['entry_id'] = $entry_id;
460 275 $filter_args['form_id'] = $form_id;
461 -
462 276 $event = apply_filters( 'frm_trigger_create_action', 'create', $args );
463 277
464 278 self::trigger_actions( $event, $form_id, $entry_id, 'all', $args );
465 279 }
466 280
467 - /**
468 - * @param string $event
469 - */
281 + /**
282 + * @param string $event
283 + */
470 284 public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
471 285 $action_status = array(
472 286 'post_status' => 'publish',
473 287 );
474 - $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status );
288 + $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status );
475 289
476 290 if ( empty( $form_actions ) ) {
477 - return;
478 - }
291 + return;
292 + }
479 293
480 294 FrmForm::maybe_get_form( $form );
481 295
482 - $link_settings = self::get_form_actions( $type );
483 - if ( 'all' != $type ) {
484 - $link_settings = array( $type => $link_settings );
485 - }
296 + $link_settings = self::get_form_actions( $type );
297 + if ( 'all' != $type ) {
298 + $link_settings = array( $type => $link_settings );
299 + }
486 300
487 - $stored_actions = array();
301 + $stored_actions = array();
488 302 $action_priority = array();
489 303
490 304 if ( in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
491 305 $this_event = 'import';
@@ -492,19 +306,19 @@
492 306 } else {
493 307 $this_event = $event;
494 308 }
495 309
496 - foreach ( $form_actions as $action ) {
310 + foreach ( $form_actions as $action ) {
497 311
498 - $skip_this_action = ! in_array( $this_event, $action->post_content['event'], true ) || FrmOnSubmitAction::$slug === $action->post_excerpt;
312 + $skip_this_action = ( ! in_array( $this_event, $action->post_content['event'] ) );
499 313 $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) );
500 314 if ( $skip_this_action ) {
501 - continue;
502 - }
315 + continue;
316 + }
503 317
504 - if ( ! is_object( $entry ) ) {
505 - $entry = FrmEntry::getOne( $entry, true );
506 - }
318 + if ( ! is_object( $entry ) ) {
319 + $entry = FrmEntry::getOne( $entry, true );
320 + }
507 321
508 322 if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) {
509 323 continue;
510 324 }
@@ -516,68 +330,68 @@
516 330 $trigger_children = apply_filters( 'frm_use_embedded_form_actions', false, compact( 'form', 'entry' ) );
517 331 if ( ! $trigger_children ) {
518 332 continue;
519 333 }
520 - }
334 + }
521 335
522 - // Check conditional logic.
336 + // check conditional logic
523 337 $stop = FrmFormAction::action_conditions_met( $action, $entry );
524 - if ( $stop ) {
525 - continue;
526 - }
338 + if ( $stop ) {
339 + continue;
340 + }
527 341
528 - // Store actions so they can be triggered with the correct priority.
529 - $stored_actions[ $action->ID ] = $action;
530 - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
342 + // store actions so they can be triggered with the correct priority
343 + $stored_actions[ $action->ID ] = $action;
344 + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
531 345
532 346 unset( $action );
533 - }
347 + }
534 348
535 - if ( ! empty( $stored_actions ) ) {
349 + if ( ! empty( $stored_actions ) ) {
536 350 asort( $action_priority );
537 351
538 - // Make sure hooks are loaded.
539 - new FrmNotification();
352 + // make sure hooks are loaded
353 + new FrmNotification();
540 354
541 - foreach ( $action_priority as $action_id => $priority ) {
542 - $action = $stored_actions[ $action_id ];
355 + foreach ( $action_priority as $action_id => $priority ) {
356 + $action = $stored_actions[ $action_id ];
543 357 do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
544 358 do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
545 359
546 - // If post is created, get updated $entry object.
547 - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
360 + // If post is created, get updated $entry object
361 + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
548 362 $entry = FrmEntry::getOne( $entry->id, true );
549 - }
550 - }
551 - }
552 - }
363 + }
364 + }
365 + }
366 + }
553 367
554 368 public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
555 369 if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
556 - // Continue if we know which actions to copy.
557 - return;
558 - }
370 + // continue if we know which actions to copy
371 + return;
372 + }
559 373
560 374 $action_controls = self::get_form_actions();
561 375
562 - foreach ( $action_controls as $action_control ) {
563 - $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
564 - unset( $action_control );
565 - }
566 - }
376 + foreach ( $action_controls as $action_control ) {
377 + $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
378 + unset( $action_control );
379 + }
380 + }
567 381
568 - public static function limit_by_type( $where ) {
569 - global $frm_vars, $wpdb;
382 + public static function limit_by_type( $where ) {
383 + global $frm_vars, $wpdb;
570 384
571 - if ( ! isset( $frm_vars['action_type'] ) ) {
572 - return $where;
573 - }
385 + if ( ! isset( $frm_vars['action_type'] ) ) {
386 + return $where;
387 + }
574 388
575 - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
389 + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
390 + return $where;
391 + }
392 +}
576 393
577 - return $where;
578 - }
579 -}
580 394
581 395 class Frm_Form_Action_Factory {
582 396 public $actions = array();
583 397
@@ -600,9 +414,9 @@
600 414
601 415 foreach ( $keys as $key ) {
602 416 // don't register new action if old action with the same id is already registered
603 417 if ( ! isset( $this->actions[ $key ] ) ) {
604 - $this->actions[ $key ]->_register();
418 + $this->actions[ $key ]->_register();
605 419 }
606 420 }
607 421 }
608 422 }