PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.10
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.10
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 +92 -566 6.26.16.10 View file →
@@ -6,9 +6,9 @@
6 6 class FrmFormsController {
7 7
8 8 /**
9 9 * Track the form that opened the redirect URL in a new tab. This is used to check if we should show the default
10 - * message in the current tab.
10 + * message in the currect tab.
11 11 *
12 12 * @since 6.2
13 13 *
14 14 * @var array Keys are form IDs and values are 1.
@@ -14,21 +14,10 @@
14 14 * @var array Keys are form IDs and values are 1.
15 15 */
16 16 private static $redirected_in_new_tab = array();
17 17
18 - /**
19 - * The HTML for the Formdiable TinyMCE button (That triggers a popup to insert shortcodes)
20 - * is stored here and re-used as an optimization.
21 - *
22 - * @since 6.11
23 - *
24 - * @var string|null
25 - */
26 - private static $formidable_tinymce_button;
27 -
28 18 public static function menu() {
29 19 $menu_label = __( 'Forms', 'formidable' );
30 -
31 20 if ( ! FrmAppHelper::pro_is_installed() ) {
32 21 $menu_label .= ' (Lite)';
33 22 }
34 23 add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
@@ -68,9 +57,9 @@
68 57 $data_message = __( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' );
69 58 $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 59 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 60 esc_html_e( 'Conditional Logic', 'formidable' );
72 - FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon', array( 'aria-hidden' => 'true' ) );
61 + FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown6_icon', array( 'aria-hidden' => 'true' ) );
73 62 echo '</a>';
74 63 }
75 64
76 65 /**
@@ -77,12 +66,8 @@
77 66 * By default, Divi processes form shortcodes on the edit post page.
78 67 * Now that won't do.
79 68 *
80 69 * @since 3.01
81 - *
82 - * @param array $shortcodes List of shortcodes to process.
83 - *
84 - * @return array
85 70 */
86 71 public static function prevent_divi_conflict( $shortcodes ) {
87 72 $shortcodes[] = 'formidable';
88 73
@@ -97,14 +82,12 @@
97 82
98 83 $message = '';
99 84 $params = FrmForm::list_page_params();
100 85 $errors = self::process_bulk_form_actions( array() );
101 -
102 86 if ( isset( $errors['message'] ) ) {
103 87 $message = $errors['message'];
104 88 unset( $errors['message'] );
105 89 }
106 -
107 90 $errors = apply_filters( 'frm_admin_list_form_action', $errors );
108 91
109 92 self::display_forms_list( $params, $message, $errors );
110 93 }
@@ -114,24 +97,14 @@
114 97 *
115 98 * @since 2.02.11
116 99 *
117 100 * @param int|object $form
118 - *
119 - * @return void
120 101 */
121 102 private static function create_default_email_action( $form ) {
122 103 FrmForm::maybe_get_form( $form );
123 -
124 - if ( ! is_object( $form ) ) {
125 - return;
126 - }
127 -
128 104 $create_email = apply_filters( 'frm_create_default_email_action', true, $form );
129 105
130 106 if ( $create_email ) {
131 - /**
132 - * @var FrmFormAction
133 - */
134 107 $action_control = FrmFormActionsController::get_form_actions( 'email' );
135 108 $action_control->create( $form->id );
136 109 }
137 110 }
@@ -141,18 +114,12 @@
141 114 *
142 115 * @since 6.0.0
143 116 *
144 117 * @param int|object $form Form object or ID.
145 - *
146 - * @return void
147 118 */
148 119 private static function create_default_on_submit_action( $form ) {
149 120 FrmForm::maybe_get_form( $form );
150 121
151 - if ( ! is_object( $form ) ) {
152 - return;
153 - }
154 -
155 122 /**
156 123 * Enable or disable the default On Submit action.
157 124 *
158 125 * @since 6.0.0
@@ -162,11 +129,8 @@
162 129 */
163 130 $create = apply_filters( 'frm_create_default_on_submit_action', true, $form );
164 131
165 132 if ( $create ) {
166 - /**
167 - * @var FrmFormAction
168 - */
169 133 $action_control = FrmFormActionsController::get_form_actions( FrmOnSubmitAction::$slug );
170 134 $action_control->create( $form->id );
171 135 }
172 136 }
@@ -176,18 +140,12 @@
176 140 *
177 141 * @since 6.9
178 142 *
179 143 * @param int|object $form Form ID or object.
180 - *
181 - * @return void
182 144 */
183 145 private static function create_submit_button_field( $form ) {
184 146 FrmForm::maybe_get_form( $form );
185 147
186 - if ( ! is_object( $form ) ) {
187 - return;
188 - }
189 -
190 148 if ( FrmSubmitHelper::get_submit_field( $form->id ) ) {
191 149 // Do not create submit button field if it exists.
192 150 return;
193 151 }
@@ -195,9 +153,9 @@
195 153 FrmField::create(
196 154 array(
197 155 'type' => FrmSubmitHelper::FIELD_TYPE,
198 156 'name' => __( 'Submit', 'formidable' ),
199 - 'field_order' => FrmSubmitHelper::DEFAULT_ORDER,
157 + 'field_order' => 9999,
200 158 'form_id' => $form->id,
201 159 'field_options' => FrmFieldsHelper::get_default_field_options( FrmSubmitHelper::FIELD_TYPE ),
202 160 'description' => '',
203 161 'default_value' => '',
@@ -206,10 +164,8 @@
206 164 );
207 165 }
208 166
209 167 /**
210 - * @param array|false $values
211 - *
212 168 * @return void
213 169 */
214 170 public static function edit( $values = false ) {
215 171 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -221,9 +177,8 @@
221 177
222 178 /**
223 179 * @param mixed $id
224 180 * @param string $message
225 - *
226 181 * @return void
227 182 */
228 183 public static function settings( $id = false, $message = '' ) {
229 184 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -268,9 +223,8 @@
268 223
269 224 FrmForm::update( $id, $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
270 225
271 226 $antispam_is_on = ! empty( $_POST['options']['antispam'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
272 -
273 227 if ( $antispam_is_on !== $antispam_was_on ) {
274 228 FrmAntiSpam::clear_caches();
275 229 }
276 230
@@ -280,9 +234,8 @@
280 234 }
281 235
282 236 /**
283 237 * @param int $form_id
284 - *
285 238 * @return bool
286 239 */
287 240 private static function antispam_was_on( $form_id ) {
288 241 $form = FrmForm::getOne( $form_id );
@@ -289,10 +242,8 @@
289 242 return ! empty( $form->options['antispam'] );
290 243 }
291 244
292 245 /**
293 - * @param array $values
294 - *
295 246 * @return void
296 247 */
297 248 public static function update( $values = array() ) {
298 249 if ( empty( $values ) ) {
@@ -305,9 +256,8 @@
305 256 }
306 257
307 258 $errors = FrmForm::validate( $values );
308 259 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
309 -
310 260 if ( $permission_error !== false ) {
311 261 $errors['form'] = $permission_error;
312 262 }
313 263
@@ -326,9 +276,9 @@
326 276 if ( self::is_too_long( $values ) ) {
327 277 $message .= '<br/> ' . sprintf(
328 278 /* translators: %1$s: Start link HTML, %2$s: end link HTML */
329 279 __( '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">',
280 + '<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 281 '</a>'
332 282 );
333 283 }
334 284
@@ -339,32 +289,17 @@
339 289 self::get_edit_vars( $id, array(), $message );
340 290 }
341 291
342 292 /**
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 293 * Remove the draft flag from any new fields from this current session.
357 294 *
358 295 * @since 6.8
359 296 *
360 297 * @param int $form_id
361 - *
362 298 * @return void
363 299 */
364 300 private static function maybe_remove_draft_option_from_fields( $form_id ) {
365 301 $draft_field_ids_csv = FrmAppHelper::get_post_param( 'draft_fields', '', 'sanitize_text_field' );
366 -
367 302 if ( ! $draft_field_ids_csv ) {
368 303 // If the draft_fields input is empty there are no new fields in the session.
369 304 return;
370 305 }
@@ -369,9 +304,8 @@
369 304 return;
370 305 }
371 306
372 307 $draft_field_ids = array_filter( explode( ',', $draft_field_ids_csv ), 'is_numeric' );
373 -
374 308 if ( ! $draft_field_ids ) {
375 309 // Exit early if the draft fields input is invalid. It should be a CSV of integer values.
376 310 return;
377 311 }
@@ -376,9 +310,8 @@
376 310 return;
377 311 }
378 312
379 313 $draft_field_rows = FrmFieldsHelper::get_draft_field_results( $form_id, $draft_field_ids );
380 -
381 314 foreach ( $draft_field_rows as $row ) {
382 315 $row->field_options['draft'] = 0;
383 316 FrmField::update( $row->id, array( 'field_options' => $row->field_options ) );
384 317 }
@@ -390,10 +323,8 @@
390 323 * were likely not saved either.
391 324 *
392 325 * @since 3.06.01
393 326 *
394 - * @param array $values
395 - *
396 327 * @return bool
397 328 */
398 329 private static function is_too_long( $values ) {
399 330 return empty( $values['frm_end'] );
@@ -429,17 +360,13 @@
429 360 * @return string|null
430 361 */
431 362 public static function page_preview() {
432 363 $params = FrmForm::list_page_params();
433 -
434 - if ( ! $params['form'] || is_numeric( $params['form'] ) ) {
364 + if ( ! $params['form'] ) {
435 365 return null;
436 366 }
437 367
438 - self::maybe_block_preview( $params['form'] );
439 -
440 368 $form = FrmForm::getOne( $params['form'] );
441 -
442 369 if ( ! $form ) {
443 370 return null;
444 371 }
445 372
@@ -451,19 +378,9 @@
451 378 *
452 379 * @return void
453 380 */
454 381 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
382 + echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
466 383 }
467 384
468 385 /**
469 386 * @return void
@@ -474,19 +391,9 @@
474 391
475 392 global $frm_vars;
476 393 $frm_vars['preview'] = true;
477 394
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 395 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
488 -
489 396 if ( $include_theme ) {
490 397 self::set_preview_query();
491 398 self::load_theme_preview();
492 399 } else {
@@ -509,9 +416,8 @@
509 416 'post_type' => 'page',
510 417 );
511 418
512 419 $page_for_posts = get_option( 'page_for_posts' );
513 -
514 420 if ( is_numeric( $page_for_posts ) ) {
515 421 // Avoid querying for the "Posts Page" or "Blog Page" so we don't display 10 forms.
516 422 $page_query['post__not_in'] = array( $page_for_posts );
517 423 }
@@ -516,15 +422,13 @@
516 422 $page_query['post__not_in'] = array( $page_for_posts );
517 423 }
518 424
519 425 $random_page = get_posts( $page_query );
520 -
521 426 if ( ! $random_page ) {
522 427 return;
523 428 }
524 429
525 430 $random_page = reset( $random_page );
526 -
527 431 if ( ! is_a( $random_page, 'WP_Post' ) ) {
528 432 // The return type can also be int.
529 433 return;
530 434 }
@@ -546,9 +450,8 @@
546 450 *
547 451 * @since 5.5.2
548 452 *
549 453 * @param WP_Post $page The page object.
550 - *
551 454 * @return void
552 455 */
553 456 private static function set_post_global( $page ) {
554 457 global $post;
@@ -581,9 +484,8 @@
581 484 *
582 485 * @since 6.5.2
583 486 *
584 487 * @param array $classes The body classes list.
585 - *
586 488 * @return array
587 489 */
588 490 public static function preview_block_theme_body_classnames( $classes ) {
589 491 $classes[] = 'has-global-padding';
@@ -607,12 +509,8 @@
607 509 echo '<div class="container entry-content">';
608 510 the_content();
609 511 echo '</div>';
610 512
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 513 self::get_template( 'footer' );
616 514 }
617 515 }
618 516
@@ -617,14 +515,12 @@
617 515 }
618 516
619 517 /**
620 518 * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call
621 - * and renders required html fragments calling required functions.
519 + * and renders required html fragements calling required functions.
622 520 *
623 521 * @since 6.7.1
624 - *
625 522 * @param string $template
626 - *
627 523 * @return void
628 524 */
629 525 private static function get_template( $template ) {
630 526 if ( self::should_try_getting_template( $template ) ) {
@@ -645,11 +541,9 @@
645 541 /**
646 542 * Returns true if calling a template function doesn't trigger deprecation warnings.
647 543 *
648 544 * @since 6.7.1
649 - *
650 545 * @param string $template
651 - *
652 546 * @return bool
653 547 */
654 548 private static function should_try_getting_template( $template ) {
655 549 $stylesheet_path = get_stylesheet_directory();
@@ -663,12 +557,8 @@
663 557 /**
664 558 * Set the page title for the theme preview page
665 559 *
666 560 * @since 3.0
667 - *
668 - * @param string $title
669 - *
670 - * @return string
671 561 */
672 562 public static function preview_page_title( $title ) {
673 563 if ( in_the_loop() ) {
674 564 $title = self::preview_title( $title );
@@ -682,9 +572,8 @@
682 572 *
683 573 * @since 3.0
684 574 *
685 575 * @param string $title
686 - *
687 576 * @return string
688 577 */
689 578 public static function preview_title( $title ) {
690 579 return __( 'Form Preview', 'formidable' );
@@ -695,9 +584,8 @@
695 584 *
696 585 * @since 3.0
697 586 *
698 587 * @param string $content
699 - *
700 588 * @return string
701 589 */
702 590 public static function preview_content( $content ) {
703 591 if ( in_the_loop() ) {
@@ -712,38 +600,23 @@
712 600 /**
713 601 * @since 3.0
714 602 */
715 603 private static function load_direct_preview() {
604 + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
605 +
606 + // print_emoji_styles is deprecated.
607 + remove_action( 'wp_print_styles', 'print_emoji_styles' );
608 +
716 609 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
717 -
718 610 if ( $key == '' ) {
719 611 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
720 612 }
721 613
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 614 $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 - );
615 + if ( empty( $form ) ) {
616 + $form = FrmForm::getAll( array(), '', 1 );
742 617 }
743 618
744 - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
745 -
746 619 self::fix_deprecated_null_param_warning();
747 620
748 621 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
749 622 }
@@ -748,31 +621,8 @@
748 621 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
749 622 }
750 623
751 624 /**
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 625 * Some themes have a null $src value.
776 626 * This function adds a filter to ensure that $src is not null.
777 627 * WP will call str_starts_with with the null value triggering a deprecated message otherwise.
778 628 *
@@ -784,9 +634,8 @@
784 634 add_filter(
785 635 'script_loader_src',
786 636 /**
787 637 * @param string|null $src
788 - *
789 638 * @return string
790 639 */
791 640 function ( $src ) {
792 641 if ( is_null( $src ) ) {
@@ -802,9 +651,8 @@
802 651 }
803 652
804 653 /**
805 654 * @param array $ids
806 - *
807 655 * @return string
808 656 */
809 657 public static function bulk_untrash( $ids ) {
810 658 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -865,9 +713,8 @@
865 713 // Check nonce url.
866 714 check_admin_referer( $status . '_form_' . $params['id'] );
867 715
868 716 $count = 0;
869 -
870 717 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
871 718 ++$count;
872 719 }
873 720
@@ -890,9 +737,8 @@
890 737 }
891 738
892 739 /**
893 740 * @param array $ids
894 - *
895 741 * @return string
896 742 */
897 743 public static function bulk_trash( $ids ) {
898 744 FrmAppHelper::permission_check( 'frm_delete_forms' );
@@ -897,9 +743,8 @@
897 743 public static function bulk_trash( $ids ) {
898 744 FrmAppHelper::permission_check( 'frm_delete_forms' );
899 745
900 746 $count = 0;
901 -
902 747 foreach ( $ids as $id ) {
903 748 if ( FrmForm::trash( $id ) ) {
904 749 ++$count;
905 750 }
@@ -904,12 +749,8 @@
904 749 ++$count;
905 750 }
906 751 }
907 752
908 - if ( ! $count ) {
909 - return '';
910 - }
911 -
912 753 $current_page = FrmAppHelper::get_simple_request(
913 754 array(
914 755 'param' => 'form_type',
915 756 'type' => 'request',
@@ -934,9 +775,8 @@
934 775 // Check nonce url.
935 776 check_admin_referer( 'destroy_form_' . $params['id'] );
936 777
937 778 $count = 0;
938 -
939 779 if ( FrmForm::destroy( $params['id'] ) ) {
940 780 ++$count;
941 781 }
942 782
@@ -947,9 +787,8 @@
947 787 }
948 788
949 789 /**
950 790 * @param array $ids
951 - *
952 791 * @return string
953 792 */
954 793 public static function bulk_destroy( $ids ) {
955 794 FrmAppHelper::permission_check( 'frm_delete_forms' );
@@ -954,12 +793,10 @@
954 793 public static function bulk_destroy( $ids ) {
955 794 FrmAppHelper::permission_check( 'frm_delete_forms' );
956 795
957 796 $count = 0;
958 -
959 797 foreach ( $ids as $id ) {
960 798 $d = FrmForm::destroy( $id );
961 -
962 799 if ( $d ) {
963 800 ++$count;
964 801 }
965 802 }
@@ -977,9 +814,8 @@
977 814 */
978 815 public static function delete_all() {
979 816 // Check nonce url.
980 817 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
981 -
982 818 if ( $permission_error !== false ) {
983 819 self::display_forms_list( array(), '', array( $permission_error ) );
984 820
985 821 return;
@@ -1065,19 +901,14 @@
1065 901 * @return void
1066 902 */
1067 903 public static function insert_form_button() {
1068 904 if ( current_user_can( 'frm_view_forms' ) ) {
1069 - // Store the result in memory and re-use it when this function is called multiple times.
1070 - // This helps speed up the form builder when there are a lot of HTML fields, where this
1071 - // button is inserted once per HTML field.
1072 - // In a form with 66 HTML fields, this saves 0.5 seconds on page load time, tested locally.
1073 - if ( ! isset( self::$formidable_tinymce_button ) ) {
1074 - FrmAppHelper::load_admin_wide_js();
1075 - $menu_name = FrmAppHelper::get_menu_name();
1076 - $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
1077 - self::$formidable_tinymce_button = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">' . FrmAppHelper::kses( $icon, 'all' ) . ' ' . esc_html( $menu_name ) . '</a>';
1078 - }
1079 - echo self::$formidable_tinymce_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
905 + FrmAppHelper::load_admin_wide_js();
906 + $menu_name = FrmAppHelper::get_menu_name();
907 + $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
908 + echo '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">' .
909 + FrmAppHelper::kses( $icon, 'all' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
910 + ' ' . esc_html( $menu_name ) . '</a>';
1080 911 }
1081 912 }
1082 913
1083 914 /**
@@ -1121,9 +952,8 @@
1121 952 private static function should_insert_form_popup() {
1122 953 if ( FrmAppHelper::is_form_builder_page() ) {
1123 954 return true;
1124 955 }
1125 -
1126 956 $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
1127 957 return in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ), true );
1128 958 }
1129 959
@@ -1131,9 +961,8 @@
1131 961 FrmAppHelper::permission_check( 'frm_view_forms' );
1132 962 check_ajax_referer( 'frm_ajax', 'nonce' );
1133 963
1134 964 $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
1135 -
1136 965 if ( empty( $shortcode ) ) {
1137 966 wp_die();
1138 967 }
1139 968
@@ -1159,9 +988,8 @@
1159 988 'label' => __( 'Minimize form HTML', 'formidable' ),
1160 989 ),
1161 990 );
1162 991 }
1163 -
1164 992 $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
1165 993
1166 994 if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
1167 995 // allow other shortcodes to use the required form id option
@@ -1181,9 +1009,8 @@
1181 1009 *
1182 1010 * @param array $params
1183 1011 * @param string $message
1184 1012 * @param array $errors
1185 - *
1186 1013 * @return void
1187 1014 */
1188 1015 public static function display_forms_list( $params = array(), $message = '', $errors = array() ) {
1189 1016 FrmAppHelper::permission_check( 'frm_view_forms' );
@@ -1206,39 +1033,27 @@
1206 1033
1207 1034 $wp_list_table->prepare_items();
1208 1035
1209 1036 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
1210 -
1211 1037 if ( $pagenum > $total_pages && $total_pages > 0 ) {
1212 1038 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
1213 1039 die();
1214 1040 }
1215 1041
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 1042 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php';
1224 1043 }
1225 1044
1226 1045 /**
1227 1046 * @param array<string,string> $columns
1228 - *
1229 1047 * @return array<string,string>
1230 1048 */
1231 1049 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 - }
1050 + $columns['cb'] = '<input type="checkbox" />';
1051 + $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1052 + $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1053 + $columns['id'] = 'ID';
1054 + $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1055 + $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1241 1056 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
1242 1057
1243 1058 add_screen_option(
1244 1059 'per_page',
@@ -1266,9 +1081,8 @@
1266 1081 }
1267 1082
1268 1083 /**
1269 1084 * @param mixed $hidden_columns
1270 - *
1271 1085 * @return array
1272 1086 */
1273 1087 public static function hidden_columns( $hidden_columns ) {
1274 1088 if ( ! is_array( $hidden_columns ) ) {
@@ -1289,15 +1103,8 @@
1289 1103
1290 1104 return $hidden_columns;
1291 1105 }
1292 1106
1293 - /**
1294 - * @param mixed $save
1295 - * @param string $option
1296 - * @param int|string $value
1297 - *
1298 - * @return mixed
1299 - */
1300 1107 public static function save_per_page( $save, $option, $value ) {
1301 1108 if ( $option === 'formidable_page_formidable_per_page' ) {
1302 1109 $save = (int) $value;
1303 1110 }
@@ -1309,9 +1116,8 @@
1309 1116 * @param int|string $id
1310 1117 * @param array $errors
1311 1118 * @param string $message
1312 1119 * @param bool $create_link
1313 - *
1314 1120 * @return void
1315 1121 */
1316 1122 private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1317 1123 global $frm_vars;
@@ -1326,9 +1132,8 @@
1326 1132 'page' => 'formidable',
1327 1133 )
1328 1134 ),
1329 1135 );
1330 -
1331 1136 if ( ! $form ) {
1332 1137 FrmAppController::show_error_modal( $error_args );
1333 1138 return;
1334 1139 }
@@ -1382,9 +1187,8 @@
1382 1187 */
1383 1188 $values['fields'] = apply_filters( 'frm_fields_in_form_builder', $fields, compact( 'form' ) );
1384 1189
1385 1190 $edit_message = __( 'Form was successfully updated.', 'formidable' );
1386 -
1387 1191 if ( $form->is_template && $message == $edit_message ) {
1388 1192 $message = __( 'Template was successfully updated.', 'formidable' );
1389 1193 }
1390 1194
@@ -1389,9 +1193,10 @@
1389 1193 }
1390 1194
1391 1195 self::maybe_update_form_builder_message( $message );
1392 1196
1393 - $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1197 + $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
1198 + $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1394 1199
1395 1200 if ( defined( 'DOING_AJAX' ) ) {
1396 1201 wp_die();
1397 1202 }
@@ -1400,12 +1205,11 @@
1400 1205 }
1401 1206
1402 1207 /**
1403 1208 * @param array $fields
1404 - *
1405 1209 * @return array
1406 1210 */
1407 - public static function update_form_builder_fields( $fields ) {
1211 + public static function update_form_builder_fields( $fields, $form ) {
1408 1212 foreach ( $fields as $field ) {
1409 1213 $field->do_not_include_icons = true;
1410 1214 }
1411 1215 return $fields;
@@ -1410,13 +1214,8 @@
1410 1214 }
1411 1215 return $fields;
1412 1216 }
1413 1217
1414 - /**
1415 - * @param string $message
1416 - *
1417 - * @return void
1418 - */
1419 1218 public static function maybe_update_form_builder_message( &$message ) {
1420 1219 if ( 'form_duplicated' === FrmAppHelper::simple_get( 'message' ) ) {
1421 1220 $message = __( 'Form was Successfully Copied', 'formidable' );
1422 1221 }
@@ -1425,9 +1224,8 @@
1425 1224 /**
1426 1225 * @param int|string $id
1427 1226 * @param array $errors
1428 1227 * @param array|string $args
1429 - *
1430 1228 * @return void
1431 1229 */
1432 1230 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1433 1231 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -1495,12 +1293,8 @@
1495 1293 }
1496 1294
1497 1295 /**
1498 1296 * @since 4.0
1499 - *
1500 - * @param array $atts
1501 - *
1502 - * @return void
1503 1297 */
1504 1298 public static function form_publish_button( $atts ) {
1505 1299 $values = $atts['values'];
1506 1300 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
@@ -1511,9 +1305,8 @@
1511 1305 *
1512 1306 * @since 4.0
1513 1307 *
1514 1308 * @param array $values
1515 - *
1516 1309 * @return array
1517 1310 */
1518 1311 private static function get_settings_tabs( $values ) {
1519 1312 $sections = array(
@@ -1519,9 +1312,9 @@
1519 1312 $sections = array(
1520 1313 'advanced' => array(
1521 1314 'name' => __( 'General', 'formidable' ),
1522 1315 'title' => __( 'General Form Settings', 'formidable' ),
1523 - 'function' => array( self::class, 'advanced_settings' ),
1316 + 'function' => array( __CLASS__, 'advanced_settings' ),
1524 1317 'icon' => 'frm_icon_font frm_settings_icon',
1525 1318 ),
1526 1319 'email' => array(
1527 1320 'name' => __( 'Actions & Notifications', 'formidable' ),
@@ -1537,9 +1330,8 @@
1537 1330 'medium' => 'permissions',
1538 1331 'upgrade' => __( 'Form Permissions', 'formidable' ),
1539 1332 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1540 1333 'screenshot' => 'permissions.png',
1541 - 'learn-more' => FrmAppHelper::get_doc_url( 'general-form-settings/#kb-form-permissions', 'form-permissions-settings' ),
1542 1334 ),
1543 1335 ),
1544 1336 'scheduling' => array(
1545 1337 'name' => __( 'Form Scheduling', 'formidable' ),
@@ -1548,14 +1340,13 @@
1548 1340 'data' => array(
1549 1341 'medium' => 'scheduling',
1550 1342 'upgrade' => __( 'Form scheduling settings', 'formidable' ),
1551 1343 'screenshot' => 'scheduling.png',
1552 - 'learn-more' => FrmAppHelper::get_doc_url( 'general-form-settings/#kb-form-scheduling', 'form-scheduling-settings' ),
1553 1344 ),
1554 1345 ),
1555 1346 'buttons' => array(
1556 1347 'name' => __( 'Buttons', 'formidable' ),
1557 - 'class' => self::class,
1348 + 'class' => __CLASS__,
1558 1349 'function' => 'buttons_settings',
1559 1350 'icon' => 'frm_icon_font frm_button_icon',
1560 1351 ),
1561 1352 'landing' => array(
@@ -1573,9 +1364,8 @@
1573 1364 array(
1574 1365 'upgrade' => __( 'Conversational Forms', 'formidable' ),
1575 1366 'message' => __( 'Ask one question at a time for automated conversations.', 'formidable' ),
1576 1367 'screenshot' => 'chat.png',
1577 - 'learn-more' => FrmAppHelper::get_doc_url( 'conversational-forms', 'conversational-forms-settings', false ),
1578 1368 )
1579 1369 ),
1580 1370 ),
1581 1371 'abandonment' => array(
@@ -1587,22 +1377,23 @@
1587 1377 array(
1588 1378 'upgrade' => __( 'Form abandonment settings', 'formidable' ),
1589 1379 'message' => __( 'Unlock the power of data capture to boost lead generation and master the art of form optimization.', 'formidable' ),
1590 1380 'screenshot' => 'abandonment.png',
1591 - 'learn-more' => FrmAppHelper::get_doc_url( 'features/form-abandonment-wordpress-plugin', 'form-abandonment-settings', false ),
1592 1381 )
1593 1382 ),
1594 1383 ),
1595 1384 'html' => array(
1596 1385 'name' => __( 'Customize HTML', 'formidable' ),
1597 - 'class' => self::class,
1386 + 'class' => __CLASS__,
1598 1387 'function' => 'html_settings',
1599 1388 'icon' => 'frm_icon_font frm_code_icon',
1600 1389 ),
1601 1390 );
1602 1391
1603 - if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1604 - unset( $sections['buttons'] );
1392 + foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1393 + if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1394 + unset( $sections[ $feature ] );
1395 + }
1605 1396 }
1606 1397
1607 1398 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1608 1399
@@ -1637,9 +1428,8 @@
1637 1428 /**
1638 1429 * @since 4.0
1639 1430 *
1640 1431 * @param array $values
1641 - *
1642 1432 * @return void
1643 1433 */
1644 1434 public static function advanced_settings( $values ) {
1645 1435 $first_h3 = 'frm_first_h3';
@@ -1648,9 +1438,8 @@
1648 1438 }
1649 1439
1650 1440 /**
1651 1441 * @param array $values
1652 - *
1653 1442 * @return void
1654 1443 */
1655 1444 public static function render_spam_settings( $values ) {
1656 1445 if ( function_exists( 'akismet_http_post' ) ) {
@@ -1655,9 +1444,9 @@
1655 1444 public static function render_spam_settings( $values ) {
1656 1445 if ( function_exists( 'akismet_http_post' ) ) {
1657 1446 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
1658 1447 }
1659 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/stopforumspam.php';
1448 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/honeypot.php';
1660 1449 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php';
1661 1450 }
1662 1451
1663 1452 /**
@@ -1663,9 +1452,8 @@
1663 1452 /**
1664 1453 * @since 4.0
1665 1454 *
1666 1455 * @param array $values
1667 - *
1668 1456 * @return void
1669 1457 */
1670 1458 public static function buttons_settings( $values ) {
1671 1459 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
@@ -1674,9 +1462,8 @@
1674 1462 /**
1675 1463 * @since 4.0
1676 1464 *
1677 1465 * @param array $values
1678 - *
1679 1466 * @return void
1680 1467 */
1681 1468 public static function html_settings( $values ) {
1682 1469 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
@@ -1687,9 +1474,8 @@
1687 1474 *
1688 1475 * @since 2.03.08
1689 1476 *
1690 1477 * @param array|bool $values
1691 - *
1692 1478 * @return void
1693 1479 */
1694 1480 private static function clean_submit_html( &$values ) {
1695 1481 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
@@ -1714,9 +1500,8 @@
1714 1500
1715 1501 /**
1716 1502 * @param int|string $form_id
1717 1503 * @param string $class
1718 - *
1719 1504 * @return void
1720 1505 */
1721 1506 public static function mb_tags_box( $form_id, $class = '' ) {
1722 1507 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -1743,12 +1528,8 @@
1743 1528 }
1744 1529
1745 1530 /**
1746 1531 * @since 3.04.01
1747 - *
1748 - * @param array $atts
1749 - *
1750 - * @return array
1751 1532 */
1752 1533 private static function advanced_helpers( $atts ) {
1753 1534 $advanced_helpers = array(
1754 1535 'default' => array(
@@ -1757,12 +1538,10 @@
1757 1538 ),
1758 1539 );
1759 1540
1760 1541 $user_fields = self::user_shortcodes();
1761 -
1762 1542 if ( $user_fields ) {
1763 1543 $user_helpers = array();
1764 -
1765 1544 foreach ( $user_fields as $uk => $uf ) {
1766 1545 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1767 1546 unset( $uk, $uf );
1768 1547 }
@@ -1787,10 +1566,8 @@
1787 1566 * Get an array of the options to display in the advanced tab
1788 1567 * of the customization panel
1789 1568 *
1790 1569 * @since 2.0.6
1791 - *
1792 - * @return array
1793 1570 */
1794 1571 private static function get_advanced_shortcodes() {
1795 1572 $adv_shortcodes = array(
1796 1573 'x sep=", "' => array(
@@ -1816,10 +1593,8 @@
1816 1593 }
1817 1594
1818 1595 /**
1819 1596 * @since 3.04.01
1820 - *
1821 - * @return array
1822 1597 */
1823 1598 private static function user_shortcodes() {
1824 1599 $options = array(
1825 1600 'ID' => __( 'User ID', 'formidable' ),
@@ -1838,12 +1613,8 @@
1838 1613 /**
1839 1614 * Get an array of the helper shortcodes to display in the customization panel
1840 1615 *
1841 1616 * @since 2.0.6
1842 - *
1843 - * @param bool $settings_tab
1844 - *
1845 - * @return array
1846 1617 */
1847 1618 private static function get_shortcode_helpers( $settings_tab ) {
1848 1619 $entry_shortcodes = array(
1849 1620 'id' => __( 'Entry ID', 'formidable' ),
@@ -1854,25 +1625,26 @@
1854 1625 'updated-at' => __( 'Entry updated', 'formidable' ),
1855 1626 '' => '',
1856 1627 'siteurl' => __( 'Site URL', 'formidable' ),
1857 1628 'sitename' => __( 'Site Name', 'formidable' ),
1858 - 'form_name' => __( 'Form Name', 'formidable' ),
1859 1629 );
1860 1630
1861 - $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1862 -
1863 1631 if ( ! FrmAppHelper::pro_is_installed() ) {
1864 1632 unset( $entry_shortcodes['post_id'] );
1865 1633 }
1866 1634
1635 + if ( $settings_tab ) {
1636 + $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1637 + $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1638 + $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1639 + $entry_shortcodes['form_name'] = __( 'Form Name', 'formidable' );
1640 + }
1641 +
1867 1642 /**
1868 1643 * Use this hook to add or remove buttons in the helpers section
1869 1644 * in the customization panel
1870 1645 *
1871 1646 * @since 2.0.6
1872 - *
1873 - * @param array $entry_shortcodes
1874 - * @param bool $settings_tab
1875 1647 */
1876 1648 $entry_shortcodes = apply_filters( 'frm_helper_shortcodes', $entry_shortcodes, $settings_tab );
1877 1649
1878 1650 return $entry_shortcodes;
@@ -1881,9 +1653,8 @@
1881 1653 /**
1882 1654 * Insert the form class setting into the form.
1883 1655 *
1884 1656 * @param stdClass $form
1885 - *
1886 1657 * @return void
1887 1658 */
1888 1659 public static function form_classes( $form ) {
1889 1660 if ( isset( $form->options['form_class'] ) ) {
@@ -1894,9 +1665,9 @@
1894 1665 echo ' frm_js_validate ';
1895 1666 self::add_js_validate_form_to_global_vars( $form );
1896 1667 }
1897 1668
1898 - if ( FrmForm::is_ajax_on( $form ) ) {
1669 + if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) {
1899 1670 echo ' frm_ajax_submit ';
1900 1671 }
1901 1672 }
1902 1673
@@ -1906,9 +1677,8 @@
1906 1677 * @param stdClass $form
1907 1678 */
1908 1679 public static function add_js_validate_form_to_global_vars( $form ) {
1909 1680 global $frm_vars;
1910 -
1911 1681 if ( ! isset( $frm_vars['js_validate_forms'] ) ) {
1912 1682 $frm_vars['js_validate_forms'] = array();
1913 1683 }
1914 1684 $frm_vars['js_validate_forms'][ $form->id ] = $form;
@@ -1931,9 +1701,8 @@
1931 1701 /**
1932 1702 * @param string $content
1933 1703 * @param int|stdClass|string $form
1934 1704 * @param false|int|stdClass|string $entry
1935 - *
1936 1705 * @return string
1937 1706 */
1938 1707 public static function filter_content( $content, $form, $entry = false ) {
1939 1708 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1938,9 +1707,8 @@
1938 1707 public static function filter_content( $content, $form, $entry = false ) {
1939 1708 $content = self::replace_form_name_shortcodes( $content, $form );
1940 1709
1941 1710 self::get_entry_by_param( $entry );
1942 -
1943 1711 if ( ! $entry ) {
1944 1712 return $content;
1945 1713 }
1946 1714
@@ -1947,16 +1715,8 @@
1947 1715 if ( is_object( $form ) ) {
1948 1716 $form = $form->id;
1949 1717 }
1950 1718
1951 - /*
1952 - * Repeater actions adds `parent_entry` to `$entry` store the parent entry data. If `parent_entry` is not empty,
1953 - * use the parent form ID instead of repeater form ID to fix the parent form field shortcodes doesn't work.
1954 - */
1955 - if ( ! empty( $entry->parent_entry ) ) {
1956 - $form = $entry->parent_entry->form_id;
1957 - }
1958 -
1959 1719 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1960 1720 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1961 1721
1962 1722 return $content;
@@ -1968,9 +1728,8 @@
1968 1728 * @since 5.5
1969 1729 *
1970 1730 * @param array|string $string
1971 1731 * @param int|stdClass|string $form
1972 - *
1973 1732 * @return array|string
1974 1733 */
1975 1734 public static function replace_form_name_shortcodes( $string, $form ) {
1976 1735 if ( ! is_string( $string ) ) {
@@ -1990,9 +1749,8 @@
1990 1749 }
1991 1750
1992 1751 /**
1993 1752 * @param false|int|stdClass|string $entry
1994 - *
1995 1753 * @return void
1996 1754 */
1997 1755 private static function get_entry_by_param( &$entry ) {
1998 1756 if ( ! $entry || ! is_object( $entry ) ) {
@@ -2003,15 +1761,8 @@
2003 1761 FrmEntry::maybe_get_entry( $entry );
2004 1762 }
2005 1763 }
2006 1764
2007 - /**
2008 - * @param string $content
2009 - * @param false|object $entry
2010 - * @param array $shortcodes
2011 - *
2012 - * @return string
2013 - */
2014 1765 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
2015 1766 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
2016 1767 }
2017 1768
@@ -2016,9 +1767,8 @@
2016 1767 }
2017 1768
2018 1769 /**
2019 1770 * @param array $errors
2020 - *
2021 1771 * @return array
2022 1772 */
2023 1773 public static function process_bulk_form_actions( $errors ) {
2024 1774 if ( ! $_REQUEST ) {
@@ -2025,9 +1775,8 @@
2025 1775 return $errors;
2026 1776 }
2027 1777
2028 1778 $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
2029 -
2030 1779 if ( $bulkaction == - 1 ) {
2031 1780 $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
2032 1781 }
2033 1782
@@ -2037,9 +1786,8 @@
2037 1786 $bulkaction = str_replace( 'bulk_', '', $bulkaction );
2038 1787 }
2039 1788
2040 1789 $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
2041 -
2042 1790 if ( empty( $ids ) ) {
2043 1791 $errors[] = __( 'No forms were specified', 'formidable' );
2044 1792
2045 1793 return $errors;
@@ -2045,9 +1793,8 @@
2045 1793 return $errors;
2046 1794 }
2047 1795
2048 1796 $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
2049 -
2050 1797 if ( $permission_error !== false ) {
2051 1798 $errors[] = $permission_error;
2052 1799
2053 1800 return $errors;
@@ -2074,23 +1821,8 @@
2074 1821
2075 1822 return $errors;
2076 1823 }
2077 1824
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 1825 public static function route() {
2094 1826 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
2095 1827 $vars = array();
2096 1828 FrmAppHelper::include_svg();
@@ -2101,13 +1833,11 @@
2101 1833 // Javascript needs to be allowed in some field settings.
2102 1834 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
2103 1835 $json_vars = htmlspecialchars_decode( nl2br( str_replace( '&quot;', '"', wp_unslash( $_POST['frm_compact_fields'] ) ) ) );
2104 1836 $json_vars = json_decode( $json_vars, true );
2105 -
2106 1837 if ( empty( $json_vars ) ) {
2107 1838 // json decoding failed so we should return an error message.
2108 1839 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
2109 -
2110 1840 if ( 'edit' === $action ) {
2111 1841 $action = 'update';
2112 1842 }
2113 1843
@@ -2120,9 +1850,8 @@
2120 1850 $_POST = array_merge( $_POST, $_REQUEST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
2121 1851 }
2122 1852 } else {
2123 1853 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
2124 -
2125 1854 if ( isset( $_REQUEST['delete_all'] ) ) {
2126 1855 // Override the action for this page.
2127 1856 $action = 'delete_all';
2128 1857 }
@@ -2141,22 +1870,18 @@
2141 1870 case 'settings':
2142 1871 case 'update_settings':
2143 1872 return self::$action( $vars );
2144 1873 case 'lite-reports':
2145 - self::no_reports( $vars );
2146 - return;
1874 + return self::no_reports( $vars );
2147 1875 case 'views':
2148 - self::no_views( $vars );
2149 - return;
1876 + return self::no_views( $vars );
2150 1877 default:
2151 1878 do_action( 'frm_form_action_' . $action );
2152 -
2153 1879 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
2154 1880 return;
2155 1881 }
2156 1882
2157 1883 $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
2158 -
2159 1884 if ( $action == - 1 ) {
2160 1885 $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
2161 1886 }
2162 1887
@@ -2167,9 +1892,8 @@
2167 1892 return;
2168 1893 }
2169 1894
2170 1895 $message = FrmAppHelper::get_param( 'message' );
2171 -
2172 1896 if ( 'form_duplicate_error' === $message ) {
2173 1897 self::display_forms_list( array(), '', array( __( 'There was a problem duplicating the form', 'formidable' ) ) );
2174 1898 return;
2175 1899 }
@@ -2205,45 +1929,29 @@
2205 1929 // Get posted data
2206 1930 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2207 1931 $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2208 1932
2209 - $form = FrmForm::getOne( $form_id );
1933 + // Update the form name and form key.
1934 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
1935 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
2210 1936
2211 - if ( ! $form ) {
2212 - wp_send_json_error( __( 'Form not found', 'formidable' ) );
2213 - }
1937 + wp_send_json_success( compact( 'form_key' ) );
1938 + }
2214 1939
2215 - if ( $name === $form->name ) {
2216 - // Nothing to change so exit early.
2217 - wp_send_json_success();
2218 - }
1940 + public static function json_error( $errors ) {
1941 + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
2219 1942
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' ) );
1943 + return $errors;
2235 1944 }
2236 1945
2237 1946 /**
2238 - * @param array $errors
1947 + * Education for premium features.
2239 1948 *
2240 - * @return array
1949 + * @since 4.05
1950 + * @return void
2241 1951 */
2242 - public static function json_error( $errors ) {
2243 - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
2244 -
2245 - return $errors;
1952 + public static function add_form_style_tab_options() {
1953 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php';
2246 1954 }
2247 1955
2248 1956 /**
2249 1957 * Add education about views.
@@ -2248,12 +1956,8 @@
2248 1956 /**
2249 1957 * Add education about views.
2250 1958 *
2251 1959 * @since 4.07
2252 - *
2253 - * @param array $values
2254 - *
2255 - * @return void
2256 1960 */
2257 1961 public static function no_views( $values = array() ) {
2258 1962 FrmAppHelper::include_svg();
2259 1963 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -2265,12 +1969,8 @@
2265 1969 /**
2266 1970 * Add education about reports.
2267 1971 *
2268 1972 * @since 4.07
2269 - *
2270 - * @param array $values
2271 - *
2272 - * @return void
2273 1973 */
2274 1974 public static function no_reports( $values = array() ) {
2275 1975 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
2276 1976 $form = $id ? FrmForm::getOne( $id ) : false;
@@ -2296,9 +1996,8 @@
2296 1996 * @since 4.05.02
2297 1997 */
2298 1998 private static function move_menu_to_footer() {
2299 1999 $settings = FrmAppHelper::get_settings();
2300 -
2301 2000 if ( empty( $settings->admin_bar ) ) {
2302 2001 remove_action( 'wp_body_open', 'wp_admin_bar_render', 0 );
2303 2002 }
2304 2003 }
@@ -2304,15 +2003,13 @@
2304 2003 }
2305 2004
2306 2005 public static function admin_bar_configure() {
2307 2006 global $frm_vars;
2308 -
2309 2007 if ( empty( $frm_vars['forms_loaded'] ) ) {
2310 2008 return;
2311 2009 }
2312 2010
2313 2011 $actions = array();
2314 -
2315 2012 foreach ( $frm_vars['forms_loaded'] as $form ) {
2316 2013 if ( is_object( $form ) ) {
2317 2014 $actions[ $form->id ] = $form->name;
2318 2015 }
@@ -2346,12 +2043,8 @@
2346 2043 }
2347 2044
2348 2045 /**
2349 2046 * @since 2.05.07
2350 - *
2351 - * @param array $actions
2352 - *
2353 - * @return void
2354 2047 */
2355 2048 private static function add_forms_to_admin_bar( $actions ) {
2356 2049 global $wp_admin_bar;
2357 2050
@@ -2362,9 +2055,9 @@
2362 2055 $wp_admin_bar->add_node(
2363 2056 array(
2364 2057 'parent' => 'frm-forms',
2365 2058 'id' => 'edit_form_' . $form_id,
2366 - 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name,
2059 + 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
2367 2060 'href' => FrmForm::get_edit_link( $form_id ),
2368 2061 )
2369 2062 );
2370 2063 }
@@ -2373,14 +2066,12 @@
2373 2066 /**
2374 2067 * The formidable shortcode
2375 2068 *
2376 2069 * @param array $atts The params from the shortcode.
2377 - *
2378 2070 * @return string
2379 2071 */
2380 2072 public static function get_form_shortcode( $atts ) {
2381 2073 global $frm_vars;
2382 -
2383 2074 if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2384 2075 $sc = '[formidable';
2385 2076 $sc .= FrmAppHelper::array_to_html_params( $atts );
2386 2077 return $sc . ']';
@@ -2409,9 +2100,8 @@
2409 2100 * @since 5.2.01
2410 2101 *
2411 2102 * @param false|int|string $id
2412 2103 * @param false|string $key
2413 - *
2414 2104 * @return false|stdClass
2415 2105 */
2416 2106 private static function maybe_get_form_by_id_or_key( $id, $key ) {
2417 2107 if ( ! $id ) {
@@ -2425,9 +2115,8 @@
2425 2115 * @param false|string $key
2426 2116 * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2427 2117 * @param bool|int|string $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2428 2118 * @param array $atts
2429 - *
2430 2119 * @return string
2431 2120 */
2432 2121 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
2433 2122 $form = self::maybe_get_form_by_id_or_key( $id, $key );
@@ -2475,9 +2164,8 @@
2475 2164 }
2476 2165
2477 2166 /**
2478 2167 * @param false|int|string $id
2479 - *
2480 2168 * @return false|stdClass
2481 2169 */
2482 2170 private static function maybe_get_form_to_show( $id ) {
2483 2171 $form = false;
@@ -2484,9 +2172,8 @@
2484 2172
2485 2173 if ( ! empty( $id ) ) {
2486 2174 // Form id or key is set.
2487 2175 $form = FrmForm::getOne( $id );
2488 -
2489 2176 if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) {
2490 2177 $form = false;
2491 2178 }
2492 2179 }
@@ -2493,25 +2180,12 @@
2493 2180
2494 2181 return $form;
2495 2182 }
2496 2183
2497 - /**
2498 - * @param object $form
2499 - *
2500 - * @return bool
2501 - */
2502 2184 private static function is_viewable_draft_form( $form ) {
2503 2185 return $form->status === 'draft' && current_user_can( 'frm_edit_forms' ) && ! FrmAppHelper::is_preview_page();
2504 2186 }
2505 2187
2506 - /**
2507 - * @param object $form
2508 - * @param bool $title
2509 - * @param bool $description
2510 - * @param array $atts
2511 - *
2512 - * @return string
2513 - */
2514 2188 public static function get_form( $form, $title, $description, $atts = array() ) {
2515 2189 ob_start();
2516 2190
2517 2191 do_action( 'frm_before_get_form', $atts );
@@ -2526,25 +2200,12 @@
2526 2200
2527 2201 return $contents;
2528 2202 }
2529 2203
2530 - /**
2531 - * @param array $params
2532 - *
2533 - * @return void
2534 - */
2535 2204 public static function enqueue_scripts( $params ) {
2536 2205 do_action( 'frm_enqueue_form_scripts', $params );
2537 2206 }
2538 2207
2539 - /**
2540 - * @param object $form
2541 - * @param bool $title
2542 - * @param bool $description
2543 - * @param array $atts
2544 - *
2545 - * @return void
2546 - */
2547 2208 public static function get_form_contents( $form, $title, $description, $atts ) {
2548 2209 $params = FrmForm::get_params( $form );
2549 2210 $errors = self::get_saved_errors( $form, $params );
2550 2211 $fields = FrmFieldsHelper::get_form_fields( $form->id, $errors );
@@ -2558,9 +2219,8 @@
2558 2219 FrmFormState::set_initial_value( 'title', $title );
2559 2220 FrmFormState::set_initial_value( 'description', $description );
2560 2221
2561 2222 do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
2562 -
2563 2223 if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
2564 2224 self::show_form_after_submit( $pass_args );
2565 2225 }
2566 2226 } elseif ( ! empty( $errors ) ) {
@@ -2591,13 +2251,8 @@
2591 2251 /**
2592 2252 * If the form was processed earlier (init), get the generated errors
2593 2253 *
2594 2254 * @since 2.05
2595 - *
2596 - * @param object $form
2597 - * @param array $params
2598 - *
2599 - * @return array
2600 2255 */
2601 2256 private static function get_saved_errors( $form, $params ) {
2602 2257 global $frm_vars;
2603 2258
@@ -2619,12 +2274,8 @@
2619 2274 }
2620 2275
2621 2276 /**
2622 2277 * @since 2.2.7
2623 - *
2624 - * @param int|string $form_id
2625 - *
2626 - * @return int
2627 2278 */
2628 2279 public static function just_created_entry( $form_id ) {
2629 2280 global $frm_vars;
2630 2281
@@ -2642,9 +2293,8 @@
2642 2293 *
2643 2294 * @type object $form Form object.
2644 2295 * @type int $entry_id Entry ID.
2645 2296 * }
2646 - *
2647 2297 * @return array|string
2648 2298 */
2649 2299 private static function get_confirmation_method( $atts ) {
2650 2300 $action = FrmOnSubmitHelper::current_event( $atts );
@@ -2652,9 +2302,8 @@
2652 2302 $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2653 2303
2654 2304 if ( ! empty( $atts['entry_id'] ) ) {
2655 2305 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2656 -
2657 2306 if ( $met_actions ) {
2658 2307 $method = $met_actions;
2659 2308 }
2660 2309 }
@@ -2667,15 +2316,8 @@
2667 2316
2668 2317 return $method;
2669 2318 }
2670 2319
2671 - /**
2672 - * @param object $form
2673 - * @param array $params
2674 - * @param array $args
2675 - *
2676 - * @return void
2677 - */
2678 2320 public static function maybe_trigger_redirect( $form, $params, $args ) {
2679 2321 if ( ! isset( $params['id'] ) ) {
2680 2322 global $frm_vars;
2681 2323 $params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id'];
@@ -2703,9 +2345,9 @@
2703 2345 * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}.
2704 2346 */
2705 2347 public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) {
2706 2348 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'] ) ) {
2349 + if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) ) {
2708 2350 $event = FrmOnSubmitHelper::current_event( $params );
2709 2351 FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event );
2710 2352 $conf_method = 'redirect';
2711 2353 }
@@ -2715,15 +2357,8 @@
2715 2357 self::trigger_redirect( $form, $params, $args );
2716 2358 }
2717 2359 }
2718 2360
2719 - /**
2720 - * @param object $form
2721 - * @param array $params
2722 - * @param array $args
2723 - *
2724 - * @return void
2725 - */
2726 2361 public static function trigger_redirect( $form, $params, $args ) {
2727 2362 $success_args = array(
2728 2363 'action' => $params['action'],
2729 2364 'conf_method' => 'redirect',
@@ -2782,9 +2417,8 @@
2782 2417 * @since 6.0
2783 2418 *
2784 2419 * @param array $args See {@see FrmFormsController::run_success_action()}.
2785 2420 * @param string $event Form event. Default is `create`.
2786 - *
2787 2421 * @return array Array of actions that meet the conditional logics.
2788 2422 */
2789 2423 public static function get_met_on_submit_actions( $args, $event = 'create' ) {
2790 2424 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
@@ -2790,9 +2424,9 @@
2790 2424 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
2791 2425 return array();
2792 2426 }
2793 2427
2794 - // If a redirect action has already opened the URL in a new tab, we show the default message in the current tab.
2428 + // If a redirect action has already opened the URL in a new tab, we show the default message in the currect tab.
2795 2429 if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) {
2796 2430 return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) );
2797 2431 }
2798 2432
@@ -2857,9 +2491,8 @@
2857 2491 *
2858 2492 * @param object $action Form action object.
2859 2493 * @param array $args See {@see FrmFormsController::run_success_action()}.
2860 2494 * @param string $event Form event. Default is `create`.
2861 - *
2862 2495 * @return bool
2863 2496 */
2864 2497 private static function is_valid_on_submit_action( $action, $args, $event = 'create' ) {
2865 2498 $action_type = FrmOnSubmitHelper::get_action_type( $action );
@@ -2881,9 +2514,8 @@
2881 2514 return false;
2882 2515 }
2883 2516
2884 2517 $page = get_post( $action->post_content['success_page_id'] );
2885 -
2886 2518 if ( ! $page || 'trash' === $page->post_status ) {
2887 2519 return false;
2888 2520 }
2889 2521 }
@@ -2905,9 +2537,8 @@
2905 2537 'entry_id' => $args['entry_id'],
2906 2538 'action' => FrmOnSubmitHelper::current_event( $args ),
2907 2539 )
2908 2540 );
2909 -
2910 2541 if ( ! is_array( $args['conf_method'] ) ) {
2911 2542 self::run_success_action( $args );
2912 2543 return;
2913 2544 }
@@ -2934,9 +2565,8 @@
2934 2565 * @param array $args See {@see FrmFormsController::run_success_action()}.
2935 2566 */
2936 2567 public static function run_multi_on_submit_actions( $args ) {
2937 2568 $redirect_action = null;
2938 -
2939 2569 foreach ( $args['conf_method'] as $action ) {
2940 2570 if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $action ) ) {
2941 2571 // We catch the redirect action to run it last.
2942 2572 $redirect_action = $action;
@@ -2974,9 +2604,8 @@
2974 2604 * @since 6.0
2975 2605 *
2976 2606 * @param array $args See {@see FrmFormsController::run_success_action()}.
2977 2607 * @param object $action On Submit action object.
2978 - *
2979 2608 * @return array
2980 2609 */
2981 2610 private static function get_run_success_action_args( $args, $action ) {
2982 2611 $new_args = $args;
@@ -3000,17 +2629,12 @@
3000 2629 }
3001 2630
3002 2631 /**
3003 2632 * @since 3.0
3004 - *
3005 - * @param array $args
3006 - *
3007 - * @return void
3008 2633 */
3009 2634 private static function load_page_after_submit( $args ) {
3010 2635 global $post;
3011 2636 $opt = $args['success_opt'];
3012 -
3013 2637 if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
3014 2638 $page = get_post( $args['form']->options[ $opt . '_page_id' ] );
3015 2639 $old_post = $post;
3016 2640 $post = $page;
@@ -3034,9 +2658,8 @@
3034 2658 }
3035 2659
3036 2660 /**
3037 2661 * @since 3.0
3038 - *
3039 2662 * @param array $args See {@see FrmFormsController::run_success_action()}.
3040 2663 */
3041 2664 private static function redirect_after_submit( $args ) {
3042 2665 add_filter( 'frm_use_wpautop', '__return_false' );
@@ -3059,9 +2682,9 @@
3059 2682 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
3060 2683 wp_die();
3061 2684 }
3062 2685
3063 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) {
2686 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) {
3064 2687 // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
3065 2688 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
3066 2689 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
3067 2690 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
@@ -3103,51 +2726,31 @@
3103 2726 *
3104 2727 * @since 6.3.1
3105 2728 *
3106 2729 * @param array $args See {@see FrmFormsController::run_success_action()}.
3107 - *
3108 2730 * @return array
3109 2731 */
3110 2732 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;
2733 + $response_data = array( 'redirect' => $args['success_url'] );
3116 2734
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 2735 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
3124 2736 $response_data['openInNewTab'] = 1;
3125 2737
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();
2738 + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
3129 2739
3130 - $args['form']->options['success_msg'] = $args['message'];
3131 - $args['form']->options['edit_msg'] = $args['message'];
2740 + $args['form']->options['success_msg'] = $args['message'];
2741 + $args['form']->options['edit_msg'] = $args['message'];
2742 + if ( ! isset( $args['fields'] ) ) {
2743 + $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2744 + }
3132 2745
3133 - if ( ! isset( $args['fields'] ) ) {
3134 - $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
3135 - }
2746 + $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
3136 2747
3137 - $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2748 + ob_start();
2749 + self::show_lone_success_messsage( $args );
2750 + $response_data['content'] = ob_get_clean();
3138 2751
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 2752 $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 2753 }
3151 2754
3152 2755 return $response_data;
3153 2756 }
@@ -3159,9 +2762,9 @@
3159 2762 *
3160 2763 * @param array $args See {@see FrmFormsController::run_success_action()}.
3161 2764 */
3162 2765 private static function redirect_after_submit_using_js( $args ) {
3163 - $success_msg = $args['form']->options['redirect_delay_msg'];
2766 + $success_msg = FrmOnSubmitHelper::get_default_redirect_msg();
3164 2767 $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args );
3165 2768 $success_url = esc_url_raw( $args['success_url'] );
3166 2769
3167 2770 /**
@@ -3168,11 +2771,11 @@
3168 2771 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
3169 2772 *
3170 2773 * @since 6.0
3171 2774 *
3172 - * @param int $delay_time Delay time in milliseconds.
2775 + * @param int $delay_time Delay time in miliseconds.
3173 2776 */
3174 - $delay_time = apply_filters( 'frm_redirect_delay_time', 1000 * $args['form']->options['redirect_delay_time'] );
2777 + $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
3175 2778
3176 2779 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
3177 2780 $redirect_js = 'window.open("' . $success_url . '", "_blank")';
3178 2781 } else {
@@ -3182,15 +2785,13 @@
3182 2785 add_filter( 'frm_use_wpautop', '__return_true' );
3183 2786
3184 2787 echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3185 2788 echo '<script>';
3186 -
3187 2789 if ( empty( $args['doing_ajax'] ) ) {
3188 2790 // Not AJAX submit, delay JS until window.load.
3189 2791 echo 'window.onload=function(){';
3190 2792 }
3191 2793 echo 'setTimeout(function(){' . $redirect_js . '}, ' . intval( $delay_time ) . ');'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3192 -
3193 2794 if ( empty( $args['doing_ajax'] ) ) {
3194 2795 echo '};';
3195 2796 }
3196 2797 echo '</script>';
@@ -3203,10 +2804,8 @@
3203 2804 * @param string $success_msg
3204 2805 * @param array $args
3205 2806 */
3206 2807 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 2808 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
3210 2809 self::get_redirect_fallback_message( $success_url, $args ) .
3211 2810 '</div></div>';
3212 2811
@@ -3225,14 +2824,12 @@
3225 2824 * @since 6.3.1
3226 2825 *
3227 2826 * @param string $success_url Redirect URL.
3228 2827 * @param array $args Contains `form` object.
3229 - *
3230 2828 * @return string
3231 2829 */
3232 2830 private static function get_redirect_fallback_message( $success_url, $args ) {
3233 2831 $target = '';
3234 -
3235 2832 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
3236 2833 $target = ' target="_blank"';
3237 2834 }
3238 2835
@@ -3247,12 +2844,8 @@
3247 2844 /**
3248 2845 * Prepare to show the success message and empty form after submit
3249 2846 *
3250 2847 * @since 2.05
3251 - *
3252 - * @param array $atts
3253 - *
3254 - * @return void
3255 2848 */
3256 2849 public static function show_message_after_save( $atts ) {
3257 2850 $atts['message'] = self::prepare_submit_message( $atts['form'], $atts['entry_id'], $atts );
3258 2851
@@ -3258,9 +2851,8 @@
3258 2851
3259 2852 if ( ! isset( $atts['form']->options['show_form'] ) || $atts['form']->options['show_form'] ) {
3260 2853 if ( isset( $atts['action'] ) && 'update' === $atts['action'] && is_callable( array( 'FrmProEntriesController', 'show_front_end_form_with_entry' ) ) ) {
3261 2854 $entry = FrmEntry::getOne( $atts['entry_id'] );
3262 -
3263 2855 if ( $entry ) {
3264 2856 // This is copied from the Pro plugin.
3265 2857 $atts['conf_message'] = FrmProEntriesController::confirmation( 'message', $atts['form'], $atts['form']->options, $entry->id, $atts );
3266 2858 $atts['show_form'] = FrmProEntriesController::is_form_displayed_after_edit( $atts['form'] );
@@ -3269,9 +2861,9 @@
3269 2861 } else {
3270 2862 self::show_form_after_submit( $atts );
3271 2863 }
3272 2864 } else {
3273 - self::show_lone_success_message( $atts );
2865 + self::show_lone_success_messsage( $atts );
3274 2866 }
3275 2867 }
3276 2868
3277 2869 /**
@@ -3277,12 +2869,8 @@
3277 2869 /**
3278 2870 * Show an empty form
3279 2871 *
3280 2872 * @since 2.05
3281 - *
3282 - * @param array $args
3283 - *
3284 - * @return void
3285 2873 */
3286 2874 private static function show_form_after_submit( $args ) {
3287 2875 self::fill_atts_for_form_display( $args );
3288 2876
@@ -3303,9 +2891,9 @@
3303 2891
3304 2892 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
3305 2893
3306 2894 $frm_settings = FrmAppHelper::get_settings();
3307 - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value;
2895 + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
3308 2896
3309 2897 global $frm_vars;
3310 2898 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
3311 2899
@@ -3314,19 +2902,12 @@
3314 2902 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
3315 2903 }
3316 2904
3317 2905 /**
3318 - * Gets message placement.
3319 - *
3320 2906 * @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'.
2907 + * @return string - 'before', 'after', or 'submit'
3327 2908 */
3328 - public static function message_placement( $form, $message ) {
2909 + private static function message_placement( $form, $message ) {
3329 2910 $place = 'before';
3330 2911
3331 2912 if ( $message && isset( $form->options['form_class'] ) ) {
3332 2913 if ( strpos( $form->options['form_class'], 'frm_below_success' ) !== false ) {
@@ -3336,14 +2917,10 @@
3336 2917 }
3337 2918 }
3338 2919
3339 2920 /**
3340 - * Filter the message placement.
3341 - *
3342 2921 * @since 4.05.02
3343 - *
3344 - * @param string $place Accepts 'before', 'after', or 'submit'.
3345 - * @param array $args Args.
2922 + * @return string - 'before' or 'after'
3346 2923 */
3347 2924 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
3348 2925 }
3349 2926
@@ -3350,12 +2927,8 @@
3350 2927 /**
3351 2928 * Get all the values needed on the new.php entry page
3352 2929 *
3353 2930 * @since 2.05
3354 - *
3355 - * @param array $args
3356 - *
3357 - * @return void
3358 2931 */
3359 2932 private static function fill_atts_for_form_display( &$args ) {
3360 2933 if ( ! isset( $args['title'] ) && isset( $args['show_title'] ) ) {
3361 2934 $args['title'] = $args['show_title'];
@@ -3380,14 +2953,10 @@
3380 2953 /**
3381 2954 * Show the success message without the form
3382 2955 *
3383 2956 * @since 2.05
3384 - *
3385 - * @param array $atts
3386 - *
3387 - * @return void
3388 2957 */
3389 - private static function show_lone_success_message( $atts ) {
2958 + private static function show_lone_success_messsage( $atts ) {
3390 2959 global $frm_vars;
3391 2960 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
3392 2961 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
3393 2962
@@ -3408,17 +2977,16 @@
3408 2977 *
3409 2978 * @param object $form Form object.
3410 2979 * @param int $entry_id Entry ID.
3411 2980 * @param array $args See {@see FrmFormsController::run_success_action()}.
3412 - *
3413 2981 * @return string
3414 2982 */
3415 2983 private static function prepare_submit_message( $form, $entry_id, $args = array() ) {
3416 2984 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
3417 - $opt = $args['success_opt'] ?? 'success';
2985 + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
3418 2986
3419 2987 if ( $entry_id && is_numeric( $entry_id ) ) {
3420 - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg;
2988 + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
3421 2989 $class = 'frm_message';
3422 2990 } else {
3423 2991 $message = $frm_settings->failed_msg;
3424 2992 $class = FrmFormsHelper::form_error_class();
@@ -3459,15 +3027,8 @@
3459 3027 public static function has_combo_js_file() {
3460 3028 return is_readable( FrmAppHelper::plugin_path() . '/js/frm.min.js' );
3461 3029 }
3462 3030
3463 - /**
3464 - * @param object $form
3465 - * @param int|string $this_load
3466 - * @param bool $global_load
3467 - *
3468 - * @return void
3469 - */
3470 3031 public static function maybe_load_css( $form, $this_load, $global_load ) {
3471 3032 $load_css = FrmForm::is_form_loaded( $form, $this_load, $global_load );
3472 3033
3473 3034 if ( ! $load_css ) {
@@ -3497,9 +3058,8 @@
3497 3058 return;
3498 3059 }
3499 3060
3500 3061 global $wp_styles;
3501 -
3502 3062 if ( is_array( $wp_styles->queue ) && in_array( 'formidable', $wp_styles->queue, true ) ) {
3503 3063 wp_print_styles( 'formidable' );
3504 3064 }
3505 3065 }
@@ -3514,16 +3074,10 @@
3514 3074 private static function should_load_late() {
3515 3075 return ! function_exists( 'aioseo' );
3516 3076 }
3517 3077
3518 - /**
3519 - * @param string $tag
3520 - * @param string $handle
3521 - *
3522 - * @return string
3523 - */
3524 3078 public static function defer_script_loading( $tag, $handle ) {
3525 - if ( 'captcha-api' === $handle && ! strpos( $tag, 'defer' ) ) {
3079 + if ( 'captcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
3526 3080 $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
3527 3081 }
3528 3082
3529 3083 return $tag;
@@ -3528,13 +3082,8 @@
3528 3082
3529 3083 return $tag;
3530 3084 }
3531 3085
3532 - /**
3533 - * @param string $location
3534 - *
3535 - * @return void
3536 - */
3537 3086 public static function footer_js( $location = 'footer' ) {
3538 3087 global $frm_vars;
3539 3088
3540 3089 FrmStylesController::enqueue_css();
@@ -3541,20 +3090,13 @@
3541 3090
3542 3091 if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3543 3092 // load formidable js
3544 3093 wp_enqueue_script( 'formidable' );
3545 -
3546 - FrmHoneypot::maybe_print_honeypot_js();
3547 3094 }
3548 3095 }
3549 3096
3550 3097 /**
3551 3098 * @since 2.0.8
3552 - *
3553 - * @param array $atts
3554 - * @param string $content
3555 - *
3556 - * @return void
3557 3099 */
3558 3100 private static function maybe_minimize_form( $atts, &$content ) {
3559 3101 // check if minimizing is turned on
3560 3102 if ( self::is_minification_on( $atts ) ) {
@@ -3563,11 +3105,8 @@
3563 3105 }
3564 3106
3565 3107 /**
3566 3108 * @since 2.0.8
3567 - *
3568 - * @param array $atts
3569 - *
3570 3109 * @return bool
3571 3110 */
3572 3111 private static function is_minification_on( $atts ) {
3573 3112 return ! empty( $atts['minimize'] );
@@ -3579,9 +3118,8 @@
3579 3118 * @return void
3580 3119 */
3581 3120 public static function landing_page_preview_option() {
3582 3121 $dir = apply_filters( 'frm_landing_page_preview_option', false );
3583 -
3584 3122 if ( false === $dir || ! file_exists( $dir . 'landing-page-preview-option.php' ) ) {
3585 3123 $dir = self::get_form_views_path();
3586 3124 }
3587 3125 include $dir . 'landing-page-preview-option.php';
@@ -3610,15 +3148,13 @@
3610 3148
3611 3149 check_ajax_referer( 'frm_ajax', 'nonce' );
3612 3150
3613 3151 $type = FrmAppHelper::get_post_param( 'type', '', 'sanitize_text_field' );
3614 -
3615 3152 if ( ! $type || ! in_array( $type, array( 'form', 'view' ), true ) ) {
3616 3153 die( 0 );
3617 3154 }
3618 3155
3619 3156 $object_id = FrmAppHelper::get_post_param( 'object_id', '', 'absint' );
3620 -
3621 3157 if ( ! $object_id ) {
3622 3158 die( 0 );
3623 3159 }
3624 3160
@@ -3630,15 +3166,13 @@
3630 3166 $postarr['post_content'] = apply_filters( 'frm_create_page_with_' . $type . '_shortcode_content', '', $object_id );
3631 3167 }
3632 3168
3633 3169 $name = FrmAppHelper::get_post_param( 'name', '', 'sanitize_text_field' );
3634 -
3635 3170 if ( $name ) {
3636 3171 $postarr['post_title'] = $name;
3637 3172 }
3638 3173
3639 3174 $success = wp_insert_post( $postarr );
3640 -
3641 3175 if ( ! is_numeric( $success ) || ! $success ) {
3642 3176 die( 0 );
3643 3177 }
3644 3178
@@ -3652,9 +3186,8 @@
3652 3186 /**
3653 3187 * @since 5.3
3654 3188 *
3655 3189 * @param int $form_id
3656 - *
3657 3190 * @return string
3658 3191 */
3659 3192 private static function get_page_shortcode_content_for_form( $form_id ) {
3660 3193 $shortcode = '[formidable id="' . $form_id . '"]';
@@ -3696,12 +3229,8 @@
3696 3229 }
3697 3230
3698 3231 /**
3699 3232 * @deprecated 4.0
3700 - *
3701 - * @param array $values
3702 - *
3703 - * @return void
3704 3233 */
3705 3234 public static function create( $values = array() ) {
3706 3235 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3707 3236 self::update( $values );
@@ -3707,16 +3236,13 @@
3707 3236 self::update( $values );
3708 3237 }
3709 3238
3710 3239 /**
3711 - * Education for premium features.
3240 + * @deprecated 6.7
3712 3241 *
3713 - * @since 4.05
3714 - * @deprecated 6.16.3
3715 - *
3716 - * @return void
3242 + * @return bool
3717 3243 */
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';
3244 + public static function expired() {
3245 + _deprecated_function( __METHOD__, '6.7' );
3246 + return FrmAddonsController::is_license_expired();
3721 3247 }
3722 3248 }