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