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