PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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/FrmFormsController.php +78 -523 6.266.13 View file →
@@ -26,9 +26,8 @@
26 26 private static $formidable_tinymce_button;
27 27
28 28 public static function menu() {
29 29 $menu_label = __( 'Forms', 'formidable' );
30 -
31 30 if ( ! FrmAppHelper::pro_is_installed() ) {
32 31 $menu_label .= ' (Lite)';
33 32 }
34 33 add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
@@ -68,9 +67,9 @@
68 67 $data_message = __( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' );
69 68 $data_message .= ' <img src="' . esc_url( $images_url ) . '/survey-logic.png" srcset="' . esc_url( $images_url ) . 'survey-logic@2x.png 2x" alt="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '"/>';
70 69 echo '<a href="javascript:void(0)" class="frm_noallow frm_show_upgrade frm_add_logic_link frm-collapsed frm-flex-justify" data-upgrade="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '" data-message="' . esc_attr( $data_message ) . '" data-medium="builder" data-content="logic">';
71 70 esc_html_e( 'Conditional Logic', 'formidable' );
72 - FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon', array( 'aria-hidden' => 'true' ) );
71 + FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown6_icon', array( 'aria-hidden' => 'true' ) );
73 72 echo '</a>';
74 73 }
75 74
76 75 /**
@@ -77,12 +76,8 @@
77 76 * By default, Divi processes form shortcodes on the edit post page.
78 77 * Now that won't do.
79 78 *
80 79 * @since 3.01
81 - *
82 - * @param array $shortcodes List of shortcodes to process.
83 - *
84 - * @return array
85 80 */
86 81 public static function prevent_divi_conflict( $shortcodes ) {
87 82 $shortcodes[] = 'formidable';
88 83
@@ -97,14 +92,12 @@
97 92
98 93 $message = '';
99 94 $params = FrmForm::list_page_params();
100 95 $errors = self::process_bulk_form_actions( array() );
101 -
102 96 if ( isset( $errors['message'] ) ) {
103 97 $message = $errors['message'];
104 98 unset( $errors['message'] );
105 99 }
106 -
107 100 $errors = apply_filters( 'frm_admin_list_form_action', $errors );
108 101
109 102 self::display_forms_list( $params, $message, $errors );
110 103 }
@@ -114,24 +107,14 @@
114 107 *
115 108 * @since 2.02.11
116 109 *
117 110 * @param int|object $form
118 - *
119 - * @return void
120 111 */
121 112 private static function create_default_email_action( $form ) {
122 113 FrmForm::maybe_get_form( $form );
123 -
124 - if ( ! is_object( $form ) ) {
125 - return;
126 - }
127 -
128 114 $create_email = apply_filters( 'frm_create_default_email_action', true, $form );
129 115
130 116 if ( $create_email ) {
131 - /**
132 - * @var FrmFormAction
133 - */
134 117 $action_control = FrmFormActionsController::get_form_actions( 'email' );
135 118 $action_control->create( $form->id );
136 119 }
137 120 }
@@ -141,18 +124,12 @@
141 124 *
142 125 * @since 6.0.0
143 126 *
144 127 * @param int|object $form Form object or ID.
145 - *
146 - * @return void
147 128 */
148 129 private static function create_default_on_submit_action( $form ) {
149 130 FrmForm::maybe_get_form( $form );
150 131
151 - if ( ! is_object( $form ) ) {
152 - return;
153 - }
154 -
155 132 /**
156 133 * Enable or disable the default On Submit action.
157 134 *
158 135 * @since 6.0.0
@@ -162,11 +139,8 @@
162 139 */
163 140 $create = apply_filters( 'frm_create_default_on_submit_action', true, $form );
164 141
165 142 if ( $create ) {
166 - /**
167 - * @var FrmFormAction
168 - */
169 143 $action_control = FrmFormActionsController::get_form_actions( FrmOnSubmitAction::$slug );
170 144 $action_control->create( $form->id );
171 145 }
172 146 }
@@ -176,18 +150,12 @@
176 150 *
177 151 * @since 6.9
178 152 *
179 153 * @param int|object $form Form ID or object.
180 - *
181 - * @return void
182 154 */
183 155 private static function create_submit_button_field( $form ) {
184 156 FrmForm::maybe_get_form( $form );
185 157
186 - if ( ! is_object( $form ) ) {
187 - return;
188 - }
189 -
190 158 if ( FrmSubmitHelper::get_submit_field( $form->id ) ) {
191 159 // Do not create submit button field if it exists.
192 160 return;
193 161 }
@@ -195,9 +163,9 @@
195 163 FrmField::create(
196 164 array(
197 165 'type' => FrmSubmitHelper::FIELD_TYPE,
198 166 'name' => __( 'Submit', 'formidable' ),
199 - 'field_order' => FrmSubmitHelper::DEFAULT_ORDER,
167 + 'field_order' => 9999,
200 168 'form_id' => $form->id,
201 169 'field_options' => FrmFieldsHelper::get_default_field_options( FrmSubmitHelper::FIELD_TYPE ),
202 170 'description' => '',
203 171 'default_value' => '',
@@ -206,10 +174,8 @@
206 174 );
207 175 }
208 176
209 177 /**
210 - * @param array|false $values
211 - *
212 178 * @return void
213 179 */
214 180 public static function edit( $values = false ) {
215 181 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -221,9 +187,8 @@
221 187
222 188 /**
223 189 * @param mixed $id
224 190 * @param string $message
225 - *
226 191 * @return void
227 192 */
228 193 public static function settings( $id = false, $message = '' ) {
229 194 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -268,9 +233,8 @@
268 233
269 234 FrmForm::update( $id, $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
270 235
271 236 $antispam_is_on = ! empty( $_POST['options']['antispam'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
272 -
273 237 if ( $antispam_is_on !== $antispam_was_on ) {
274 238 FrmAntiSpam::clear_caches();
275 239 }
276 240
@@ -280,9 +244,8 @@
280 244 }
281 245
282 246 /**
283 247 * @param int $form_id
284 - *
285 248 * @return bool
286 249 */
287 250 private static function antispam_was_on( $form_id ) {
288 251 $form = FrmForm::getOne( $form_id );
@@ -289,10 +252,8 @@
289 252 return ! empty( $form->options['antispam'] );
290 253 }
291 254
292 255 /**
293 - * @param array $values
294 - *
295 256 * @return void
296 257 */
297 258 public static function update( $values = array() ) {
298 259 if ( empty( $values ) ) {
@@ -305,9 +266,8 @@
305 266 }
306 267
307 268 $errors = FrmForm::validate( $values );
308 269 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
309 -
310 270 if ( $permission_error !== false ) {
311 271 $errors['form'] = $permission_error;
312 272 }
313 273
@@ -326,9 +286,9 @@
326 286 if ( self::is_too_long( $values ) ) {
327 287 $message .= '<br/> ' . sprintf(
328 288 /* translators: %1$s: Start link HTML, %2$s: end link HTML */
329 289 __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
330 - '<a href="' . esc_url( self::get_form_too_long_docs_url() ) . '" target="_blank" rel="noopener">',
290 + '<a href="https://formidableforms.com/knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/?utm_source=WordPress&utm_medium=builder&utm_campaign=liteplugin" target="_blank" rel="noopener">',
331 291 '</a>'
332 292 );
333 293 }
334 294
@@ -339,32 +299,17 @@
339 299 self::get_edit_vars( $id, array(), $message );
340 300 }
341 301
342 302 /**
343 - * @since 6.25.1
344 - *
345 - * @return string
346 - */
347 - private static function get_form_too_long_docs_url() {
348 - $utm = array(
349 - 'campaign' => 'builder',
350 - 'content' => 'form-too-long',
351 - );
352 - return FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/' );
353 - }
354 -
355 - /**
356 303 * Remove the draft flag from any new fields from this current session.
357 304 *
358 305 * @since 6.8
359 306 *
360 307 * @param int $form_id
361 - *
362 308 * @return void
363 309 */
364 310 private static function maybe_remove_draft_option_from_fields( $form_id ) {
365 311 $draft_field_ids_csv = FrmAppHelper::get_post_param( 'draft_fields', '', 'sanitize_text_field' );
366 -
367 312 if ( ! $draft_field_ids_csv ) {
368 313 // If the draft_fields input is empty there are no new fields in the session.
369 314 return;
370 315 }
@@ -369,9 +314,8 @@
369 314 return;
370 315 }
371 316
372 317 $draft_field_ids = array_filter( explode( ',', $draft_field_ids_csv ), 'is_numeric' );
373 -
374 318 if ( ! $draft_field_ids ) {
375 319 // Exit early if the draft fields input is invalid. It should be a CSV of integer values.
376 320 return;
377 321 }
@@ -376,9 +320,8 @@
376 320 return;
377 321 }
378 322
379 323 $draft_field_rows = FrmFieldsHelper::get_draft_field_results( $form_id, $draft_field_ids );
380 -
381 324 foreach ( $draft_field_rows as $row ) {
382 325 $row->field_options['draft'] = 0;
383 326 FrmField::update( $row->id, array( 'field_options' => $row->field_options ) );
384 327 }
@@ -390,10 +333,8 @@
390 333 * were likely not saved either.
391 334 *
392 335 * @since 3.06.01
393 336 *
394 - * @param array $values
395 - *
396 337 * @return bool
397 338 */
398 339 private static function is_too_long( $values ) {
399 340 return empty( $values['frm_end'] );
@@ -429,17 +370,13 @@
429 370 * @return string|null
430 371 */
431 372 public static function page_preview() {
432 373 $params = FrmForm::list_page_params();
433 -
434 - if ( ! $params['form'] || is_numeric( $params['form'] ) ) {
374 + if ( ! $params['form'] ) {
435 375 return null;
436 376 }
437 377
438 - self::maybe_block_preview( $params['form'] );
439 -
440 378 $form = FrmForm::getOne( $params['form'] );
441 -
442 379 if ( ! $form ) {
443 380 return null;
444 381 }
445 382
@@ -451,19 +388,9 @@
451 388 *
452 389 * @return void
453 390 */
454 391 public static function show_page_preview() {
455 - $preview = self::page_preview();
456 -
457 - if ( is_null( $preview ) ) {
458 - wp_die(
459 - '<h1>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</h1>',
460 - '<p>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</p>',
461 - 404
462 - );
463 - }
464 -
465 - echo $preview; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
392 + echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
466 393 }
467 394
468 395 /**
469 396 * @return void
@@ -474,19 +401,9 @@
474 401
475 402 global $frm_vars;
476 403 $frm_vars['preview'] = true;
477 404
478 - // print_emoji_styles is deprecated.
479 - remove_action( 'wp_print_styles', 'print_emoji_styles' );
480 -
481 - if ( FrmTestModeController::should_add_test_mode_container() ) {
482 - do_action( 'frm_test_mode_init' );
483 - add_action( 'wp_enqueue_scripts', 'FrmTestModeController::register_and_enqueue_required_scripts' );
484 - add_filter( 'frm_filter_final_form', 'FrmTestModeController::maybe_add_test_mode_container', 99 );
485 - }
486 -
487 405 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
488 -
489 406 if ( $include_theme ) {
490 407 self::set_preview_query();
491 408 self::load_theme_preview();
492 409 } else {
@@ -509,9 +426,8 @@
509 426 'post_type' => 'page',
510 427 );
511 428
512 429 $page_for_posts = get_option( 'page_for_posts' );
513 -
514 430 if ( is_numeric( $page_for_posts ) ) {
515 431 // Avoid querying for the "Posts Page" or "Blog Page" so we don't display 10 forms.
516 432 $page_query['post__not_in'] = array( $page_for_posts );
517 433 }
@@ -516,15 +432,13 @@
516 432 $page_query['post__not_in'] = array( $page_for_posts );
517 433 }
518 434
519 435 $random_page = get_posts( $page_query );
520 -
521 436 if ( ! $random_page ) {
522 437 return;
523 438 }
524 439
525 440 $random_page = reset( $random_page );
526 -
527 441 if ( ! is_a( $random_page, 'WP_Post' ) ) {
528 442 // The return type can also be int.
529 443 return;
530 444 }
@@ -546,9 +460,8 @@
546 460 *
547 461 * @since 5.5.2
548 462 *
549 463 * @param WP_Post $page The page object.
550 - *
551 464 * @return void
552 465 */
553 466 private static function set_post_global( $page ) {
554 467 global $post;
@@ -581,9 +494,8 @@
581 494 *
582 495 * @since 6.5.2
583 496 *
584 497 * @param array $classes The body classes list.
585 - *
586 498 * @return array
587 499 */
588 500 public static function preview_block_theme_body_classnames( $classes ) {
589 501 $classes[] = 'has-global-padding';
@@ -607,12 +519,8 @@
607 519 echo '<div class="container entry-content">';
608 520 the_content();
609 521 echo '</div>';
610 522
611 - // Prevent extra unexpected forms in the footer.
612 - // For some reason this happens in the Twenty Twenty Five theme.
613 - add_filter( 'frm_filter_final_form', '__return_empty_string' );
614 -
615 523 self::get_template( 'footer' );
616 524 }
617 525 }
618 526
@@ -620,11 +528,9 @@
620 528 * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call
621 529 * and renders required html fragments calling required functions.
622 530 *
623 531 * @since 6.7.1
624 - *
625 532 * @param string $template
626 - *
627 533 * @return void
628 534 */
629 535 private static function get_template( $template ) {
630 536 if ( self::should_try_getting_template( $template ) ) {
@@ -645,11 +551,9 @@
645 551 /**
646 552 * Returns true if calling a template function doesn't trigger deprecation warnings.
647 553 *
648 554 * @since 6.7.1
649 - *
650 555 * @param string $template
651 - *
652 556 * @return bool
653 557 */
654 558 private static function should_try_getting_template( $template ) {
655 559 $stylesheet_path = get_stylesheet_directory();
@@ -663,12 +567,8 @@
663 567 /**
664 568 * Set the page title for the theme preview page
665 569 *
666 570 * @since 3.0
667 - *
668 - * @param string $title
669 - *
670 - * @return string
671 571 */
672 572 public static function preview_page_title( $title ) {
673 573 if ( in_the_loop() ) {
674 574 $title = self::preview_title( $title );
@@ -682,9 +582,8 @@
682 582 *
683 583 * @since 3.0
684 584 *
685 585 * @param string $title
686 - *
687 586 * @return string
688 587 */
689 588 public static function preview_title( $title ) {
690 589 return __( 'Form Preview', 'formidable' );
@@ -695,9 +594,8 @@
695 594 *
696 595 * @since 3.0
697 596 *
698 597 * @param string $content
699 - *
700 598 * @return string
701 599 */
702 600 public static function preview_content( $content ) {
703 601 if ( in_the_loop() ) {
@@ -712,38 +610,23 @@
712 610 /**
713 611 * @since 3.0
714 612 */
715 613 private static function load_direct_preview() {
614 + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
615 +
616 + // print_emoji_styles is deprecated.
617 + remove_action( 'wp_print_styles', 'print_emoji_styles' );
618 +
716 619 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
717 -
718 620 if ( $key == '' ) {
719 621 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
720 622 }
721 623
722 - if ( ! $key ) {
723 - $error = __( 'Form key is missing', 'formidable' );
724 - wp_die(
725 - '<h1>' . esc_html( $error ) . '</h1>',
726 - '<p>' . esc_html( $error ) . '</p>',
727 - 404
728 - );
729 - }
730 -
731 - self::maybe_block_preview( $key );
732 -
733 624 $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
734 -
735 - if ( ! $form ) {
736 - $error = __( 'Form does not exist', 'formidable' );
737 - wp_die(
738 - '<h1>' . esc_html( $error ) . '</h1>',
739 - '<p>' . esc_html( $error ) . '</p>',
740 - 404
741 - );
625 + if ( empty( $form ) ) {
626 + $form = FrmForm::getAll( array(), '', 1 );
742 627 }
743 628
744 - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
745 -
746 629 self::fix_deprecated_null_param_warning();
747 630
748 631 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
749 632 }
@@ -748,31 +631,8 @@
748 631 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
749 632 }
750 633
751 634 /**
752 - * Block the form preview for the contact form by default if the user cannot view forms.
753 - * This is to prevent the contact form being exploited.
754 - * Since this form is added by default and every site uses the same key, it is too easy
755 - * to guess this form.
756 - *
757 - * @since 6.20
758 - *
759 - * @param string $form_key Form key.
760 - *
761 - * @return void
762 - */
763 - public static function maybe_block_preview( $form_key ) {
764 - if ( FrmFormsHelper::should_block_preview( $form_key ) ) {
765 - $error = __( 'You do not have permission to view this form', 'formidable' );
766 - wp_die(
767 - '<h1>' . esc_html( $error ) . '</h1>',
768 - '<p>' . esc_html( $error ) . '</p>',
769 - 403
770 - );
771 - }
772 - }
773 -
774 - /**
775 635 * Some themes have a null $src value.
776 636 * This function adds a filter to ensure that $src is not null.
777 637 * WP will call str_starts_with with the null value triggering a deprecated message otherwise.
778 638 *
@@ -784,9 +644,8 @@
784 644 add_filter(
785 645 'script_loader_src',
786 646 /**
787 647 * @param string|null $src
788 - *
789 648 * @return string
790 649 */
791 650 function ( $src ) {
792 651 if ( is_null( $src ) ) {
@@ -802,9 +661,8 @@
802 661 }
803 662
804 663 /**
805 664 * @param array $ids
806 - *
807 665 * @return string
808 666 */
809 667 public static function bulk_untrash( $ids ) {
810 668 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -865,9 +723,8 @@
865 723 // Check nonce url.
866 724 check_admin_referer( $status . '_form_' . $params['id'] );
867 725
868 726 $count = 0;
869 -
870 727 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
871 728 ++$count;
872 729 }
873 730
@@ -890,9 +747,8 @@
890 747 }
891 748
892 749 /**
893 750 * @param array $ids
894 - *
895 751 * @return string
896 752 */
897 753 public static function bulk_trash( $ids ) {
898 754 FrmAppHelper::permission_check( 'frm_delete_forms' );
@@ -897,9 +753,8 @@
897 753 public static function bulk_trash( $ids ) {
898 754 FrmAppHelper::permission_check( 'frm_delete_forms' );
899 755
900 756 $count = 0;
901 -
902 757 foreach ( $ids as $id ) {
903 758 if ( FrmForm::trash( $id ) ) {
904 759 ++$count;
905 760 }
@@ -904,12 +759,8 @@
904 759 ++$count;
905 760 }
906 761 }
907 762
908 - if ( ! $count ) {
909 - return '';
910 - }
911 -
912 763 $current_page = FrmAppHelper::get_simple_request(
913 764 array(
914 765 'param' => 'form_type',
915 766 'type' => 'request',
@@ -934,9 +785,8 @@
934 785 // Check nonce url.
935 786 check_admin_referer( 'destroy_form_' . $params['id'] );
936 787
937 788 $count = 0;
938 -
939 789 if ( FrmForm::destroy( $params['id'] ) ) {
940 790 ++$count;
941 791 }
942 792
@@ -947,9 +797,8 @@
947 797 }
948 798
949 799 /**
950 800 * @param array $ids
951 - *
952 801 * @return string
953 802 */
954 803 public static function bulk_destroy( $ids ) {
955 804 FrmAppHelper::permission_check( 'frm_delete_forms' );
@@ -954,12 +803,10 @@
954 803 public static function bulk_destroy( $ids ) {
955 804 FrmAppHelper::permission_check( 'frm_delete_forms' );
956 805
957 806 $count = 0;
958 -
959 807 foreach ( $ids as $id ) {
960 808 $d = FrmForm::destroy( $id );
961 -
962 809 if ( $d ) {
963 810 ++$count;
964 811 }
965 812 }
@@ -977,9 +824,8 @@
977 824 */
978 825 public static function delete_all() {
979 826 // Check nonce url.
980 827 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
981 -
982 828 if ( $permission_error !== false ) {
983 829 self::display_forms_list( array(), '', array( $permission_error ) );
984 830
985 831 return;
@@ -1121,9 +967,8 @@
1121 967 private static function should_insert_form_popup() {
1122 968 if ( FrmAppHelper::is_form_builder_page() ) {
1123 969 return true;
1124 970 }
1125 -
1126 971 $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
1127 972 return in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ), true );
1128 973 }
1129 974
@@ -1131,9 +976,8 @@
1131 976 FrmAppHelper::permission_check( 'frm_view_forms' );
1132 977 check_ajax_referer( 'frm_ajax', 'nonce' );
1133 978
1134 979 $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
1135 -
1136 980 if ( empty( $shortcode ) ) {
1137 981 wp_die();
1138 982 }
1139 983
@@ -1159,9 +1003,8 @@
1159 1003 'label' => __( 'Minimize form HTML', 'formidable' ),
1160 1004 ),
1161 1005 );
1162 1006 }
1163 -
1164 1007 $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
1165 1008
1166 1009 if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
1167 1010 // allow other shortcodes to use the required form id option
@@ -1181,9 +1024,8 @@
1181 1024 *
1182 1025 * @param array $params
1183 1026 * @param string $message
1184 1027 * @param array $errors
1185 - *
1186 1028 * @return void
1187 1029 */
1188 1030 public static function display_forms_list( $params = array(), $message = '', $errors = array() ) {
1189 1031 FrmAppHelper::permission_check( 'frm_view_forms' );
@@ -1206,39 +1048,27 @@
1206 1048
1207 1049 $wp_list_table->prepare_items();
1208 1050
1209 1051 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
1210 -
1211 1052 if ( $pagenum > $total_pages && $total_pages > 0 ) {
1212 1053 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
1213 1054 die();
1214 1055 }
1215 1056
1216 - $inbox = new FrmInbox();
1217 - $error = $inbox->check_for_error();
1218 -
1219 - if ( $error ) {
1220 - $show_messages = array( $error['subject'] . '. ' . $error['message'] );
1221 - }
1222 -
1223 1057 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php';
1224 1058 }
1225 1059
1226 1060 /**
1227 1061 * @param array<string,string> $columns
1228 - *
1229 1062 * @return array<string,string>
1230 1063 */
1231 1064 public static function get_columns( $columns ) {
1232 - $columns['cb'] = '<input type="checkbox" />';
1233 - $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1234 - $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1235 - $columns['id'] = 'ID';
1236 - $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1237 -
1238 - if ( 'trash' !== FrmAppHelper::simple_get( 'form_type' ) ) {
1239 - $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1240 - }
1065 + $columns['cb'] = '<input type="checkbox" />';
1066 + $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1067 + $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1068 + $columns['id'] = 'ID';
1069 + $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1070 + $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1241 1071 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
1242 1072
1243 1073 add_screen_option(
1244 1074 'per_page',
@@ -1266,9 +1096,8 @@
1266 1096 }
1267 1097
1268 1098 /**
1269 1099 * @param mixed $hidden_columns
1270 - *
1271 1100 * @return array
1272 1101 */
1273 1102 public static function hidden_columns( $hidden_columns ) {
1274 1103 if ( ! is_array( $hidden_columns ) ) {
@@ -1289,15 +1118,8 @@
1289 1118
1290 1119 return $hidden_columns;
1291 1120 }
1292 1121
1293 - /**
1294 - * @param mixed $save
1295 - * @param string $option
1296 - * @param int|string $value
1297 - *
1298 - * @return mixed
1299 - */
1300 1122 public static function save_per_page( $save, $option, $value ) {
1301 1123 if ( $option === 'formidable_page_formidable_per_page' ) {
1302 1124 $save = (int) $value;
1303 1125 }
@@ -1309,9 +1131,8 @@
1309 1131 * @param int|string $id
1310 1132 * @param array $errors
1311 1133 * @param string $message
1312 1134 * @param bool $create_link
1313 - *
1314 1135 * @return void
1315 1136 */
1316 1137 private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1317 1138 global $frm_vars;
@@ -1326,9 +1147,8 @@
1326 1147 'page' => 'formidable',
1327 1148 )
1328 1149 ),
1329 1150 );
1330 -
1331 1151 if ( ! $form ) {
1332 1152 FrmAppController::show_error_modal( $error_args );
1333 1153 return;
1334 1154 }
@@ -1382,9 +1202,8 @@
1382 1202 */
1383 1203 $values['fields'] = apply_filters( 'frm_fields_in_form_builder', $fields, compact( 'form' ) );
1384 1204
1385 1205 $edit_message = __( 'Form was successfully updated.', 'formidable' );
1386 -
1387 1206 if ( $form->is_template && $message == $edit_message ) {
1388 1207 $message = __( 'Template was successfully updated.', 'formidable' );
1389 1208 }
1390 1209
@@ -1389,9 +1208,10 @@
1389 1208 }
1390 1209
1391 1210 self::maybe_update_form_builder_message( $message );
1392 1211
1393 - $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1212 + $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
1213 + $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1394 1214
1395 1215 if ( defined( 'DOING_AJAX' ) ) {
1396 1216 wp_die();
1397 1217 }
@@ -1400,12 +1220,11 @@
1400 1220 }
1401 1221
1402 1222 /**
1403 1223 * @param array $fields
1404 - *
1405 1224 * @return array
1406 1225 */
1407 - public static function update_form_builder_fields( $fields ) {
1226 + public static function update_form_builder_fields( $fields, $form ) {
1408 1227 foreach ( $fields as $field ) {
1409 1228 $field->do_not_include_icons = true;
1410 1229 }
1411 1230 return $fields;
@@ -1410,13 +1229,8 @@
1410 1229 }
1411 1230 return $fields;
1412 1231 }
1413 1232
1414 - /**
1415 - * @param string $message
1416 - *
1417 - * @return void
1418 - */
1419 1233 public static function maybe_update_form_builder_message( &$message ) {
1420 1234 if ( 'form_duplicated' === FrmAppHelper::simple_get( 'message' ) ) {
1421 1235 $message = __( 'Form was Successfully Copied', 'formidable' );
1422 1236 }
@@ -1425,9 +1239,8 @@
1425 1239 /**
1426 1240 * @param int|string $id
1427 1241 * @param array $errors
1428 1242 * @param array|string $args
1429 - *
1430 1243 * @return void
1431 1244 */
1432 1245 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1433 1246 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -1495,12 +1308,8 @@
1495 1308 }
1496 1309
1497 1310 /**
1498 1311 * @since 4.0
1499 - *
1500 - * @param array $atts
1501 - *
1502 - * @return void
1503 1312 */
1504 1313 public static function form_publish_button( $atts ) {
1505 1314 $values = $atts['values'];
1506 1315 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
@@ -1511,9 +1320,8 @@
1511 1320 *
1512 1321 * @since 4.0
1513 1322 *
1514 1323 * @param array $values
1515 - *
1516 1324 * @return array
1517 1325 */
1518 1326 private static function get_settings_tabs( $values ) {
1519 1327 $sections = array(
@@ -1519,9 +1327,9 @@
1519 1327 $sections = array(
1520 1328 'advanced' => array(
1521 1329 'name' => __( 'General', 'formidable' ),
1522 1330 'title' => __( 'General Form Settings', 'formidable' ),
1523 - 'function' => array( self::class, 'advanced_settings' ),
1331 + 'function' => array( __CLASS__, 'advanced_settings' ),
1524 1332 'icon' => 'frm_icon_font frm_settings_icon',
1525 1333 ),
1526 1334 'email' => array(
1527 1335 'name' => __( 'Actions & Notifications', 'formidable' ),
@@ -1537,9 +1345,8 @@
1537 1345 'medium' => 'permissions',
1538 1346 'upgrade' => __( 'Form Permissions', 'formidable' ),
1539 1347 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1540 1348 'screenshot' => 'permissions.png',
1541 - 'learn-more' => FrmAppHelper::get_doc_url( 'general-form-settings/#kb-form-permissions', 'form-permissions-settings' ),
1542 1349 ),
1543 1350 ),
1544 1351 'scheduling' => array(
1545 1352 'name' => __( 'Form Scheduling', 'formidable' ),
@@ -1548,14 +1355,13 @@
1548 1355 'data' => array(
1549 1356 'medium' => 'scheduling',
1550 1357 'upgrade' => __( 'Form scheduling settings', 'formidable' ),
1551 1358 'screenshot' => 'scheduling.png',
1552 - 'learn-more' => FrmAppHelper::get_doc_url( 'general-form-settings/#kb-form-scheduling', 'form-scheduling-settings' ),
1553 1359 ),
1554 1360 ),
1555 1361 'buttons' => array(
1556 1362 'name' => __( 'Buttons', 'formidable' ),
1557 - 'class' => self::class,
1363 + 'class' => __CLASS__,
1558 1364 'function' => 'buttons_settings',
1559 1365 'icon' => 'frm_icon_font frm_button_icon',
1560 1366 ),
1561 1367 'landing' => array(
@@ -1573,9 +1379,8 @@
1573 1379 array(
1574 1380 'upgrade' => __( 'Conversational Forms', 'formidable' ),
1575 1381 'message' => __( 'Ask one question at a time for automated conversations.', 'formidable' ),
1576 1382 'screenshot' => 'chat.png',
1577 - 'learn-more' => FrmAppHelper::get_doc_url( 'conversational-forms', 'conversational-forms-settings', false ),
1578 1383 )
1579 1384 ),
1580 1385 ),
1581 1386 'abandonment' => array(
@@ -1587,22 +1392,23 @@
1587 1392 array(
1588 1393 'upgrade' => __( 'Form abandonment settings', 'formidable' ),
1589 1394 'message' => __( 'Unlock the power of data capture to boost lead generation and master the art of form optimization.', 'formidable' ),
1590 1395 'screenshot' => 'abandonment.png',
1591 - 'learn-more' => FrmAppHelper::get_doc_url( 'features/form-abandonment-wordpress-plugin', 'form-abandonment-settings', false ),
1592 1396 )
1593 1397 ),
1594 1398 ),
1595 1399 'html' => array(
1596 1400 'name' => __( 'Customize HTML', 'formidable' ),
1597 - 'class' => self::class,
1401 + 'class' => __CLASS__,
1598 1402 'function' => 'html_settings',
1599 1403 'icon' => 'frm_icon_font frm_code_icon',
1600 1404 ),
1601 1405 );
1602 1406
1603 - if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1604 - unset( $sections['buttons'] );
1407 + foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1408 + if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1409 + unset( $sections[ $feature ] );
1410 + }
1605 1411 }
1606 1412
1607 1413 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1608 1414
@@ -1637,9 +1443,8 @@
1637 1443 /**
1638 1444 * @since 4.0
1639 1445 *
1640 1446 * @param array $values
1641 - *
1642 1447 * @return void
1643 1448 */
1644 1449 public static function advanced_settings( $values ) {
1645 1450 $first_h3 = 'frm_first_h3';
@@ -1648,9 +1453,8 @@
1648 1453 }
1649 1454
1650 1455 /**
1651 1456 * @param array $values
1652 - *
1653 1457 * @return void
1654 1458 */
1655 1459 public static function render_spam_settings( $values ) {
1656 1460 if ( function_exists( 'akismet_http_post' ) ) {
@@ -1655,9 +1459,9 @@
1655 1459 public static function render_spam_settings( $values ) {
1656 1460 if ( function_exists( 'akismet_http_post' ) ) {
1657 1461 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
1658 1462 }
1659 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/stopforumspam.php';
1463 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/honeypot.php';
1660 1464 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php';
1661 1465 }
1662 1466
1663 1467 /**
@@ -1663,9 +1467,8 @@
1663 1467 /**
1664 1468 * @since 4.0
1665 1469 *
1666 1470 * @param array $values
1667 - *
1668 1471 * @return void
1669 1472 */
1670 1473 public static function buttons_settings( $values ) {
1671 1474 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
@@ -1674,9 +1477,8 @@
1674 1477 /**
1675 1478 * @since 4.0
1676 1479 *
1677 1480 * @param array $values
1678 - *
1679 1481 * @return void
1680 1482 */
1681 1483 public static function html_settings( $values ) {
1682 1484 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
@@ -1687,9 +1489,8 @@
1687 1489 *
1688 1490 * @since 2.03.08
1689 1491 *
1690 1492 * @param array|bool $values
1691 - *
1692 1493 * @return void
1693 1494 */
1694 1495 private static function clean_submit_html( &$values ) {
1695 1496 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
@@ -1714,9 +1515,8 @@
1714 1515
1715 1516 /**
1716 1517 * @param int|string $form_id
1717 1518 * @param string $class
1718 - *
1719 1519 * @return void
1720 1520 */
1721 1521 public static function mb_tags_box( $form_id, $class = '' ) {
1722 1522 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -1743,12 +1543,8 @@
1743 1543 }
1744 1544
1745 1545 /**
1746 1546 * @since 3.04.01
1747 - *
1748 - * @param array $atts
1749 - *
1750 - * @return array
1751 1547 */
1752 1548 private static function advanced_helpers( $atts ) {
1753 1549 $advanced_helpers = array(
1754 1550 'default' => array(
@@ -1757,12 +1553,10 @@
1757 1553 ),
1758 1554 );
1759 1555
1760 1556 $user_fields = self::user_shortcodes();
1761 -
1762 1557 if ( $user_fields ) {
1763 1558 $user_helpers = array();
1764 -
1765 1559 foreach ( $user_fields as $uk => $uf ) {
1766 1560 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1767 1561 unset( $uk, $uf );
1768 1562 }
@@ -1787,10 +1581,8 @@
1787 1581 * Get an array of the options to display in the advanced tab
1788 1582 * of the customization panel
1789 1583 *
1790 1584 * @since 2.0.6
1791 - *
1792 - * @return array
1793 1585 */
1794 1586 private static function get_advanced_shortcodes() {
1795 1587 $adv_shortcodes = array(
1796 1588 'x sep=", "' => array(
@@ -1816,10 +1608,8 @@
1816 1608 }
1817 1609
1818 1610 /**
1819 1611 * @since 3.04.01
1820 - *
1821 - * @return array
1822 1612 */
1823 1613 private static function user_shortcodes() {
1824 1614 $options = array(
1825 1615 'ID' => __( 'User ID', 'formidable' ),
@@ -1838,12 +1628,8 @@
1838 1628 /**
1839 1629 * Get an array of the helper shortcodes to display in the customization panel
1840 1630 *
1841 1631 * @since 2.0.6
1842 - *
1843 - * @param bool $settings_tab
1844 - *
1845 - * @return array
1846 1632 */
1847 1633 private static function get_shortcode_helpers( $settings_tab ) {
1848 1634 $entry_shortcodes = array(
1849 1635 'id' => __( 'Entry ID', 'formidable' ),
@@ -1854,25 +1640,26 @@
1854 1640 'updated-at' => __( 'Entry updated', 'formidable' ),
1855 1641 '' => '',
1856 1642 'siteurl' => __( 'Site URL', 'formidable' ),
1857 1643 'sitename' => __( 'Site Name', 'formidable' ),
1858 - 'form_name' => __( 'Form Name', 'formidable' ),
1859 1644 );
1860 1645
1861 - $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1862 -
1863 1646 if ( ! FrmAppHelper::pro_is_installed() ) {
1864 1647 unset( $entry_shortcodes['post_id'] );
1865 1648 }
1866 1649
1650 + if ( $settings_tab ) {
1651 + $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1652 + $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1653 + $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1654 + $entry_shortcodes['form_name'] = __( 'Form Name', 'formidable' );
1655 + }
1656 +
1867 1657 /**
1868 1658 * Use this hook to add or remove buttons in the helpers section
1869 1659 * in the customization panel
1870 1660 *
1871 1661 * @since 2.0.6
1872 - *
1873 - * @param array $entry_shortcodes
1874 - * @param bool $settings_tab
1875 1662 */
1876 1663 $entry_shortcodes = apply_filters( 'frm_helper_shortcodes', $entry_shortcodes, $settings_tab );
1877 1664
1878 1665 return $entry_shortcodes;
@@ -1881,9 +1668,8 @@
1881 1668 /**
1882 1669 * Insert the form class setting into the form.
1883 1670 *
1884 1671 * @param stdClass $form
1885 - *
1886 1672 * @return void
1887 1673 */
1888 1674 public static function form_classes( $form ) {
1889 1675 if ( isset( $form->options['form_class'] ) ) {
@@ -1894,9 +1680,9 @@
1894 1680 echo ' frm_js_validate ';
1895 1681 self::add_js_validate_form_to_global_vars( $form );
1896 1682 }
1897 1683
1898 - if ( FrmForm::is_ajax_on( $form ) ) {
1684 + if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) {
1899 1685 echo ' frm_ajax_submit ';
1900 1686 }
1901 1687 }
1902 1688
@@ -1906,9 +1692,8 @@
1906 1692 * @param stdClass $form
1907 1693 */
1908 1694 public static function add_js_validate_form_to_global_vars( $form ) {
1909 1695 global $frm_vars;
1910 -
1911 1696 if ( ! isset( $frm_vars['js_validate_forms'] ) ) {
1912 1697 $frm_vars['js_validate_forms'] = array();
1913 1698 }
1914 1699 $frm_vars['js_validate_forms'][ $form->id ] = $form;
@@ -1931,9 +1716,8 @@
1931 1716 /**
1932 1717 * @param string $content
1933 1718 * @param int|stdClass|string $form
1934 1719 * @param false|int|stdClass|string $entry
1935 - *
1936 1720 * @return string
1937 1721 */
1938 1722 public static function filter_content( $content, $form, $entry = false ) {
1939 1723 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1938,9 +1722,8 @@
1938 1722 public static function filter_content( $content, $form, $entry = false ) {
1939 1723 $content = self::replace_form_name_shortcodes( $content, $form );
1940 1724
1941 1725 self::get_entry_by_param( $entry );
1942 -
1943 1726 if ( ! $entry ) {
1944 1727 return $content;
1945 1728 }
1946 1729
@@ -1968,9 +1751,8 @@
1968 1751 * @since 5.5
1969 1752 *
1970 1753 * @param array|string $string
1971 1754 * @param int|stdClass|string $form
1972 - *
1973 1755 * @return array|string
1974 1756 */
1975 1757 public static function replace_form_name_shortcodes( $string, $form ) {
1976 1758 if ( ! is_string( $string ) ) {
@@ -1990,9 +1772,8 @@
1990 1772 }
1991 1773
1992 1774 /**
1993 1775 * @param false|int|stdClass|string $entry
1994 - *
1995 1776 * @return void
1996 1777 */
1997 1778 private static function get_entry_by_param( &$entry ) {
1998 1779 if ( ! $entry || ! is_object( $entry ) ) {
@@ -2003,15 +1784,8 @@
2003 1784 FrmEntry::maybe_get_entry( $entry );
2004 1785 }
2005 1786 }
2006 1787
2007 - /**
2008 - * @param string $content
2009 - * @param false|object $entry
2010 - * @param array $shortcodes
2011 - *
2012 - * @return string
2013 - */
2014 1788 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
2015 1789 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
2016 1790 }
2017 1791
@@ -2016,9 +1790,8 @@
2016 1790 }
2017 1791
2018 1792 /**
2019 1793 * @param array $errors
2020 - *
2021 1794 * @return array
2022 1795 */
2023 1796 public static function process_bulk_form_actions( $errors ) {
2024 1797 if ( ! $_REQUEST ) {
@@ -2025,9 +1798,8 @@
2025 1798 return $errors;
2026 1799 }
2027 1800
2028 1801 $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
2029 -
2030 1802 if ( $bulkaction == - 1 ) {
2031 1803 $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
2032 1804 }
2033 1805
@@ -2037,9 +1809,8 @@
2037 1809 $bulkaction = str_replace( 'bulk_', '', $bulkaction );
2038 1810 }
2039 1811
2040 1812 $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
2041 -
2042 1813 if ( empty( $ids ) ) {
2043 1814 $errors[] = __( 'No forms were specified', 'formidable' );
2044 1815
2045 1816 return $errors;
@@ -2045,9 +1816,8 @@
2045 1816 return $errors;
2046 1817 }
2047 1818
2048 1819 $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
2049 -
2050 1820 if ( $permission_error !== false ) {
2051 1821 $errors[] = $permission_error;
2052 1822
2053 1823 return $errors;
@@ -2074,23 +1844,8 @@
2074 1844
2075 1845 return $errors;
2076 1846 }
2077 1847
2078 - /**
2079 - * Includes html that shows a message when the device is too small to use Formidable Forms admin pages.
2080 - *
2081 - * @since 6.20
2082 - *
2083 - * @return void
2084 - */
2085 - public static function include_device_too_small_message() {
2086 - if ( ! FrmAppHelper::is_formidable_admin() ) {
2087 - return;
2088 - }
2089 -
2090 - include FrmAppHelper::plugin_path() . '/classes/views/shared/small-device-message.php';
2091 - }
2092 -
2093 1848 public static function route() {
2094 1849 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
2095 1850 $vars = array();
2096 1851 FrmAppHelper::include_svg();
@@ -2101,13 +1856,11 @@
2101 1856 // Javascript needs to be allowed in some field settings.
2102 1857 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
2103 1858 $json_vars = htmlspecialchars_decode( nl2br( str_replace( '&quot;', '"', wp_unslash( $_POST['frm_compact_fields'] ) ) ) );
2104 1859 $json_vars = json_decode( $json_vars, true );
2105 -
2106 1860 if ( empty( $json_vars ) ) {
2107 1861 // json decoding failed so we should return an error message.
2108 1862 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
2109 -
2110 1863 if ( 'edit' === $action ) {
2111 1864 $action = 'update';
2112 1865 }
2113 1866
@@ -2120,9 +1873,8 @@
2120 1873 $_POST = array_merge( $_POST, $_REQUEST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
2121 1874 }
2122 1875 } else {
2123 1876 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
2124 -
2125 1877 if ( isset( $_REQUEST['delete_all'] ) ) {
2126 1878 // Override the action for this page.
2127 1879 $action = 'delete_all';
2128 1880 }
@@ -2148,15 +1900,13 @@
2148 1900 self::no_views( $vars );
2149 1901 return;
2150 1902 default:
2151 1903 do_action( 'frm_form_action_' . $action );
2152 -
2153 1904 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
2154 1905 return;
2155 1906 }
2156 1907
2157 1908 $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
2158 -
2159 1909 if ( $action == - 1 ) {
2160 1910 $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
2161 1911 }
2162 1912
@@ -2167,9 +1917,8 @@
2167 1917 return;
2168 1918 }
2169 1919
2170 1920 $message = FrmAppHelper::get_param( 'message' );
2171 -
2172 1921 if ( 'form_duplicate_error' === $message ) {
2173 1922 self::display_forms_list( array(), '', array( __( 'There was a problem duplicating the form', 'formidable' ) ) );
2174 1923 return;
2175 1924 }
@@ -2205,45 +1954,29 @@
2205 1954 // Get posted data
2206 1955 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2207 1956 $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2208 1957
2209 - $form = FrmForm::getOne( $form_id );
1958 + // Update the form name and form key.
1959 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
1960 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
2210 1961
2211 - if ( ! $form ) {
2212 - wp_send_json_error( __( 'Form not found', 'formidable' ) );
2213 - }
1962 + wp_send_json_success( compact( 'form_key' ) );
1963 + }
2214 1964
2215 - if ( $name === $form->name ) {
2216 - // Nothing to change so exit early.
2217 - wp_send_json_success();
2218 - }
1965 + public static function json_error( $errors ) {
1966 + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
2219 1967
2220 - $to_update = array(
2221 - 'name' => $name,
2222 - );
2223 -
2224 - if ( '' !== $name ) {
2225 - // Only update form_key if name is not empty.
2226 - $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
2227 - $to_update['form_key'] = $form_key;
2228 - } else {
2229 - $form_key = $form->form_key;
2230 - }
2231 -
2232 - FrmForm::update( $form_id, $to_update );
2233 -
2234 - wp_send_json_success( compact( 'form_key' ) );
1968 + return $errors;
2235 1969 }
2236 1970
2237 1971 /**
2238 - * @param array $errors
1972 + * Education for premium features.
2239 1973 *
2240 - * @return array
1974 + * @since 4.05
1975 + * @return void
2241 1976 */
2242 - public static function json_error( $errors ) {
2243 - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
2244 -
2245 - return $errors;
1977 + public static function add_form_style_tab_options() {
1978 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php';
2246 1979 }
2247 1980
2248 1981 /**
2249 1982 * Add education about views.
@@ -2249,10 +1982,8 @@
2249 1982 * Add education about views.
2250 1983 *
2251 1984 * @since 4.07
2252 1985 *
2253 - * @param array $values
2254 - *
2255 1986 * @return void
2256 1987 */
2257 1988 public static function no_views( $values = array() ) {
2258 1989 FrmAppHelper::include_svg();
@@ -2266,10 +1997,8 @@
2266 1997 * Add education about reports.
2267 1998 *
2268 1999 * @since 4.07
2269 2000 *
2270 - * @param array $values
2271 - *
2272 2001 * @return void
2273 2002 */
2274 2003 public static function no_reports( $values = array() ) {
2275 2004 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -2296,9 +2025,8 @@
2296 2025 * @since 4.05.02
2297 2026 */
2298 2027 private static function move_menu_to_footer() {
2299 2028 $settings = FrmAppHelper::get_settings();
2300 -
2301 2029 if ( empty( $settings->admin_bar ) ) {
2302 2030 remove_action( 'wp_body_open', 'wp_admin_bar_render', 0 );
2303 2031 }
2304 2032 }
@@ -2304,15 +2032,13 @@
2304 2032 }
2305 2033
2306 2034 public static function admin_bar_configure() {
2307 2035 global $frm_vars;
2308 -
2309 2036 if ( empty( $frm_vars['forms_loaded'] ) ) {
2310 2037 return;
2311 2038 }
2312 2039
2313 2040 $actions = array();
2314 -
2315 2041 foreach ( $frm_vars['forms_loaded'] as $form ) {
2316 2042 if ( is_object( $form ) ) {
2317 2043 $actions[ $form->id ] = $form->name;
2318 2044 }
@@ -2346,12 +2072,8 @@
2346 2072 }
2347 2073
2348 2074 /**
2349 2075 * @since 2.05.07
2350 - *
2351 - * @param array $actions
2352 - *
2353 - * @return void
2354 2076 */
2355 2077 private static function add_forms_to_admin_bar( $actions ) {
2356 2078 global $wp_admin_bar;
2357 2079
@@ -2362,9 +2084,9 @@
2362 2084 $wp_admin_bar->add_node(
2363 2085 array(
2364 2086 'parent' => 'frm-forms',
2365 2087 'id' => 'edit_form_' . $form_id,
2366 - 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name,
2088 + 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
2367 2089 'href' => FrmForm::get_edit_link( $form_id ),
2368 2090 )
2369 2091 );
2370 2092 }
@@ -2373,14 +2095,12 @@
2373 2095 /**
2374 2096 * The formidable shortcode
2375 2097 *
2376 2098 * @param array $atts The params from the shortcode.
2377 - *
2378 2099 * @return string
2379 2100 */
2380 2101 public static function get_form_shortcode( $atts ) {
2381 2102 global $frm_vars;
2382 -
2383 2103 if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2384 2104 $sc = '[formidable';
2385 2105 $sc .= FrmAppHelper::array_to_html_params( $atts );
2386 2106 return $sc . ']';
@@ -2409,9 +2129,8 @@
2409 2129 * @since 5.2.01
2410 2130 *
2411 2131 * @param false|int|string $id
2412 2132 * @param false|string $key
2413 - *
2414 2133 * @return false|stdClass
2415 2134 */
2416 2135 private static function maybe_get_form_by_id_or_key( $id, $key ) {
2417 2136 if ( ! $id ) {
@@ -2425,9 +2144,8 @@
2425 2144 * @param false|string $key
2426 2145 * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2427 2146 * @param bool|int|string $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2428 2147 * @param array $atts
2429 - *
2430 2148 * @return string
2431 2149 */
2432 2150 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
2433 2151 $form = self::maybe_get_form_by_id_or_key( $id, $key );
@@ -2475,9 +2193,8 @@
2475 2193 }
2476 2194
2477 2195 /**
2478 2196 * @param false|int|string $id
2479 - *
2480 2197 * @return false|stdClass
2481 2198 */
2482 2199 private static function maybe_get_form_to_show( $id ) {
2483 2200 $form = false;
@@ -2484,9 +2201,8 @@
2484 2201
2485 2202 if ( ! empty( $id ) ) {
2486 2203 // Form id or key is set.
2487 2204 $form = FrmForm::getOne( $id );
2488 -
2489 2205 if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) {
2490 2206 $form = false;
2491 2207 }
2492 2208 }
@@ -2493,25 +2209,12 @@
2493 2209
2494 2210 return $form;
2495 2211 }
2496 2212
2497 - /**
2498 - * @param object $form
2499 - *
2500 - * @return bool
2501 - */
2502 2213 private static function is_viewable_draft_form( $form ) {
2503 2214 return $form->status === 'draft' && current_user_can( 'frm_edit_forms' ) && ! FrmAppHelper::is_preview_page();
2504 2215 }
2505 2216
2506 - /**
2507 - * @param object $form
2508 - * @param bool $title
2509 - * @param bool $description
2510 - * @param array $atts
2511 - *
2512 - * @return string
2513 - */
2514 2217 public static function get_form( $form, $title, $description, $atts = array() ) {
2515 2218 ob_start();
2516 2219
2517 2220 do_action( 'frm_before_get_form', $atts );
@@ -2526,25 +2229,12 @@
2526 2229
2527 2230 return $contents;
2528 2231 }
2529 2232
2530 - /**
2531 - * @param array $params
2532 - *
2533 - * @return void
2534 - */
2535 2233 public static function enqueue_scripts( $params ) {
2536 2234 do_action( 'frm_enqueue_form_scripts', $params );
2537 2235 }
2538 2236
2539 - /**
2540 - * @param object $form
2541 - * @param bool $title
2542 - * @param bool $description
2543 - * @param array $atts
2544 - *
2545 - * @return void
2546 - */
2547 2237 public static function get_form_contents( $form, $title, $description, $atts ) {
2548 2238 $params = FrmForm::get_params( $form );
2549 2239 $errors = self::get_saved_errors( $form, $params );
2550 2240 $fields = FrmFieldsHelper::get_form_fields( $form->id, $errors );
@@ -2558,9 +2248,8 @@
2558 2248 FrmFormState::set_initial_value( 'title', $title );
2559 2249 FrmFormState::set_initial_value( 'description', $description );
2560 2250
2561 2251 do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
2562 -
2563 2252 if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
2564 2253 self::show_form_after_submit( $pass_args );
2565 2254 }
2566 2255 } elseif ( ! empty( $errors ) ) {
@@ -2591,13 +2280,8 @@
2591 2280 /**
2592 2281 * If the form was processed earlier (init), get the generated errors
2593 2282 *
2594 2283 * @since 2.05
2595 - *
2596 - * @param object $form
2597 - * @param array $params
2598 - *
2599 - * @return array
2600 2284 */
2601 2285 private static function get_saved_errors( $form, $params ) {
2602 2286 global $frm_vars;
2603 2287
@@ -2619,12 +2303,8 @@
2619 2303 }
2620 2304
2621 2305 /**
2622 2306 * @since 2.2.7
2623 - *
2624 - * @param int|string $form_id
2625 - *
2626 - * @return int
2627 2307 */
2628 2308 public static function just_created_entry( $form_id ) {
2629 2309 global $frm_vars;
2630 2310
@@ -2642,9 +2322,8 @@
2642 2322 *
2643 2323 * @type object $form Form object.
2644 2324 * @type int $entry_id Entry ID.
2645 2325 * }
2646 - *
2647 2326 * @return array|string
2648 2327 */
2649 2328 private static function get_confirmation_method( $atts ) {
2650 2329 $action = FrmOnSubmitHelper::current_event( $atts );
@@ -2652,9 +2331,8 @@
2652 2331 $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2653 2332
2654 2333 if ( ! empty( $atts['entry_id'] ) ) {
2655 2334 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2656 -
2657 2335 if ( $met_actions ) {
2658 2336 $method = $met_actions;
2659 2337 }
2660 2338 }
@@ -2667,15 +2345,8 @@
2667 2345
2668 2346 return $method;
2669 2347 }
2670 2348
2671 - /**
2672 - * @param object $form
2673 - * @param array $params
2674 - * @param array $args
2675 - *
2676 - * @return void
2677 - */
2678 2349 public static function maybe_trigger_redirect( $form, $params, $args ) {
2679 2350 if ( ! isset( $params['id'] ) ) {
2680 2351 global $frm_vars;
2681 2352 $params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id'];
@@ -2703,9 +2374,9 @@
2703 2374 * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}.
2704 2375 */
2705 2376 public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) {
2706 2377 if ( is_array( $conf_method ) && 1 === count( $conf_method ) ) {
2707 - if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) && empty( $conf_method[0]->post_content['redirect_delay'] ) ) {
2378 + if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) ) {
2708 2379 $event = FrmOnSubmitHelper::current_event( $params );
2709 2380 FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event );
2710 2381 $conf_method = 'redirect';
2711 2382 }
@@ -2715,15 +2386,8 @@
2715 2386 self::trigger_redirect( $form, $params, $args );
2716 2387 }
2717 2388 }
2718 2389
2719 - /**
2720 - * @param object $form
2721 - * @param array $params
2722 - * @param array $args
2723 - *
2724 - * @return void
2725 - */
2726 2390 public static function trigger_redirect( $form, $params, $args ) {
2727 2391 $success_args = array(
2728 2392 'action' => $params['action'],
2729 2393 'conf_method' => 'redirect',
@@ -2782,9 +2446,8 @@
2782 2446 * @since 6.0
2783 2447 *
2784 2448 * @param array $args See {@see FrmFormsController::run_success_action()}.
2785 2449 * @param string $event Form event. Default is `create`.
2786 - *
2787 2450 * @return array Array of actions that meet the conditional logics.
2788 2451 */
2789 2452 public static function get_met_on_submit_actions( $args, $event = 'create' ) {
2790 2453 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
@@ -2857,9 +2520,8 @@
2857 2520 *
2858 2521 * @param object $action Form action object.
2859 2522 * @param array $args See {@see FrmFormsController::run_success_action()}.
2860 2523 * @param string $event Form event. Default is `create`.
2861 - *
2862 2524 * @return bool
2863 2525 */
2864 2526 private static function is_valid_on_submit_action( $action, $args, $event = 'create' ) {
2865 2527 $action_type = FrmOnSubmitHelper::get_action_type( $action );
@@ -2881,9 +2543,8 @@
2881 2543 return false;
2882 2544 }
2883 2545
2884 2546 $page = get_post( $action->post_content['success_page_id'] );
2885 -
2886 2547 if ( ! $page || 'trash' === $page->post_status ) {
2887 2548 return false;
2888 2549 }
2889 2550 }
@@ -2905,9 +2566,8 @@
2905 2566 'entry_id' => $args['entry_id'],
2906 2567 'action' => FrmOnSubmitHelper::current_event( $args ),
2907 2568 )
2908 2569 );
2909 -
2910 2570 if ( ! is_array( $args['conf_method'] ) ) {
2911 2571 self::run_success_action( $args );
2912 2572 return;
2913 2573 }
@@ -2934,9 +2594,8 @@
2934 2594 * @param array $args See {@see FrmFormsController::run_success_action()}.
2935 2595 */
2936 2596 public static function run_multi_on_submit_actions( $args ) {
2937 2597 $redirect_action = null;
2938 -
2939 2598 foreach ( $args['conf_method'] as $action ) {
2940 2599 if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $action ) ) {
2941 2600 // We catch the redirect action to run it last.
2942 2601 $redirect_action = $action;
@@ -2974,9 +2633,8 @@
2974 2633 * @since 6.0
2975 2634 *
2976 2635 * @param array $args See {@see FrmFormsController::run_success_action()}.
2977 2636 * @param object $action On Submit action object.
2978 - *
2979 2637 * @return array
2980 2638 */
2981 2639 private static function get_run_success_action_args( $args, $action ) {
2982 2640 $new_args = $args;
@@ -3000,17 +2658,12 @@
3000 2658 }
3001 2659
3002 2660 /**
3003 2661 * @since 3.0
3004 - *
3005 - * @param array $args
3006 - *
3007 - * @return void
3008 2662 */
3009 2663 private static function load_page_after_submit( $args ) {
3010 2664 global $post;
3011 2665 $opt = $args['success_opt'];
3012 -
3013 2666 if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
3014 2667 $page = get_post( $args['form']->options[ $opt . '_page_id' ] );
3015 2668 $old_post = $post;
3016 2669 $post = $page;
@@ -3034,9 +2687,8 @@
3034 2687 }
3035 2688
3036 2689 /**
3037 2690 * @since 3.0
3038 - *
3039 2691 * @param array $args See {@see FrmFormsController::run_success_action()}.
3040 2692 */
3041 2693 private static function redirect_after_submit( $args ) {
3042 2694 add_filter( 'frm_use_wpautop', '__return_false' );
@@ -3059,9 +2711,9 @@
3059 2711 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
3060 2712 wp_die();
3061 2713 }
3062 2714
3063 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) {
2715 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) {
3064 2716 // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
3065 2717 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
3066 2718 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
3067 2719 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
@@ -3103,51 +2755,31 @@
3103 2755 *
3104 2756 * @since 6.3.1
3105 2757 *
3106 2758 * @param array $args See {@see FrmFormsController::run_success_action()}.
3107 - *
3108 2759 * @return array
3109 2760 */
3110 2761 private static function get_ajax_redirect_response_data( $args ) {
3111 - $response_data = array(
3112 - 'redirect' => $args['success_url'],
3113 - 'content' => '',
3114 - );
3115 - $unset_content = true;
2762 + $response_data = array( 'redirect' => $args['success_url'] );
3116 2763
3117 - if ( ! empty( $args['form']->options['redirect_delay'] ) ) {
3118 - $response_data['delay'] = $args['form']->options['redirect_delay_time'];
3119 - $response_data['content'] .= self::get_redirect_message( $args['success_url'], $args['form']->options['redirect_delay_msg'], $args );
3120 - $unset_content = false;
3121 - }
3122 -
3123 2764 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
3124 2765 $response_data['openInNewTab'] = 1;
3125 2766
3126 - // Only show open in new tab text if there is no delay.
3127 - if ( empty( $response_data['content'] ) ) {
3128 - $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2767 + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
3129 2768
3130 - $args['form']->options['success_msg'] = $args['message'];
3131 - $args['form']->options['edit_msg'] = $args['message'];
2769 + $args['form']->options['success_msg'] = $args['message'];
2770 + $args['form']->options['edit_msg'] = $args['message'];
2771 + if ( ! isset( $args['fields'] ) ) {
2772 + $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2773 + }
3132 2774
3133 - if ( ! isset( $args['fields'] ) ) {
3134 - $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
3135 - }
2775 + $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
3136 2776
3137 - $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2777 + ob_start();
2778 + self::show_lone_success_message( $args );
2779 + $response_data['content'] = ob_get_clean();
3138 2780
3139 - ob_start();
3140 - self::show_lone_success_message( $args );
3141 - $response_data['content'] .= ob_get_clean();
3142 - $unset_content = false;
3143 - }//end if
3144 -
3145 2781 $response_data['fallbackMsg'] = self::get_redirect_fallback_message( $args['success_url'], $args );
3146 - }//end if
3147 -
3148 - if ( $unset_content && '' === $response_data['content'] ) {
3149 - unset( $response_data['content'] );
3150 2782 }
3151 2783
3152 2784 return $response_data;
3153 2785 }
@@ -3159,9 +2791,9 @@
3159 2791 *
3160 2792 * @param array $args See {@see FrmFormsController::run_success_action()}.
3161 2793 */
3162 2794 private static function redirect_after_submit_using_js( $args ) {
3163 - $success_msg = $args['form']->options['redirect_delay_msg'];
2795 + $success_msg = FrmOnSubmitHelper::get_default_redirect_msg();
3164 2796 $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args );
3165 2797 $success_url = esc_url_raw( $args['success_url'] );
3166 2798
3167 2799 /**
@@ -3170,9 +2802,9 @@
3170 2802 * @since 6.0
3171 2803 *
3172 2804 * @param int $delay_time Delay time in milliseconds.
3173 2805 */
3174 - $delay_time = apply_filters( 'frm_redirect_delay_time', 1000 * $args['form']->options['redirect_delay_time'] );
2806 + $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
3175 2807
3176 2808 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
3177 2809 $redirect_js = 'window.open("' . $success_url . '", "_blank")';
3178 2810 } else {
@@ -3182,15 +2814,13 @@
3182 2814 add_filter( 'frm_use_wpautop', '__return_true' );
3183 2815
3184 2816 echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3185 2817 echo '<script>';
3186 -
3187 2818 if ( empty( $args['doing_ajax'] ) ) {
3188 2819 // Not AJAX submit, delay JS until window.load.
3189 2820 echo 'window.onload=function(){';
3190 2821 }
3191 2822 echo 'setTimeout(function(){' . $redirect_js . '}, ' . intval( $delay_time ) . ');'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3192 -
3193 2823 if ( empty( $args['doing_ajax'] ) ) {
3194 2824 echo '};';
3195 2825 }
3196 2826 echo '</script>';
@@ -3203,10 +2833,8 @@
3203 2833 * @param string $success_msg
3204 2834 * @param array $args
3205 2835 */
3206 2836 private static function get_redirect_message( $success_url, $success_msg, $args ) {
3207 - $success_msg = apply_filters( 'frm_content', $success_msg, $args['form'], $args['entry_id'] );
3208 - $success_msg = do_shortcode( FrmAppHelper::use_wpautop( $success_msg ) );
3209 2837 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
3210 2838 self::get_redirect_fallback_message( $success_url, $args ) .
3211 2839 '</div></div>';
3212 2840
@@ -3225,14 +2853,12 @@
3225 2853 * @since 6.3.1
3226 2854 *
3227 2855 * @param string $success_url Redirect URL.
3228 2856 * @param array $args Contains `form` object.
3229 - *
3230 2857 * @return string
3231 2858 */
3232 2859 private static function get_redirect_fallback_message( $success_url, $args ) {
3233 2860 $target = '';
3234 -
3235 2861 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
3236 2862 $target = ' target="_blank"';
3237 2863 }
3238 2864
@@ -3247,12 +2873,8 @@
3247 2873 /**
3248 2874 * Prepare to show the success message and empty form after submit
3249 2875 *
3250 2876 * @since 2.05
3251 - *
3252 - * @param array $atts
3253 - *
3254 - * @return void
3255 2877 */
3256 2878 public static function show_message_after_save( $atts ) {
3257 2879 $atts['message'] = self::prepare_submit_message( $atts['form'], $atts['entry_id'], $atts );
3258 2880
@@ -3258,9 +2880,8 @@
3258 2880
3259 2881 if ( ! isset( $atts['form']->options['show_form'] ) || $atts['form']->options['show_form'] ) {
3260 2882 if ( isset( $atts['action'] ) && 'update' === $atts['action'] && is_callable( array( 'FrmProEntriesController', 'show_front_end_form_with_entry' ) ) ) {
3261 2883 $entry = FrmEntry::getOne( $atts['entry_id'] );
3262 -
3263 2884 if ( $entry ) {
3264 2885 // This is copied from the Pro plugin.
3265 2886 $atts['conf_message'] = FrmProEntriesController::confirmation( 'message', $atts['form'], $atts['form']->options, $entry->id, $atts );
3266 2887 $atts['show_form'] = FrmProEntriesController::is_form_displayed_after_edit( $atts['form'] );
@@ -3277,12 +2898,8 @@
3277 2898 /**
3278 2899 * Show an empty form
3279 2900 *
3280 2901 * @since 2.05
3281 - *
3282 - * @param array $args
3283 - *
3284 - * @return void
3285 2902 */
3286 2903 private static function show_form_after_submit( $args ) {
3287 2904 self::fill_atts_for_form_display( $args );
3288 2905
@@ -3303,9 +2920,9 @@
3303 2920
3304 2921 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
3305 2922
3306 2923 $frm_settings = FrmAppHelper::get_settings();
3307 - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value;
2924 + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
3308 2925
3309 2926 global $frm_vars;
3310 2927 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
3311 2928
@@ -3314,19 +2931,12 @@
3314 2931 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
3315 2932 }
3316 2933
3317 2934 /**
3318 - * Gets message placement.
3319 - *
3320 2935 * @since 4.05.02
3321 - * @since 6.26 This method changed from `private` to `public`.
3322 - *
3323 - * @param object $form Form object.
3324 - * @param string $message The message.
3325 - *
3326 - * @return string Accepts 'before', 'after', or 'submit'.
2936 + * @return string - 'before', 'after', or 'submit'
3327 2937 */
3328 - public static function message_placement( $form, $message ) {
2938 + private static function message_placement( $form, $message ) {
3329 2939 $place = 'before';
3330 2940
3331 2941 if ( $message && isset( $form->options['form_class'] ) ) {
3332 2942 if ( strpos( $form->options['form_class'], 'frm_below_success' ) !== false ) {
@@ -3336,14 +2946,10 @@
3336 2946 }
3337 2947 }
3338 2948
3339 2949 /**
3340 - * Filter the message placement.
3341 - *
3342 2950 * @since 4.05.02
3343 - *
3344 - * @param string $place Accepts 'before', 'after', or 'submit'.
3345 - * @param array $args Args.
2951 + * @return string - 'before' or 'after'
3346 2952 */
3347 2953 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
3348 2954 }
3349 2955
@@ -3350,12 +2956,8 @@
3350 2956 /**
3351 2957 * Get all the values needed on the new.php entry page
3352 2958 *
3353 2959 * @since 2.05
3354 - *
3355 - * @param array $args
3356 - *
3357 - * @return void
3358 2960 */
3359 2961 private static function fill_atts_for_form_display( &$args ) {
3360 2962 if ( ! isset( $args['title'] ) && isset( $args['show_title'] ) ) {
3361 2963 $args['title'] = $args['show_title'];
@@ -3380,12 +2982,8 @@
3380 2982 /**
3381 2983 * Show the success message without the form
3382 2984 *
3383 2985 * @since 2.05
3384 - *
3385 - * @param array $atts
3386 - *
3387 - * @return void
3388 2986 */
3389 2987 private static function show_lone_success_message( $atts ) {
3390 2988 global $frm_vars;
3391 2989 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
@@ -3408,17 +3006,16 @@
3408 3006 *
3409 3007 * @param object $form Form object.
3410 3008 * @param int $entry_id Entry ID.
3411 3009 * @param array $args See {@see FrmFormsController::run_success_action()}.
3412 - *
3413 3010 * @return string
3414 3011 */
3415 3012 private static function prepare_submit_message( $form, $entry_id, $args = array() ) {
3416 3013 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
3417 - $opt = $args['success_opt'] ?? 'success';
3014 + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
3418 3015
3419 3016 if ( $entry_id && is_numeric( $entry_id ) ) {
3420 - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg;
3017 + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
3421 3018 $class = 'frm_message';
3422 3019 } else {
3423 3020 $message = $frm_settings->failed_msg;
3424 3021 $class = FrmFormsHelper::form_error_class();
@@ -3459,15 +3056,8 @@
3459 3056 public static function has_combo_js_file() {
3460 3057 return is_readable( FrmAppHelper::plugin_path() . '/js/frm.min.js' );
3461 3058 }
3462 3059
3463 - /**
3464 - * @param object $form
3465 - * @param int|string $this_load
3466 - * @param bool $global_load
3467 - *
3468 - * @return void
3469 - */
3470 3060 public static function maybe_load_css( $form, $this_load, $global_load ) {
3471 3061 $load_css = FrmForm::is_form_loaded( $form, $this_load, $global_load );
3472 3062
3473 3063 if ( ! $load_css ) {
@@ -3497,9 +3087,8 @@
3497 3087 return;
3498 3088 }
3499 3089
3500 3090 global $wp_styles;
3501 -
3502 3091 if ( is_array( $wp_styles->queue ) && in_array( 'formidable', $wp_styles->queue, true ) ) {
3503 3092 wp_print_styles( 'formidable' );
3504 3093 }
3505 3094 }
@@ -3514,16 +3103,10 @@
3514 3103 private static function should_load_late() {
3515 3104 return ! function_exists( 'aioseo' );
3516 3105 }
3517 3106
3518 - /**
3519 - * @param string $tag
3520 - * @param string $handle
3521 - *
3522 - * @return string
3523 - */
3524 3107 public static function defer_script_loading( $tag, $handle ) {
3525 - if ( 'captcha-api' === $handle && ! strpos( $tag, 'defer' ) ) {
3108 + if ( 'captcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
3526 3109 $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
3527 3110 }
3528 3111
3529 3112 return $tag;
@@ -3528,13 +3111,8 @@
3528 3111
3529 3112 return $tag;
3530 3113 }
3531 3114
3532 - /**
3533 - * @param string $location
3534 - *
3535 - * @return void
3536 - */
3537 3115 public static function footer_js( $location = 'footer' ) {
3538 3116 global $frm_vars;
3539 3117
3540 3118 FrmStylesController::enqueue_css();
@@ -3541,20 +3119,13 @@
3541 3119
3542 3120 if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3543 3121 // load formidable js
3544 3122 wp_enqueue_script( 'formidable' );
3545 -
3546 - FrmHoneypot::maybe_print_honeypot_js();
3547 3123 }
3548 3124 }
3549 3125
3550 3126 /**
3551 3127 * @since 2.0.8
3552 - *
3553 - * @param array $atts
3554 - * @param string $content
3555 - *
3556 - * @return void
3557 3128 */
3558 3129 private static function maybe_minimize_form( $atts, &$content ) {
3559 3130 // check if minimizing is turned on
3560 3131 if ( self::is_minification_on( $atts ) ) {
@@ -3563,11 +3134,8 @@
3563 3134 }
3564 3135
3565 3136 /**
3566 3137 * @since 2.0.8
3567 - *
3568 - * @param array $atts
3569 - *
3570 3138 * @return bool
3571 3139 */
3572 3140 private static function is_minification_on( $atts ) {
3573 3141 return ! empty( $atts['minimize'] );
@@ -3579,9 +3147,8 @@
3579 3147 * @return void
3580 3148 */
3581 3149 public static function landing_page_preview_option() {
3582 3150 $dir = apply_filters( 'frm_landing_page_preview_option', false );
3583 -
3584 3151 if ( false === $dir || ! file_exists( $dir . 'landing-page-preview-option.php' ) ) {
3585 3152 $dir = self::get_form_views_path();
3586 3153 }
3587 3154 include $dir . 'landing-page-preview-option.php';
@@ -3610,15 +3177,13 @@
3610 3177
3611 3178 check_ajax_referer( 'frm_ajax', 'nonce' );
3612 3179
3613 3180 $type = FrmAppHelper::get_post_param( 'type', '', 'sanitize_text_field' );
3614 -
3615 3181 if ( ! $type || ! in_array( $type, array( 'form', 'view' ), true ) ) {
3616 3182 die( 0 );
3617 3183 }
3618 3184
3619 3185 $object_id = FrmAppHelper::get_post_param( 'object_id', '', 'absint' );
3620 -
3621 3186 if ( ! $object_id ) {
3622 3187 die( 0 );
3623 3188 }
3624 3189
@@ -3630,15 +3195,13 @@
3630 3195 $postarr['post_content'] = apply_filters( 'frm_create_page_with_' . $type . '_shortcode_content', '', $object_id );
3631 3196 }
3632 3197
3633 3198 $name = FrmAppHelper::get_post_param( 'name', '', 'sanitize_text_field' );
3634 -
3635 3199 if ( $name ) {
3636 3200 $postarr['post_title'] = $name;
3637 3201 }
3638 3202
3639 3203 $success = wp_insert_post( $postarr );
3640 -
3641 3204 if ( ! is_numeric( $success ) || ! $success ) {
3642 3205 die( 0 );
3643 3206 }
3644 3207
@@ -3652,9 +3215,8 @@
3652 3215 /**
3653 3216 * @since 5.3
3654 3217 *
3655 3218 * @param int $form_id
3656 - *
3657 3219 * @return string
3658 3220 */
3659 3221 private static function get_page_shortcode_content_for_form( $form_id ) {
3660 3222 $shortcode = '[formidable id="' . $form_id . '"]';
@@ -3696,12 +3258,8 @@
3696 3258 }
3697 3259
3698 3260 /**
3699 3261 * @deprecated 4.0
3700 - *
3701 - * @param array $values
3702 - *
3703 - * @return void
3704 3262 */
3705 3263 public static function create( $values = array() ) {
3706 3264 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3707 3265 self::update( $values );
@@ -3707,16 +3265,13 @@
3707 3265 self::update( $values );
3708 3266 }
3709 3267
3710 3268 /**
3711 - * Education for premium features.
3269 + * @deprecated 6.7
3712 3270 *
3713 - * @since 4.05
3714 - * @deprecated 6.16.3
3715 - *
3716 - * @return void
3271 + * @return bool
3717 3272 */
3718 - public static function add_form_style_tab_options() {
3719 - _deprecated_function( __METHOD__, '6.16.3' );
3720 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php';
3273 + public static function expired() {
3274 + _deprecated_function( __METHOD__, '6.7' );
3275 + return FrmAddonsController::is_license_expired();
3721 3276 }
3722 3277 }