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/models/FrmFormAction.php +16 -74 6.55.0 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 ) {
@@ -202,20 +197,15 @@
202 197 public function get_field_id( $field_name ) {
203 198 return $field_name . '_' . $this->number;
204 199 }
205 200
206 - /**
207 - * @param int|string $number
208 - * @return void
209 - */
201 + // Private Function. Don't worry about this.
202 +
210 203 public function _set( $number ) {
211 204 $this->number = $number;
212 205 $this->id = $this->id_base . '-' . $number;
213 206 }
214 207
215 - /**
216 - * @return object
217 - */
218 208 public function prepare_new( $form_id = false ) {
219 209 if ( $form_id ) {
220 210 $this->form_id = $form_id;
221 211 }
@@ -252,11 +242,8 @@
252 242
253 243 return $this->save_settings( $action );
254 244 }
255 245
256 - /**
257 - * @return void
258 - */
259 246 public function duplicate_form_actions( $form_id, $old_id ) {
260 247 if ( $form_id == $old_id ) {
261 248 // don't duplicate the actions if this is a template getting updated
262 249 return;
@@ -292,11 +279,8 @@
292 279
293 280 return $post_id;
294 281 }
295 282
296 - /**
297 - * @param object $action
298 - */
299 283 public function duplicate_one( $action, $form_id ) {
300 284 global $frm_duplicate_ids;
301 285
302 286 $action->menu_order = $form_id;
@@ -367,12 +351,11 @@
367 351 if ( $this->updated ) {
368 352 return;
369 353 }
370 354
371 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
372 355 if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
373 356 // Sanitizing removes scripts and <email> type of values.
374 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
357 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
375 358 $settings = wp_unslash( $_POST[ $this->option_name ] );
376 359 } else {
377 360 return;
378 361 }
@@ -399,8 +382,9 @@
399 382 $new_instance['post_type'] = FrmFormActionsController::$action_post_type;
400 383 $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number;
401 384 $new_instance['menu_order'] = $this->form_id;
402 385 $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
386 +
403 387 $instance = $this->update( $new_instance, $old_instance );
404 388
405 389 /**
406 390 * Filter an action's settings before saving.
@@ -417,9 +401,9 @@
417 401 */
418 402 $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this );
419 403
420 404 $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 );
405 + $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this );
422 406
423 407 if ( false !== $instance ) {
424 408 $all_instances[ $number ] = $instance;
425 409 }
@@ -435,25 +419,19 @@
435 419 /**
436 420 * If the status of the action has changed, update it
437 421 *
438 422 * @since 3.04
439 - *
440 - * @param array $new_instance
441 - * @param stdClass|array $old_instance
442 - * @return void
443 423 */
444 424 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;
425 + if ( $new_instance['post_status'] !== $old_instance->post_status ) {
426 + self::clear_cache();
427 + wp_update_post(
428 + array(
429 + 'ID' => $new_instance['ID'],
430 + 'post_status' => $new_instance['post_status'],
431 + )
432 + );
447 433 }
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 434 }
457 435
458 436 public function save_settings( $settings ) {
459 437 self::clear_cache();
@@ -523,13 +501,10 @@
523 501 }
524 502
525 503 /**
526 504 * @since 3.04
527 - *
528 505 * @param array $args
529 506 * @param string $default_status
530 - *
531 - * @return void
532 507 */
533 508 protected static function prepare_get_action( &$args, $default_status = 'publish' ) {
534 509 if ( is_numeric( $args ) ) {
535 510 // for reverse compatibility. $limit was changed to $args
@@ -567,14 +542,9 @@
567 542 return ! empty( $payment_actions );
568 543 }
569 544
570 545 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 546 self::prepare_get_action( $atts, 'any' );
576 -
577 547 $limit = $atts['limit'];
578 548
579 549 if ( $form_id ) {
580 550 $this->form_id = $form_id;
@@ -616,11 +586,8 @@
616 586
617 587 return $settings;
618 588 }
619 589
620 - /**
621 - * @return array
622 - */
623 590 public static function action_args( $form_id = 0, $limit = 99 ) {
624 591 $args = array(
625 592 'post_type' => FrmFormActionsController::$action_post_type,
626 593 'post_status' => 'publish',
@@ -635,11 +602,8 @@
635 602
636 603 return $args;
637 604 }
638 605
639 - /**
640 - * @param WP_Post|array $action
641 - */
642 606 public function prepare_action( $action ) {
643 607 $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
644 608 $action->post_excerpt = sanitize_title( $action->post_excerpt );
645 609
@@ -649,9 +613,9 @@
649 613 $action->post_content += $default_values;
650 614
651 615 foreach ( $default_values as $k => $vals ) {
652 616 if ( is_array( $vals ) && ! empty( $vals ) ) {
653 - if ( 'event' === $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
617 + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
654 618 continue;
655 619 }
656 620 $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
657 621 }
@@ -663,11 +627,8 @@
663 627
664 628 return $action;
665 629 }
666 630
667 - /**
668 - * @return void
669 - */
670 631 public function destroy( $form_id = false, $type = 'default' ) {
671 632 global $wpdb;
672 633
673 634 $this->form_id = $form_id;
@@ -691,10 +652,8 @@
691 652 /**
692 653 * Delete the action cache when a form action is created, deleted, or updated
693 654 *
694 655 * @since 2.0.5
695 - *
696 - * @return void
697 656 */
698 657 public static function clear_cache() {
699 658 FrmDb::cache_delete_group( 'frm_actions' );
700 659 }
@@ -702,11 +661,8 @@
702 661 public function get_settings() {
703 662 return self::get_action_for_form( $this->form_id, $this->id_base );
704 663 }
705 664
706 - /**
707 - * @return array
708 - */
709 665 public function get_global_defaults() {
710 666 $defaults = $this->get_defaults();
711 667
712 668 if ( ! isset( $defaults['event'] ) ) {
@@ -824,14 +780,11 @@
824 780 /**
825 781 * Prepare the logic value for comparison against the entered value
826 782 *
827 783 * @since 2.01.02
828 - *
829 784 * @deprecated 4.06.02
830 785 *
831 786 * @param array|string $logic_value
832 - *
833 - * @return void
834 787 */
835 788 private static function prepare_logic_value( &$logic_value, $action, $entry ) {
836 789 if ( is_array( $logic_value ) ) {
837 790 $logic_value = reset( $logic_value );
@@ -879,13 +832,8 @@
879 832
880 833 return $observed_value;
881 834 }
882 835
883 - /**
884 - * @param string $class
885 - *
886 - * @return array
887 - */
888 836 public static function default_action_opts( $class = '' ) {
889 837 return array(
890 838 'classes' => 'frm_icon_font ' . $class,
891 839 'active' => false,
@@ -904,11 +852,8 @@
904 852
905 853 return apply_filters( 'frm_action_triggers', $triggers );
906 854 }
907 855
908 - /**
909 - * @return void
910 - */
911 856 public function render_conditional_logic_call_to_action() {
912 857 ?>
913 858 <h3>
914 859 <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 ); ?>">
@@ -917,11 +862,8 @@
917 862 </h3>
918 863 <?php
919 864 }
920 865
921 - /**
922 - * @return string
923 - */
924 866 protected function get_upgrade_text() {
925 867 return __( 'Conditional form actions', 'formidable' );
926 868 }
927 869 }