PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.17
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.17
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 +7 -171 6.266.17 View file →
@@ -3,12 +3,8 @@
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 8
13 9 /**
14 10 * @var array|null
@@ -67,9 +63,8 @@
67 63 'constantcontact' => 'FrmDefConstContactAction',
68 64 'getresponse' => 'FrmDefGetResponseAction',
69 65 'hubspot' => 'FrmDefHubspotAction',
70 66 'zapier' => 'FrmDefZapierAction',
71 - 'n8n' => 'FrmDefN8NAction',
72 67 'twilio' => 'FrmDefTwilioAction',
73 68 'highrise' => 'FrmDefHighriseAction',
74 69 'mailpoet' => 'FrmDefMailpoetAction',
75 70 'aweber' => 'FrmDefAweberAction',
@@ -76,14 +71,9 @@
76 71 'convertkit' => 'FrmDefConvertKitAction',
77 72 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction',
78 73 );
79 74
80 - if ( ! FrmAppHelper::show_new_feature( 'n8n' ) ) {
81 - unset( $action_classes['n8n'] );
82 - }
83 -
84 75 $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes );
85 - $action_classes = self::maybe_unset_highrise( $action_classes );
86 76
87 77 include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php';
88 78 include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php';
89 79
@@ -92,24 +82,8 @@
92 82 }
93 83 }
94 84
95 85 /**
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 86 * @since 4.0
113 87 *
114 88 * @param array $values
115 89 */
@@ -128,17 +102,11 @@
128 102 /**
129 103 * Add unknown actions to a group.
130 104 *
131 105 * @since 4.0
132 - *
133 - * @param array $action_controls
134 - * @param array $groups
135 - *
136 - * @return void
137 106 */
138 107 private static function maybe_add_action_to_group( $action_controls, &$groups ) {
139 108 $grouped = array();
140 -
141 109 foreach ( $groups as $group ) {
142 110 if ( isset( $group['actions'] ) ) {
143 111 $grouped = array_merge( $grouped, $group['actions'] );
144 112 }
@@ -149,9 +117,8 @@
149 117 continue;
150 118 }
151 119
152 120 $this_group = $action->action_options['group'];
153 -
154 121 if ( ! isset( $groups[ $this_group ] ) ) {
155 122 $this_group = 'misc';
156 123 }
157 124
@@ -200,15 +167,18 @@
200 167 'constantcontact',
201 168 'getresponse',
202 169 'aweber',
203 170 'mailpoet',
204 - 'convertkit',
205 171 ),
206 172 ),
207 173 'crm' => array(
208 174 'name' => __( 'CRM', 'formidable' ),
209 175 'icon' => 'frm_icon_font frm_address_card_icon',
210 - 'actions' => self::get_crm_actions(),
176 + 'actions' => array(
177 + 'salesforce',
178 + 'hubspot',
179 + 'highrise',
180 + ),
211 181 ),
212 182 );
213 183
214 184 return apply_filters( 'frm_action_groups', $groups );
@@ -214,41 +184,16 @@
214 184 return apply_filters( 'frm_action_groups', $groups );
215 185 }
216 186
217 187 /**
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 188 * Get the number of currently active form actions.
241 189 *
242 190 * @since 4.0
243 191 *
244 - * @param array $action_controls
245 - *
246 192 * @return array
247 193 */
248 194 private static function active_actions( $action_controls ) {
249 195 $allowed = array();
250 -
251 196 foreach ( $action_controls as $action_control ) {
252 197 if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) {
253 198 $allowed[] = $action_control->id_base;
254 199 }
@@ -259,9 +204,8 @@
259 204 /**
260 205 * For each add-on, add an li, class, and javascript function. If active, add an additional class.
261 206 *
262 207 * @since 4.0
263 - *
264 208 * @param object $action_control
265 209 * @param array $allowed
266 210 */
267 211 public static function show_action_icon_link( $action_control, $allowed ) {
@@ -281,9 +225,8 @@
281 225 if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) {
282 226 $classes .= ' frm_active_action';
283 227 } else {
284 228 $classes .= ' frm_inactive_action';
285 -
286 229 if ( $default_position !== false && ( $allowed_count + $default_position ) < 6 ) {
287 230 $group_class .= ' frm-default-show';
288 231 }
289 232
@@ -290,9 +233,8 @@
290 233 $data['data-upgrade'] = $upgrade_label;
291 234 $data['data-medium'] = 'settings-' . $action_control->id_base;
292 235
293 236 $upgrading = FrmAddonsController::install_link( $action_control->action_options['plugin'] );
294 -
295 237 if ( isset( $upgrading['url'] ) ) {
296 238 $data['data-oneclick'] = json_encode( $upgrading );
297 239 }
298 240
@@ -300,9 +242,8 @@
300 242 $data['data-message'] = $action_control->action_options['message'];
301 243 }
302 244
303 245 $requires = FrmFormsHelper::get_plan_required( $upgrading );
304 -
305 246 if ( $requires && 'free' !== $requires ) {
306 247 $data['data-requires'] = $requires;
307 248 }
308 249 }//end if
@@ -308,9 +249,8 @@
308 249 }//end if
309 250
310 251 // HTML to include on the icon.
311 252 $icon_atts = array();
312 -
313 253 if ( $action_control->action_options['color'] !== 'var(--primary-700)' ) {
314 254 $icon_atts = array(
315 255 'style' => '--primary-700:' . $action_control->action_options['color'],
316 256 );
@@ -320,14 +260,12 @@
320 260 }
321 261
322 262 /**
323 263 * @param string $action
324 - *
325 264 * @return array|FrmFormAction A single form action is returned when a specific $action value is requested.
326 265 */
327 266 public static function get_form_actions( $action = 'all' ) {
328 267 $temp_actions = self::$registered_actions;
329 -
330 268 if ( empty( $temp_actions ) ) {
331 269 self::actions_init();
332 270 $temp_actions = self::$registered_actions->actions;
333 271 } else {
@@ -348,13 +286,8 @@
348 286 }
349 287
350 288 /**
351 289 * @since 2.0
352 - *
353 - * @param object $form
354 - * @param array $values
355 - *
356 - * @return void
357 290 */
358 291 public static function list_actions( $form, $values ) {
359 292 if ( empty( $form ) ) {
360 293 return;
@@ -402,20 +335,17 @@
402 335 * @since 6.17
403 336 *
404 337 * @param int|string $form_id
405 338 * @param array $form_actions
406 - *
407 339 * @return void
408 340 */
409 341 private static function maybe_show_limit_warning( $form_id, $form_actions ) {
410 342 $count = count( $form_actions );
411 -
412 343 if ( $count < 99 ) {
413 344 return;
414 345 }
415 346
416 347 $limit = FrmFormAction::get_action_limit( $form_id );
417 -
418 348 if ( $limit < 99 || $count < $limit ) {
419 349 return;
420 350 }
421 351
@@ -431,17 +361,8 @@
431 361 );
432 362 echo '</div>';
433 363 }
434 364
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 365 public static function action_control( $form_action, $form, $action_key, $action_control, $values ) {
445 366 $action_control->_set( $action_key );
446 367
447 368 $use_logging = self::should_show_log_message( $form_action->post_excerpt );
@@ -483,9 +404,8 @@
483 404 $action_key = FrmAppHelper::get_param( 'action_id', '', 'post', 'absint' );
484 405 $action_type = FrmAppHelper::get_param( 'action_type', '', 'post', 'sanitize_text_field' );
485 406
486 407 $action_control = self::get_form_actions( $action_type );
487 -
488 408 if ( empty( $action_control ) ) {
489 409 wp_die();
490 410 }
491 411
@@ -501,11 +421,8 @@
501 421 }
502 422
503 423 /**
504 424 * @since 3.06.04
505 - *
506 - * @param string $action_type
507 - *
508 425 * @return bool
509 426 */
510 427 private static function should_show_log_message( $action_type ) {
511 428 $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' );
@@ -511,14 +428,8 @@
511 428 $logging = array( 'api', 'salesforce', 'constantcontact', 'activecampaign' );
512 429 return in_array( $action_type, $logging, true ) && ! function_exists( 'frm_log_autoloader' );
513 430 }
514 431
515 - /**
516 - * @param int|string $form_id
517 - * @param array $values
518 - *
519 - * @return object
520 - */
521 432 private static function fields_to_values( $form_id, array &$values ) {
522 433 $form = FrmForm::getOne( $form_id );
523 434
524 435 $values = array(
@@ -526,14 +437,12 @@
526 437 'id' => $form->id,
527 438 );
528 439
529 440 $fields = FrmField::get_all_for_form( $form->id );
530 -
531 441 foreach ( $fields as $k => $f ) {
532 442 $f = (array) $f;
533 443 $opts = (array) $f['field_options'];
534 444 $f = array_merge( $opts, $f );
535 -
536 445 if ( ! isset( $f['post_field'] ) ) {
537 446 $f['post_field'] = '';
538 447 }
539 448 $values['fields'][] = $f;
@@ -544,15 +453,13 @@
544 453 }
545 454
546 455 /**
547 456 * @param int $form_id
548 - *
549 457 * @return void
550 458 */
551 459 public static function update_settings( $form_id ) {
552 460 FrmAppHelper::permission_check( 'frm_edit_forms' );
553 461 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
554 -
555 462 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
556 463 $frm_settings = FrmAppHelper::get_settings();
557 464 $error_args = array(
558 465 'title' => __( 'Verification failed', 'formidable' ),
@@ -585,9 +492,8 @@
585 492 $new_actions = array();
586 493
587 494 foreach ( $registered_actions as $registered_action ) {
588 495 $action_ids = $registered_action->update_callback( $form_id );
589 -
590 496 if ( ! empty( $action_ids ) ) {
591 497 $new_actions[] = $action_ids;
592 498 }
593 499 }
@@ -595,9 +501,8 @@
595 501 // Only use array_merge if there are new actions.
596 502 if ( ! empty( $new_actions ) ) {
597 503 $new_actions = call_user_func_array( 'array_merge', $new_actions );
598 504 }
599 -
600 505 $old_actions = array_diff( $old_actions, $new_actions );
601 506
602 507 self::delete_missing_actions( $old_actions );
603 508
@@ -603,13 +508,8 @@
603 508
604 509 FrmOnSubmitHelper::save_on_submit_settings( $form_id );
605 510 }
606 511
607 - /**
608 - * @param array $old_actions
609 - *
610 - * @return void
611 - */
612 512 public static function delete_missing_actions( $old_actions ) {
613 513 if ( ! empty( $old_actions ) ) {
614 514 foreach ( $old_actions as $old_id ) {
615 515 wp_delete_post( $old_id );
@@ -617,15 +517,8 @@
617 517 FrmDb::cache_delete_group( 'frm_actions' );
618 518 }
619 519 }
620 520
621 - /**
622 - * @param int|string $entry_id
623 - * @param int|string $form_id
624 - * @param array $args
625 - *
626 - * @return void
627 - */
628 521 public static function trigger_create_actions( $entry_id, $form_id, $args = array() ) {
629 522 $filter_args = $args;
630 523 $filter_args['entry_id'] = $entry_id;
631 524 $filter_args['form_id'] = $form_id;
@@ -642,15 +535,9 @@
642 535 self::trigger_actions( $event, $form_id, $entry_id, 'all', $args );
643 536 }
644 537
645 538 /**
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
539 + * @param string $event
653 540 */
654 541 public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
655 542 $action_status = array(
656 543 'post_status' => 'publish',
@@ -662,14 +549,9 @@
662 549 }
663 550
664 551 FrmForm::maybe_get_form( $form );
665 552
666 - if ( ! is_object( $form ) ) {
667 - return;
668 - }
669 -
670 553 $link_settings = self::get_form_actions( $type );
671 -
672 554 if ( 'all' !== $type ) {
673 555 $link_settings = array( $type => $link_settings );
674 556 }
675 557
@@ -685,9 +567,8 @@
685 567 foreach ( $form_actions as $action ) {
686 568
687 569 $skip_this_action = ! in_array( $this_event, $action->post_content['event'], true ) || FrmOnSubmitAction::$slug === $action->post_excerpt;
688 570 $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) );
689 -
690 571 if ( $skip_this_action ) {
691 572 continue;
692 573 }
693 574
@@ -698,14 +579,13 @@
698 579 if ( empty( $entry ) || ( FrmEntriesHelper::DRAFT_ENTRY_STATUS === (int) $entry->is_draft && 'draft' !== $event ) ) {
699 580 continue;
700 581 }
701 582
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'] );
583 + $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 584
704 585 if ( $child_entry ) {
705 586 // maybe trigger actions for sub forms
706 587 $trigger_children = apply_filters( 'frm_use_embedded_form_actions', false, compact( 'form', 'entry' ) );
707 -
708 588 if ( ! $trigger_children ) {
709 589 continue;
710 590 }
711 591 }
@@ -711,9 +591,8 @@
711 591 }
712 592
713 593 // Check conditional logic.
714 594 $stop = FrmFormAction::action_conditions_met( $action, $entry );
715 -
716 595 if ( $stop ) {
717 596 continue;
718 597 }
719 598
@@ -756,15 +635,8 @@
756 635 }//end foreach
757 636 }//end if
758 637 }
759 638
760 - /**
761 - * @param int|string $form_id
762 - * @param array $values
763 - * @param array $args
764 - *
765 - * @return void
766 - */
767 639 public static function duplicate_form_actions( $form_id, $values, $args = array() ) {
768 640 if ( empty( $args['old_id'] ) ) {
769 641 // Continue if we know which actions to copy.
770 642 return;
@@ -780,13 +652,8 @@
780 652 unset( $action_control );
781 653 }
782 654 }
783 655
784 - /**
785 - * @param string $where
786 - *
787 - * @return string
788 - */
789 656 public static function limit_by_type( $where ) {
790 657 global $frm_vars, $wpdb;
791 658
792 659 if ( ! isset( $frm_vars['action_type'] ) ) {
@@ -796,32 +663,11 @@
796 663 $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] );
797 664
798 665 return $where;
799 666 }
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 667 }
818 668
819 669 class Frm_Form_Action_Factory {
820 -
821 - /**
822 - * @var array
823 - */
824 670 public $actions = array();
825 671
826 672 public function __construct() {
827 673 add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 );
@@ -826,22 +672,12 @@
826 672 public function __construct() {
827 673 add_action( 'frm_form_actions_init', array( $this, '_register_actions' ), 100 );
828 674 }
829 675
830 - /**
831 - * @param string $action_class
832 - *
833 - * @return void
834 - */
835 676 public function register( $action_class ) {
836 677 $this->actions[ $action_class ] = new $action_class();
837 678 }
838 679
839 - /**
840 - * @param string $action_class
841 - *
842 - * @return void
843 - */
844 680 public function unregister( $action_class ) {
845 681 if ( isset( $this->actions[ $action_class ] ) ) {
846 682 unset( $this->actions[ $action_class ] );
847 683 }