PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.19
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.19
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 +103 -15 6.4.26.19 View file →
@@ -4,8 +4,12 @@
4 4 }
5 5
6 6 class FrmFormActionsController {
7 7 public static $action_post_type = 'frm_form_actions';
8 +
9 + /**
10 + * @var array|null
11 + */
8 12 public static $registered_actions;
9 13
10 14 /**
11 15 * Variables saved in the post:
@@ -48,9 +52,9 @@
48 52 'email' => 'FrmEmailAction',
49 53 'wppost' => 'FrmDefPostAction',
50 54 'register' => 'FrmDefRegAction',
51 55 'paypal' => 'FrmDefPayPalAction',
52 - 'payment' => 'FrmDefHrsAction',
56 + 'payment' => 'FrmTransLiteAction',
53 57 'quiz' => 'FrmDefQuizAction',
54 58 'quiz_outcome' => 'FrmDefQuizOutcomeAction',
55 59 'mailchimp' => 'FrmDefMlcmpAction',
56 60 'api' => 'FrmDefApiAction',
@@ -63,8 +67,9 @@
63 67 'twilio' => 'FrmDefTwilioAction',
64 68 'highrise' => 'FrmDefHighriseAction',
65 69 'mailpoet' => 'FrmDefMailpoetAction',
66 70 'aweber' => 'FrmDefAweberAction',
71 + 'convertkit' => 'FrmDefConvertKitAction',
67 72 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction',
68 73 );
69 74
70 75 $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes );
@@ -240,9 +245,9 @@
240 245 $requires = FrmFormsHelper::get_plan_required( $upgrading );
241 246 if ( $requires && 'free' !== $requires ) {
242 247 $data['data-requires'] = $requires;
243 248 }
244 - }
249 + }//end if
245 250
246 251 // HTML to include on the icon.
247 252 $icon_atts = array();
248 253 if ( $action_control->action_options['color'] !== 'var(--primary-700)' ) {
@@ -253,8 +258,12 @@
253 258
254 259 include FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_icon.php';
255 260 }
256 261
262 + /**
263 + * @param string $action
264 + * @return array|FrmFormAction A single form action is returned when a specific $action value is requested.
265 + */
257 266 public static function get_form_actions( $action = 'all' ) {
258 267 $temp_actions = self::$registered_actions;
259 268 if ( empty( $temp_actions ) ) {
260 269 self::actions_init();
@@ -265,9 +274,9 @@
265 274
266 275 $actions = array();
267 276
268 277 foreach ( $temp_actions as $a ) {
269 - if ( 'all' != $action && $a->id_base == $action ) {
278 + if ( 'all' !== $action && $a->id_base == $action ) {
270 279 return $a;
271 280 }
272 281
273 282 $actions[ $a->id_base ] = $a;
@@ -295,8 +304,11 @@
295 304 'post_status' => 'all',
296 305 );
297 306 $form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters );
298 307
308 + /**
309 + * @var array
310 + */
299 311 $action_controls = self::get_form_actions();
300 312
301 313 $action_map = array();
302 314
@@ -303,8 +315,10 @@
303 315 foreach ( $action_controls as $key => $control ) {
304 316 $action_map[ $control->id_base ] = $key;
305 317 }
306 318
319 + self::maybe_show_limit_warning( $form->id, $form_actions );
320 +
307 321 foreach ( $form_actions as $action ) {
308 322 if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
309 323 // don't try and show settings if action no longer exists
310 324 continue;
@@ -313,8 +327,42 @@
313 327 self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values );
314 328 }
315 329 }
316 330
331 + /**
332 + * Show a warning before the form actions list if there are 99 actions, and the limit is set to 99.
333 + * If it is filtered, the warning is still shown when applicable, just using the new limit.
334 + *
335 + * @since 6.17
336 + *
337 + * @param int|string $form_id
338 + * @param array $form_actions
339 + * @return void
340 + */
341 + private static function maybe_show_limit_warning( $form_id, $form_actions ) {
342 + $count = count( $form_actions );
343 + if ( $count < 99 ) {
344 + return;
345 + }
346 +
347 + $limit = FrmFormAction::get_action_limit( $form_id );
348 + if ( $limit < 99 || $count < $limit ) {
349 + return;
350 + }
351 +
352 + $documentation_url = 'https://formidableforms.com/knowledgebase/frm_form_action_limit/#kb-increase-limit-of-form-actions';
353 +
354 + echo '<div class="frm_warning_style">';
355 + FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon' );
356 + echo '&nbsp;';
357 + printf(
358 + // translators: %s: URL to documentation
359 + esc_html__( 'You have reached your form action limit. To increase this limit, you will require additional code. Visit our documentation at %s.', 'formidable' ),
360 + '<a href="' . esc_url( $documentation_url ) . '" target="_blank">' . esc_html( $documentation_url ) . '</a>'
361 + );
362 + echo '</div>';
363 + }
364 +
317 365 public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
318 366 $action_control->_set( $action_key );
319 367
320 368 $use_logging = self::should_show_log_message( $form_action->post_excerpt );
@@ -330,8 +378,11 @@
330 378
331 379 $action_key = FrmAppHelper::get_param( 'list_id', '', 'post', 'absint' );
332 380 $action_type = FrmAppHelper::get_param( 'type', '', 'post', 'sanitize_text_field' );
333 381
382 + /**
383 + * @var FrmFormAction
384 + */
334 385 $action_control = self::get_form_actions( $action_type );
335 386 $action_control->_set( $action_key );
336 387
337 388 $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' );
@@ -374,9 +425,9 @@
374 425 * @return bool
375 426 */
376 427 private static function should_show_log_message( $action_type ) {
377 428 $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' );
378 - return in_array( $action_type, $logging ) && ! function_exists( 'frm_log_autoloader' );
429 + return in_array( $action_type, $logging, true ) && ! function_exists( 'frm_log_autoloader' );
379 430 }
380 431
381 432 private static function fields_to_values( $form_id, array &$values ) {
382 433 $form = FrmForm::getOne( $form_id );
@@ -409,9 +460,22 @@
409 460 FrmAppHelper::permission_check( 'frm_edit_forms' );
410 461 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
411 462 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
412 463 $frm_settings = FrmAppHelper::get_settings();
413 - wp_die( esc_html( $frm_settings->admin_permission ) );
464 + $error_args = array(
465 + 'title' => __( 'Verification failed', 'formidable' ),
466 + 'body' => $frm_settings->admin_permission,
467 + 'cancel_url' => add_query_arg(
468 + array(
469 + 'page' => 'formidable',
470 + 'frm_action' => 'settings',
471 + 'id' => $form_id,
472 + ),
473 + admin_url( 'admin.php?' )
474 + ),
475 + );
476 + FrmAppController::show_error_modal( $error_args );
477 + return;
414 478 }
415 479
416 480 global $wpdb;
417 481
@@ -458,9 +522,16 @@
458 522 $filter_args = $args;
459 523 $filter_args['entry_id'] = $entry_id;
460 524 $filter_args['form_id'] = $form_id;
461 525
462 - $event = apply_filters( 'frm_trigger_create_action', 'create', $args );
526 + /**
527 + * @since 2.0.23
528 + * @since 6.11.2 $filter_args is now passed instead of $args. It includes additional ID data.
529 + *
530 + * @param string $event 'create' by default. Pro may filter this value to 'draft' instead.
531 + * @param array $filter_args
532 + */
533 + $event = apply_filters( 'frm_trigger_create_action', 'create', $filter_args );
463 534
464 535 self::trigger_actions( $event, $form_id, $entry_id, 'all', $args );
465 536 }
466 537
@@ -479,9 +550,9 @@
479 550
480 551 FrmForm::maybe_get_form( $form );
481 552
482 553 $link_settings = self::get_form_actions( $type );
483 - if ( 'all' != $type ) {
554 + if ( 'all' !== $type ) {
484 555 $link_settings = array( $type => $link_settings );
485 556 }
486 557
487 558 $stored_actions = array();
@@ -486,9 +557,9 @@
486 557
487 558 $stored_actions = array();
488 559 $action_priority = array();
489 560
490 - if ( in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
561 + if ( in_array( $event, array( 'create', 'update' ), true ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
491 562 $this_event = 'import';
492 563 } else {
493 564 $this_event = $event;
494 565 }
@@ -529,9 +600,9 @@
529 600 $stored_actions[ $action->ID ] = $action;
530 601 $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority'];
531 602
532 603 unset( $action );
533 - }
604 + }//end foreach
534 605
535 606 if ( ! empty( $stored_actions ) ) {
536 607 asort( $action_priority );
537 608
@@ -539,25 +610,42 @@
539 610 new FrmNotification();
540 611
541 612 foreach ( $action_priority as $action_id => $priority ) {
542 613 $action = $stored_actions[ $action_id ];
543 - do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
544 - do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
545 614
615 + /**
616 + * Allows custom form action trigger.
617 + *
618 + * @since 6.10
619 + *
620 + * @param bool $skip Skip default trigger.
621 + * @param object $action Action object.
622 + * @param object $entry Entry object.
623 + * @param object $form Form object.
624 + * @param string $event Event ('create' or 'update').
625 + */
626 + if ( false === apply_filters( 'frm_custom_trigger_action', false, $action, $entry, $form, $event ) ) {
627 + do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event );
628 + do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form );
629 + }
630 +
546 631 // If post is created, get updated $entry object.
547 - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) {
632 + if ( $action->post_excerpt === 'wppost' && $event === 'create' ) {
548 633 $entry = FrmEntry::getOne( $entry->id, true );
549 634 }
550 - }
551 - }
635 + }//end foreach
636 + }//end if
552 637 }
553 638
554 639 public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
555 - if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) {
640 + if ( empty( $args['old_id'] ) ) {
556 641 // Continue if we know which actions to copy.
557 642 return;
558 643 }
559 644
645 + /**
646 + * @var array
647 + */
560 648 $action_controls = self::get_form_actions();
561 649
562 650 foreach ( $action_controls as $action_control ) {
563 651 $action_control->duplicate_form_actions( $form_id, $args['old_id'] );