PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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 +285 -498 6.256.8 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,18 +14,8 @@
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 20 if ( ! FrmAppHelper::pro_is_installed() ) {
31 21 $menu_label .= ' (Lite)';
@@ -64,12 +54,12 @@
64 54 */
65 55 public static function logic_tip() {
66 56 $images_url = FrmAppHelper::plugin_url() . '/images/';
67 57 $data_message = __( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' );
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' ) . '"/>';
58 + $data_message .= ' <img src="' . esc_attr( $images_url ) . '/survey-logic.png" srcset="' . esc_attr( $images_url ) . 'survey-logic@2x.png 2x" alt="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '"/>';
69 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">';
70 60 esc_html_e( 'Conditional Logic', 'formidable' );
71 - 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' ) );
72 62 echo '</a>';
73 63 }
74 64
75 65 /**
@@ -106,23 +96,15 @@
106 96 * Create the default email action
107 97 *
108 98 * @since 2.02.11
109 99 *
110 - * @param int|object $form
111 - * @return void
100 + * @param object|int $form
112 101 */
113 102 private static function create_default_email_action( $form ) {
114 103 FrmForm::maybe_get_form( $form );
115 - if ( ! is_object( $form ) ) {
116 - return;
117 - }
118 -
119 104 $create_email = apply_filters( 'frm_create_default_email_action', true, $form );
120 105
121 106 if ( $create_email ) {
122 - /**
123 - * @var FrmFormAction
124 - */
125 107 $action_control = FrmFormActionsController::get_form_actions( 'email' );
126 108 $action_control->create( $form->id );
127 109 }
128 110 }
@@ -131,16 +113,12 @@
131 113 * Create the default On submit action
132 114 *
133 115 * @since 6.0.0
134 116 *
135 - * @param int|object $form Form object or ID.
136 - * @return void
117 + * @param object|int $form Form object or ID.
137 118 */
138 119 private static function create_default_on_submit_action( $form ) {
139 120 FrmForm::maybe_get_form( $form );
140 - if ( ! is_object( $form ) ) {
141 - return;
142 - }
143 121
144 122 /**
145 123 * Enable or disable the default On Submit action.
146 124 *
@@ -151,65 +129,21 @@
151 129 */
152 130 $create = apply_filters( 'frm_create_default_on_submit_action', true, $form );
153 131
154 132 if ( $create ) {
155 - /**
156 - * @var FrmFormAction
157 - */
158 133 $action_control = FrmFormActionsController::get_form_actions( FrmOnSubmitAction::$slug );
159 134 $action_control->create( $form->id );
160 135 }
161 136 }
162 137
163 - /**
164 - * Creates submit button field.
165 - *
166 - * @since 6.9
167 - *
168 - * @param int|object $form Form ID or object.
169 - * @return void
170 - */
171 - private static function create_submit_button_field( $form ) {
172 - FrmForm::maybe_get_form( $form );
173 - if ( ! is_object( $form ) ) {
174 - return;
175 - }
176 -
177 - if ( FrmSubmitHelper::get_submit_field( $form->id ) ) {
178 - // Do not create submit button field if it exists.
179 - return;
180 - }
181 -
182 - FrmField::create(
183 - array(
184 - 'type' => FrmSubmitHelper::FIELD_TYPE,
185 - 'name' => __( 'Submit', 'formidable' ),
186 - 'field_order' => FrmSubmitHelper::DEFAULT_ORDER,
187 - 'form_id' => $form->id,
188 - 'field_options' => FrmFieldsHelper::get_default_field_options( FrmSubmitHelper::FIELD_TYPE ),
189 - 'description' => '',
190 - 'default_value' => '',
191 - 'options' => array(),
192 - )
193 - );
194 - }
195 -
196 - /**
197 - * @return void
198 - */
199 138 public static function edit( $values = false ) {
200 139 FrmAppHelper::permission_check( 'frm_edit_forms' );
201 140
202 141 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
203 142
204 - self::get_edit_vars( $id );
143 + return self::get_edit_vars( $id );
205 144 }
206 145
207 - /**
208 - * @param mixed $id
209 - * @param string $message
210 - * @return void
211 - */
212 146 public static function settings( $id = false, $message = '' ) {
213 147 FrmAppHelper::permission_check( 'frm_edit_forms' );
214 148
215 149 if ( ! $id || ! is_numeric( $id ) ) {
@@ -217,9 +151,9 @@
217 151 }
218 152
219 153 FrmOnSubmitHelper::maybe_migrate_submit_settings_to_action( $id );
220 154
221 - self::get_settings_vars( $id, array(), $message );
155 + return self::get_settings_vars( $id, array(), $message );
222 156 }
223 157
224 158 public static function update_settings() {
225 159 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -226,9 +160,9 @@
226 160 $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
227 161
228 162 if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
229 163 $frm_settings = FrmAppHelper::get_settings();
230 - $error_args = array(
164 + $error_args = array(
231 165 'title' => __( 'Verification failed', 'formidable' ),
232 166 'body' => $frm_settings->admin_permission,
233 167 'cancel_text' => __( 'Cancel', 'formidable' ),
234 168 );
@@ -237,14 +171,13 @@
237 171 }
238 172
239 173 $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
240 174
241 - $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
175 + $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
242 176 $warnings = FrmFormsHelper::check_for_warnings( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
243 177
244 178 if ( count( $errors ) > 0 ) {
245 - self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
246 - return;
179 + return self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
247 180 }
248 181
249 182 do_action( 'frm_before_update_form_settings', $id );
250 183
@@ -258,9 +191,9 @@
258 191 }
259 192
260 193 $message = __( 'Settings Successfully Updated', 'formidable' );
261 194
262 - self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
195 + return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
263 196 }
264 197
265 198 /**
266 199 * @param int $form_id
@@ -270,11 +203,8 @@
270 203 $form = FrmForm::getOne( $form_id );
271 204 return ! empty( $form->options['antispam'] );
272 205 }
273 206
274 - /**
275 - * @return void
276 - */
277 207 public static function update( $values = array() ) {
278 208 if ( empty( $values ) ) {
279 209 $values = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing
280 210 }
@@ -292,31 +222,30 @@
292 222
293 223 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
294 224
295 225 if ( count( $errors ) > 0 ) {
296 - self::get_edit_vars( $id, $errors );
297 - return;
298 - }
226 + return self::get_edit_vars( $id, $errors );
227 + } else {
228 + self::maybe_remove_draft_option_from_fields( $id );
299 229
300 - self::maybe_remove_draft_option_from_fields( $id );
230 + FrmForm::update( $id, $values );
231 + $message = __( 'Form was successfully updated.', 'formidable' );
301 232
302 - FrmForm::update( $id, $values );
303 - $message = __( 'Form was successfully updated.', 'formidable' );
233 + if ( self::is_too_long( $values ) ) {
234 + $message .= '<br/> ' . sprintf(
235 + /* translators: %1$s: Start link HTML, %2$s: end link HTML */
236 + __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
237 + '<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">',
238 + '</a>'
239 + );
240 + }
304 241
305 - if ( self::is_too_long( $values ) ) {
306 - $message .= '<br/> ' . sprintf(
307 - /* translators: %1$s: Start link HTML, %2$s: end link HTML */
308 - __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
309 - '<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">',
310 - '</a>'
311 - );
312 - }
242 + if ( defined( 'DOING_AJAX' ) ) {
243 + wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
244 + }
313 245
314 - if ( defined( 'DOING_AJAX' ) ) {
315 - wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
316 - }
317 -
318 - self::get_edit_vars( $id, array(), $message );
246 + return self::get_edit_vars( $id, array(), $message );
247 + }//end if
319 248 }
320 249
321 250 /**
322 251 * Remove the draft flag from any new fields from this current session.
@@ -351,13 +280,35 @@
351 280 * If it's missing, it means other values at the end of the form
352 281 * were likely not saved either.
353 282 *
354 283 * @since 3.06.01
284 + */
285 + private static function is_too_long( $values ) {
286 + return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] );
287 + }
288 +
289 + /**
290 + * Redirect to the url for creating from a template
291 + * Also delete the current form
355 292 *
356 - * @return bool
293 + * @since 2.0
294 + * @deprecated 3.06
357 295 */
358 - private static function is_too_long( $values ) {
359 - return empty( $values['frm_end'] );
296 + public static function _create_from_template() {
297 + _deprecated_function( __FUNCTION__, '3.06' );
298 +
299 + FrmAppHelper::permission_check( 'frm_edit_forms' );
300 + check_ajax_referer( 'frm_ajax', 'nonce' );
301 +
302 + $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
303 + $template_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
304 +
305 + if ( $current_form ) {
306 + FrmForm::destroy( $current_form );
307 + }
308 +
309 + echo esc_url_raw( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template_id ) ) );
310 + wp_die();
360 311 }
361 312
362 313 public static function duplicate() {
363 314 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -374,10 +325,10 @@
374 325 $message = 'form_duplicate_error';
375 326
376 327 if ( $form ) {
377 328 $new_template = FrmAppHelper::simple_get( 'new_template' ) ? '&new_template=true' : '';
378 - $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
379 - $message = 'form_duplicated';
329 + $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
330 + $message = 'form_duplicated';
380 331 }
381 332
382 333 $url .= '&message=' . $message;
383 334
@@ -385,24 +336,20 @@
385 336 exit();
386 337 }
387 338
388 339 /**
389 - * @return string|null
340 + * @return string
390 341 */
391 342 public static function page_preview() {
392 343 $params = FrmForm::list_page_params();
393 - if ( ! $params['form'] || is_numeric( $params['form'] ) ) {
394 - return null;
344 + if ( ! $params['form'] ) {
345 + return;
395 346 }
396 347
397 - self::maybe_block_preview( $params['form'] );
398 -
399 348 $form = FrmForm::getOne( $params['form'] );
400 - if ( ! $form ) {
401 - return null;
349 + if ( $form ) {
350 + return self::show_form( $form->id, '', 'auto', 'auto' );
402 351 }
403 -
404 - return self::show_form( $form->id, '', 'auto', 'auto' );
405 352 }
406 353
407 354 /**
408 355 * @since 3.0
@@ -409,18 +356,9 @@
409 356 *
410 357 * @return void
411 358 */
412 359 public static function show_page_preview() {
413 - $preview = self::page_preview();
414 - if ( is_null( $preview ) ) {
415 - wp_die(
416 - '<h1>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</h1>',
417 - '<p>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</p>',
418 - 404
419 - );
420 - }
421 -
422 - echo $preview; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
360 + echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
423 361 }
424 362
425 363 /**
426 364 * @return void
@@ -431,17 +369,8 @@
431 369
432 370 global $frm_vars;
433 371 $frm_vars['preview'] = true;
434 372
435 - // print_emoji_styles is deprecated.
436 - remove_action( 'wp_print_styles', 'print_emoji_styles' );
437 -
438 - if ( FrmTestModeController::should_add_test_mode_container() ) {
439 - do_action( 'frm_test_mode_init' );
440 - add_action( 'wp_enqueue_scripts', 'FrmTestModeController::register_and_enqueue_required_scripts' );
441 - add_filter( 'frm_filter_final_form', 'FrmTestModeController::maybe_add_test_mode_container', 99 );
442 - }
443 -
444 373 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
445 374 if ( $include_theme ) {
446 375 self::set_preview_query();
447 376 self::load_theme_preview();
@@ -508,10 +437,8 @@
508 437 }
509 438
510 439 /**
511 440 * @since 3.0
512 - *
513 - * @return void
514 441 */
515 442 private static function load_theme_preview() {
516 443 add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
517 444 add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
@@ -543,10 +470,8 @@
543 470
544 471 /**
545 472 * Not every theme supports get_template_part( 'page' ).
546 473 * When this is not supported, false is returned, and we can handle a fallback.
547 - *
548 - * @return void
549 474 */
550 475 private static function fallback_when_page_template_part_is_not_supported_by_theme() {
551 476 if ( have_posts() ) {
552 477 the_post();
@@ -558,12 +483,8 @@
558 483 echo '<div class="container entry-content">';
559 484 the_content();
560 485 echo '</div>';
561 486
562 - // Prevent extra unexpected forms in the footer.
563 - // For some reason this happens in the Twenty Twenty Five theme.
564 - add_filter( 'frm_filter_final_form', '__return_empty_string' );
565 -
566 487 self::get_template( 'footer' );
567 488 }
568 489 }
569 490
@@ -568,9 +489,9 @@
568 489 }
569 490
570 491 /**
571 492 * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call
572 - * and renders required html fragments calling required functions.
493 + * and renders required html fragements calling required functions.
573 494 *
574 495 * @since 6.7.1
575 496 * @param string $template
576 497 * @return void
@@ -620,14 +541,11 @@
620 541 return $title;
621 542 }
622 543
623 544 /**
624 - * Set the page title for the theme preview page.
545 + * Set the page title for the theme preview page
625 546 *
626 547 * @since 3.0
627 - *
628 - * @param string $title
629 - * @return string
630 548 */
631 549 public static function preview_title( $title ) {
632 550 return __( 'Form Preview', 'formidable' );
633 551 }
@@ -653,88 +571,23 @@
653 571 /**
654 572 * @since 3.0
655 573 */
656 574 private static function load_direct_preview() {
575 + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
576 +
657 577 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
658 578 if ( $key == '' ) {
659 579 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
660 580 }
661 581
662 - if ( ! $key ) {
663 - $error = __( 'Form key is missing', 'formidable' );
664 - wp_die(
665 - '<h1>' . esc_html( $error ) . '</h1>',
666 - '<p>' . esc_html( $error ) . '</p>',
667 - 404
668 - );
669 - }
670 -
671 - self::maybe_block_preview( $key );
672 -
673 582 $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
674 - if ( ! $form ) {
675 - $error = __( 'Form does not exist', 'formidable' );
676 - wp_die(
677 - '<h1>' . esc_html( $error ) . '</h1>',
678 - '<p>' . esc_html( $error ) . '</p>',
679 - 404
680 - );
583 + if ( empty( $form ) ) {
584 + $form = FrmForm::getAll( array(), '', 1 );
681 585 }
682 586
683 - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
684 -
685 - self::fix_deprecated_null_param_warning();
686 -
687 - require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
587 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
688 588 }
689 589
690 - /**
691 - * Block the form preview for the contact form by default if the user cannot view forms.
692 - * This is to prevent the contact form being exploited.
693 - * Since this form is added by default and every site uses the same key, it is too easy
694 - * to guess this form.
695 - *
696 - * @since 6.20
697 - *
698 - * @param string $form_key Form key.
699 - * @return void
700 - */
701 - public static function maybe_block_preview( $form_key ) {
702 - if ( FrmFormsHelper::should_block_preview( $form_key ) ) {
703 - $error = __( 'You do not have permission to view this form', 'formidable' );
704 - wp_die(
705 - '<h1>' . esc_html( $error ) . '</h1>',
706 - '<p>' . esc_html( $error ) . '</p>',
707 - 403
708 - );
709 - }
710 - }
711 -
712 - /**
713 - * Some themes have a null $src value.
714 - * This function adds a filter to ensure that $src is not null.
715 - * WP will call str_starts_with with the null value triggering a deprecated message otherwise.
716 - *
717 - * @since 6.10
718 - *
719 - * @return void
720 - */
721 - private static function fix_deprecated_null_param_warning() {
722 - add_filter(
723 - 'script_loader_src',
724 - /**
725 - * @param string|null $src
726 - * @return string
727 - */
728 - function ( $src ) {
729 - if ( is_null( $src ) ) {
730 - $src = '';
731 - }
732 - return $src;
733 - }
734 - );
735 - }
736 -
737 590 public static function untrash() {
738 591 self::change_form_status( 'untrash' );
739 592 }
740 593
@@ -802,9 +655,9 @@
802 655 check_admin_referer( $status . '_form_' . $params['id'] );
803 656
804 657 $count = 0;
805 658 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
806 - ++$count;
659 + $count ++;
807 660 }
808 661
809 662 $form_type = FrmAppHelper::get_simple_request(
810 663 array(
@@ -816,9 +669,9 @@
816 669 /* translators: %1$s: Number of forms */
817 670 $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
818 671
819 672 /* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */
820 - $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
673 + $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
821 674
822 675 $message = $available_status[ $status ]['message'];
823 676
824 677 self::display_forms_list( $params, $message );
@@ -823,12 +676,8 @@
823 676
824 677 self::display_forms_list( $params, $message );
825 678 }
826 679
827 - /**
828 - * @param array $ids
829 - * @return string
830 - */
831 680 public static function bulk_trash( $ids ) {
832 681 FrmAppHelper::permission_check( 'frm_delete_forms' );
833 682
834 683 $count = 0;
@@ -833,16 +682,12 @@
833 682
834 683 $count = 0;
835 684 foreach ( $ids as $id ) {
836 685 if ( FrmForm::trash( $id ) ) {
837 - ++$count;
686 + $count ++;
838 687 }
839 688 }
840 689
841 - if ( ! $count ) {
842 - return '';
843 - }
844 -
845 690 $current_page = FrmAppHelper::get_simple_request(
846 691 array(
847 692 'param' => 'form_type',
848 693 'type' => 'request',
@@ -868,9 +713,9 @@
868 713 check_admin_referer( 'destroy_form_' . $params['id'] );
869 714
870 715 $count = 0;
871 716 if ( FrmForm::destroy( $params['id'] ) ) {
872 - ++$count;
717 + $count ++;
873 718 }
874 719
875 720 /* translators: %1$s: Number of forms */
876 721 $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count );
@@ -877,12 +722,8 @@
877 722
878 723 self::display_forms_list( $params, $message );
879 724 }
880 725
881 - /**
882 - * @param array $ids
883 - * @return string
884 - */
885 726 public static function bulk_destroy( $ids ) {
886 727 FrmAppHelper::permission_check( 'frm_delete_forms' );
887 728
888 729 $count = 0;
@@ -888,9 +729,9 @@
888 729 $count = 0;
889 730 foreach ( $ids as $id ) {
890 731 $d = FrmForm::destroy( $id );
891 732 if ( $d ) {
892 - ++$count;
733 + $count ++;
893 734 }
894 735 }
895 736
896 737 if ( $count ) {
@@ -915,9 +756,9 @@
915 756
916 757 $count = FrmForm::scheduled_delete( time() );
917 758 $url = remove_query_arg( array( 'delete_all' ) );
918 759
919 - $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
760 + $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
920 761
921 762 wp_safe_redirect( $url );
922 763 die();
923 764 }
@@ -933,9 +774,9 @@
933 774
934 775 $new_values = self::get_modal_values();
935 776 $new_values['form_key'] = $new_values['name'];
936 777 $new_values['options'] = array(
937 - 'antispam' => 1,
778 + 'antispam' => 1,
938 779 'on_submit_migrated' => 1,
939 780 );
940 781
941 782 /**
@@ -954,9 +795,8 @@
954 795 * @param int $form_id
955 796 */
956 797 do_action( 'frm_build_new_form', $form_id );
957 798
958 - self::create_submit_button_field( $form_id );
959 799 self::create_default_on_submit_action( $form_id );
960 800 self::create_default_email_action( $form_id );
961 801
962 802 $response = array(
@@ -970,10 +810,8 @@
970 810 /**
971 811 * Before creating a new form, get the name and description from the modal.
972 812 *
973 813 * @since 4.0
974 - *
975 - * @return array<string,string>
976 814 */
977 815 public static function get_modal_values() {
978 816 $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
979 817 $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
@@ -988,24 +826,17 @@
988 826 * Inserts Formidable button
989 827 * Hook exists since 2.5.0
990 828 *
991 829 * @since 2.0.15
992 - *
993 - * @return void
994 830 */
995 831 public static function insert_form_button() {
996 832 if ( current_user_can( 'frm_view_forms' ) ) {
997 - // Store the result in memory and re-use it when this function is called multiple times.
998 - // This helps speed up the form builder when there are a lot of HTML fields, where this
999 - // button is inserted once per HTML field.
1000 - // In a form with 66 HTML fields, this saves 0.5 seconds on page load time, tested locally.
1001 - if ( ! isset( self::$formidable_tinymce_button ) ) {
1002 - FrmAppHelper::load_admin_wide_js();
1003 - $menu_name = FrmAppHelper::get_menu_name();
1004 - $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
1005 - 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>';
1006 - }
1007 - echo self::$formidable_tinymce_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
833 + FrmAppHelper::load_admin_wide_js();
834 + $menu_name = FrmAppHelper::get_menu_name();
835 + $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
836 + 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' ) . '">' .
837 + FrmAppHelper::kses( $icon, 'all' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
838 + ' ' . esc_html( $menu_name ) . '</a>';
1008 839 }
1009 840 }
1010 841
1011 842 /**
@@ -1093,9 +924,9 @@
1093 924 $form_id = $opts['form_id'];
1094 925 unset( $opts['form_id'] );
1095 926 }
1096 927
1097 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php';
928 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
1098 929
1099 930 echo '</div>';
1100 931
1101 932 wp_die();
@@ -1135,14 +966,8 @@
1135 966 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
1136 967 die();
1137 968 }
1138 969
1139 - $inbox = new FrmInbox();
1140 - $error = $inbox->check_for_error();
1141 - if ( $error ) {
1142 - $show_messages = array( $error['subject'] . '. ' . $error['message'] );
1143 - }
1144 -
1145 970 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php';
1146 971 }
1147 972
1148 973 /**
@@ -1149,16 +974,14 @@
1149 974 * @param array<string,string> $columns
1150 975 * @return array<string,string>
1151 976 */
1152 977 public static function get_columns( $columns ) {
1153 - $columns['cb'] = '<input type="checkbox" />';
1154 - $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1155 - $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1156 - $columns['id'] = 'ID';
1157 - $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1158 - if ( 'trash' !== FrmAppHelper::simple_get( 'form_type' ) ) {
1159 - $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1160 - }
978 + $columns['cb'] = '<input type="checkbox" />';
979 + $columns['name'] = esc_html__( 'Form Title', 'formidable' );
980 + $columns['entries'] = esc_html__( 'Entries', 'formidable' );
981 + $columns['id'] = 'ID';
982 + $columns['form_key'] = esc_html__( 'Key', 'formidable' );
983 + $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1161 984 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
1162 985
1163 986 add_screen_option(
1164 987 'per_page',
@@ -1171,11 +994,8 @@
1171 994
1172 995 return $columns;
1173 996 }
1174 997
1175 - /**
1176 - * @return array<string,string>
1177 - */
1178 998 public static function get_sortable_columns() {
1179 999 return array(
1180 1000 'id' => 'id',
1181 1001 'name' => 'name',
@@ -1209,9 +1029,9 @@
1209 1029 return $hidden_columns;
1210 1030 }
1211 1031
1212 1032 public static function save_per_page( $save, $option, $value ) {
1213 - if ( $option === 'formidable_page_formidable_per_page' ) {
1033 + if ( $option == 'formidable_page_formidable_per_page' ) {
1214 1034 $save = (int) $value;
1215 1035 }
1216 1036
1217 1037 return $save;
@@ -1216,23 +1036,16 @@
1216 1036
1217 1037 return $save;
1218 1038 }
1219 1039
1220 - /**
1221 - * @param int|string $id
1222 - * @param array $errors
1223 - * @param string $message
1224 - * @param bool $create_link
1225 - * @return void
1226 - */
1227 1040 private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1228 1041 global $frm_vars;
1229 1042
1230 - $form = FrmForm::getOne( $id );
1043 + $form = FrmForm::getOne( $id );
1231 1044 $error_args = array(
1232 - 'title' => __( 'You can\'t edit the form', 'formidable' ),
1233 - 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
1234 - 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
1045 + 'title' => __( 'You can\'t edit the form', 'formidable' ),
1046 + 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
1047 + 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
1235 1048 'continue_url' => add_query_arg(
1236 1049 array(
1237 1050 'page' => 'formidable',
1238 1051 )
@@ -1243,10 +1056,10 @@
1243 1056 return;
1244 1057 }
1245 1058
1246 1059 if ( 'trash' === $form->status ) {
1247 - $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
1248 - $error_args['continue_url'] = add_query_arg(
1060 + $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
1061 + $error_args['continue_url'] = add_query_arg(
1249 1062 array(
1250 1063 'page' => 'formidable',
1251 1064 '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ),
1252 1065 'form_type' => 'trash',
@@ -1270,9 +1083,8 @@
1270 1083
1271 1084 // Automatically add end section fields if they don't exist (2.0 migration).
1272 1085 $reset_fields = false;
1273 1086 FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
1274 - FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields );
1275 1087
1276 1088 if ( $reset_fields ) {
1277 1089 $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
1278 1090 }
@@ -1298,9 +1110,10 @@
1298 1110 }
1299 1111
1300 1112 self::maybe_update_form_builder_message( $message );
1301 1113
1302 - $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1114 + $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
1115 + $has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] );
1303 1116
1304 1117 if ( defined( 'DOING_AJAX' ) ) {
1305 1118 wp_die();
1306 1119 }
@@ -1307,12 +1120,8 @@
1307 1120
1308 1121 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php';
1309 1122 }
1310 1123
1311 - /**
1312 - * @param array $fields
1313 - * @return array
1314 - */
1315 1124 public static function update_form_builder_fields( $fields, $form ) {
1316 1125 foreach ( $fields as $field ) {
1317 1126 $field->do_not_include_icons = true;
1318 1127 }
@@ -1324,21 +1133,13 @@
1324 1133 $message = __( 'Form was Successfully Copied', 'formidable' );
1325 1134 }
1326 1135 }
1327 1136
1328 - /**
1329 - * @param int|string $id
1330 - * @param array $errors
1331 - * @param array|string $args
1332 - * @return void
1333 - */
1334 1137 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1335 1138 FrmAppHelper::permission_check( 'frm_edit_forms' );
1336 1139
1337 1140 global $frm_vars;
1338 1141
1339 - self::maybe_print_media_templates();
1340 -
1341 1142 if ( ! is_array( $args ) ) {
1342 1143 // For reverse compatibility.
1343 1144 $args = array(
1344 1145 'message' => $args,
@@ -1371,38 +1172,17 @@
1371 1172
1372 1173 $sections = self::get_settings_tabs( $values );
1373 1174 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' );
1374 1175
1375 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php';
1176 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
1376 1177 }
1377 1178
1378 1179 /**
1379 - * Print WordPress media templates email actions does not trigger a "Uncaught Error: Template not found: #tmpl-media-selection" error when the media button is clicked.
1380 - *
1381 - * @since 6.10
1382 - *
1383 - * @return void
1384 - */
1385 - private static function maybe_print_media_templates() {
1386 - if ( FrmAppHelper::pro_is_included() ) {
1387 - // This issue does not exist when Pro is active so exit early.
1388 - return;
1389 - }
1390 -
1391 - add_action(
1392 - 'wp_enqueue_editor',
1393 - function () {
1394 - wp_print_media_templates();
1395 - }
1396 - );
1397 - }
1398 -
1399 - /**
1400 1180 * @since 4.0
1401 1181 */
1402 1182 public static function form_publish_button( $atts ) {
1403 1183 $values = $atts['values'];
1404 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
1184 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
1405 1185 }
1406 1186
1407 1187 /**
1408 1188 * Get a list of all the settings tabs for the form settings page.
@@ -1416,9 +1196,9 @@
1416 1196 $sections = array(
1417 1197 'advanced' => array(
1418 1198 'name' => __( 'General', 'formidable' ),
1419 1199 'title' => __( 'General Form Settings', 'formidable' ),
1420 - 'function' => array( self::class, 'advanced_settings' ),
1200 + 'function' => array( __CLASS__, 'advanced_settings' ),
1421 1201 'icon' => 'frm_icon_font frm_settings_icon',
1422 1202 ),
1423 1203 'email' => array(
1424 1204 'name' => __( 'Actions & Notifications', 'formidable' ),
@@ -1427,9 +1207,9 @@
1427 1207 'icon' => 'frm_icon_font frm_mail_bulk_icon',
1428 1208 ),
1429 1209 'permissions' => array(
1430 1210 'name' => __( 'Form Permissions', 'formidable' ),
1431 - 'icon' => 'frm_icon_font frm_lock_closed_icon',
1211 + 'icon' => 'frm_icon_font frm_lock_icon',
1432 1212 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1433 1213 'data' => array(
1434 1214 'medium' => 'permissions',
1435 1215 'upgrade' => __( 'Form Permissions', 'formidable' ),
@@ -1436,9 +1216,9 @@
1436 1216 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1437 1217 'screenshot' => 'permissions.png',
1438 1218 ),
1439 1219 ),
1440 - 'scheduling' => array(
1220 + 'scheduling' => array(
1441 1221 'name' => __( 'Form Scheduling', 'formidable' ),
1442 1222 'icon' => 'frm_icon_font frm_calendar_icon',
1443 1223 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1444 1224 'data' => array(
@@ -1448,9 +1228,9 @@
1448 1228 ),
1449 1229 ),
1450 1230 'buttons' => array(
1451 1231 'name' => __( 'Buttons', 'formidable' ),
1452 - 'class' => self::class,
1232 + 'class' => __CLASS__,
1453 1233 'function' => 'buttons_settings',
1454 1234 'icon' => 'frm_icon_font frm_button_icon',
1455 1235 ),
1456 1236 'landing' => array(
@@ -1471,9 +1251,9 @@
1471 1251 'screenshot' => 'chat.png',
1472 1252 )
1473 1253 ),
1474 1254 ),
1475 - 'abandonment' => array(
1255 + 'abandonment' => array(
1476 1256 'name' => __( 'Form Abandonment', 'formidable' ),
1477 1257 'icon' => 'frm_icon_font frm_abandoned_icon',
1478 1258 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1479 1259 'data' => FrmAppHelper::get_upgrade_data_params(
@@ -1486,18 +1266,14 @@
1486 1266 ),
1487 1267 ),
1488 1268 'html' => array(
1489 1269 'name' => __( 'Customize HTML', 'formidable' ),
1490 - 'class' => self::class,
1270 + 'class' => __CLASS__,
1491 1271 'function' => 'html_settings',
1492 1272 'icon' => 'frm_icon_font frm_code_icon',
1493 1273 ),
1494 1274 );
1495 1275
1496 - if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1497 - unset( $sections['buttons'] );
1498 - }
1499 -
1500 1276 foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1501 1277 if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1502 1278 unset( $sections[ $feature ] );
1503 1279 }
@@ -1504,8 +1280,13 @@
1504 1280 }
1505 1281
1506 1282 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1507 1283
1284 + if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
1285 + // Prevent settings from showing in 2 spots.
1286 + unset( $sections['permissions'], $sections['scheduling'] );
1287 + }
1288 +
1508 1289 foreach ( $sections as $key => $section ) {
1509 1290 $defaults = array(
1510 1291 'html_class' => '',
1511 1292 'name' => ucfirst( $key ),
@@ -1536,9 +1317,8 @@
1536 1317 /**
1537 1318 * @since 4.0
1538 1319 *
1539 1320 * @param array $values
1540 - * @return void
1541 1321 */
1542 1322 public static function advanced_settings( $values ) {
1543 1323 $first_h3 = 'frm_first_h3';
1544 1324
@@ -1546,15 +1326,14 @@
1546 1326 }
1547 1327
1548 1328 /**
1549 1329 * @param array $values
1550 - * @return void
1551 1330 */
1552 1331 public static function render_spam_settings( $values ) {
1553 1332 if ( function_exists( 'akismet_http_post' ) ) {
1554 1333 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
1555 1334 }
1556 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/stopforumspam.php';
1335 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/honeypot.php';
1557 1336 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php';
1558 1337 }
1559 1338
1560 1339 /**
@@ -1560,12 +1339,16 @@
1560 1339 /**
1561 1340 * @since 4.0
1562 1341 *
1563 1342 * @param array $values
1564 - * @return void
1565 1343 */
1566 1344 public static function buttons_settings( $values ) {
1567 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
1345 + $styles = apply_filters( 'frm_get_style_opts', array() );
1346 +
1347 + $frm_settings = FrmAppHelper::get_settings();
1348 + $no_global_style = $frm_settings->load_style === 'none';
1349 +
1350 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php' );
1568 1351 }
1569 1352
1570 1353 /**
1571 1354 * @since 4.0
@@ -1570,12 +1353,11 @@
1570 1353 /**
1571 1354 * @since 4.0
1572 1355 *
1573 1356 * @param array $values
1574 - * @return void
1575 1357 */
1576 1358 public static function html_settings( $values ) {
1577 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
1359 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' );
1578 1360 }
1579 1361
1580 1362 /**
1581 1363 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -1581,10 +1363,9 @@
1581 1363 * Replace old Submit Button href with new href to avoid errors in Chrome
1582 1364 *
1583 1365 * @since 2.03.08
1584 1366 *
1585 - * @param array|bool $values
1586 - * @return void
1367 + * @param array|boolean $values
1587 1368 */
1588 1369 private static function clean_submit_html( &$values ) {
1589 1370 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
1590 1371 $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
@@ -1605,13 +1386,8 @@
1605 1386
1606 1387 return $classes;
1607 1388 }
1608 1389
1609 - /**
1610 - * @param int|string $form_id
1611 - * @param string $class
1612 - * @return void
1613 - */
1614 1390 public static function mb_tags_box( $form_id, $class = '' ) {
1615 1391 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1616 1392
1617 1393 /**
@@ -1624,9 +1400,9 @@
1624 1400 */
1625 1401 $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) );
1626 1402 $linked_forms = array();
1627 1403 $col = 'one';
1628 - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' );
1404 + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
1629 1405
1630 1406 $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
1631 1407 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1632 1408
@@ -1631,9 +1407,9 @@
1631 1407 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1632 1408
1633 1409 $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
1634 1410
1635 - include FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php';
1411 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
1636 1412 }
1637 1413
1638 1414 /**
1639 1415 * @since 3.04.01
@@ -1646,9 +1422,9 @@
1646 1422 ),
1647 1423 );
1648 1424
1649 1425 $user_fields = self::user_shortcodes();
1650 - if ( $user_fields ) {
1426 + if ( ! empty( $user_fields ) ) {
1651 1427 $user_helpers = array();
1652 1428 foreach ( $user_fields as $uk => $uf ) {
1653 1429 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1654 1430 unset( $uk, $uf );
@@ -1654,9 +1430,9 @@
1654 1430 unset( $uk, $uf );
1655 1431 }
1656 1432
1657 1433 $advanced_helpers['user_id'] = array(
1658 - 'codes' => $user_helpers,
1434 + 'codes' => $user_helpers,
1659 1435 );
1660 1436 }
1661 1437
1662 1438 /**
@@ -1733,16 +1509,21 @@
1733 1509 'updated-at' => __( 'Entry updated', 'formidable' ),
1734 1510 '' => '',
1735 1511 'siteurl' => __( 'Site URL', 'formidable' ),
1736 1512 'sitename' => __( 'Site Name', 'formidable' ),
1737 - 'form_name' => __( 'Form Name', 'formidable' ),
1738 1513 );
1739 1514
1740 - $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1741 1515 if ( ! FrmAppHelper::pro_is_installed() ) {
1742 1516 unset( $entry_shortcodes['post_id'] );
1743 1517 }
1744 1518
1519 + if ( $settings_tab ) {
1520 + $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1521 + $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1522 + $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1523 + $entry_shortcodes['form_name'] = __( 'Form Name', 'formidable' );
1524 + }
1525 +
1745 1526 /**
1746 1527 * Use this hook to add or remove buttons in the helpers section
1747 1528 * in the customization panel
1748 1529 *
@@ -1768,9 +1549,9 @@
1768 1549 echo ' frm_js_validate ';
1769 1550 self::add_js_validate_form_to_global_vars( $form );
1770 1551 }
1771 1552
1772 - if ( FrmForm::is_ajax_on( $form ) ) {
1553 + if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) {
1773 1554 echo ' frm_ajax_submit ';
1774 1555 }
1775 1556 }
1776 1557
@@ -1792,11 +1573,11 @@
1792 1573 check_ajax_referer( 'frm_ajax', 'nonce' );
1793 1574
1794 1575 echo FrmEntriesController::show_entry_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1795 1576 array(
1796 - 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1577 + 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
1797 1578 'default_email' => true,
1798 - 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1579 + 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
1799 1580 )
1800 1581 );
1801 1582 wp_die();
1802 1583 }
@@ -1802,10 +1583,10 @@
1802 1583 }
1803 1584
1804 1585 /**
1805 1586 * @param string $content
1806 - * @param int|stdClass|string $form
1807 - * @param false|int|stdClass|string $entry
1587 + * @param stdClass|string|int $form
1588 + * @param stdClass|string|int|false $entry
1808 1589 * @return string
1809 1590 */
1810 1591 public static function filter_content( $content, $form, $entry = false ) {
1811 1592 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1818,16 +1599,8 @@
1818 1599 if ( is_object( $form ) ) {
1819 1600 $form = $form->id;
1820 1601 }
1821 1602
1822 - /*
1823 - * Repeater actions adds `parent_entry` to `$entry` store the parent entry data. If `parent_entry` is not empty,
1824 - * use the parent form ID instead of repeater form ID to fix the parent form field shortcodes doesn't work.
1825 - */
1826 - if ( ! empty( $entry->parent_entry ) ) {
1827 - $form = $entry->parent_entry->form_id;
1828 - }
1829 -
1830 1603 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1831 1604 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1832 1605
1833 1606 return $content;
@@ -1837,11 +1610,11 @@
1837 1610 * Replace any [form_name] shortcodes in a string.
1838 1611 *
1839 1612 * @since 5.5
1840 1613 *
1841 - * @param array|string $string
1842 - * @param int|stdClass|string $form
1843 - * @return array|string
1614 + * @param string|array $string
1615 + * @param stdClass|string|int $form
1616 + * @return string|array
1844 1617 */
1845 1618 public static function replace_form_name_shortcodes( $string, $form ) {
1846 1619 if ( ! is_string( $string ) ) {
1847 1620 return $string;
@@ -1859,9 +1632,9 @@
1859 1632 return str_replace( '[form_name]', $form_name, $string );
1860 1633 }
1861 1634
1862 1635 /**
1863 - * @param false|int|stdClass|string $entry
1636 + * @param stdClass|string|int|false $entry
1864 1637 * @return void
1865 1638 */
1866 1639 private static function get_entry_by_param( &$entry ) {
1867 1640 if ( ! $entry || ! is_object( $entry ) ) {
@@ -1876,12 +1649,8 @@
1876 1649 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1877 1650 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1878 1651 }
1879 1652
1880 - /**
1881 - * @param array $errors
1882 - * @return array
1883 - */
1884 1653 public static function process_bulk_form_actions( $errors ) {
1885 1654 if ( ! $_REQUEST ) {
1886 1655 return $errors;
1887 1656 }
@@ -1925,9 +1694,9 @@
1925 1694 case 'untrash':
1926 1695 $message = self::bulk_untrash( $ids );
1927 1696 }
1928 1697
1929 - if ( ! empty( $message ) ) {
1698 + if ( isset( $message ) && ! empty( $message ) ) {
1930 1699 $errors['message'] = $message;
1931 1700 }
1932 1701
1933 1702 return $errors;
@@ -1932,26 +1701,13 @@
1932 1701
1933 1702 return $errors;
1934 1703 }
1935 1704
1936 - /**
1937 - * Includes html that shows a message when the device is too small to use Formidable Forms admin pages.
1938 - *
1939 - * @since 6.20
1940 - * @return void
1941 - */
1942 - public static function include_device_too_small_message() {
1943 - if ( ! FrmAppHelper::is_formidable_admin() ) {
1944 - return;
1945 - }
1946 -
1947 - include FrmAppHelper::plugin_path() . '/classes/views/shared/small-device-message.php';
1948 - }
1949 -
1950 1705 public static function route() {
1951 1706 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1952 1707 $vars = array();
1953 1708 FrmAppHelper::include_svg();
1709 +
1954 1710 if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1955 1711 FrmAppHelper::permission_check( 'frm_edit_forms' );
1956 1712
1957 1713 // Javascript needs to be allowed in some field settings.
@@ -1960,9 +1716,9 @@
1960 1716 $json_vars = json_decode( $json_vars, true );
1961 1717 if ( empty( $json_vars ) ) {
1962 1718 // json decoding failed so we should return an error message.
1963 1719 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1964 - if ( 'edit' === $action ) {
1720 + if ( 'edit' == $action ) {
1965 1721 $action = 'update';
1966 1722 }
1967 1723
1968 1724 add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
@@ -1984,8 +1740,10 @@
1984 1740 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1985 1741 FrmAppHelper::trigger_hook_load( 'form' );
1986 1742
1987 1743 switch ( $action ) {
1744 + case 'new':
1745 + return self::new_form( $vars );
1988 1746 case 'create':
1989 1747 case 'edit':
1990 1748 case 'update':
1991 1749 case 'trash':
@@ -1994,13 +1752,11 @@
1994 1752 case 'settings':
1995 1753 case 'update_settings':
1996 1754 return self::$action( $vars );
1997 1755 case 'lite-reports':
1998 - self::no_reports( $vars );
1999 - return;
1756 + return self::no_reports( $vars );
2000 1757 case 'views':
2001 - self::no_views( $vars );
2002 - return;
1758 + return self::no_views( $vars );
2003 1759 default:
2004 1760 do_action( 'frm_form_action_' . $action );
2005 1761 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
2006 1762 return;
@@ -2055,32 +1811,12 @@
2055 1811 // Get posted data
2056 1812 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2057 1813 $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2058 1814
2059 - $form = FrmForm::getOne( $form_id );
2060 - if ( ! $form ) {
2061 - wp_send_json_error( __( 'Form not found', 'formidable' ) );
2062 - }
1815 + // Update the form name and form key.
1816 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
1817 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
2063 1818
2064 - if ( $name === $form->name ) {
2065 - // Nothing to change so exit early.
2066 - wp_send_json_success();
2067 - }
2068 -
2069 - $to_update = array(
2070 - 'name' => $name,
2071 - );
2072 -
2073 - if ( '' !== $name ) {
2074 - // Only update form_key if name is not empty.
2075 - $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
2076 - $to_update['form_key'] = $form_key;
2077 - } else {
2078 - $form_key = $form->form_key;
2079 - }
2080 -
2081 - FrmForm::update( $form_id, $to_update );
2082 -
2083 1819 wp_send_json_success( compact( 'form_key' ) );
2084 1820 }
2085 1821
2086 1822 public static function json_error( $errors ) {
@@ -2089,13 +1825,20 @@
2089 1825 return $errors;
2090 1826 }
2091 1827
2092 1828 /**
1829 + * Education for premium features.
1830 + *
1831 + * @since 4.05
1832 + */
1833 + public static function add_form_style_tab_options() {
1834 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' );
1835 + }
1836 +
1837 + /**
2093 1838 * Add education about views.
2094 1839 *
2095 1840 * @since 4.07
2096 - *
2097 - * @return void
2098 1841 */
2099 1842 public static function no_views( $values = array() ) {
2100 1843 FrmAppHelper::include_svg();
2101 1844 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -2107,10 +1850,8 @@
2107 1850 /**
2108 1851 * Add education about reports.
2109 1852 *
2110 1853 * @since 4.07
2111 - *
2112 - * @return void
2113 1854 */
2114 1855 public static function no_reports( $values = array() ) {
2115 1856 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
2116 1857 $form = $id ? FrmForm::getOne( $id ) : false;
@@ -2195,9 +1936,9 @@
2195 1936 $wp_admin_bar->add_node(
2196 1937 array(
2197 1938 'parent' => 'frm-forms',
2198 1939 'id' => 'edit_form_' . $form_id,
2199 - 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name,
1940 + 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
2200 1941 'href' => FrmForm::get_edit_link( $form_id ),
2201 1942 )
2202 1943 );
2203 1944 }
@@ -2210,10 +1951,10 @@
2210 1951 * @return string
2211 1952 */
2212 1953 public static function get_form_shortcode( $atts ) {
2213 1954 global $frm_vars;
2214 - if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2215 - $sc = '[formidable';
1955 + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1956 + $sc = '[formidable';
2216 1957 $sc .= FrmAppHelper::array_to_html_params( $atts );
2217 1958 return $sc . ']';
2218 1959 }
2219 1960
@@ -2238,11 +1979,11 @@
2238 1979
2239 1980 /**
2240 1981 * @since 5.2.01
2241 1982 *
2242 - * @param false|int|string $id
2243 - * @param false|string $key
2244 - * @return false|stdClass
1983 + * @param string|int|false $id
1984 + * @param string|false $key
1985 + * @return stdClass|false
2245 1986 */
2246 1987 private static function maybe_get_form_by_id_or_key( $id, $key ) {
2247 1988 if ( ! $id ) {
2248 1989 $id = $key;
@@ -2250,12 +1991,12 @@
2250 1991 return self::maybe_get_form_to_show( $id );
2251 1992 }
2252 1993
2253 1994 /**
2254 - * @param false|int|string $id
2255 - * @param false|string $key
2256 - * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2257 - * @param bool|int|string $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1995 + * @param string|int|false $id
1996 + * @param string|false $key
1997 + * @param string|int|bool $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1998 + * @param string|int|bool $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2258 1999 * @param array $atts
2259 2000 * @return string
2260 2001 */
2261 2002 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
@@ -2303,10 +2044,10 @@
2303 2044 return $form;
2304 2045 }
2305 2046
2306 2047 /**
2307 - * @param false|int|string $id
2308 - * @return false|stdClass
2048 + * @param string|int|false $id
2049 + * @return stdClass|false
2309 2050 */
2310 2051 private static function maybe_get_form_to_show( $id ) {
2311 2052 $form = false;
2312 2053
@@ -2370,11 +2111,11 @@
2370 2111
2371 2112 do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
2372 2113
2373 2114 if ( apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
2374 - $entry_id = self::just_created_entry( $form->id );
2375 - $pass_args['entry_id'] = $entry_id;
2376 - $pass_args['reset'] = true;
2115 + $entry_id = self::just_created_entry( $form->id );
2116 + $pass_args['entry_id'] = $entry_id;
2117 + $pass_args['reset'] = true;
2377 2118
2378 2119 self::run_on_submit_actions( $pass_args );
2379 2120
2380 2121 do_action(
@@ -2418,9 +2159,9 @@
2418 2159 */
2419 2160 public static function just_created_entry( $form_id ) {
2420 2161 global $frm_vars;
2421 2162
2422 - return isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
2163 + return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
2423 2164 }
2424 2165
2425 2166 /**
2426 2167 * Gets confirmation method.
@@ -2433,14 +2174,14 @@
2433 2174 *
2434 2175 * @type object $form Form object.
2435 2176 * @type int $entry_id Entry ID.
2436 2177 * }
2437 - * @return array|string
2178 + * @return string|array
2438 2179 */
2439 2180 private static function get_confirmation_method( $atts ) {
2440 2181 $action = FrmOnSubmitHelper::current_event( $atts );
2441 2182 $opt = 'update' === $action ? 'edit_action' : 'success_action';
2442 - $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2183 + $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
2443 2184
2444 2185 if ( ! empty( $atts['entry_id'] ) ) {
2445 2186 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2446 2187 if ( $met_actions ) {
@@ -2449,9 +2190,9 @@
2449 2190 }
2450 2191
2451 2192 $method = apply_filters( 'frm_success_filter', $method, $atts['form'], $action );
2452 2193
2453 - if ( $method !== 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2194 + if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2454 2195 $method = 'message';
2455 2196 }
2456 2197
2457 2198 return $method;
@@ -2485,9 +2226,9 @@
2485 2226 * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}.
2486 2227 */
2487 2228 public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) {
2488 2229 if ( is_array( $conf_method ) && 1 === count( $conf_method ) ) {
2489 - if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) && empty( $conf_method[0]->post_content['redirect_delay'] ) ) {
2230 + if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) ) {
2490 2231 $event = FrmOnSubmitHelper::current_event( $params );
2491 2232 FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event );
2492 2233 $conf_method = 'redirect';
2493 2234 }
@@ -2536,9 +2277,9 @@
2536 2277 unset( $extra_args['form'] );
2537 2278
2538 2279 do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
2539 2280
2540 - $opt = ! isset( $args['action'] ) || $args['action'] === 'create' ? 'success' : 'edit';
2281 + $opt = ( ! isset( $args['action'] ) || $args['action'] === 'create' ) ? 'success' : 'edit';
2541 2282
2542 2283 $args['success_opt'] = $opt;
2543 2284 $args['ajax'] = ! empty( $frm_vars['ajax'] );
2544 2285
@@ -2564,16 +2305,16 @@
2564 2305 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
2565 2306 return array();
2566 2307 }
2567 2308
2568 - // If a redirect action has already opened the URL in a new tab, we show the default message in the current tab.
2309 + // If a redirect action has already opened the URL in a new tab, we show the default message in the currect tab.
2569 2310 if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) {
2570 2311 return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) );
2571 2312 }
2572 2313
2573 - $entry = FrmEntry::getOne( $args['entry_id'], true );
2574 - $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2575 - $met_actions = array();
2314 + $entry = FrmEntry::getOne( $args['entry_id'], true );
2315 + $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2316 + $met_actions = array();
2576 2317 $has_redirect = false;
2577 2318
2578 2319 foreach ( $actions as $action ) {
2579 2320 if ( ! in_array( $event, $action->post_content['event'], true ) ) {
@@ -2822,9 +2563,9 @@
2822 2563 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
2823 2564 wp_die();
2824 2565 }
2825 2566
2826 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) {
2567 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) {
2827 2568 // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2828 2569 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2829 2570 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
2830 2571 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
@@ -2869,46 +2610,28 @@
2869 2610 * @param array $args See {@see FrmFormsController::run_success_action()}.
2870 2611 * @return array
2871 2612 */
2872 2613 private static function get_ajax_redirect_response_data( $args ) {
2873 - $response_data = array(
2874 - 'redirect' => $args['success_url'],
2875 - 'content' => '',
2876 - );
2877 - $unset_content = true;
2614 + $response_data = array( 'redirect' => $args['success_url'] );
2878 2615
2879 - if ( ! empty( $args['form']->options['redirect_delay'] ) ) {
2880 - $response_data['delay'] = $args['form']->options['redirect_delay_time'];
2881 - $response_data['content'] .= self::get_redirect_message( $args['success_url'], $args['form']->options['redirect_delay_msg'], $args );
2882 - $unset_content = false;
2883 - }
2884 -
2885 2616 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2886 2617 $response_data['openInNewTab'] = 1;
2887 2618
2888 - // Only show open in new tab text if there is no delay.
2889 - if ( empty( $response_data['content'] ) ) {
2890 - $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2619 + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2891 2620
2892 - $args['form']->options['success_msg'] = $args['message'];
2893 - $args['form']->options['edit_msg'] = $args['message'];
2894 - if ( ! isset( $args['fields'] ) ) {
2895 - $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2896 - }
2621 + $args['form']->options['success_msg'] = $args['message'];
2622 + $args['form']->options['edit_msg'] = $args['message'];
2623 + if ( ! isset( $args['fields'] ) ) {
2624 + $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2625 + }
2897 2626
2898 - $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2627 + $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2899 2628
2900 - ob_start();
2901 - self::show_lone_success_message( $args );
2902 - $response_data['content'] .= ob_get_clean();
2903 - $unset_content = false;
2904 - }//end if
2629 + ob_start();
2630 + self::show_lone_success_messsage( $args );
2631 + $response_data['content'] = ob_get_clean();
2905 2632
2906 2633 $response_data['fallbackMsg'] = self::get_redirect_fallback_message( $args['success_url'], $args );
2907 - }//end if
2908 -
2909 - if ( $unset_content && '' === $response_data['content'] ) {
2910 - unset( $response_data['content'] );
2911 2634 }
2912 2635
2913 2636 return $response_data;
2914 2637 }
@@ -2920,9 +2643,9 @@
2920 2643 *
2921 2644 * @param array $args See {@see FrmFormsController::run_success_action()}.
2922 2645 */
2923 2646 private static function redirect_after_submit_using_js( $args ) {
2924 - $success_msg = $args['form']->options['redirect_delay_msg'];
2647 + $success_msg = FrmOnSubmitHelper::get_default_redirect_msg();
2925 2648 $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args );
2926 2649 $success_url = esc_url_raw( $args['success_url'] );
2927 2650
2928 2651 /**
@@ -2929,11 +2652,11 @@
2929 2652 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
2930 2653 *
2931 2654 * @since 6.0
2932 2655 *
2933 - * @param int $delay_time Delay time in milliseconds.
2656 + * @param int $delay_time Delay time in miliseconds.
2934 2657 */
2935 - $delay_time = apply_filters( 'frm_redirect_delay_time', 1000 * $args['form']->options['redirect_delay_time'] );
2658 + $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
2936 2659
2937 2660 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2938 2661 $redirect_js = 'window.open("' . $success_url . '", "_blank")';
2939 2662 } else {
@@ -2962,10 +2685,8 @@
2962 2685 * @param string $success_msg
2963 2686 * @param array $args
2964 2687 */
2965 2688 private static function get_redirect_message( $success_url, $success_msg, $args ) {
2966 - $success_msg = apply_filters( 'frm_content', $success_msg, $args['form'], $args['entry_id'] );
2967 - $success_msg = do_shortcode( FrmAppHelper::use_wpautop( $success_msg ) );
2968 2689 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
2969 2690 self::get_redirect_fallback_message( $success_url, $args ) .
2970 2691 '</div></div>';
2971 2692
@@ -3021,9 +2742,9 @@
3021 2742 } else {
3022 2743 self::show_form_after_submit( $atts );
3023 2744 }
3024 2745 } else {
3025 - self::show_lone_success_message( $atts );
2746 + self::show_lone_success_messsage( $atts );
3026 2747 }
3027 2748 }
3028 2749
3029 2750 /**
@@ -3051,9 +2772,9 @@
3051 2772
3052 2773 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
3053 2774
3054 2775 $frm_settings = FrmAppHelper::get_settings();
3055 - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value;
2776 + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
3056 2777
3057 2778 global $frm_vars;
3058 2779 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
3059 2780
@@ -3062,10 +2783,11 @@
3062 2783 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
3063 2784 }
3064 2785
3065 2786 /**
2787 + * @return string - 'before', 'after', or 'submit'
2788 + *
3066 2789 * @since 4.05.02
3067 - * @return string - 'before', 'after', or 'submit'
3068 2790 */
3069 2791 private static function message_placement( $form, $message ) {
3070 2792 $place = 'before';
3071 2793
@@ -3077,10 +2799,11 @@
3077 2799 }
3078 2800 }
3079 2801
3080 2802 /**
2803 + * @return string - 'before' or 'after'
2804 + *
3081 2805 * @since 4.05.02
3082 - * @return string - 'before' or 'after'
3083 2806 */
3084 2807 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
3085 2808 }
3086 2809
@@ -3114,9 +2837,9 @@
3114 2837 * Show the success message without the form
3115 2838 *
3116 2839 * @since 2.05
3117 2840 */
3118 - private static function show_lone_success_message( $atts ) {
2841 + private static function show_lone_success_messsage( $atts ) {
3119 2842 global $frm_vars;
3120 2843 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
3121 2844 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
3122 2845
@@ -3125,9 +2848,9 @@
3125 2848 $errors = array();
3126 2849 $form = $atts['form'];
3127 2850 $message = $atts['message'];
3128 2851
3129 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
2852 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
3130 2853 }
3131 2854
3132 2855 /**
3133 2856 * Prepare the success message before it's shown
@@ -3141,12 +2864,12 @@
3141 2864 * @return string
3142 2865 */
3143 2866 private static function prepare_submit_message( $form, $entry_id, $args = array() ) {
3144 2867 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
3145 - $opt = $args['success_opt'] ?? 'success';
2868 + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
3146 2869
3147 2870 if ( $entry_id && is_numeric( $entry_id ) ) {
3148 - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg;
2871 + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
3149 2872 $class = 'frm_message';
3150 2873 } else {
3151 2874 $message = $frm_settings->failed_msg;
3152 2875 $class = FrmFormsHelper::form_error_class();
@@ -3247,13 +2970,11 @@
3247 2970 global $frm_vars;
3248 2971
3249 2972 FrmStylesController::enqueue_css();
3250 2973
3251 - if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
2974 + if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3252 2975 // load formidable js
3253 2976 wp_enqueue_script( 'formidable' );
3254 -
3255 - FrmHoneypot::maybe_print_honeypot_js();
3256 2977 }
3257 2978 }
3258 2979
3259 2980 /**
@@ -3267,12 +2988,12 @@
3267 2988 }
3268 2989
3269 2990 /**
3270 2991 * @since 2.0.8
3271 - * @return bool
2992 + * @return boolean
3272 2993 */
3273 2994 private static function is_minification_on( $atts ) {
3274 - return ! empty( $atts['minimize'] );
2995 + return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
3275 2996 }
3276 2997
3277 2998 /**
3278 2999 * @since 5.0.16
@@ -3370,9 +3091,9 @@
3370 3091
3371 3092 check_ajax_referer( 'frm_ajax', 'nonce' );
3372 3093
3373 3094 $html = FrmAppHelper::clip(
3374 - function () {
3095 + function() {
3375 3096 FrmAppHelper::maybe_autocomplete_pages_options(
3376 3097 array(
3377 3098 'field_name' => 'frm_page_dropdown',
3378 3099 'page_id' => '',
@@ -3392,8 +3113,15 @@
3392 3113
3393 3114 /**
3394 3115 * @deprecated 4.0
3395 3116 */
3117 + public static function new_form( $values = array() ) {
3118 + FrmDeprecated::new_form( $values );
3119 + }
3120 +
3121 + /**
3122 + * @deprecated 4.0
3123 + */
3396 3124 public static function create( $values = array() ) {
3397 3125 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3398 3126 self::update( $values );
3399 3127 }
@@ -3398,16 +3126,75 @@
3398 3126 self::update( $values );
3399 3127 }
3400 3128
3401 3129 /**
3402 - * Education for premium features.
3130 + * @deprecated 3.0
3131 + * @codeCoverageIgnore
3132 + */
3133 + public static function bulk_create_template( $ids ) {
3134 + return FrmDeprecated::bulk_create_template( $ids );
3135 + }
3136 +
3137 + /**
3138 + * @deprecated 3.0
3139 + * @codeCoverageIgnore
3140 + */
3141 + public static function edit_key() {
3142 + FrmDeprecated::edit_key();
3143 + }
3144 +
3145 + /**
3146 + * @deprecated 3.0
3147 + * @codeCoverageIgnore
3148 + */
3149 + public static function edit_description() {
3150 + FrmDeprecated::edit_description();
3151 + }
3152 +
3153 + /**
3154 + * @deprecated 4.08
3155 + * @since 3.06
3156 + */
3157 + public static function add_new() {
3158 + _deprecated_function( __FUNCTION__, '4.08' );
3159 + }
3160 +
3161 + /**
3162 + * Create a custom template from a form
3403 3163 *
3404 - * @since 4.05
3405 - * @deprecated 6.16.3
3164 + * @since 3.06
3165 + * @deprecated 6.7
3166 + */
3167 + public static function build_template() {
3168 + _deprecated_function( __METHOD__, '6.7' );
3169 + }
3170 +
3171 + /**
3172 + * @deprecated 6.7
3406 3173 *
3174 + * @return bool
3175 + */
3176 + public static function expired() {
3177 + _deprecated_function( __METHOD__, '6.7' );
3178 + return FrmAddonsController::is_license_expired();
3179 + }
3180 +
3181 + /**
3182 + * Get data from api before rendering it so that we can flag the modal as expired
3183 + *
3184 + * @deprecated 6.7
3185 + *
3407 3186 * @return void
3408 3187 */
3409 - public static function add_form_style_tab_options() {
3410 - _deprecated_function( __METHOD__, '6.16.3' );
3411 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php';
3188 + public static function before_list_templates() {
3189 + _deprecated_function( __METHOD__, '6.7' );
3190 + }
3191 +
3192 + /**
3193 + * @deprecated 6.7
3194 + *
3195 + * @return void
3196 + */
3197 + public static function list_templates() {
3198 + _deprecated_function( __METHOD__, '6.7' );
3412 3199 }
3413 3200 }