PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.07.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.07.01
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/models/FrmFormAction.php +17 -107 6.54.07.01 View file →
@@ -34,10 +34,9 @@
34 34
35 35 /**
36 36 * Echo the settings update form
37 37 *
38 - * @param WP_Post $instance Current settings
39 - * @param array $args
38 + * @param array $instance Current settings
40 39 */
41 40 public function form( $instance, $args = array() ) {
42 41 echo '<p class="no-options-widget">' . esc_html__( 'There are no options for this action.', 'formidable' ) . '</p>';
43 42
@@ -50,11 +49,8 @@
50 49 public function get_defaults() {
51 50 return array();
52 51 }
53 52
54 - /**
55 - * @return array
56 - */
57 53 public function get_switch_fields() {
58 54 return array();
59 55 }
60 56
@@ -97,9 +93,8 @@
97 93 'plugin' => $this->id_base,
98 94 'tooltip' => $name,
99 95 'group' => $id_base,
100 96 'color' => '',
101 - 'keywords' => '',
102 97 );
103 98
104 99 $action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
105 100 $group = $this->get_group( $action_options );
@@ -110,9 +105,9 @@
110 105 shuffle( $colors );
111 106 $action_options['color'] = 'var(--' . reset( $colors ) . ')';
112 107 }
113 108
114 - $upgrade_class = isset( $action_options['classes'] ) && $action_options['classes'] === 'frm_show_upgrade';
109 + $upgrade_class = $action_options['classes'] === 'frm_show_upgrade';
115 110 if ( $action_options['group'] === $id_base ) {
116 111 $upgrade_class = strpos( $action_options['classes'], 'frm_show_upgrade' ) !== false;
117 112 $action_options['classes'] = $group['icon'];
118 113 } elseif ( ! isset( $action_options['classes'] ) || empty( $action_options['classes'] ) || $upgrade_class ) {
@@ -134,23 +129,8 @@
134 129 self::__construct( $id_base, $name, $action_options, $control_options );
135 130 }
136 131
137 132 /**
138 - * Help to switch old field id by new field id for duplicate form
139 - *
140 - * @param string $action id of the field that needs to be switched
141 - *
142 - * @return string
143 - */
144 - public function maybe_switch_field_ids( $action ) {
145 - $updated_action = apply_filters( 'frm_maybe_switch_field_ids', $action );
146 - if ( $updated_action === $action ) {
147 - $updated_action = FrmFieldsHelper::switch_field_ids( $action );
148 - }
149 - return $updated_action;
150 - }
151 -
152 - /**
153 133 * @since 4.0
154 134 */
155 135 protected function get_group( $action_options ) {
156 136 $groups = FrmFormActionsController::form_action_groups();
@@ -202,20 +182,15 @@
202 182 public function get_field_id( $field_name ) {
203 183 return $field_name . '_' . $this->number;
204 184 }
205 185
206 - /**
207 - * @param int|string $number
208 - * @return void
209 - */
186 + // Private Function. Don't worry about this.
187 +
210 188 public function _set( $number ) {
211 189 $this->number = $number;
212 190 $this->id = $this->id_base . '-' . $number;
213 191 }
214 192
215 - /**
216 - * @return object
217 - */
218 193 public function prepare_new( $form_id = false ) {
219 194 if ( $form_id ) {
220 195 $this->form_id = $form_id;
221 196 }
@@ -252,11 +227,8 @@
252 227
253 228 return $this->save_settings( $action );
254 229 }
255 230
256 - /**
257 - * @return void
258 - */
259 231 public function duplicate_form_actions( $form_id, $old_id ) {
260 232 if ( $form_id == $old_id ) {
261 233 // don't duplicate the actions if this is a template getting updated
262 234 return;
@@ -292,17 +264,13 @@
292 264
293 265 return $post_id;
294 266 }
295 267
296 - /**
297 - * @param object $action
298 - */
299 268 public function duplicate_one( $action, $form_id ) {
300 269 global $frm_duplicate_ids;
301 270
302 271 $action->menu_order = $form_id;
303 272 $switch = $this->get_global_switch_fields();
304 -
305 273 foreach ( (array) $action->post_content as $key => $val ) {
306 274 if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
307 275 $action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
308 276 } elseif ( ! is_array( $val ) ) {
@@ -344,9 +312,9 @@
344 312 $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
345 313 } elseif ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
346 314 $action[ $ck ] = $frm_duplicate_ids[ $cv ];
347 315 } elseif ( $ck == $subkey ) {
348 - $action[ $ck ] = $this->maybe_switch_field_ids( $action[ $ck ] );
316 + $action[ $ck ] = FrmFieldsHelper::switch_field_ids( $action[ $ck ] );
349 317 }
350 318 }
351 319 }
352 320
@@ -367,12 +335,11 @@
367 335 if ( $this->updated ) {
368 336 return;
369 337 }
370 338
371 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
372 339 if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
373 340 // Sanitizing removes scripts and <email> type of values.
374 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
341 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
375 342 $settings = wp_unslash( $_POST[ $this->option_name ] );
376 343 } else {
377 344 return;
378 345 }
@@ -399,8 +366,9 @@
399 366 $new_instance['post_type'] = FrmFormActionsController::$action_post_type;
400 367 $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number;
401 368 $new_instance['menu_order'] = $this->form_id;
402 369 $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
370 +
403 371 $instance = $this->update( $new_instance, $old_instance );
404 372
405 373 /**
406 374 * Filter an action's settings before saving.
@@ -417,9 +385,9 @@
417 385 */
418 386 $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this );
419 387
420 388 $instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
421 - $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
389 + $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this );
422 390
423 391 if ( false !== $instance ) {
424 392 $all_instances[ $number ] = $instance;
425 393 }
@@ -435,25 +403,19 @@
435 403 /**
436 404 * If the status of the action has changed, update it
437 405 *
438 406 * @since 3.04
439 - *
440 - * @param array $new_instance
441 - * @param stdClass|array $old_instance
442 - * @return void
443 407 */
444 408 protected function maybe_update_status( $new_instance, $old_instance ) {
445 - if ( ! is_object( $old_instance ) || $new_instance['post_status'] === $old_instance->post_status ) {
446 - return;
409 + if ( $new_instance['post_status'] !== $old_instance->post_status ) {
410 + self::clear_cache();
411 + wp_update_post(
412 + array(
413 + 'ID' => $new_instance['ID'],
414 + 'post_status' => $new_instance['post_status'],
415 + )
416 + );
447 417 }
448 -
449 - self::clear_cache();
450 - wp_update_post(
451 - array(
452 - 'ID' => $new_instance['ID'],
453 - 'post_status' => $new_instance['post_status'],
454 - )
455 - );
456 418 }
457 419
458 420 public function save_settings( $settings ) {
459 421 self::clear_cache();
@@ -523,13 +485,10 @@
523 485 }
524 486
525 487 /**
526 488 * @since 3.04
527 - *
528 489 * @param array $args
529 490 * @param string $default_status
530 - *
531 - * @return void
532 491 */
533 492 protected static function prepare_get_action( &$args, $default_status = 'publish' ) {
534 493 if ( is_numeric( $args ) ) {
535 494 // for reverse compatibility. $limit was changed to $args
@@ -567,14 +526,9 @@
567 526 return ! empty( $payment_actions );
568 527 }
569 528
570 529 public function get_all( $form_id = false, $atts = array() ) {
571 - if ( is_array( $atts ) && ! isset( $atts['limit'] ) && $this->action_options['limit'] > 99 ) {
572 - $atts['limit'] = $this->action_options['limit'];
573 - }
574 -
575 530 self::prepare_get_action( $atts, 'any' );
576 -
577 531 $limit = $atts['limit'];
578 532
579 533 if ( $form_id ) {
580 534 $this->form_id = $form_id;
@@ -616,11 +570,8 @@
616 570
617 571 return $settings;
618 572 }
619 573
620 - /**
621 - * @return array
622 - */
623 574 public static function action_args( $form_id = 0, $limit = 99 ) {
624 575 $args = array(
625 576 'post_type' => FrmFormActionsController::$action_post_type,
626 577 'post_status' => 'publish',
@@ -635,11 +586,8 @@
635 586
636 587 return $args;
637 588 }
638 589
639 - /**
640 - * @param WP_Post|array $action
641 - */
642 590 public function prepare_action( $action ) {
643 591 $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
644 592 $action->post_excerpt = sanitize_title( $action->post_excerpt );
645 593
@@ -649,9 +597,9 @@
649 597 $action->post_content += $default_values;
650 598
651 599 foreach ( $default_values as $k => $vals ) {
652 600 if ( is_array( $vals ) && ! empty( $vals ) ) {
653 - if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
601 + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
654 602 continue;
655 603 }
656 604 $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
657 605 }
@@ -663,11 +611,8 @@
663 611
664 612 return $action;
665 613 }
666 614
667 - /**
668 - * @return void
669 - */
670 615 public function destroy( $form_id = false, $type = 'default' ) {
671 616 global $wpdb;
672 617
673 618 $this->form_id = $form_id;
@@ -691,10 +636,8 @@
691 636 /**
692 637 * Delete the action cache when a form action is created, deleted, or updated
693 638 *
694 639 * @since 2.0.5
695 - *
696 - * @return void
697 640 */
698 641 public static function clear_cache() {
699 642 FrmDb::cache_delete_group( 'frm_actions' );
700 643 }
@@ -702,11 +645,8 @@
702 645 public function get_settings() {
703 646 return self::get_action_for_form( $this->form_id, $this->id_base );
704 647 }
705 648
706 - /**
707 - * @return array
708 - */
709 649 public function get_global_defaults() {
710 650 $defaults = $this->get_defaults();
711 651
712 652 if ( ! isset( $defaults['event'] ) ) {
@@ -726,10 +666,8 @@
726 666 public function get_global_switch_fields() {
727 667 $switch = $this->get_switch_fields();
728 668 $switch['conditions'] = array( 'hide_field' );
729 669
730 - $switch = apply_filters( 'frm_global_switch_fields', $switch );
731 -
732 670 return $switch;
733 671 }
734 672
735 673 /**
@@ -824,14 +762,11 @@
824 762 /**
825 763 * Prepare the logic value for comparison against the entered value
826 764 *
827 765 * @since 2.01.02
828 - *
829 766 * @deprecated 4.06.02
830 767 *
831 768 * @param array|string $logic_value
832 - *
833 - * @return void
834 769 */
835 770 private static function prepare_logic_value( &$logic_value, $action, $entry ) {
836 771 if ( is_array( $logic_value ) ) {
837 772 $logic_value = reset( $logic_value );
@@ -879,13 +814,8 @@
879 814
880 815 return $observed_value;
881 816 }
882 817
883 - /**
884 - * @param string $class
885 - *
886 - * @return array
887 - */
888 818 public static function default_action_opts( $class = '' ) {
889 819 return array(
890 820 'classes' => 'frm_icon_font ' . $class,
891 821 'active' => false,
@@ -902,26 +832,6 @@
902 832 'import' => __( 'Entry is imported', 'formidable' ),
903 833 );
904 834
905 835 return apply_filters( 'frm_action_triggers', $triggers );
906 - }
907 -
908 - /**
909 - * @return void
910 - */
911 - public function render_conditional_logic_call_to_action() {
912 - ?>
913 - <h3>
914 - <a href="javascript:void(0)" class="frm_show_upgrade frm_noallow" data-upgrade="<?php echo esc_attr( $this->get_upgrade_text() ); ?>" data-medium="conditional-<?php echo esc_attr( $this->id_base ); ?>">
915 - <?php esc_html_e( 'Use Conditional Logic', 'formidable' ); ?>
916 - </a>
917 - </h3>
918 - <?php
919 - }
920 -
921 - /**
922 - * @return string
923 - */
924 - protected function get_upgrade_text() {
925 - return __( 'Conditional form actions', 'formidable' );
926 836 }
927 837 }