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 +14 -71 6.35.0 View file →
@@ -49,11 +49,8 @@
49 49 public function get_defaults() {
50 50 return array();
51 51 }
52 52
53 - /**
54 - * @return array
55 - */
56 53 public function get_switch_fields() {
57 54 return array();
58 55 }
59 56
@@ -96,9 +93,8 @@
96 93 'plugin' => $this->id_base,
97 94 'tooltip' => $name,
98 95 'group' => $id_base,
99 96 'color' => '',
100 - 'keywords' => '',
101 97 );
102 98
103 99 $action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
104 100 $group = $this->get_group( $action_options );
@@ -109,9 +105,9 @@
109 105 shuffle( $colors );
110 106 $action_options['color'] = 'var(--' . reset( $colors ) . ')';
111 107 }
112 108
113 - $upgrade_class = isset( $action_options['classes'] ) && $action_options['classes'] === 'frm_show_upgrade';
109 + $upgrade_class = $action_options['classes'] === 'frm_show_upgrade';
114 110 if ( $action_options['group'] === $id_base ) {
115 111 $upgrade_class = strpos( $action_options['classes'], 'frm_show_upgrade' ) !== false;
116 112 $action_options['classes'] = $group['icon'];
117 113 } elseif ( ! isset( $action_options['classes'] ) || empty( $action_options['classes'] ) || $upgrade_class ) {
@@ -201,20 +197,15 @@
201 197 public function get_field_id( $field_name ) {
202 198 return $field_name . '_' . $this->number;
203 199 }
204 200
205 - /**
206 - * @param int|string $number
207 - * @return void
208 - */
201 + // Private Function. Don't worry about this.
202 +
209 203 public function _set( $number ) {
210 204 $this->number = $number;
211 205 $this->id = $this->id_base . '-' . $number;
212 206 }
213 207
214 - /**
215 - * @return object
216 - */
217 208 public function prepare_new( $form_id = false ) {
218 209 if ( $form_id ) {
219 210 $this->form_id = $form_id;
220 211 }
@@ -251,11 +242,8 @@
251 242
252 243 return $this->save_settings( $action );
253 244 }
254 245
255 - /**
256 - * @return void
257 - */
258 246 public function duplicate_form_actions( $form_id, $old_id ) {
259 247 if ( $form_id == $old_id ) {
260 248 // don't duplicate the actions if this is a template getting updated
261 249 return;
@@ -291,11 +279,8 @@
291 279
292 280 return $post_id;
293 281 }
294 282
295 - /**
296 - * @param object $action
297 - */
298 283 public function duplicate_one( $action, $form_id ) {
299 284 global $frm_duplicate_ids;
300 285
301 286 $action->menu_order = $form_id;
@@ -366,12 +351,11 @@
366 351 if ( $this->updated ) {
367 352 return;
368 353 }
369 354
370 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
371 355 if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) {
372 356 // Sanitizing removes scripts and <email> type of values.
373 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
357 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
374 358 $settings = wp_unslash( $_POST[ $this->option_name ] );
375 359 } else {
376 360 return;
377 361 }
@@ -398,8 +382,9 @@
398 382 $new_instance['post_type'] = FrmFormActionsController::$action_post_type;
399 383 $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number;
400 384 $new_instance['menu_order'] = $this->form_id;
401 385 $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
386 +
402 387 $instance = $this->update( $new_instance, $old_instance );
403 388
404 389 /**
405 390 * Filter an action's settings before saving.
@@ -416,9 +401,9 @@
416 401 */
417 402 $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this );
418 403
419 404 $instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this );
420 - $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 );
421 406
422 407 if ( false !== $instance ) {
423 408 $all_instances[ $number ] = $instance;
424 409 }
@@ -434,25 +419,19 @@
434 419 /**
435 420 * If the status of the action has changed, update it
436 421 *
437 422 * @since 3.04
438 - *
439 - * @param array $new_instance
440 - * @param stdClass|array $old_instance
441 - * @return void
442 423 */
443 424 protected function maybe_update_status( $new_instance, $old_instance ) {
444 - if ( ! is_object( $old_instance ) || $new_instance['post_status'] === $old_instance->post_status ) {
445 - 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 + );
446 433 }
447 -
448 - self::clear_cache();
449 - wp_update_post(
450 - array(
451 - 'ID' => $new_instance['ID'],
452 - 'post_status' => $new_instance['post_status'],
453 - )
454 - );
455 434 }
456 435
457 436 public function save_settings( $settings ) {
458 437 self::clear_cache();
@@ -522,13 +501,10 @@
522 501 }
523 502
524 503 /**
525 504 * @since 3.04
526 - *
527 505 * @param array $args
528 506 * @param string $default_status
529 - *
530 - * @return void
531 507 */
532 508 protected static function prepare_get_action( &$args, $default_status = 'publish' ) {
533 509 if ( is_numeric( $args ) ) {
534 510 // for reverse compatibility. $limit was changed to $args
@@ -566,14 +542,9 @@
566 542 return ! empty( $payment_actions );
567 543 }
568 544
569 545 public function get_all( $form_id = false, $atts = array() ) {
570 - if ( is_array( $atts ) && ! isset( $atts['limit'] ) && $this->action_options['limit'] > 99 ) {
571 - $atts['limit'] = $this->action_options['limit'];
572 - }
573 -
574 546 self::prepare_get_action( $atts, 'any' );
575 -
576 547 $limit = $atts['limit'];
577 548
578 549 if ( $form_id ) {
579 550 $this->form_id = $form_id;
@@ -615,11 +586,8 @@
615 586
616 587 return $settings;
617 588 }
618 589
619 - /**
620 - * @return array
621 - */
622 590 public static function action_args( $form_id = 0, $limit = 99 ) {
623 591 $args = array(
624 592 'post_type' => FrmFormActionsController::$action_post_type,
625 593 'post_status' => 'publish',
@@ -634,11 +602,8 @@
634 602
635 603 return $args;
636 604 }
637 605
638 - /**
639 - * @param WP_Post|array $action
640 - */
641 606 public function prepare_action( $action ) {
642 607 $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
643 608 $action->post_excerpt = sanitize_title( $action->post_excerpt );
644 609
@@ -662,11 +627,8 @@
662 627
663 628 return $action;
664 629 }
665 630
666 - /**
667 - * @return void
668 - */
669 631 public function destroy( $form_id = false, $type = 'default' ) {
670 632 global $wpdb;
671 633
672 634 $this->form_id = $form_id;
@@ -690,10 +652,8 @@
690 652 /**
691 653 * Delete the action cache when a form action is created, deleted, or updated
692 654 *
693 655 * @since 2.0.5
694 - *
695 - * @return void
696 656 */
697 657 public static function clear_cache() {
698 658 FrmDb::cache_delete_group( 'frm_actions' );
699 659 }
@@ -701,11 +661,8 @@
701 661 public function get_settings() {
702 662 return self::get_action_for_form( $this->form_id, $this->id_base );
703 663 }
704 664
705 - /**
706 - * @return array
707 - */
708 665 public function get_global_defaults() {
709 666 $defaults = $this->get_defaults();
710 667
711 668 if ( ! isset( $defaults['event'] ) ) {
@@ -823,14 +780,11 @@
823 780 /**
824 781 * Prepare the logic value for comparison against the entered value
825 782 *
826 783 * @since 2.01.02
827 - *
828 784 * @deprecated 4.06.02
829 785 *
830 786 * @param array|string $logic_value
831 - *
832 - * @return void
833 787 */
834 788 private static function prepare_logic_value( &$logic_value, $action, $entry ) {
835 789 if ( is_array( $logic_value ) ) {
836 790 $logic_value = reset( $logic_value );
@@ -878,13 +832,8 @@
878 832
879 833 return $observed_value;
880 834 }
881 835
882 - /**
883 - * @param string $class
884 - *
885 - * @return array
886 - */
887 836 public static function default_action_opts( $class = '' ) {
888 837 return array(
889 838 'classes' => 'frm_icon_font ' . $class,
890 839 'active' => false,
@@ -903,11 +852,8 @@
903 852
904 853 return apply_filters( 'frm_action_triggers', $triggers );
905 854 }
906 855
907 - /**
908 - * @return void
909 - */
910 856 public function render_conditional_logic_call_to_action() {
911 857 ?>
912 858 <h3>
913 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 ); ?>">
@@ -916,11 +862,8 @@
916 862 </h3>
917 863 <?php
918 864 }
919 865
920 - /**
921 - * @return string
922 - */
923 866 protected function get_upgrade_text() {
924 867 return __( 'Conditional form actions', 'formidable' );
925 868 }
926 869 }