PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24
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 +9 -116 6.266.24 View file →
@@ -88,10 +88,8 @@
88 88 * Echo the settings update form
89 89 *
90 90 * @param WP_Post $instance Current settings.
91 91 * @param array $args
92 - *
93 - * @return string
94 92 */
95 93 public function form( $instance, $args = array() ) {
96 94 echo '<p class="no-options-widget">' . esc_html__( 'There are no options for this action.', 'formidable' ) . '</p>';
97 95
@@ -111,14 +109,8 @@
111 109 public function get_switch_fields() {
112 110 return array();
113 111 }
114 112
115 - /**
116 - * @param object $action
117 - * @param object $form
118 - *
119 - * @return object
120 - */
121 113 public function migrate_values( $action, $form ) {
122 114 return $action;
123 115 }
124 116
@@ -171,9 +163,8 @@
171 163 $action_options['color'] = 'var(--' . reset( $colors ) . ')';
172 164 }
173 165
174 166 $upgrade_class = isset( $action_options['classes'] ) && $action_options['classes'] === 'frm_show_upgrade';
175 -
176 167 if ( $action_options['group'] === $id_base ) {
177 168 $upgrade_class = strpos( $action_options['classes'], 'frm_show_upgrade' ) !== false;
178 169 $action_options['classes'] = $group['icon'];
179 170 } elseif ( empty( $action_options['classes'] ) || $upgrade_class ) {
@@ -189,13 +180,8 @@
189 180 }
190 181
191 182 /**
192 183 * @param string $id_base
193 - * @param string $name
194 - * @param array $action_options
195 - * @param array $control_options
196 - *
197 - * @return void
198 184 */
199 185 public function FrmFormAction( $id_base, $name, $action_options = array(), $control_options = array() ) {
200 186 self::__construct( $id_base, $name, $action_options, $control_options );
201 187 }
@@ -208,9 +194,8 @@
208 194 * @return string
209 195 */
210 196 public function maybe_switch_field_ids( $action ) {
211 197 $updated_action = apply_filters( 'frm_maybe_switch_field_ids', $action );
212 -
213 198 if ( $updated_action === $action ) {
214 199 $updated_action = FrmFieldsHelper::switch_field_ids( $action );
215 200 }
216 201 return $updated_action;
@@ -217,12 +202,8 @@
217 202 }
218 203
219 204 /**
220 205 * @since 4.0
221 - *
222 - * @param array $action_options
223 - *
224 - * @return array
225 206 */
226 207 protected function get_group( $action_options ) {
227 208 $groups = FrmFormActionsController::form_action_groups();
228 209 $group = 'misc';
@@ -249,9 +230,8 @@
249 230 *
250 231 * This function should be used in form() methods to create name attributes for fields to be saved by update()
251 232 *
252 233 * @param string $field_name Field name.
253 - * @param string $post_field
254 234 *
255 235 * @return string Name attribute for $field_name
256 236 */
257 237 public function get_field_name( $field_name, $post_field = 'post_content' ) {
@@ -276,9 +256,8 @@
276 256 }
277 257
278 258 /**
279 259 * @param int|string $number
280 - *
281 260 * @return void
282 261 */
283 262 public function _set( $number ) {
284 263 $this->number = $number;
@@ -285,10 +264,8 @@
285 264 $this->id = $this->id_base . '-' . $number;
286 265 }
287 266
288 267 /**
289 - * @param false|int|string $form_id
290 - *
291 268 * @return object
292 269 */
293 270 public function prepare_new( $form_id = false ) {
294 271 if ( $form_id ) {
@@ -319,13 +296,8 @@
319 296
320 297 return (object) $form_action;
321 298 }
322 299
323 - /**
324 - * @param int|string $form_id
325 - *
326 - * @return int|WP_Error
327 - */
328 300 public function create( $form_id ) {
329 301 $this->form_id = $form_id;
330 302
331 303 $action = $this->prepare_new();
@@ -333,11 +305,8 @@
333 305 return $this->save_settings( $action );
334 306 }
335 307
336 308 /**
337 - * @param int|string $form_id
338 - * @param int|string $old_id
339 - *
340 309 * @return void
341 310 */
342 311 public function duplicate_form_actions( $form_id, $old_id ) {
343 312 if ( $form_id == $old_id ) {
@@ -348,9 +317,8 @@
348 317 $this->form_id = $old_id;
349 318 $actions = $this->get_all( $old_id );
350 319
351 320 $this->form_id = $form_id;
352 -
353 321 foreach ( $actions as $action ) {
354 322 $this->duplicate_one( $action, $form_id );
355 323 unset( $action );
356 324 }
@@ -361,10 +329,8 @@
361 329 *
362 330 * @since 2.0
363 331 *
364 332 * @param array $action
365 - * @param array $forms
366 - *
367 333 * @return int $post_id
368 334 */
369 335 public function maybe_create_action( $action, $forms ) {
370 336 if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && isset( $forms[ $action['menu_order'] ] ) && $forms[ $action['menu_order'] ] === 'updated' ) {
@@ -380,12 +346,9 @@
380 346 return $post_id;
381 347 }
382 348
383 349 /**
384 - * @param object $action
385 - * @param int|string $form_id
386 - *
387 - * @return int|WP_Error
350 + * @param object $action
388 351 */
389 352 public function duplicate_one( $action, $form_id ) {
390 353 global $frm_duplicate_ids;
391 354
@@ -414,15 +377,8 @@
414 377
415 378 return $this->save_settings( $action );
416 379 }
417 380
418 - /**
419 - * @param array $action
420 - * @param array|string $subkey
421 - * @param mixed $val
422 - *
423 - * @return array
424 - */
425 381 private function duplicate_array_walk( $action, $subkey, $val ) {
426 382 global $frm_duplicate_ids;
427 383
428 384 if ( is_array( $subkey ) ) {
@@ -453,12 +409,8 @@
453 409 /**
454 410 * Deal with changed settings.
455 411 *
456 412 * Do NOT over-ride this function
457 - *
458 - * @param int|string $form_id
459 - *
460 - * @return array|null
461 413 */
462 414 public function update_callback( $form_id ) {
463 415 $this->form_id = $form_id;
464 416
@@ -482,9 +434,9 @@
482 434
483 435 foreach ( $settings as $number => $new_instance ) {
484 436 $this->_set( $number );
485 437
486 - $old_instance = $all_instances[ $number ] ?? array();
438 + $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
487 439
488 440 if ( ! isset( $new_instance['post_status'] ) ) {
489 441 $new_instance['post_status'] = 'draft';
490 442 }
@@ -499,9 +451,9 @@
499 451
500 452 $new_instance['post_type'] = FrmFormActionsController::$action_post_type;
501 453 $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number;
502 454 $new_instance['menu_order'] = $this->form_id;
503 - $new_instance['post_date'] = $old_instance->post_date ?? '';
455 + $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
504 456 $instance = $this->update( $new_instance, $old_instance );
505 457
506 458 /**
507 459 * Filter an action's settings before saving.
@@ -539,9 +491,8 @@
539 491 * @since 3.04
540 492 *
541 493 * @param array $new_instance
542 494 * @param array|stdClass $old_instance
543 - *
544 495 * @return void
545 496 */
546 497 protected function maybe_update_status( $new_instance, $old_instance ) {
547 498 if ( ! is_object( $old_instance ) || $new_instance['post_status'] === $old_instance->post_status ) {
@@ -558,9 +509,8 @@
558 509 }
559 510
560 511 /**
561 512 * @param array $settings
562 - *
563 513 * @return int|WP_Error
564 514 */
565 515 public function save_settings( $settings ) {
566 516 self::clear_cache();
@@ -567,16 +517,10 @@
567 517
568 518 return FrmDb::save_settings( $settings, 'frm_actions' );
569 519 }
570 520
571 - /**
572 - * @param int $id
573 - *
574 - * @return object|null
575 - */
576 521 public function get_single_action( $id ) {
577 522 $action = get_post( $id );
578 -
579 523 if ( $action ) {
580 524 $action = $this->prepare_action( $action );
581 525 $this->_set( $id );
582 526 }
@@ -583,27 +527,14 @@
583 527
584 528 return $action;
585 529 }
586 530
587 - /**
588 - * @param int|string $form_id
589 - *
590 - * @return array
591 - */
592 531 public function get_one( $form_id ) {
593 532 return $this->get_all( $form_id, 1 );
594 533 }
595 534
596 - /**
597 - * @param int|string $form_id
598 - * @param string $type
599 - * @param array $atts
600 - *
601 - * @return array
602 - */
603 535 public static function get_action_for_form( $form_id, $type = 'all', $atts = array() ) {
604 536 $action_controls = FrmFormActionsController::get_form_actions( $type );
605 -
606 537 if ( empty( $action_controls ) ) {
607 538 // don't continue if there are no available actions
608 539 return array();
609 540 }
@@ -627,9 +558,8 @@
627 558 return array();
628 559 }
629 560
630 561 $settings = array();
631 -
632 562 foreach ( $actions as $action ) {
633 563 // some plugins/themes are formatting the post_excerpt
634 564 $action->post_excerpt = sanitize_title( $action->post_excerpt );
635 565
@@ -682,9 +612,8 @@
682 612 $args = array(
683 613 'limit' => $args,
684 614 );
685 615 }
686 -
687 616 $defaults = array(
688 617 'limit' => 99,
689 618 'post_status' => $default_status,
690 619 );
@@ -691,12 +620,9 @@
691 620 $args = wp_parse_args( $args, $defaults );
692 621 }
693 622
694 623 /**
695 - * @param int $action_id
696 - * @param string $type
697 - *
698 - * @return bool|object
624 + * @param int $action_id
699 625 */
700 626 public static function get_single_action_type( $action_id, $type ) {
701 627 if ( ! $type ) {
702 628 return false;
@@ -710,24 +636,18 @@
710 636 return $action_control->get_single_action( $action_id );
711 637 }
712 638
713 639 /**
714 - * @param int $form_id
715 - * @param string $type
640 + * @param int $form_id
716 641 *
717 642 * @return bool
718 643 */
719 644 public static function form_has_action_type( $form_id, $type ) {
720 - $actions = self::get_action_for_form( $form_id, $type );
721 - return ! empty( $actions );
645 + $payment_actions = self::get_action_for_form( $form_id, $type );
646 +
647 + return ! empty( $payment_actions );
722 648 }
723 649
724 - /**
725 - * @param false|int|string $form_id
726 - * @param array $atts
727 - *
728 - * @return array
729 - */
730 650 public function get_all( $form_id = false, $atts = array() ) {
731 651 if ( is_array( $atts ) && ! isset( $atts['limit'] ) && $this->action_options['limit'] > 99 ) {
732 652 $atts['limit'] = $this->action_options['limit'];
733 653 }
@@ -759,9 +679,8 @@
759 679 return array();
760 680 }
761 681
762 682 $settings = array();
763 -
764 683 foreach ( $actions as $action ) {
765 684 if ( count( $settings ) >= $limit ) {
766 685 continue;
767 686 }
@@ -778,11 +697,8 @@
778 697 return $settings;
779 698 }
780 699
781 700 /**
782 - * @param int $form_id
783 - * @param int $limit
784 - *
785 701 * @return array
786 702 */
787 703 public static function action_args( $form_id = 0, $limit = 99 ) {
788 704 $args = array(
@@ -800,11 +716,9 @@
800 716 return $args;
801 717 }
802 718
803 719 /**
804 - * @param WP_Post $action
805 - *
806 - * @return WP_Post
720 + * @param array|WP_Post $action
807 721 */
808 722 public function prepare_action( $action ) {
809 723 $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content );
810 724 $action->post_excerpt = sanitize_title( $action->post_excerpt );
@@ -830,11 +744,8 @@
830 744 return $action;
831 745 }
832 746
833 747 /**
834 - * @param false|int|string $form_id
835 - * @param string $type
836 - *
837 748 * @return void
838 749 */
839 750 public function destroy( $form_id = false, $type = 'default' ) {
840 751 global $wpdb;
@@ -841,13 +752,11 @@
841 752
842 753 $this->form_id = $form_id;
843 754
844 755 $query = array( 'post_type' => FrmFormActionsController::$action_post_type );
845 -
846 756 if ( $form_id ) {
847 757 $query['menu_order'] = $form_id;
848 758 }
849 -
850 759 if ( 'all' != $type ) {
851 760 $query['post_excerpt'] = $this->id_base;
852 761 }
853 762
@@ -869,11 +778,8 @@
869 778 public static function clear_cache() {
870 779 FrmDb::cache_delete_group( 'frm_actions' );
871 780 }
872 781
873 - /**
874 - * @return array
875 - */
876 782 public function get_settings() {
877 783 return self::get_action_for_form( $this->form_id, $this->id_base );
878 784 }
879 785
@@ -896,11 +802,8 @@
896 802
897 803 return $defaults;
898 804 }
899 805
900 - /**
901 - * @return array
902 - */
903 806 public function get_global_switch_fields() {
904 807 $switch = $this->get_switch_fields();
905 808 $switch['conditions'] = array( 'hide_field' );
906 809
@@ -910,13 +813,8 @@
910 813 }
911 814
912 815 /**
913 816 * Migrate settings from form->options into new action.
914 - *
915 - * @param object $form
916 - * @param string $update
917 - *
918 - * @return int|WP_Error
919 817 */
920 818 public function migrate_to_2( $form, $update = 'update' ) {
921 819 $action = $this->prepare_new( $form->id );
922 820 FrmAppHelper::unserialize_or_decode( $form->options );
@@ -960,9 +858,8 @@
960 858
961 859 /**
962 860 * @param WP_Post $action
963 861 * @param stdClass $entry
964 - *
965 862 * @return bool
966 863 */
967 864 public static function action_conditions_met( $action, $entry ) {
968 865 if ( is_callable( 'FrmProFormActionsController::action_conditions_met' ) ) {
@@ -1015,11 +912,8 @@
1015 912 'limit' => 0,
1016 913 );
1017 914 }
1018 915
1019 - /**
1020 - * @return array
1021 - */
1022 916 public static function trigger_labels() {
1023 917 $triggers = array(
1024 918 'draft' => __( 'Draft is saved', 'formidable' ),
1025 919 'create' => __( 'Entry is created', 'formidable' ),
@@ -1056,9 +950,8 @@
1056 950 *
1057 951 * @since 6.10
1058 952 *
1059 953 * @param int $form_id Form ID.
1060 - *
1061 954 * @return object[]
1062 955 */
1063 956 protected function get_form_fields( $form_id ) {
1064 957 // Get form fields, include embedded and repeater child fields.