PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.01.02
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.01.02
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 +52 -333 6.264.01.02 View file →
@@ -1,19 +1,8 @@
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 -
8 - /**
9 - * @var string
10 - */
11 4 public static $action_post_type = 'frm_form_actions';
12 -
13 - /**
14 - * @var array|null
15 - */
16 5 public static $registered_actions;
17 6
18 7 /**
19 8 * Variables saved in the post:
@@ -46,47 +35,33 @@
46 35 self::register_actions();
47 36 do_action( 'frm_form_actions_init' );
48 37 }
49 38
50 - /**
51 - * @return void
52 - */
53 39 public static function register_actions() {
54 40 $action_classes = array(
55 - 'on_submit' => 'FrmOnSubmitAction',
56 - 'email' => 'FrmEmailAction',
57 - 'wppost' => 'FrmDefPostAction',
58 - 'register' => 'FrmDefRegAction',
59 - 'paypal' => 'FrmDefPayPalAction',
60 - 'payment' => 'FrmTransLiteAction',
61 - 'quiz' => 'FrmDefQuizAction',
62 - 'quiz_outcome' => 'FrmDefQuizOutcomeAction',
63 - 'mailchimp' => 'FrmDefMlcmpAction',
64 - 'api' => 'FrmDefApiAction',
65 - 'salesforce' => 'FrmDefSalesforceAction',
66 - 'activecampaign' => 'FrmDefActiveCampaignAction',
67 - 'constantcontact' => 'FrmDefConstContactAction',
68 - 'getresponse' => 'FrmDefGetResponseAction',
69 - 'hubspot' => 'FrmDefHubspotAction',
70 - 'zapier' => 'FrmDefZapierAction',
71 - 'n8n' => 'FrmDefN8NAction',
72 - 'twilio' => 'FrmDefTwilioAction',
73 - 'highrise' => 'FrmDefHighriseAction',
74 - 'mailpoet' => 'FrmDefMailpoetAction',
75 - 'aweber' => 'FrmDefAweberAction',
76 - 'convertkit' => 'FrmDefConvertKitAction',
77 - 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction',
41 + 'email' => 'FrmEmailAction',
42 + 'wppost' => 'FrmDefPostAction',
43 + 'register' => 'FrmDefRegAction',
44 + 'paypal' => 'FrmDefPayPalAction',
45 + 'payment' => 'FrmDefHrsAction',
46 + 'mailchimp' => 'FrmDefMlcmpAction',
47 + 'api' => 'FrmDefApiAction',
48 +
49 + 'salesforce' => 'FrmDefSalesforceAction',
50 + 'activecampaign' => 'FrmDefActiveCampaignAction',
51 + 'constantcontact' => 'FrmDefConstContactAction',
52 + 'getresponse' => 'FrmDefGetResponseAction',
53 + 'hubspot' => 'FrmDefHubspotAction',
54 + 'twilio' => 'FrmDefTwilioAction',
55 + 'highrise' => 'FrmDefHighriseAction',
56 + 'mailpoet' => 'FrmDefMailpoetAction',
57 + 'aweber' => 'FrmDefAweberAction',
78 58 );
79 59
80 - if ( ! FrmAppHelper::show_new_feature( 'n8n' ) ) {
81 - unset( $action_classes['n8n'] );
82 - }
83 -
84 60 $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes );
85 - $action_classes = self::maybe_unset_highrise( $action_classes );
86 61
87 - include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php';
88 - include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php';
62 + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' );
63 + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' );
89 64
90 65 foreach ( $action_classes as $action_class ) {
91 66 self::$registered_actions->register( $action_class );
92 67 }
@@ -92,24 +67,8 @@
92 67 }
93 68 }
94 69
95 70 /**
96 - * Remove the Highrise action if it is not registered.
97 - *
98 - * @since 6.23
99 - *
100 - * @param array $action_classes
101 - *
102 - * @return array
103 - */
104 - private static function maybe_unset_highrise( $action_classes ) {
105 - if ( 'FrmDefHighriseAction' === ( $action_classes['highrise'] ?? '' ) ) {
106 - unset( $action_classes['highrise'] );
107 - }
108 - return $action_classes;
109 - }
110 -
111 - /**
112 71 * @since 4.0
113 72 *
114 73 * @param array $values
115 74 */
@@ -121,9 +80,9 @@
121 80 self::maybe_add_action_to_group( $action_controls, $groups );
122 81
123 82 $allowed = self::active_actions( $action_controls );
124 83
125 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/settings.php';
84 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/settings.php' );
126 85 }
127 86
128 87 /**
129 88 * Add unknown actions to a group.
@@ -128,17 +87,11 @@
128 87 /**
129 88 * Add unknown actions to a group.
130 89 *
131 90 * @since 4.0
132 - *
133 - * @param array $action_controls
134 - * @param array $groups
135 - *
136 - * @return void
137 91 */
138 92 private static function maybe_add_action_to_group( $action_controls, &$groups ) {
139 93 $grouped = array();
140 -
141 94 foreach ( $groups as $group ) {
142 95 if ( isset( $group['actions'] ) ) {
143 96 $grouped = array_merge( $grouped, $group['actions'] );
144 97 }
@@ -149,9 +102,8 @@
149 102 continue;
150 103 }
151 104
152 105 $this_group = $action->action_options['group'];
153 -
154 106 if ( ! isset( $groups[ $this_group ] ) ) {
155 107 $this_group = 'misc';
156 108 }
157 109
@@ -170,9 +122,9 @@
170 122 * @return array
171 123 */
172 124 public static function form_action_groups() {
173 125 $groups = array(
174 - 'misc' => array(
126 + 'misc' => array(
175 127 'name' => '',
176 128 'icon' => 'frm_icon_font frm_shuffle_icon',
177 129 'actions' => array(
178 130 'email',
@@ -177,10 +129,8 @@
177 129 'actions' => array(
178 130 'email',
179 131 'wppost',
180 132 'register',
181 - 'quiz',
182 - 'quiz_outcome',
183 133 'twilio',
184 134 ),
185 135 ),
186 136 'payment' => array(
@@ -200,15 +150,18 @@
200 150 'constantcontact',
201 151 'getresponse',
202 152 'aweber',
203 153 'mailpoet',
204 - 'convertkit',
205 154 ),
206 155 ),
207 156 'crm' => array(
208 157 'name' => __( 'CRM', 'formidable' ),
209 158 'icon' => 'frm_icon_font frm_address_card_icon',
210 - 'actions' => self::get_crm_actions(),
159 + 'actions' => array(
160 + 'salesforce',
161 + 'hubspot',
162 + 'highrise',
163 + ),
211 164 ),
212 165 );
213 166
214 167 return apply_filters( 'frm_action_groups', $groups );
@@ -214,41 +167,16 @@
214 167 return apply_filters( 'frm_action_groups', $groups );
215 168 }
216 169
217 170 /**
218 - * Get the actions to include in the CRM section.
219 - *
220 - * @since 6.23
221 - *
222 - * @return array
223 - */
224 - private static function get_crm_actions() {
225 - $crm_actions = array(
226 - 'salesforce',
227 - 'hubspot',
228 - );
229 -
230 - // Only include Highrise when the add-on is active.
231 - // This is because Highrise is deprecated. We don't want to show it in Lite.
232 - if ( class_exists( 'FrmHrsSettings' ) ) {
233 - $crm_actions[] = 'highrise';
234 - }
235 -
236 - return $crm_actions;
237 - }
238 -
239 - /**
240 171 * Get the number of currently active form actions.
241 172 *
242 173 * @since 4.0
243 174 *
244 - * @param array $action_controls
245 - *
246 175 * @return array
247 176 */
248 177 private static function active_actions( $action_controls ) {
249 178 $allowed = array();
250 -
251 179 foreach ( $action_controls as $action_control ) {
252 180 if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) {
253 181 $allowed[] = $action_control->id_base;
254 182 }
@@ -259,9 +187,8 @@
259 187 /**
260 188 * For each add-on, add an li, class, and javascript function. If active, add an additional class.
261 189 *
262 190 * @since 4.0
263 - *
264 191 * @param object $action_control
265 192 * @param array $allowed
266 193 */
267 194 public static function show_action_icon_link( $action_control, $allowed ) {
@@ -272,9 +199,9 @@
272 199
273 200 /* translators: %s: Name of form action */
274 201 $upgrade_label = sprintf( esc_html__( '%s form actions', 'formidable' ), $action_control->action_options['tooltip'] );
275 202
276 - $default_shown = array( 'wppost', 'register', 'payment', 'quiz', 'hubspot' );
203 + $default_shown = array( 'wppost', 'register', 'paypal', 'payment', 'mailchimp' );
277 204 $default_shown = array_values( array_diff( $default_shown, $allowed ) );
278 205 $default_position = array_search( $action_control->id_base, $default_shown );
279 206 $allowed_count = count( $allowed );
280 207
@@ -281,9 +208,8 @@
281 208 if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) {
282 209 $classes .= ' frm_active_action';
283 210 } else {
284 211 $classes .= ' frm_inactive_action';
285 -
286 212 if ( $default_position !== false && ( $allowed_count + $default_position ) < 6 ) {
287 213 $group_class .= ' frm-default-show';
288 214 }
289 215
@@ -290,44 +216,26 @@
290 216 $data['data-upgrade'] = $upgrade_label;
291 217 $data['data-medium'] = 'settings-' . $action_control->id_base;
292 218
293 219 $upgrading = FrmAddonsController::install_link( $action_control->action_options['plugin'] );
294 -
295 220 if ( isset( $upgrading['url'] ) ) {
296 221 $data['data-oneclick'] = json_encode( $upgrading );
297 222 }
223 + }
298 224
299 - if ( isset( $action_control->action_options['message'] ) ) {
300 - $data['data-message'] = $action_control->action_options['message'];
301 - }
302 -
303 - $requires = FrmFormsHelper::get_plan_required( $upgrading );
304 -
305 - if ( $requires && 'free' !== $requires ) {
306 - $data['data-requires'] = $requires;
307 - }
308 - }//end if
309 -
310 225 // HTML to include on the icon.
311 226 $icon_atts = array();
312 -
313 - if ( $action_control->action_options['color'] !== 'var(--primary-700)' ) {
227 + if ( $action_control->action_options['color'] !== 'var(--primary-hover)' ) {
314 228 $icon_atts = array(
315 - 'style' => '--primary-700:' . $action_control->action_options['color'],
229 + 'style' => '--primary-hover:' . $action_control->action_options['color'],
316 230 );
317 231 }
318 232
319 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php';
233 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php' );
320 234 }
321 235
322 - /**
323 - * @param string $action
324 - *
325 - * @return array|FrmFormAction A single form action is returned when a specific $action value is requested.
326 - */
327 236 public static function get_form_actions( $action = 'all' ) {
328 237 $temp_actions = self::$registered_actions;
329 -
330 238 if ( empty( $temp_actions ) ) {
331 239 self::actions_init();
332 240 $temp_actions = self::$registered_actions->actions;
333 241 } else {
@@ -336,9 +244,9 @@
336 244
337 245 $actions = array();
338 246
339 247 foreach ( $temp_actions as $a ) {
340 - if ( 'all' !== $action && $a->id_base == $action ) {
248 + if ( 'all' != $action && $a->id_base == $action ) {
341 249 return $a;
342 250 }
343 251
344 252 $actions[ $a->id_base ] = $a;
@@ -348,13 +256,8 @@
348 256 }
349 257
350 258 /**
351 259 * @since 2.0
352 - *
353 - * @param object $form
354 - * @param array $values
355 - *
356 - * @return void
357 260 */
358 261 public static function list_actions( $form, $values ) {
359 262 if ( empty( $form ) ) {
360 263 return;
@@ -371,11 +274,8 @@
371 274 'post_status' => 'all',
372 275 );
373 276 $form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters );
374 277
375 - /**
376 - * @var array
377 - */
378 278 $action_controls = self::get_form_actions();
379 279
380 280 $action_map = array();
381 281
@@ -382,10 +282,8 @@
382 282 foreach ( $action_controls as $key => $control ) {
383 283 $action_map[ $control->id_base ] = $key;
384 284 }
385 285
386 - self::maybe_show_limit_warning( $form->id, $form_actions );
387 -
388 286 foreach ( $form_actions as $action ) {
389 287 if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
390 288 // don't try and show settings if action no longer exists
391 289 continue;
@@ -394,60 +292,14 @@
394 292 self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
395 293 }
396 294 }
397 295
398 - /**
399 - * Show a warning before the form actions list if there are 99 actions, and the limit is set to 99.
400 - * If it is filtered, the warning is still shown when applicable, just using the new limit.
401 - *
402 - * @since 6.17
403 - *
404 - * @param int|string $form_id
405 - * @param array $form_actions
406 - *
407 - * @return void
408 - */
409 - private static function maybe_show_limit_warning( $form_id, $form_actions ) {
410 - $count = count( $form_actions );
411 -
412 - if ( $count < 99 ) {
413 - return;
414 - }
415 -
416 - $limit = FrmFormAction::get_action_limit( $form_id );
417 -
418 - if ( $limit < 99 || $count < $limit ) {
419 - return;
420 - }
421 -
422 - $documentation_url = 'https://formidableforms.com/knowledgebase/frm_form_action_limit/#kb-increase-limit-of-form-actions';
423 -
424 - echo '<div class="frm_warning_style">';
425 - FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon' );
426 - echo '&nbsp;';
427 - printf(
428 - // translators: %s: URL to documentation
429 - esc_html__( 'You have reached your form action limit. To increase this limit, you will require additional code. Visit our documentation at %s.', 'formidable' ),
430 - '<a href="' . esc_url( $documentation_url ) . '" target="_blank">' . esc_html( $documentation_url ) . '</a>'
431 - );
432 - echo '</div>';
433 - }
434 -
435 - /**
436 - * @param WP_Post $form_action
437 - * @param object $form
438 - * @param int $action_key Action ID.
439 - * @param FrmFormAction $action_control
440 - * @param array $values
441 - *
442 - * @return void
443 - */
444 296 public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
445 297 $action_control->_set( $action_key );
446 298
447 299 $use_logging = self::should_show_log_message( $form_action->post_excerpt );
448 300
449 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php';
301 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
450 302 }
451 303
452 304 public static function add_form_action() {
453 305 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -457,11 +309,8 @@
457 309
458 310 $action_key = FrmAppHelper::get_param( 'list_id', '', 'post', 'absint' );
459 311 $action_type = FrmAppHelper::get_param( 'type', '', 'post', 'sanitize_text_field' );
460 312
461 - /**
462 - * @var FrmFormAction
463 - */
464 313 $action_control = self::get_form_actions( $action_type );
465 314 $action_control->_set( $action_key );
466 315
467 316 $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' );
@@ -471,9 +320,9 @@
471 320
472 321 $values = array();
473 322 $form = self::fields_to_values( $form_id, $values );
474 323
475 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php';
324 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' );
476 325 wp_die();
477 326 }
478 327
479 328 public static function fill_action() {
@@ -483,9 +332,8 @@
483 332 $action_key = FrmAppHelper::get_param( 'action_id', '', 'post', 'absint' );
484 333 $action_type = FrmAppHelper::get_param( 'action_type', '', 'post', 'sanitize_text_field' );
485 334
486 335 $action_control = self::get_form_actions( $action_type );
487 -
488 336 if ( empty( $action_control ) ) {
489 337 wp_die();
490 338 }
491 339
@@ -495,30 +343,21 @@
495 343 $form = self::fields_to_values( $form_action->menu_order, $values );
496 344
497 345 $use_logging = self::should_show_log_message( $action_type );
498 346
499 - include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php';
347 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' );
500 348 wp_die();
501 349 }
502 350
503 351 /**
504 352 * @since 3.06.04
505 - *
506 - * @param string $action_type
507 - *
508 353 * @return bool
509 354 */
510 355 private static function should_show_log_message( $action_type ) {
511 356 $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' );
512 - return in_array( $action_type, $logging, true ) && ! function_exists( 'frm_log_autoloader' );
357 + return in_array( $action_type, $logging ) && ! function_exists( 'frm_log_autoloader' );
513 358 }
514 359
515 - /**
516 - * @param int|string $form_id
517 - * @param array $values
518 - *
519 - * @return object
520 - */
521 360 private static function fields_to_values( $form_id, array &$values ) {
522 361 $form = FrmForm::getOne( $form_id );
523 362
524 363 $values = array(
@@ -526,14 +365,12 @@
526 365 'id' => $form->id,
527 366 );
528 367
529 368 $fields = FrmField::get_all_for_form( $form->id );
530 -
531 369 foreach ( $fields as $k => $f ) {
532 370 $f = (array) $f;
533 371 $opts = (array) $f['field_options'];
534 372 $f = array_merge( $opts, $f );
535 -
536 373 if ( ! isset( $f['post_field'] ) ) {
537 374 $f['post_field'] = '';
538 375 }
539 376 $values['fields'][] = $f;
@@ -542,33 +379,12 @@
542 379
543 380 return $form;
544 381 }
545 382
546 - /**
547 - * @param int $form_id
548 - *
549 - * @return void
550 - */
551 383 public static function update_settings( $form_id ) {
552 - FrmAppHelper::permission_check( 'frm_edit_forms' );
553 384 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
554 -
555 385 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
556 - $frm_settings = FrmAppHelper::get_settings();
557 - $error_args = array(
558 - 'title' => __( 'Verification failed', 'formidable' ),
559 - 'body' => $frm_settings->admin_permission,
560 - 'cancel_url' => add_query_arg(
561 - array(
562 - 'page' => 'formidable',
563 - 'frm_action' => 'settings',
564 - 'id' => $form_id,
565 - ),
566 - admin_url( 'admin.php?' )
567 - ),
568 - );
569 - FrmAppController::show_error_modal( $error_args );
570 - return;
386 + wp_die( esc_html__( 'You do not have permission to do that', 'formidable' ) );
571 387 }
572 388
573 389 global $wpdb;
574 390
@@ -585,9 +401,8 @@
585 401 $new_actions = array();
586 402
587 403 foreach ( $registered_actions as $registered_action ) {
588 404 $action_ids = $registered_action->update_callback( $form_id );
589 -
590 405 if ( ! empty( $action_ids ) ) {
591 406 $new_actions[] = $action_ids;
592 407 }
593 408 }
@@ -595,21 +410,13 @@
595 410 // Only use array_merge if there are new actions.
596 411 if ( ! empty( $new_actions ) ) {
597 412 $new_actions = call_user_func_array( 'array_merge', $new_actions );
598 413 }
599 -
600 414 $old_actions = array_diff( $old_actions, $new_actions );
601 415
602 416 self::delete_missing_actions( $old_actions );
603 -
604 - FrmOnSubmitHelper::save_on_submit_settings( $form_id );
605 417 }
606 418
607 - /**
608 - * @param array $old_actions
609 - *
610 - * @return void
611 - */
612 419 public static function delete_missing_actions( $old_actions ) {
613 420 if ( ! empty( $old_actions ) ) {
614 421 foreach ( $old_actions as $old_id ) {
615 422 wp_delete_post( $old_id );
@@ -617,46 +424,26 @@
617 424 FrmDb::cache_delete_group( 'frm_actions' );
618 425 }
619 426 }
620 427
621 - /**
622 - * @param int|string $entry_id
623 - * @param int|string $form_id
624 - * @param array $args
625 - *
626 - * @return void
627 - */
628 428 public static function trigger_create_actions( $entry_id, $form_id, $args = array() ) {
629 429 $filter_args = $args;
630 430 $filter_args['entry_id'] = $entry_id;
631 431 $filter_args['form_id'] = $form_id;
632 432
633 - /**
634 - * @since 2.0.23
635 - * @since 6.11.2 $filter_args is now passed instead of $args. It includes additional ID data.
636 - *
637 - * @param string $event 'create' by default. Pro may filter this value to 'draft' instead.
638 - * @param array $filter_args
639 - */
640 - $event = apply_filters( 'frm_trigger_create_action', 'create', $filter_args );
433 + $event = apply_filters( 'frm_trigger_create_action', 'create', $args );
641 434
642 435 self::trigger_actions( $event, $form_id, $entry_id, 'all', $args );
643 436 }
644 437
645 438 /**
646 - * @param string $event
647 - * @param int|object|string $form
648 - * @param int|string $entry
649 - * @param string $type
650 - * @param array $args
651 - *
652 - * @return void
439 + * @param string $event
653 440 */
654 441 public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
655 442 $action_status = array(
656 443 'post_status' => 'publish',
657 444 );
658 - $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status );
445 + $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type, $action_status );
659 446
660 447 if ( empty( $form_actions ) ) {
661 448 return;
662 449 }
@@ -662,15 +449,10 @@
662 449 }
663 450
664 451 FrmForm::maybe_get_form( $form );
665 452
666 - if ( ! is_object( $form ) ) {
667 - return;
668 - }
669 -
670 453 $link_settings = self::get_form_actions( $type );
671 -
672 - if ( 'all' !== $type ) {
454 + if ( 'all' != $type ) {
673 455 $link_settings = array( $type => $link_settings );
674 456 }
675 457
676 458 $stored_actions = array();
@@ -675,9 +457,9 @@
675 457
676 458 $stored_actions = array();
677 459 $action_priority = array();
678 460
679 - if ( in_array( $event, array( 'create', 'update' ), true ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
461 + if ( in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
680 462 $this_event = 'import';
681 463 } else {
682 464 $this_event = $event;
683 465 }
@@ -683,11 +465,10 @@
683 465 }
684 466
685 467 foreach ( $form_actions as $action ) {
686 468
687 - $skip_this_action = ! in_array( $this_event, $action->post_content['event'], true ) || FrmOnSubmitAction::$slug === $action->post_excerpt;
469 + $skip_this_action = ( ! in_array( $this_event, $action->post_content['event'] ) );
688 470 $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) );
689 -
690 471 if ( $skip_this_action ) {
691 472 continue;
692 473 }
693 474
@@ -694,18 +475,17 @@
694 475 if ( ! is_object( $entry ) ) {
695 476 $entry = FrmEntry::getOne( $entry, true );
696 477 }
697 478
698 - if ( empty( $entry ) || ( FrmEntriesHelper::DRAFT_ENTRY_STATUS === (int) $entry->is_draft && 'draft' !== $event ) ) {
479 + if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) {
699 480 continue;
700 481 }
701 482
702 - $child_entry = ( is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ! empty( $args['is_child'] );
483 + $child_entry = ( ( is_object( $form ) && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) );
703 484
704 485 if ( $child_entry ) {
705 486 // maybe trigger actions for sub forms
706 487 $trigger_children = apply_filters( 'frm_use_embedded_form_actions', false, compact( 'form', 'entry' ) );
707 -
708 488 if ( ! $trigger_children ) {
709 489 continue;
710 490 }
711 491 }
@@ -711,9 +491,8 @@
711 491 }
712 492
713 493 // Check conditional logic.
714 494 $stop = FrmFormAction::action_conditions_met( $action, $entry );
715 -
716 495 if ( $stop ) {
717 496 continue;
718 497 }
719 498
@@ -721,9 +500,9 @@
721 500 $stored_actions[ $action->ID ] = $action;
722 501 $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
723 502
724 503 unset( $action );
725 - }//end foreach
504 + }
726 505
727 506 if ( ! empty( $stored_actions ) ) {
728 507 asort( $action_priority );
729 508
@@ -731,49 +510,25 @@
731 510 new FrmNotification();
732 511
733 512 foreach ( $action_priority as $action_id => $priority ) {
734 513 $action = $stored_actions[ $action_id ];
514 + do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
515 + do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
735 516
736 - /**
737 - * Allows custom form action trigger.
738 - *
739 - * @since 6.10
740 - *
741 - * @param bool $skip Skip default trigger.
742 - * @param object $action Action object.
743 - * @param object $entry Entry object.
744 - * @param object $form Form object.
745 - * @param string $event Event ('create' or 'update').
746 - */
747 - if ( false === apply_filters( 'frm_custom_trigger_action', false, $action, $entry, $form, $event ) ) {
748 - do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
749 - do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
750 - }
751 -
752 517 // If post is created, get updated $entry object.
753 - if ( $action->post_excerpt === 'wppost' && $event === 'create' ) {
518 + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
754 519 $entry = FrmEntry::getOne( $entry->id, true );
755 520 }
756 - }//end foreach
757 - }//end if
521 + }
522 + }
758 523 }
759 524
760 - /**
761 - * @param int|string $form_id
762 - * @param array $values
763 - * @param array $args
764 - *
765 - * @return void
766 - */
767 525 public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
768 - if ( empty( $args['old_id'] ) ) {
526 + if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
769 527 // Continue if we know which actions to copy.
770 528 return;
771 529 }
772 530
773 - /**
774 - * @var array
775 - */
776 531 $action_controls = self::get_form_actions();
777 532
778 533 foreach ( $action_controls as $action_control ) {
779 534 $action_control->duplicate_form_actions( $form_id, $args['old_id'] );
@@ -780,13 +535,8 @@
780 535 unset( $action_control );
781 536 }
782 537 }
783 538
784 - /**
785 - * @param string $where
786 - *
787 - * @return string
788 - */
789 539 public static function limit_by_type( $where ) {
790 540 global $frm_vars, $wpdb;
791 541
792 542 if ( ! isset( $frm_vars['action_type'] ) ) {
@@ -796,32 +546,11 @@
796 546 $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
797 547
798 548 return $where;
799 549 }
800 -
801 - /**
802 - * Prevent WPML from filtering form actions based on the active language.
803 - *
804 - * @since 6.20
805 - *
806 - * @param bool|null $null
807 - * @param string $post_type
808 - *
809 - * @return bool|null
810 - */
811 - public static function prevent_wpml_translations( $null, $post_type ) {
812 - if ( self::$action_post_type === $post_type ) {
813 - return false;
814 - }
815 - return $null;
816 - }
817 550 }
818 551
819 552 class Frm_Form_Action_Factory {
820 -
821 - /**
822 - * @var array
823 - */
824 553 public $actions = array();
825 554
826 555 public function __construct() {
827 556 add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 );
@@ -826,22 +555,12 @@
826 555 public function __construct() {
827 556 add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 );
828 557 }
829 558
830 - /**
831 - * @param string $action_class
832 - *
833 - * @return void
834 - */
835 559 public function register( $action_class ) {
836 560 $this->actions[ $action_class ] = new $action_class();
837 561 }
838 562
839 - /**
840 - * @param string $action_class
841 - *
842 - * @return void
843 - */
844 563 public function unregister( $action_class ) {
845 564 if ( isset( $this->actions[ $action_class ] ) ) {
846 565 unset( $this->actions[ $action_class ] );
847 566 }