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