PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7.2
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 -540 6.256.7.2 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,34 +151,21 @@
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 - $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
227 160
228 - if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
229 - $frm_settings = FrmAppHelper::get_settings();
230 - $error_args = array(
231 - 'title' => __( 'Verification failed', 'formidable' ),
232 - 'body' => $frm_settings->admin_permission,
233 - 'cancel_text' => __( 'Cancel', 'formidable' ),
234 - );
235 - FrmAppController::show_error_modal( $error_args );
236 - return;
237 - }
238 -
239 161 $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
240 162
241 - $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
163 + $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
242 164 $warnings = FrmFormsHelper::check_for_warnings( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
243 165
244 166 if ( count( $errors ) > 0 ) {
245 - self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
246 - return;
167 + return self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
247 168 }
248 169
249 170 do_action( 'frm_before_update_form_settings', $id );
250 171
@@ -258,9 +179,9 @@
258 179 }
259 180
260 181 $message = __( 'Settings Successfully Updated', 'formidable' );
261 182
262 - self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
183 + return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
263 184 }
264 185
265 186 /**
266 187 * @param int $form_id
@@ -270,11 +191,8 @@
270 191 $form = FrmForm::getOne( $form_id );
271 192 return ! empty( $form->options['antispam'] );
272 193 }
273 194
274 - /**
275 - * @return void
276 - */
277 195 public static function update( $values = array() ) {
278 196 if ( empty( $values ) ) {
279 197 $values = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing
280 198 }
@@ -292,72 +210,63 @@
292 210
293 211 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
294 212
295 213 if ( count( $errors ) > 0 ) {
296 - self::get_edit_vars( $id, $errors );
297 - return;
298 - }
214 + return self::get_edit_vars( $id, $errors );
215 + } else {
216 + FrmForm::update( $id, $values );
217 + $message = __( 'Form was successfully updated.', 'formidable' );
299 218
300 - self::maybe_remove_draft_option_from_fields( $id );
219 + if ( self::is_too_long( $values ) ) {
220 + $message .= '<br/> ' . sprintf(
221 + /* translators: %1$s: Start link HTML, %2$s: end link HTML */
222 + __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
223 + '<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">',
224 + '</a>'
225 + );
226 + }
301 227
302 - FrmForm::update( $id, $values );
303 - $message = __( 'Form was successfully updated.', 'formidable' );
228 + if ( defined( 'DOING_AJAX' ) ) {
229 + wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
230 + }
304 231
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 - }
232 + return self::get_edit_vars( $id, array(), $message );
233 + }//end if
234 + }
313 235
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 );
236 + /**
237 + * Check if the value at the end of the form was included.
238 + * If it's missing, it means other values at the end of the form
239 + * were likely not saved either.
240 + *
241 + * @since 3.06.01
242 + */
243 + private static function is_too_long( $values ) {
244 + return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] );
319 245 }
320 246
321 247 /**
322 - * Remove the draft flag from any new fields from this current session.
248 + * Redirect to the url for creating from a template
249 + * Also delete the current form
323 250 *
324 - * @since 6.8
325 - *
326 - * @param int $form_id
327 - * @return void
251 + * @since 2.0
252 + * @deprecated 3.06
328 253 */
329 - private static function maybe_remove_draft_option_from_fields( $form_id ) {
330 - $draft_field_ids_csv = FrmAppHelper::get_post_param( 'draft_fields', '', 'sanitize_text_field' );
331 - if ( ! $draft_field_ids_csv ) {
332 - // If the draft_fields input is empty there are no new fields in the session.
333 - return;
334 - }
254 + public static function _create_from_template() {
255 + _deprecated_function( __FUNCTION__, '3.06' );
335 256
336 - $draft_field_ids = array_filter( explode( ',', $draft_field_ids_csv ), 'is_numeric' );
337 - if ( ! $draft_field_ids ) {
338 - // Exit early if the draft fields input is invalid. It should be a CSV of integer values.
339 - return;
340 - }
257 + FrmAppHelper::permission_check( 'frm_edit_forms' );
258 + check_ajax_referer( 'frm_ajax', 'nonce' );
341 259
342 - $draft_field_rows = FrmFieldsHelper::get_draft_field_results( $form_id, $draft_field_ids );
343 - foreach ( $draft_field_rows as $row ) {
344 - $row->field_options['draft'] = 0;
345 - FrmField::update( $row->id, array( 'field_options' => $row->field_options ) );
260 + $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
261 + $template_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
262 +
263 + if ( $current_form ) {
264 + FrmForm::destroy( $current_form );
346 265 }
347 - }
348 266
349 - /**
350 - * Check if the value at the end of the form was included.
351 - * If it's missing, it means other values at the end of the form
352 - * were likely not saved either.
353 - *
354 - * @since 3.06.01
355 - *
356 - * @return bool
357 - */
358 - private static function is_too_long( $values ) {
359 - return empty( $values['frm_end'] );
267 + echo esc_url_raw( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template_id ) ) );
268 + wp_die();
360 269 }
361 270
362 271 public static function duplicate() {
363 272 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -374,10 +283,10 @@
374 283 $message = 'form_duplicate_error';
375 284
376 285 if ( $form ) {
377 286 $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';
287 + $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
288 + $message = 'form_duplicated';
380 289 }
381 290
382 291 $url .= '&message=' . $message;
383 292
@@ -385,24 +294,20 @@
385 294 exit();
386 295 }
387 296
388 297 /**
389 - * @return string|null
298 + * @return string
390 299 */
391 300 public static function page_preview() {
392 301 $params = FrmForm::list_page_params();
393 - if ( ! $params['form'] || is_numeric( $params['form'] ) ) {
394 - return null;
302 + if ( ! $params['form'] ) {
303 + return;
395 304 }
396 305
397 - self::maybe_block_preview( $params['form'] );
398 -
399 306 $form = FrmForm::getOne( $params['form'] );
400 - if ( ! $form ) {
401 - return null;
307 + if ( $form ) {
308 + return self::show_form( $form->id, '', 'auto', 'auto' );
402 309 }
403 -
404 - return self::show_form( $form->id, '', 'auto', 'auto' );
405 310 }
406 311
407 312 /**
408 313 * @since 3.0
@@ -409,18 +314,9 @@
409 314 *
410 315 * @return void
411 316 */
412 317 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
318 + echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
423 319 }
424 320
425 321 /**
426 322 * @return void
@@ -431,17 +327,8 @@
431 327
432 328 global $frm_vars;
433 329 $frm_vars['preview'] = true;
434 330
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 331 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
445 332 if ( $include_theme ) {
446 333 self::set_preview_query();
447 334 self::load_theme_preview();
@@ -508,10 +395,8 @@
508 395 }
509 396
510 397 /**
511 398 * @since 3.0
512 - *
513 - * @return void
514 399 */
515 400 private static function load_theme_preview() {
516 401 add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
517 402 add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
@@ -543,10 +428,8 @@
543 428
544 429 /**
545 430 * Not every theme supports get_template_part( 'page' ).
546 431 * When this is not supported, false is returned, and we can handle a fallback.
547 - *
548 - * @return void
549 432 */
550 433 private static function fallback_when_page_template_part_is_not_supported_by_theme() {
551 434 if ( have_posts() ) {
552 435 the_post();
@@ -558,12 +441,8 @@
558 441 echo '<div class="container entry-content">';
559 442 the_content();
560 443 echo '</div>';
561 444
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 445 self::get_template( 'footer' );
567 446 }
568 447 }
569 448
@@ -568,9 +447,9 @@
568 447 }
569 448
570 449 /**
571 450 * 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.
451 + * and renders required html fragements calling required functions.
573 452 *
574 453 * @since 6.7.1
575 454 * @param string $template
576 455 * @return void
@@ -620,14 +499,11 @@
620 499 return $title;
621 500 }
622 501
623 502 /**
624 - * Set the page title for the theme preview page.
503 + * Set the page title for the theme preview page
625 504 *
626 505 * @since 3.0
627 - *
628 - * @param string $title
629 - * @return string
630 506 */
631 507 public static function preview_title( $title ) {
632 508 return __( 'Form Preview', 'formidable' );
633 509 }
@@ -653,88 +529,23 @@
653 529 /**
654 530 * @since 3.0
655 531 */
656 532 private static function load_direct_preview() {
533 + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
534 +
657 535 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
658 536 if ( $key == '' ) {
659 537 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
660 538 }
661 539
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 540 $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 - );
541 + if ( empty( $form ) ) {
542 + $form = FrmForm::getAll( array(), '', 1 );
681 543 }
682 544
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';
545 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
688 546 }
689 547
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 548 public static function untrash() {
738 549 self::change_form_status( 'untrash' );
739 550 }
740 551
@@ -802,9 +613,9 @@
802 613 check_admin_referer( $status . '_form_' . $params['id'] );
803 614
804 615 $count = 0;
805 616 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
806 - ++$count;
617 + $count ++;
807 618 }
808 619
809 620 $form_type = FrmAppHelper::get_simple_request(
810 621 array(
@@ -816,9 +627,9 @@
816 627 /* translators: %1$s: Number of forms */
817 628 $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
818 629
819 630 /* 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>' );
631 + $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 632
822 633 $message = $available_status[ $status ]['message'];
823 634
824 635 self::display_forms_list( $params, $message );
@@ -823,12 +634,8 @@
823 634
824 635 self::display_forms_list( $params, $message );
825 636 }
826 637
827 - /**
828 - * @param array $ids
829 - * @return string
830 - */
831 638 public static function bulk_trash( $ids ) {
832 639 FrmAppHelper::permission_check( 'frm_delete_forms' );
833 640
834 641 $count = 0;
@@ -833,16 +640,12 @@
833 640
834 641 $count = 0;
835 642 foreach ( $ids as $id ) {
836 643 if ( FrmForm::trash( $id ) ) {
837 - ++$count;
644 + $count ++;
838 645 }
839 646 }
840 647
841 - if ( ! $count ) {
842 - return '';
843 - }
844 -
845 648 $current_page = FrmAppHelper::get_simple_request(
846 649 array(
847 650 'param' => 'form_type',
848 651 'type' => 'request',
@@ -868,9 +671,9 @@
868 671 check_admin_referer( 'destroy_form_' . $params['id'] );
869 672
870 673 $count = 0;
871 674 if ( FrmForm::destroy( $params['id'] ) ) {
872 - ++$count;
675 + $count ++;
873 676 }
874 677
875 678 /* translators: %1$s: Number of forms */
876 679 $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count );
@@ -877,12 +680,8 @@
877 680
878 681 self::display_forms_list( $params, $message );
879 682 }
880 683
881 - /**
882 - * @param array $ids
883 - * @return string
884 - */
885 684 public static function bulk_destroy( $ids ) {
886 685 FrmAppHelper::permission_check( 'frm_delete_forms' );
887 686
888 687 $count = 0;
@@ -888,9 +687,9 @@
888 687 $count = 0;
889 688 foreach ( $ids as $id ) {
890 689 $d = FrmForm::destroy( $id );
891 690 if ( $d ) {
892 - ++$count;
691 + $count ++;
893 692 }
894 693 }
895 694
896 695 if ( $count ) {
@@ -915,9 +714,9 @@
915 714
916 715 $count = FrmForm::scheduled_delete( time() );
917 716 $url = remove_query_arg( array( 'delete_all' ) );
918 717
919 - $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
718 + $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
920 719
921 720 wp_safe_redirect( $url );
922 721 die();
923 722 }
@@ -933,9 +732,9 @@
933 732
934 733 $new_values = self::get_modal_values();
935 734 $new_values['form_key'] = $new_values['name'];
936 735 $new_values['options'] = array(
937 - 'antispam' => 1,
736 + 'antispam' => 1,
938 737 'on_submit_migrated' => 1,
939 738 );
940 739
941 740 /**
@@ -954,9 +753,8 @@
954 753 * @param int $form_id
955 754 */
956 755 do_action( 'frm_build_new_form', $form_id );
957 756
958 - self::create_submit_button_field( $form_id );
959 757 self::create_default_on_submit_action( $form_id );
960 758 self::create_default_email_action( $form_id );
961 759
962 760 $response = array(
@@ -970,10 +768,8 @@
970 768 /**
971 769 * Before creating a new form, get the name and description from the modal.
972 770 *
973 771 * @since 4.0
974 - *
975 - * @return array<string,string>
976 772 */
977 773 public static function get_modal_values() {
978 774 $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
979 775 $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
@@ -988,24 +784,17 @@
988 784 * Inserts Formidable button
989 785 * Hook exists since 2.5.0
990 786 *
991 787 * @since 2.0.15
992 - *
993 - * @return void
994 788 */
995 789 public static function insert_form_button() {
996 790 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
791 + FrmAppHelper::load_admin_wide_js();
792 + $menu_name = FrmAppHelper::get_menu_name();
793 + $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
794 + 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' ) . '">' .
795 + FrmAppHelper::kses( $icon, 'all' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
796 + ' ' . esc_html( $menu_name ) . '</a>';
1008 797 }
1009 798 }
1010 799
1011 800 /**
@@ -1093,9 +882,9 @@
1093 882 $form_id = $opts['form_id'];
1094 883 unset( $opts['form_id'] );
1095 884 }
1096 885
1097 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php';
886 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
1098 887
1099 888 echo '</div>';
1100 889
1101 890 wp_die();
@@ -1135,14 +924,8 @@
1135 924 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
1136 925 die();
1137 926 }
1138 927
1139 - $inbox = new FrmInbox();
1140 - $error = $inbox->check_for_error();
1141 - if ( $error ) {
1142 - $show_messages = array( $error['subject'] . '. ' . $error['message'] );
1143 - }
1144 -
1145 928 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php';
1146 929 }
1147 930
1148 931 /**
@@ -1149,16 +932,14 @@
1149 932 * @param array<string,string> $columns
1150 933 * @return array<string,string>
1151 934 */
1152 935 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 - }
936 + $columns['cb'] = '<input type="checkbox" />';
937 + $columns['name'] = esc_html__( 'Form Title', 'formidable' );
938 + $columns['entries'] = esc_html__( 'Entries', 'formidable' );
939 + $columns['id'] = 'ID';
940 + $columns['form_key'] = esc_html__( 'Key', 'formidable' );
941 + $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1161 942 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
1162 943
1163 944 add_screen_option(
1164 945 'per_page',
@@ -1171,11 +952,8 @@
1171 952
1172 953 return $columns;
1173 954 }
1174 955
1175 - /**
1176 - * @return array<string,string>
1177 - */
1178 956 public static function get_sortable_columns() {
1179 957 return array(
1180 958 'id' => 'id',
1181 959 'name' => 'name',
@@ -1209,9 +987,9 @@
1209 987 return $hidden_columns;
1210 988 }
1211 989
1212 990 public static function save_per_page( $save, $option, $value ) {
1213 - if ( $option === 'formidable_page_formidable_per_page' ) {
991 + if ( $option == 'formidable_page_formidable_per_page' ) {
1214 992 $save = (int) $value;
1215 993 }
1216 994
1217 995 return $save;
@@ -1216,23 +994,16 @@
1216 994
1217 995 return $save;
1218 996 }
1219 997
1220 - /**
1221 - * @param int|string $id
1222 - * @param array $errors
1223 - * @param string $message
1224 - * @param bool $create_link
1225 - * @return void
1226 - */
1227 998 private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1228 999 global $frm_vars;
1229 1000
1230 - $form = FrmForm::getOne( $id );
1001 + $form = FrmForm::getOne( $id );
1231 1002 $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' ),
1003 + 'title' => __( 'You can\'t edit the form', 'formidable' ),
1004 + 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
1005 + 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
1235 1006 'continue_url' => add_query_arg(
1236 1007 array(
1237 1008 'page' => 'formidable',
1238 1009 )
@@ -1243,10 +1014,10 @@
1243 1014 return;
1244 1015 }
1245 1016
1246 1017 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(
1018 + $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
1019 + $error_args['continue_url'] = add_query_arg(
1249 1020 array(
1250 1021 'page' => 'formidable',
1251 1022 '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ),
1252 1023 'form_type' => 'trash',
@@ -1270,9 +1041,8 @@
1270 1041
1271 1042 // Automatically add end section fields if they don't exist (2.0 migration).
1272 1043 $reset_fields = false;
1273 1044 FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
1274 - FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields );
1275 1045
1276 1046 if ( $reset_fields ) {
1277 1047 $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
1278 1048 }
@@ -1298,21 +1068,18 @@
1298 1068 }
1299 1069
1300 1070 self::maybe_update_form_builder_message( $message );
1301 1071
1302 - $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1072 + $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
1073 + $has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] );
1303 1074
1304 1075 if ( defined( 'DOING_AJAX' ) ) {
1305 1076 wp_die();
1077 + } else {
1078 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
1306 1079 }
1307 -
1308 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php';
1309 1080 }
1310 1081
1311 - /**
1312 - * @param array $fields
1313 - * @return array
1314 - */
1315 1082 public static function update_form_builder_fields( $fields, $form ) {
1316 1083 foreach ( $fields as $field ) {
1317 1084 $field->do_not_include_icons = true;
1318 1085 }
@@ -1324,21 +1091,13 @@
1324 1091 $message = __( 'Form was Successfully Copied', 'formidable' );
1325 1092 }
1326 1093 }
1327 1094
1328 - /**
1329 - * @param int|string $id
1330 - * @param array $errors
1331 - * @param array|string $args
1332 - * @return void
1333 - */
1334 1095 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1335 1096 FrmAppHelper::permission_check( 'frm_edit_forms' );
1336 1097
1337 1098 global $frm_vars;
1338 1099
1339 - self::maybe_print_media_templates();
1340 -
1341 1100 if ( ! is_array( $args ) ) {
1342 1101 // For reverse compatibility.
1343 1102 $args = array(
1344 1103 'message' => $args,
@@ -1371,38 +1130,17 @@
1371 1130
1372 1131 $sections = self::get_settings_tabs( $values );
1373 1132 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' );
1374 1133
1375 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php';
1134 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
1376 1135 }
1377 1136
1378 1137 /**
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 1138 * @since 4.0
1401 1139 */
1402 1140 public static function form_publish_button( $atts ) {
1403 1141 $values = $atts['values'];
1404 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
1142 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
1405 1143 }
1406 1144
1407 1145 /**
1408 1146 * Get a list of all the settings tabs for the form settings page.
@@ -1416,9 +1154,9 @@
1416 1154 $sections = array(
1417 1155 'advanced' => array(
1418 1156 'name' => __( 'General', 'formidable' ),
1419 1157 'title' => __( 'General Form Settings', 'formidable' ),
1420 - 'function' => array( self::class, 'advanced_settings' ),
1158 + 'function' => array( __CLASS__, 'advanced_settings' ),
1421 1159 'icon' => 'frm_icon_font frm_settings_icon',
1422 1160 ),
1423 1161 'email' => array(
1424 1162 'name' => __( 'Actions & Notifications', 'formidable' ),
@@ -1427,9 +1165,9 @@
1427 1165 'icon' => 'frm_icon_font frm_mail_bulk_icon',
1428 1166 ),
1429 1167 'permissions' => array(
1430 1168 'name' => __( 'Form Permissions', 'formidable' ),
1431 - 'icon' => 'frm_icon_font frm_lock_closed_icon',
1169 + 'icon' => 'frm_icon_font frm_lock_icon',
1432 1170 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1433 1171 'data' => array(
1434 1172 'medium' => 'permissions',
1435 1173 'upgrade' => __( 'Form Permissions', 'formidable' ),
@@ -1436,9 +1174,9 @@
1436 1174 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1437 1175 'screenshot' => 'permissions.png',
1438 1176 ),
1439 1177 ),
1440 - 'scheduling' => array(
1178 + 'scheduling' => array(
1441 1179 'name' => __( 'Form Scheduling', 'formidable' ),
1442 1180 'icon' => 'frm_icon_font frm_calendar_icon',
1443 1181 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1444 1182 'data' => array(
@@ -1448,9 +1186,9 @@
1448 1186 ),
1449 1187 ),
1450 1188 'buttons' => array(
1451 1189 'name' => __( 'Buttons', 'formidable' ),
1452 - 'class' => self::class,
1190 + 'class' => __CLASS__,
1453 1191 'function' => 'buttons_settings',
1454 1192 'icon' => 'frm_icon_font frm_button_icon',
1455 1193 ),
1456 1194 'landing' => array(
@@ -1471,9 +1209,9 @@
1471 1209 'screenshot' => 'chat.png',
1472 1210 )
1473 1211 ),
1474 1212 ),
1475 - 'abandonment' => array(
1213 + 'abandonment' => array(
1476 1214 'name' => __( 'Form Abandonment', 'formidable' ),
1477 1215 'icon' => 'frm_icon_font frm_abandoned_icon',
1478 1216 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1479 1217 'data' => FrmAppHelper::get_upgrade_data_params(
@@ -1486,18 +1224,14 @@
1486 1224 ),
1487 1225 ),
1488 1226 'html' => array(
1489 1227 'name' => __( 'Customize HTML', 'formidable' ),
1490 - 'class' => self::class,
1228 + 'class' => __CLASS__,
1491 1229 'function' => 'html_settings',
1492 1230 'icon' => 'frm_icon_font frm_code_icon',
1493 1231 ),
1494 1232 );
1495 1233
1496 - if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1497 - unset( $sections['buttons'] );
1498 - }
1499 -
1500 1234 foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1501 1235 if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1502 1236 unset( $sections[ $feature ] );
1503 1237 }
@@ -1504,8 +1238,13 @@
1504 1238 }
1505 1239
1506 1240 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1507 1241
1242 + if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
1243 + // Prevent settings from showing in 2 spots.
1244 + unset( $sections['permissions'], $sections['scheduling'] );
1245 + }
1246 +
1508 1247 foreach ( $sections as $key => $section ) {
1509 1248 $defaults = array(
1510 1249 'html_class' => '',
1511 1250 'name' => ucfirst( $key ),
@@ -1536,9 +1275,8 @@
1536 1275 /**
1537 1276 * @since 4.0
1538 1277 *
1539 1278 * @param array $values
1540 - * @return void
1541 1279 */
1542 1280 public static function advanced_settings( $values ) {
1543 1281 $first_h3 = 'frm_first_h3';
1544 1282
@@ -1546,15 +1284,14 @@
1546 1284 }
1547 1285
1548 1286 /**
1549 1287 * @param array $values
1550 - * @return void
1551 1288 */
1552 1289 public static function render_spam_settings( $values ) {
1553 1290 if ( function_exists( 'akismet_http_post' ) ) {
1554 1291 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
1555 1292 }
1556 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/stopforumspam.php';
1293 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/honeypot.php';
1557 1294 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php';
1558 1295 }
1559 1296
1560 1297 /**
@@ -1560,12 +1297,16 @@
1560 1297 /**
1561 1298 * @since 4.0
1562 1299 *
1563 1300 * @param array $values
1564 - * @return void
1565 1301 */
1566 1302 public static function buttons_settings( $values ) {
1567 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
1303 + $styles = apply_filters( 'frm_get_style_opts', array() );
1304 +
1305 + $frm_settings = FrmAppHelper::get_settings();
1306 + $no_global_style = $frm_settings->load_style === 'none';
1307 +
1308 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php' );
1568 1309 }
1569 1310
1570 1311 /**
1571 1312 * @since 4.0
@@ -1570,12 +1311,11 @@
1570 1311 /**
1571 1312 * @since 4.0
1572 1313 *
1573 1314 * @param array $values
1574 - * @return void
1575 1315 */
1576 1316 public static function html_settings( $values ) {
1577 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
1317 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' );
1578 1318 }
1579 1319
1580 1320 /**
1581 1321 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -1581,10 +1321,9 @@
1581 1321 * Replace old Submit Button href with new href to avoid errors in Chrome
1582 1322 *
1583 1323 * @since 2.03.08
1584 1324 *
1585 - * @param array|bool $values
1586 - * @return void
1325 + * @param array|boolean $values
1587 1326 */
1588 1327 private static function clean_submit_html( &$values ) {
1589 1328 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
1590 1329 $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
@@ -1605,13 +1344,8 @@
1605 1344
1606 1345 return $classes;
1607 1346 }
1608 1347
1609 - /**
1610 - * @param int|string $form_id
1611 - * @param string $class
1612 - * @return void
1613 - */
1614 1348 public static function mb_tags_box( $form_id, $class = '' ) {
1615 1349 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1616 1350
1617 1351 /**
@@ -1624,9 +1358,9 @@
1624 1358 */
1625 1359 $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) );
1626 1360 $linked_forms = array();
1627 1361 $col = 'one';
1628 - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' );
1362 + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
1629 1363
1630 1364 $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
1631 1365 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1632 1366
@@ -1631,9 +1365,9 @@
1631 1365 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1632 1366
1633 1367 $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
1634 1368
1635 - include FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php';
1369 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
1636 1370 }
1637 1371
1638 1372 /**
1639 1373 * @since 3.04.01
@@ -1646,9 +1380,9 @@
1646 1380 ),
1647 1381 );
1648 1382
1649 1383 $user_fields = self::user_shortcodes();
1650 - if ( $user_fields ) {
1384 + if ( ! empty( $user_fields ) ) {
1651 1385 $user_helpers = array();
1652 1386 foreach ( $user_fields as $uk => $uf ) {
1653 1387 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1654 1388 unset( $uk, $uf );
@@ -1654,9 +1388,9 @@
1654 1388 unset( $uk, $uf );
1655 1389 }
1656 1390
1657 1391 $advanced_helpers['user_id'] = array(
1658 - 'codes' => $user_helpers,
1392 + 'codes' => $user_helpers,
1659 1393 );
1660 1394 }
1661 1395
1662 1396 /**
@@ -1733,16 +1467,21 @@
1733 1467 'updated-at' => __( 'Entry updated', 'formidable' ),
1734 1468 '' => '',
1735 1469 'siteurl' => __( 'Site URL', 'formidable' ),
1736 1470 'sitename' => __( 'Site Name', 'formidable' ),
1737 - 'form_name' => __( 'Form Name', 'formidable' ),
1738 1471 );
1739 1472
1740 - $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1741 1473 if ( ! FrmAppHelper::pro_is_installed() ) {
1742 1474 unset( $entry_shortcodes['post_id'] );
1743 1475 }
1744 1476
1477 + if ( $settings_tab ) {
1478 + $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1479 + $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1480 + $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1481 + $entry_shortcodes['form_name'] = __( 'Form Name', 'formidable' );
1482 + }
1483 +
1745 1484 /**
1746 1485 * Use this hook to add or remove buttons in the helpers section
1747 1486 * in the customization panel
1748 1487 *
@@ -1768,9 +1507,9 @@
1768 1507 echo ' frm_js_validate ';
1769 1508 self::add_js_validate_form_to_global_vars( $form );
1770 1509 }
1771 1510
1772 - if ( FrmForm::is_ajax_on( $form ) ) {
1511 + if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) {
1773 1512 echo ' frm_ajax_submit ';
1774 1513 }
1775 1514 }
1776 1515
@@ -1792,11 +1531,11 @@
1792 1531 check_ajax_referer( 'frm_ajax', 'nonce' );
1793 1532
1794 1533 echo FrmEntriesController::show_entry_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1795 1534 array(
1796 - 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1535 + 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
1797 1536 'default_email' => true,
1798 - 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1537 + 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
1799 1538 )
1800 1539 );
1801 1540 wp_die();
1802 1541 }
@@ -1802,10 +1541,10 @@
1802 1541 }
1803 1542
1804 1543 /**
1805 1544 * @param string $content
1806 - * @param int|stdClass|string $form
1807 - * @param false|int|stdClass|string $entry
1545 + * @param stdClass|string|int $form
1546 + * @param stdClass|string|int|false $entry
1808 1547 * @return string
1809 1548 */
1810 1549 public static function filter_content( $content, $form, $entry = false ) {
1811 1550 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1818,16 +1557,8 @@
1818 1557 if ( is_object( $form ) ) {
1819 1558 $form = $form->id;
1820 1559 }
1821 1560
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 1561 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1831 1562 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1832 1563
1833 1564 return $content;
@@ -1837,11 +1568,11 @@
1837 1568 * Replace any [form_name] shortcodes in a string.
1838 1569 *
1839 1570 * @since 5.5
1840 1571 *
1841 - * @param array|string $string
1842 - * @param int|stdClass|string $form
1843 - * @return array|string
1572 + * @param string|array $string
1573 + * @param stdClass|string|int $form
1574 + * @return string|array
1844 1575 */
1845 1576 public static function replace_form_name_shortcodes( $string, $form ) {
1846 1577 if ( ! is_string( $string ) ) {
1847 1578 return $string;
@@ -1859,9 +1590,9 @@
1859 1590 return str_replace( '[form_name]', $form_name, $string );
1860 1591 }
1861 1592
1862 1593 /**
1863 - * @param false|int|stdClass|string $entry
1594 + * @param stdClass|string|int|false $entry
1864 1595 * @return void
1865 1596 */
1866 1597 private static function get_entry_by_param( &$entry ) {
1867 1598 if ( ! $entry || ! is_object( $entry ) ) {
@@ -1876,12 +1607,8 @@
1876 1607 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1877 1608 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1878 1609 }
1879 1610
1880 - /**
1881 - * @param array $errors
1882 - * @return array
1883 - */
1884 1611 public static function process_bulk_form_actions( $errors ) {
1885 1612 if ( ! $_REQUEST ) {
1886 1613 return $errors;
1887 1614 }
@@ -1925,9 +1652,9 @@
1925 1652 case 'untrash':
1926 1653 $message = self::bulk_untrash( $ids );
1927 1654 }
1928 1655
1929 - if ( ! empty( $message ) ) {
1656 + if ( isset( $message ) && ! empty( $message ) ) {
1930 1657 $errors['message'] = $message;
1931 1658 }
1932 1659
1933 1660 return $errors;
@@ -1932,26 +1659,13 @@
1932 1659
1933 1660 return $errors;
1934 1661 }
1935 1662
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 1663 public static function route() {
1951 1664 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1952 1665 $vars = array();
1953 1666 FrmAppHelper::include_svg();
1667 +
1954 1668 if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1955 1669 FrmAppHelper::permission_check( 'frm_edit_forms' );
1956 1670
1957 1671 // Javascript needs to be allowed in some field settings.
@@ -1960,9 +1674,9 @@
1960 1674 $json_vars = json_decode( $json_vars, true );
1961 1675 if ( empty( $json_vars ) ) {
1962 1676 // json decoding failed so we should return an error message.
1963 1677 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1964 - if ( 'edit' === $action ) {
1678 + if ( 'edit' == $action ) {
1965 1679 $action = 'update';
1966 1680 }
1967 1681
1968 1682 add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
@@ -1984,8 +1698,10 @@
1984 1698 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1985 1699 FrmAppHelper::trigger_hook_load( 'form' );
1986 1700
1987 1701 switch ( $action ) {
1702 + case 'new':
1703 + return self::new_form( $vars );
1988 1704 case 'create':
1989 1705 case 'edit':
1990 1706 case 'update':
1991 1707 case 'trash':
@@ -1994,13 +1710,11 @@
1994 1710 case 'settings':
1995 1711 case 'update_settings':
1996 1712 return self::$action( $vars );
1997 1713 case 'lite-reports':
1998 - self::no_reports( $vars );
1999 - return;
1714 + return self::no_reports( $vars );
2000 1715 case 'views':
2001 - self::no_views( $vars );
2002 - return;
1716 + return self::no_views( $vars );
2003 1717 default:
2004 1718 do_action( 'frm_form_action_' . $action );
2005 1719 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
2006 1720 return;
@@ -2055,32 +1769,12 @@
2055 1769 // Get posted data
2056 1770 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2057 1771 $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2058 1772
2059 - $form = FrmForm::getOne( $form_id );
2060 - if ( ! $form ) {
2061 - wp_send_json_error( __( 'Form not found', 'formidable' ) );
2062 - }
1773 + // Update the form name and form key.
1774 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
1775 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
2063 1776
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 1777 wp_send_json_success( compact( 'form_key' ) );
2084 1778 }
2085 1779
2086 1780 public static function json_error( $errors ) {
@@ -2089,13 +1783,20 @@
2089 1783 return $errors;
2090 1784 }
2091 1785
2092 1786 /**
1787 + * Education for premium features.
1788 + *
1789 + * @since 4.05
1790 + */
1791 + public static function add_form_style_tab_options() {
1792 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' );
1793 + }
1794 +
1795 + /**
2093 1796 * Add education about views.
2094 1797 *
2095 1798 * @since 4.07
2096 - *
2097 - * @return void
2098 1799 */
2099 1800 public static function no_views( $values = array() ) {
2100 1801 FrmAppHelper::include_svg();
2101 1802 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -2107,10 +1808,8 @@
2107 1808 /**
2108 1809 * Add education about reports.
2109 1810 *
2110 1811 * @since 4.07
2111 - *
2112 - * @return void
2113 1812 */
2114 1813 public static function no_reports( $values = array() ) {
2115 1814 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
2116 1815 $form = $id ? FrmForm::getOne( $id ) : false;
@@ -2195,9 +1894,9 @@
2195 1894 $wp_admin_bar->add_node(
2196 1895 array(
2197 1896 'parent' => 'frm-forms',
2198 1897 'id' => 'edit_form_' . $form_id,
2199 - 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name,
1898 + 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
2200 1899 'href' => FrmForm::get_edit_link( $form_id ),
2201 1900 )
2202 1901 );
2203 1902 }
@@ -2210,10 +1909,10 @@
2210 1909 * @return string
2211 1910 */
2212 1911 public static function get_form_shortcode( $atts ) {
2213 1912 global $frm_vars;
2214 - if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2215 - $sc = '[formidable';
1913 + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1914 + $sc = '[formidable';
2216 1915 $sc .= FrmAppHelper::array_to_html_params( $atts );
2217 1916 return $sc . ']';
2218 1917 }
2219 1918
@@ -2238,11 +1937,11 @@
2238 1937
2239 1938 /**
2240 1939 * @since 5.2.01
2241 1940 *
2242 - * @param false|int|string $id
2243 - * @param false|string $key
2244 - * @return false|stdClass
1941 + * @param string|int|false $id
1942 + * @param string|false $key
1943 + * @return stdClass|false
2245 1944 */
2246 1945 private static function maybe_get_form_by_id_or_key( $id, $key ) {
2247 1946 if ( ! $id ) {
2248 1947 $id = $key;
@@ -2250,12 +1949,12 @@
2250 1949 return self::maybe_get_form_to_show( $id );
2251 1950 }
2252 1951
2253 1952 /**
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.
1953 + * @param string|int|false $id
1954 + * @param string|false $key
1955 + * @param string|int|bool $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1956 + * @param string|int|bool $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2258 1957 * @param array $atts
2259 1958 * @return string
2260 1959 */
2261 1960 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
@@ -2303,10 +2002,10 @@
2303 2002 return $form;
2304 2003 }
2305 2004
2306 2005 /**
2307 - * @param false|int|string $id
2308 - * @return false|stdClass
2006 + * @param string|int|false $id
2007 + * @return stdClass|false
2309 2008 */
2310 2009 private static function maybe_get_form_to_show( $id ) {
2311 2010 $form = false;
2312 2011
@@ -2370,11 +2069,11 @@
2370 2069
2371 2070 do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
2372 2071
2373 2072 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;
2073 + $entry_id = self::just_created_entry( $form->id );
2074 + $pass_args['entry_id'] = $entry_id;
2075 + $pass_args['reset'] = true;
2377 2076
2378 2077 self::run_on_submit_actions( $pass_args );
2379 2078
2380 2079 do_action(
@@ -2418,9 +2117,9 @@
2418 2117 */
2419 2118 public static function just_created_entry( $form_id ) {
2420 2119 global $frm_vars;
2421 2120
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;
2121 + 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 2122 }
2424 2123
2425 2124 /**
2426 2125 * Gets confirmation method.
@@ -2433,14 +2132,14 @@
2433 2132 *
2434 2133 * @type object $form Form object.
2435 2134 * @type int $entry_id Entry ID.
2436 2135 * }
2437 - * @return array|string
2136 + * @return string|array
2438 2137 */
2439 2138 private static function get_confirmation_method( $atts ) {
2440 2139 $action = FrmOnSubmitHelper::current_event( $atts );
2441 2140 $opt = 'update' === $action ? 'edit_action' : 'success_action';
2442 - $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2141 + $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
2443 2142
2444 2143 if ( ! empty( $atts['entry_id'] ) ) {
2445 2144 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2446 2145 if ( $met_actions ) {
@@ -2449,9 +2148,9 @@
2449 2148 }
2450 2149
2451 2150 $method = apply_filters( 'frm_success_filter', $method, $atts['form'], $action );
2452 2151
2453 - if ( $method !== 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2152 + if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2454 2153 $method = 'message';
2455 2154 }
2456 2155
2457 2156 return $method;
@@ -2485,9 +2184,9 @@
2485 2184 * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}.
2486 2185 */
2487 2186 public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) {
2488 2187 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'] ) ) {
2188 + if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) ) {
2490 2189 $event = FrmOnSubmitHelper::current_event( $params );
2491 2190 FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event );
2492 2191 $conf_method = 'redirect';
2493 2192 }
@@ -2536,9 +2235,9 @@
2536 2235 unset( $extra_args['form'] );
2537 2236
2538 2237 do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
2539 2238
2540 - $opt = ! isset( $args['action'] ) || $args['action'] === 'create' ? 'success' : 'edit';
2239 + $opt = ( ! isset( $args['action'] ) || $args['action'] === 'create' ) ? 'success' : 'edit';
2541 2240
2542 2241 $args['success_opt'] = $opt;
2543 2242 $args['ajax'] = ! empty( $frm_vars['ajax'] );
2544 2243
@@ -2564,16 +2263,16 @@
2564 2263 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
2565 2264 return array();
2566 2265 }
2567 2266
2568 - // If a redirect action has already opened the URL in a new tab, we show the default message in the current tab.
2267 + // If a redirect action has already opened the URL in a new tab, we show the default message in the currect tab.
2569 2268 if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) {
2570 2269 return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) );
2571 2270 }
2572 2271
2573 - $entry = FrmEntry::getOne( $args['entry_id'], true );
2574 - $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2575 - $met_actions = array();
2272 + $entry = FrmEntry::getOne( $args['entry_id'], true );
2273 + $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2274 + $met_actions = array();
2576 2275 $has_redirect = false;
2577 2276
2578 2277 foreach ( $actions as $action ) {
2579 2278 if ( ! in_array( $event, $action->post_content['event'], true ) ) {
@@ -2822,9 +2521,9 @@
2822 2521 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
2823 2522 wp_die();
2824 2523 }
2825 2524
2826 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) {
2525 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) {
2827 2526 // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2828 2527 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2829 2528 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
2830 2529 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
@@ -2869,46 +2568,28 @@
2869 2568 * @param array $args See {@see FrmFormsController::run_success_action()}.
2870 2569 * @return array
2871 2570 */
2872 2571 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;
2572 + $response_data = array( 'redirect' => $args['success_url'] );
2878 2573
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 2574 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2886 2575 $response_data['openInNewTab'] = 1;
2887 2576
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();
2577 + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2891 2578
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 - }
2579 + $args['form']->options['success_msg'] = $args['message'];
2580 + $args['form']->options['edit_msg'] = $args['message'];
2581 + if ( ! isset( $args['fields'] ) ) {
2582 + $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2583 + }
2897 2584
2898 - $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2585 + $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2899 2586
2900 - ob_start();
2901 - self::show_lone_success_message( $args );
2902 - $response_data['content'] .= ob_get_clean();
2903 - $unset_content = false;
2904 - }//end if
2587 + ob_start();
2588 + self::show_lone_success_messsage( $args );
2589 + $response_data['content'] = ob_get_clean();
2905 2590
2906 2591 $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 2592 }
2912 2593
2913 2594 return $response_data;
2914 2595 }
@@ -2920,9 +2601,9 @@
2920 2601 *
2921 2602 * @param array $args See {@see FrmFormsController::run_success_action()}.
2922 2603 */
2923 2604 private static function redirect_after_submit_using_js( $args ) {
2924 - $success_msg = $args['form']->options['redirect_delay_msg'];
2605 + $success_msg = FrmOnSubmitHelper::get_default_redirect_msg();
2925 2606 $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args );
2926 2607 $success_url = esc_url_raw( $args['success_url'] );
2927 2608
2928 2609 /**
@@ -2929,11 +2610,11 @@
2929 2610 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
2930 2611 *
2931 2612 * @since 6.0
2932 2613 *
2933 - * @param int $delay_time Delay time in milliseconds.
2614 + * @param int $delay_time Delay time in miliseconds.
2934 2615 */
2935 - $delay_time = apply_filters( 'frm_redirect_delay_time', 1000 * $args['form']->options['redirect_delay_time'] );
2616 + $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
2936 2617
2937 2618 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2938 2619 $redirect_js = 'window.open("' . $success_url . '", "_blank")';
2939 2620 } else {
@@ -2962,10 +2643,8 @@
2962 2643 * @param string $success_msg
2963 2644 * @param array $args
2964 2645 */
2965 2646 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 2647 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
2969 2648 self::get_redirect_fallback_message( $success_url, $args ) .
2970 2649 '</div></div>';
2971 2650
@@ -3021,9 +2700,9 @@
3021 2700 } else {
3022 2701 self::show_form_after_submit( $atts );
3023 2702 }
3024 2703 } else {
3025 - self::show_lone_success_message( $atts );
2704 + self::show_lone_success_messsage( $atts );
3026 2705 }
3027 2706 }
3028 2707
3029 2708 /**
@@ -3051,9 +2730,9 @@
3051 2730
3052 2731 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
3053 2732
3054 2733 $frm_settings = FrmAppHelper::get_settings();
3055 - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value;
2734 + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
3056 2735
3057 2736 global $frm_vars;
3058 2737 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
3059 2738
@@ -3062,10 +2741,11 @@
3062 2741 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
3063 2742 }
3064 2743
3065 2744 /**
2745 + * @return string - 'before', 'after', or 'submit'
2746 + *
3066 2747 * @since 4.05.02
3067 - * @return string - 'before', 'after', or 'submit'
3068 2748 */
3069 2749 private static function message_placement( $form, $message ) {
3070 2750 $place = 'before';
3071 2751
@@ -3077,10 +2757,11 @@
3077 2757 }
3078 2758 }
3079 2759
3080 2760 /**
2761 + * @return string - 'before' or 'after'
2762 + *
3081 2763 * @since 4.05.02
3082 - * @return string - 'before' or 'after'
3083 2764 */
3084 2765 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
3085 2766 }
3086 2767
@@ -3114,9 +2795,9 @@
3114 2795 * Show the success message without the form
3115 2796 *
3116 2797 * @since 2.05
3117 2798 */
3118 - private static function show_lone_success_message( $atts ) {
2799 + private static function show_lone_success_messsage( $atts ) {
3119 2800 global $frm_vars;
3120 2801 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
3121 2802 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
3122 2803
@@ -3125,9 +2806,9 @@
3125 2806 $errors = array();
3126 2807 $form = $atts['form'];
3127 2808 $message = $atts['message'];
3128 2809
3129 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
2810 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
3130 2811 }
3131 2812
3132 2813 /**
3133 2814 * Prepare the success message before it's shown
@@ -3141,12 +2822,12 @@
3141 2822 * @return string
3142 2823 */
3143 2824 private static function prepare_submit_message( $form, $entry_id, $args = array() ) {
3144 2825 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
3145 - $opt = $args['success_opt'] ?? 'success';
2826 + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
3146 2827
3147 2828 if ( $entry_id && is_numeric( $entry_id ) ) {
3148 - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg;
2829 + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
3149 2830 $class = 'frm_message';
3150 2831 } else {
3151 2832 $message = $frm_settings->failed_msg;
3152 2833 $class = FrmFormsHelper::form_error_class();
@@ -3247,13 +2928,11 @@
3247 2928 global $frm_vars;
3248 2929
3249 2930 FrmStylesController::enqueue_css();
3250 2931
3251 - if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
2932 + if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3252 2933 // load formidable js
3253 2934 wp_enqueue_script( 'formidable' );
3254 -
3255 - FrmHoneypot::maybe_print_honeypot_js();
3256 2935 }
3257 2936 }
3258 2937
3259 2938 /**
@@ -3267,12 +2946,12 @@
3267 2946 }
3268 2947
3269 2948 /**
3270 2949 * @since 2.0.8
3271 - * @return bool
2950 + * @return boolean
3272 2951 */
3273 2952 private static function is_minification_on( $atts ) {
3274 - return ! empty( $atts['minimize'] );
2953 + return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
3275 2954 }
3276 2955
3277 2956 /**
3278 2957 * @since 5.0.16
@@ -3370,9 +3049,9 @@
3370 3049
3371 3050 check_ajax_referer( 'frm_ajax', 'nonce' );
3372 3051
3373 3052 $html = FrmAppHelper::clip(
3374 - function () {
3053 + function() {
3375 3054 FrmAppHelper::maybe_autocomplete_pages_options(
3376 3055 array(
3377 3056 'field_name' => 'frm_page_dropdown',
3378 3057 'page_id' => '',
@@ -3392,8 +3071,15 @@
3392 3071
3393 3072 /**
3394 3073 * @deprecated 4.0
3395 3074 */
3075 + public static function new_form( $values = array() ) {
3076 + FrmDeprecated::new_form( $values );
3077 + }
3078 +
3079 + /**
3080 + * @deprecated 4.0
3081 + */
3396 3082 public static function create( $values = array() ) {
3397 3083 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3398 3084 self::update( $values );
3399 3085 }
@@ -3398,16 +3084,75 @@
3398 3084 self::update( $values );
3399 3085 }
3400 3086
3401 3087 /**
3402 - * Education for premium features.
3088 + * @deprecated 3.0
3089 + * @codeCoverageIgnore
3090 + */
3091 + public static function bulk_create_template( $ids ) {
3092 + return FrmDeprecated::bulk_create_template( $ids );
3093 + }
3094 +
3095 + /**
3096 + * @deprecated 3.0
3097 + * @codeCoverageIgnore
3098 + */
3099 + public static function edit_key() {
3100 + FrmDeprecated::edit_key();
3101 + }
3102 +
3103 + /**
3104 + * @deprecated 3.0
3105 + * @codeCoverageIgnore
3106 + */
3107 + public static function edit_description() {
3108 + FrmDeprecated::edit_description();
3109 + }
3110 +
3111 + /**
3112 + * @deprecated 4.08
3113 + * @since 3.06
3114 + */
3115 + public static function add_new() {
3116 + _deprecated_function( __FUNCTION__, '4.08' );
3117 + }
3118 +
3119 + /**
3120 + * Create a custom template from a form
3403 3121 *
3404 - * @since 4.05
3405 - * @deprecated 6.16.3
3122 + * @since 3.06
3123 + * @deprecated 6.7
3124 + */
3125 + public static function build_template() {
3126 + _deprecated_function( __METHOD__, '6.7' );
3127 + }
3128 +
3129 + /**
3130 + * @deprecated 6.7
3406 3131 *
3132 + * @return bool
3133 + */
3134 + public static function expired() {
3135 + _deprecated_function( __METHOD__, '6.7' );
3136 + return FrmAddonsController::is_license_expired();
3137 + }
3138 +
3139 + /**
3140 + * Get data from api before rendering it so that we can flag the modal as expired
3141 + *
3142 + * @deprecated 6.7
3143 + *
3407 3144 * @return void
3408 3145 */
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';
3146 + public static function before_list_templates() {
3147 + _deprecated_function( __METHOD__, '6.7' );
3148 + }
3149 +
3150 + /**
3151 + * @deprecated 6.7
3152 + *
3153 + * @return void
3154 + */
3155 + public static function list_templates() {
3156 + _deprecated_function( __METHOD__, '6.7' );
3412 3157 }
3413 3158 }