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 +281 -550 6.25.16.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,86 +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="' . esc_url( self::get_form_too_long_docs_url() ) . '" target="_blank" rel="noopener">',
310 - '</a>'
311 - );
312 - }
313 -
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 );
232 + return self::get_edit_vars( $id, array(), $message );
233 + }//end if
319 234 }
320 235
321 236 /**
322 - * @since 6.25.1
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.
323 240 *
324 - * @return string
241 + * @since 3.06.01
325 242 */
326 - private static function get_form_too_long_docs_url() {
327 - $utm = array(
328 - 'campaign' => 'builder',
329 - 'content' => 'form-too-long',
330 - );
331 - return FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/' );
243 + private static function is_too_long( $values ) {
244 + return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] );
332 245 }
333 246
334 247 /**
335 - * 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
336 250 *
337 - * @since 6.8
338 - *
339 - * @param int $form_id
340 - * @return void
251 + * @since 2.0
252 + * @deprecated 3.06
341 253 */
342 - private static function maybe_remove_draft_option_from_fields( $form_id ) {
343 - $draft_field_ids_csv = FrmAppHelper::get_post_param( 'draft_fields', '', 'sanitize_text_field' );
344 - if ( ! $draft_field_ids_csv ) {
345 - // If the draft_fields input is empty there are no new fields in the session.
346 - return;
347 - }
254 + public static function _create_from_template() {
255 + _deprecated_function( __FUNCTION__, '3.06' );
348 256
349 - $draft_field_ids = array_filter( explode( ',', $draft_field_ids_csv ), 'is_numeric' );
350 - if ( ! $draft_field_ids ) {
351 - // Exit early if the draft fields input is invalid. It should be a CSV of integer values.
352 - return;
353 - }
257 + FrmAppHelper::permission_check( 'frm_edit_forms' );
258 + check_ajax_referer( 'frm_ajax', 'nonce' );
354 259
355 - $draft_field_rows = FrmFieldsHelper::get_draft_field_results( $form_id, $draft_field_ids );
356 - foreach ( $draft_field_rows as $row ) {
357 - $row->field_options['draft'] = 0;
358 - 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 );
359 265 }
360 - }
361 266
362 - /**
363 - * Check if the value at the end of the form was included.
364 - * If it's missing, it means other values at the end of the form
365 - * were likely not saved either.
366 - *
367 - * @since 3.06.01
368 - *
369 - * @param array $values
370 - * @return bool
371 - */
372 - private static function is_too_long( $values ) {
373 - 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();
374 269 }
375 270
376 271 public static function duplicate() {
377 272 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -388,10 +283,10 @@
388 283 $message = 'form_duplicate_error';
389 284
390 285 if ( $form ) {
391 286 $new_template = FrmAppHelper::simple_get( 'new_template' ) ? '&new_template=true' : '';
392 - $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
393 - $message = 'form_duplicated';
287 + $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
288 + $message = 'form_duplicated';
394 289 }
395 290
396 291 $url .= '&message=' . $message;
397 292
@@ -399,24 +294,20 @@
399 294 exit();
400 295 }
401 296
402 297 /**
403 - * @return string|null
298 + * @return string
404 299 */
405 300 public static function page_preview() {
406 301 $params = FrmForm::list_page_params();
407 - if ( ! $params['form'] || is_numeric( $params['form'] ) ) {
408 - return null;
302 + if ( ! $params['form'] ) {
303 + return;
409 304 }
410 305
411 - self::maybe_block_preview( $params['form'] );
412 -
413 306 $form = FrmForm::getOne( $params['form'] );
414 - if ( ! $form ) {
415 - return null;
307 + if ( $form ) {
308 + return self::show_form( $form->id, '', 'auto', 'auto' );
416 309 }
417 -
418 - return self::show_form( $form->id, '', 'auto', 'auto' );
419 310 }
420 311
421 312 /**
422 313 * @since 3.0
@@ -423,18 +314,9 @@
423 314 *
424 315 * @return void
425 316 */
426 317 public static function show_page_preview() {
427 - $preview = self::page_preview();
428 - if ( is_null( $preview ) ) {
429 - wp_die(
430 - '<h1>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</h1>',
431 - '<p>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</p>',
432 - 404
433 - );
434 - }
435 -
436 - echo $preview; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
318 + echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
437 319 }
438 320
439 321 /**
440 322 * @return void
@@ -445,17 +327,8 @@
445 327
446 328 global $frm_vars;
447 329 $frm_vars['preview'] = true;
448 330
449 - // print_emoji_styles is deprecated.
450 - remove_action( 'wp_print_styles', 'print_emoji_styles' );
451 -
452 - if ( FrmTestModeController::should_add_test_mode_container() ) {
453 - do_action( 'frm_test_mode_init' );
454 - add_action( 'wp_enqueue_scripts', 'FrmTestModeController::register_and_enqueue_required_scripts' );
455 - add_filter( 'frm_filter_final_form', 'FrmTestModeController::maybe_add_test_mode_container', 99 );
456 - }
457 -
458 331 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
459 332 if ( $include_theme ) {
460 333 self::set_preview_query();
461 334 self::load_theme_preview();
@@ -522,10 +395,8 @@
522 395 }
523 396
524 397 /**
525 398 * @since 3.0
526 - *
527 - * @return void
528 399 */
529 400 private static function load_theme_preview() {
530 401 add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
531 402 add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
@@ -557,10 +428,8 @@
557 428
558 429 /**
559 430 * Not every theme supports get_template_part( 'page' ).
560 431 * When this is not supported, false is returned, and we can handle a fallback.
561 - *
562 - * @return void
563 432 */
564 433 private static function fallback_when_page_template_part_is_not_supported_by_theme() {
565 434 if ( have_posts() ) {
566 435 the_post();
@@ -572,12 +441,8 @@
572 441 echo '<div class="container entry-content">';
573 442 the_content();
574 443 echo '</div>';
575 444
576 - // Prevent extra unexpected forms in the footer.
577 - // For some reason this happens in the Twenty Twenty Five theme.
578 - add_filter( 'frm_filter_final_form', '__return_empty_string' );
579 -
580 445 self::get_template( 'footer' );
581 446 }
582 447 }
583 448
@@ -582,9 +447,9 @@
582 447 }
583 448
584 449 /**
585 450 * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call
586 - * and renders required html fragments calling required functions.
451 + * and renders required html fragements calling required functions.
587 452 *
588 453 * @since 6.7.1
589 454 * @param string $template
590 455 * @return void
@@ -634,14 +499,11 @@
634 499 return $title;
635 500 }
636 501
637 502 /**
638 - * Set the page title for the theme preview page.
503 + * Set the page title for the theme preview page
639 504 *
640 505 * @since 3.0
641 - *
642 - * @param string $title
643 - * @return string
644 506 */
645 507 public static function preview_title( $title ) {
646 508 return __( 'Form Preview', 'formidable' );
647 509 }
@@ -667,88 +529,23 @@
667 529 /**
668 530 * @since 3.0
669 531 */
670 532 private static function load_direct_preview() {
533 + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
534 +
671 535 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
672 536 if ( $key == '' ) {
673 537 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
674 538 }
675 539
676 - if ( ! $key ) {
677 - $error = __( 'Form key is missing', 'formidable' );
678 - wp_die(
679 - '<h1>' . esc_html( $error ) . '</h1>',
680 - '<p>' . esc_html( $error ) . '</p>',
681 - 404
682 - );
683 - }
684 -
685 - self::maybe_block_preview( $key );
686 -
687 540 $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
688 - if ( ! $form ) {
689 - $error = __( 'Form does not exist', 'formidable' );
690 - wp_die(
691 - '<h1>' . esc_html( $error ) . '</h1>',
692 - '<p>' . esc_html( $error ) . '</p>',
693 - 404
694 - );
541 + if ( empty( $form ) ) {
542 + $form = FrmForm::getAll( array(), '', 1 );
695 543 }
696 544
697 - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
698 -
699 - self::fix_deprecated_null_param_warning();
700 -
701 - require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
545 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
702 546 }
703 547
704 - /**
705 - * Block the form preview for the contact form by default if the user cannot view forms.
706 - * This is to prevent the contact form being exploited.
707 - * Since this form is added by default and every site uses the same key, it is too easy
708 - * to guess this form.
709 - *
710 - * @since 6.20
711 - *
712 - * @param string $form_key Form key.
713 - * @return void
714 - */
715 - public static function maybe_block_preview( $form_key ) {
716 - if ( FrmFormsHelper::should_block_preview( $form_key ) ) {
717 - $error = __( 'You do not have permission to view this form', 'formidable' );
718 - wp_die(
719 - '<h1>' . esc_html( $error ) . '</h1>',
720 - '<p>' . esc_html( $error ) . '</p>',
721 - 403
722 - );
723 - }
724 - }
725 -
726 - /**
727 - * Some themes have a null $src value.
728 - * This function adds a filter to ensure that $src is not null.
729 - * WP will call str_starts_with with the null value triggering a deprecated message otherwise.
730 - *
731 - * @since 6.10
732 - *
733 - * @return void
734 - */
735 - private static function fix_deprecated_null_param_warning() {
736 - add_filter(
737 - 'script_loader_src',
738 - /**
739 - * @param string|null $src
740 - * @return string
741 - */
742 - function ( $src ) {
743 - if ( is_null( $src ) ) {
744 - $src = '';
745 - }
746 - return $src;
747 - }
748 - );
749 - }
750 -
751 548 public static function untrash() {
752 549 self::change_form_status( 'untrash' );
753 550 }
754 551
@@ -816,9 +613,9 @@
816 613 check_admin_referer( $status . '_form_' . $params['id'] );
817 614
818 615 $count = 0;
819 616 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
820 - ++$count;
617 + $count ++;
821 618 }
822 619
823 620 $form_type = FrmAppHelper::get_simple_request(
824 621 array(
@@ -830,9 +627,9 @@
830 627 /* translators: %1$s: Number of forms */
831 628 $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
832 629
833 630 /* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */
834 - $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>' );
835 632
836 633 $message = $available_status[ $status ]['message'];
837 634
838 635 self::display_forms_list( $params, $message );
@@ -837,12 +634,8 @@
837 634
838 635 self::display_forms_list( $params, $message );
839 636 }
840 637
841 - /**
842 - * @param array $ids
843 - * @return string
844 - */
845 638 public static function bulk_trash( $ids ) {
846 639 FrmAppHelper::permission_check( 'frm_delete_forms' );
847 640
848 641 $count = 0;
@@ -847,16 +640,12 @@
847 640
848 641 $count = 0;
849 642 foreach ( $ids as $id ) {
850 643 if ( FrmForm::trash( $id ) ) {
851 - ++$count;
644 + $count ++;
852 645 }
853 646 }
854 647
855 - if ( ! $count ) {
856 - return '';
857 - }
858 -
859 648 $current_page = FrmAppHelper::get_simple_request(
860 649 array(
861 650 'param' => 'form_type',
862 651 'type' => 'request',
@@ -882,9 +671,9 @@
882 671 check_admin_referer( 'destroy_form_' . $params['id'] );
883 672
884 673 $count = 0;
885 674 if ( FrmForm::destroy( $params['id'] ) ) {
886 - ++$count;
675 + $count ++;
887 676 }
888 677
889 678 /* translators: %1$s: Number of forms */
890 679 $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count );
@@ -891,12 +680,8 @@
891 680
892 681 self::display_forms_list( $params, $message );
893 682 }
894 683
895 - /**
896 - * @param array $ids
897 - * @return string
898 - */
899 684 public static function bulk_destroy( $ids ) {
900 685 FrmAppHelper::permission_check( 'frm_delete_forms' );
901 686
902 687 $count = 0;
@@ -902,9 +687,9 @@
902 687 $count = 0;
903 688 foreach ( $ids as $id ) {
904 689 $d = FrmForm::destroy( $id );
905 690 if ( $d ) {
906 - ++$count;
691 + $count ++;
907 692 }
908 693 }
909 694
910 695 if ( $count ) {
@@ -929,9 +714,9 @@
929 714
930 715 $count = FrmForm::scheduled_delete( time() );
931 716 $url = remove_query_arg( array( 'delete_all' ) );
932 717
933 - $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
718 + $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
934 719
935 720 wp_safe_redirect( $url );
936 721 die();
937 722 }
@@ -947,9 +732,9 @@
947 732
948 733 $new_values = self::get_modal_values();
949 734 $new_values['form_key'] = $new_values['name'];
950 735 $new_values['options'] = array(
951 - 'antispam' => 1,
736 + 'antispam' => 1,
952 737 'on_submit_migrated' => 1,
953 738 );
954 739
955 740 /**
@@ -968,9 +753,8 @@
968 753 * @param int $form_id
969 754 */
970 755 do_action( 'frm_build_new_form', $form_id );
971 756
972 - self::create_submit_button_field( $form_id );
973 757 self::create_default_on_submit_action( $form_id );
974 758 self::create_default_email_action( $form_id );
975 759
976 760 $response = array(
@@ -984,10 +768,8 @@
984 768 /**
985 769 * Before creating a new form, get the name and description from the modal.
986 770 *
987 771 * @since 4.0
988 - *
989 - * @return array<string,string>
990 772 */
991 773 public static function get_modal_values() {
992 774 $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
993 775 $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
@@ -1002,24 +784,17 @@
1002 784 * Inserts Formidable button
1003 785 * Hook exists since 2.5.0
1004 786 *
1005 787 * @since 2.0.15
1006 - *
1007 - * @return void
1008 788 */
1009 789 public static function insert_form_button() {
1010 790 if ( current_user_can( 'frm_view_forms' ) ) {
1011 - // Store the result in memory and re-use it when this function is called multiple times.
1012 - // This helps speed up the form builder when there are a lot of HTML fields, where this
1013 - // button is inserted once per HTML field.
1014 - // In a form with 66 HTML fields, this saves 0.5 seconds on page load time, tested locally.
1015 - if ( ! isset( self::$formidable_tinymce_button ) ) {
1016 - FrmAppHelper::load_admin_wide_js();
1017 - $menu_name = FrmAppHelper::get_menu_name();
1018 - $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
1019 - 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>';
1020 - }
1021 - 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>';
1022 797 }
1023 798 }
1024 799
1025 800 /**
@@ -1107,9 +882,9 @@
1107 882 $form_id = $opts['form_id'];
1108 883 unset( $opts['form_id'] );
1109 884 }
1110 885
1111 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php';
886 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
1112 887
1113 888 echo '</div>';
1114 889
1115 890 wp_die();
@@ -1149,14 +924,8 @@
1149 924 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
1150 925 die();
1151 926 }
1152 927
1153 - $inbox = new FrmInbox();
1154 - $error = $inbox->check_for_error();
1155 - if ( $error ) {
1156 - $show_messages = array( $error['subject'] . '. ' . $error['message'] );
1157 - }
1158 -
1159 928 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php';
1160 929 }
1161 930
1162 931 /**
@@ -1163,16 +932,14 @@
1163 932 * @param array<string,string> $columns
1164 933 * @return array<string,string>
1165 934 */
1166 935 public static function get_columns( $columns ) {
1167 - $columns['cb'] = '<input type="checkbox" />';
1168 - $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1169 - $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1170 - $columns['id'] = 'ID';
1171 - $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1172 - if ( 'trash' !== FrmAppHelper::simple_get( 'form_type' ) ) {
1173 - $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1174 - }
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' );
1175 942 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
1176 943
1177 944 add_screen_option(
1178 945 'per_page',
@@ -1185,11 +952,8 @@
1185 952
1186 953 return $columns;
1187 954 }
1188 955
1189 - /**
1190 - * @return array<string,string>
1191 - */
1192 956 public static function get_sortable_columns() {
1193 957 return array(
1194 958 'id' => 'id',
1195 959 'name' => 'name',
@@ -1223,9 +987,9 @@
1223 987 return $hidden_columns;
1224 988 }
1225 989
1226 990 public static function save_per_page( $save, $option, $value ) {
1227 - if ( $option === 'formidable_page_formidable_per_page' ) {
991 + if ( $option == 'formidable_page_formidable_per_page' ) {
1228 992 $save = (int) $value;
1229 993 }
1230 994
1231 995 return $save;
@@ -1230,23 +994,16 @@
1230 994
1231 995 return $save;
1232 996 }
1233 997
1234 - /**
1235 - * @param int|string $id
1236 - * @param array $errors
1237 - * @param string $message
1238 - * @param bool $create_link
1239 - * @return void
1240 - */
1241 998 private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1242 999 global $frm_vars;
1243 1000
1244 - $form = FrmForm::getOne( $id );
1001 + $form = FrmForm::getOne( $id );
1245 1002 $error_args = array(
1246 - 'title' => __( 'You can\'t edit the form', 'formidable' ),
1247 - 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
1248 - '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' ),
1249 1006 'continue_url' => add_query_arg(
1250 1007 array(
1251 1008 'page' => 'formidable',
1252 1009 )
@@ -1257,10 +1014,10 @@
1257 1014 return;
1258 1015 }
1259 1016
1260 1017 if ( 'trash' === $form->status ) {
1261 - $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
1262 - $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(
1263 1020 array(
1264 1021 'page' => 'formidable',
1265 1022 '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ),
1266 1023 'form_type' => 'trash',
@@ -1284,9 +1041,8 @@
1284 1041
1285 1042 // Automatically add end section fields if they don't exist (2.0 migration).
1286 1043 $reset_fields = false;
1287 1044 FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
1288 - FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields );
1289 1045
1290 1046 if ( $reset_fields ) {
1291 1047 $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
1292 1048 }
@@ -1312,21 +1068,18 @@
1312 1068 }
1313 1069
1314 1070 self::maybe_update_form_builder_message( $message );
1315 1071
1316 - $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'] );
1317 1074
1318 1075 if ( defined( 'DOING_AJAX' ) ) {
1319 1076 wp_die();
1077 + } else {
1078 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
1320 1079 }
1321 -
1322 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php';
1323 1080 }
1324 1081
1325 - /**
1326 - * @param array $fields
1327 - * @return array
1328 - */
1329 1082 public static function update_form_builder_fields( $fields, $form ) {
1330 1083 foreach ( $fields as $field ) {
1331 1084 $field->do_not_include_icons = true;
1332 1085 }
@@ -1338,21 +1091,13 @@
1338 1091 $message = __( 'Form was Successfully Copied', 'formidable' );
1339 1092 }
1340 1093 }
1341 1094
1342 - /**
1343 - * @param int|string $id
1344 - * @param array $errors
1345 - * @param array|string $args
1346 - * @return void
1347 - */
1348 1095 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1349 1096 FrmAppHelper::permission_check( 'frm_edit_forms' );
1350 1097
1351 1098 global $frm_vars;
1352 1099
1353 - self::maybe_print_media_templates();
1354 -
1355 1100 if ( ! is_array( $args ) ) {
1356 1101 // For reverse compatibility.
1357 1102 $args = array(
1358 1103 'message' => $args,
@@ -1385,38 +1130,17 @@
1385 1130
1386 1131 $sections = self::get_settings_tabs( $values );
1387 1132 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' );
1388 1133
1389 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php';
1134 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
1390 1135 }
1391 1136
1392 1137 /**
1393 - * 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.
1394 - *
1395 - * @since 6.10
1396 - *
1397 - * @return void
1398 - */
1399 - private static function maybe_print_media_templates() {
1400 - if ( FrmAppHelper::pro_is_included() ) {
1401 - // This issue does not exist when Pro is active so exit early.
1402 - return;
1403 - }
1404 -
1405 - add_action(
1406 - 'wp_enqueue_editor',
1407 - function () {
1408 - wp_print_media_templates();
1409 - }
1410 - );
1411 - }
1412 -
1413 - /**
1414 1138 * @since 4.0
1415 1139 */
1416 1140 public static function form_publish_button( $atts ) {
1417 1141 $values = $atts['values'];
1418 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
1142 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
1419 1143 }
1420 1144
1421 1145 /**
1422 1146 * Get a list of all the settings tabs for the form settings page.
@@ -1430,9 +1154,9 @@
1430 1154 $sections = array(
1431 1155 'advanced' => array(
1432 1156 'name' => __( 'General', 'formidable' ),
1433 1157 'title' => __( 'General Form Settings', 'formidable' ),
1434 - 'function' => array( self::class, 'advanced_settings' ),
1158 + 'function' => array( __CLASS__, 'advanced_settings' ),
1435 1159 'icon' => 'frm_icon_font frm_settings_icon',
1436 1160 ),
1437 1161 'email' => array(
1438 1162 'name' => __( 'Actions & Notifications', 'formidable' ),
@@ -1441,9 +1165,9 @@
1441 1165 'icon' => 'frm_icon_font frm_mail_bulk_icon',
1442 1166 ),
1443 1167 'permissions' => array(
1444 1168 'name' => __( 'Form Permissions', 'formidable' ),
1445 - 'icon' => 'frm_icon_font frm_lock_closed_icon',
1169 + 'icon' => 'frm_icon_font frm_lock_icon',
1446 1170 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1447 1171 'data' => array(
1448 1172 'medium' => 'permissions',
1449 1173 'upgrade' => __( 'Form Permissions', 'formidable' ),
@@ -1450,9 +1174,9 @@
1450 1174 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1451 1175 'screenshot' => 'permissions.png',
1452 1176 ),
1453 1177 ),
1454 - 'scheduling' => array(
1178 + 'scheduling' => array(
1455 1179 'name' => __( 'Form Scheduling', 'formidable' ),
1456 1180 'icon' => 'frm_icon_font frm_calendar_icon',
1457 1181 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1458 1182 'data' => array(
@@ -1462,9 +1186,9 @@
1462 1186 ),
1463 1187 ),
1464 1188 'buttons' => array(
1465 1189 'name' => __( 'Buttons', 'formidable' ),
1466 - 'class' => self::class,
1190 + 'class' => __CLASS__,
1467 1191 'function' => 'buttons_settings',
1468 1192 'icon' => 'frm_icon_font frm_button_icon',
1469 1193 ),
1470 1194 'landing' => array(
@@ -1485,9 +1209,9 @@
1485 1209 'screenshot' => 'chat.png',
1486 1210 )
1487 1211 ),
1488 1212 ),
1489 - 'abandonment' => array(
1213 + 'abandonment' => array(
1490 1214 'name' => __( 'Form Abandonment', 'formidable' ),
1491 1215 'icon' => 'frm_icon_font frm_abandoned_icon',
1492 1216 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1493 1217 'data' => FrmAppHelper::get_upgrade_data_params(
@@ -1500,18 +1224,14 @@
1500 1224 ),
1501 1225 ),
1502 1226 'html' => array(
1503 1227 'name' => __( 'Customize HTML', 'formidable' ),
1504 - 'class' => self::class,
1228 + 'class' => __CLASS__,
1505 1229 'function' => 'html_settings',
1506 1230 'icon' => 'frm_icon_font frm_code_icon',
1507 1231 ),
1508 1232 );
1509 1233
1510 - if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1511 - unset( $sections['buttons'] );
1512 - }
1513 -
1514 1234 foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1515 1235 if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1516 1236 unset( $sections[ $feature ] );
1517 1237 }
@@ -1518,8 +1238,13 @@
1518 1238 }
1519 1239
1520 1240 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1521 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 +
1522 1247 foreach ( $sections as $key => $section ) {
1523 1248 $defaults = array(
1524 1249 'html_class' => '',
1525 1250 'name' => ucfirst( $key ),
@@ -1550,9 +1275,8 @@
1550 1275 /**
1551 1276 * @since 4.0
1552 1277 *
1553 1278 * @param array $values
1554 - * @return void
1555 1279 */
1556 1280 public static function advanced_settings( $values ) {
1557 1281 $first_h3 = 'frm_first_h3';
1558 1282
@@ -1560,15 +1284,14 @@
1560 1284 }
1561 1285
1562 1286 /**
1563 1287 * @param array $values
1564 - * @return void
1565 1288 */
1566 1289 public static function render_spam_settings( $values ) {
1567 1290 if ( function_exists( 'akismet_http_post' ) ) {
1568 1291 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
1569 1292 }
1570 - 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';
1571 1294 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php';
1572 1295 }
1573 1296
1574 1297 /**
@@ -1574,12 +1297,16 @@
1574 1297 /**
1575 1298 * @since 4.0
1576 1299 *
1577 1300 * @param array $values
1578 - * @return void
1579 1301 */
1580 1302 public static function buttons_settings( $values ) {
1581 - 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' );
1582 1309 }
1583 1310
1584 1311 /**
1585 1312 * @since 4.0
@@ -1584,12 +1311,11 @@
1584 1311 /**
1585 1312 * @since 4.0
1586 1313 *
1587 1314 * @param array $values
1588 - * @return void
1589 1315 */
1590 1316 public static function html_settings( $values ) {
1591 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
1317 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' );
1592 1318 }
1593 1319
1594 1320 /**
1595 1321 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -1595,10 +1321,9 @@
1595 1321 * Replace old Submit Button href with new href to avoid errors in Chrome
1596 1322 *
1597 1323 * @since 2.03.08
1598 1324 *
1599 - * @param array|bool $values
1600 - * @return void
1325 + * @param array|boolean $values
1601 1326 */
1602 1327 private static function clean_submit_html( &$values ) {
1603 1328 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
1604 1329 $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
@@ -1619,13 +1344,8 @@
1619 1344
1620 1345 return $classes;
1621 1346 }
1622 1347
1623 - /**
1624 - * @param int|string $form_id
1625 - * @param string $class
1626 - * @return void
1627 - */
1628 1348 public static function mb_tags_box( $form_id, $class = '' ) {
1629 1349 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1630 1350
1631 1351 /**
@@ -1638,9 +1358,9 @@
1638 1358 */
1639 1359 $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) );
1640 1360 $linked_forms = array();
1641 1361 $col = 'one';
1642 - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' );
1362 + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
1643 1363
1644 1364 $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
1645 1365 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1646 1366
@@ -1645,9 +1365,9 @@
1645 1365 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1646 1366
1647 1367 $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
1648 1368
1649 - include FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php';
1369 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
1650 1370 }
1651 1371
1652 1372 /**
1653 1373 * @since 3.04.01
@@ -1660,9 +1380,9 @@
1660 1380 ),
1661 1381 );
1662 1382
1663 1383 $user_fields = self::user_shortcodes();
1664 - if ( $user_fields ) {
1384 + if ( ! empty( $user_fields ) ) {
1665 1385 $user_helpers = array();
1666 1386 foreach ( $user_fields as $uk => $uf ) {
1667 1387 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1668 1388 unset( $uk, $uf );
@@ -1668,9 +1388,9 @@
1668 1388 unset( $uk, $uf );
1669 1389 }
1670 1390
1671 1391 $advanced_helpers['user_id'] = array(
1672 - 'codes' => $user_helpers,
1392 + 'codes' => $user_helpers,
1673 1393 );
1674 1394 }
1675 1395
1676 1396 /**
@@ -1747,16 +1467,21 @@
1747 1467 'updated-at' => __( 'Entry updated', 'formidable' ),
1748 1468 '' => '',
1749 1469 'siteurl' => __( 'Site URL', 'formidable' ),
1750 1470 'sitename' => __( 'Site Name', 'formidable' ),
1751 - 'form_name' => __( 'Form Name', 'formidable' ),
1752 1471 );
1753 1472
1754 - $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1755 1473 if ( ! FrmAppHelper::pro_is_installed() ) {
1756 1474 unset( $entry_shortcodes['post_id'] );
1757 1475 }
1758 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 +
1759 1484 /**
1760 1485 * Use this hook to add or remove buttons in the helpers section
1761 1486 * in the customization panel
1762 1487 *
@@ -1782,9 +1507,9 @@
1782 1507 echo ' frm_js_validate ';
1783 1508 self::add_js_validate_form_to_global_vars( $form );
1784 1509 }
1785 1510
1786 - if ( FrmForm::is_ajax_on( $form ) ) {
1511 + if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) {
1787 1512 echo ' frm_ajax_submit ';
1788 1513 }
1789 1514 }
1790 1515
@@ -1806,11 +1531,11 @@
1806 1531 check_ajax_referer( 'frm_ajax', 'nonce' );
1807 1532
1808 1533 echo FrmEntriesController::show_entry_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1809 1534 array(
1810 - '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' ),
1811 1536 'default_email' => true,
1812 - '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' ),
1813 1538 )
1814 1539 );
1815 1540 wp_die();
1816 1541 }
@@ -1816,10 +1541,10 @@
1816 1541 }
1817 1542
1818 1543 /**
1819 1544 * @param string $content
1820 - * @param int|stdClass|string $form
1821 - * @param false|int|stdClass|string $entry
1545 + * @param stdClass|string|int $form
1546 + * @param stdClass|string|int|false $entry
1822 1547 * @return string
1823 1548 */
1824 1549 public static function filter_content( $content, $form, $entry = false ) {
1825 1550 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1832,16 +1557,8 @@
1832 1557 if ( is_object( $form ) ) {
1833 1558 $form = $form->id;
1834 1559 }
1835 1560
1836 - /*
1837 - * Repeater actions adds `parent_entry` to `$entry` store the parent entry data. If `parent_entry` is not empty,
1838 - * use the parent form ID instead of repeater form ID to fix the parent form field shortcodes doesn't work.
1839 - */
1840 - if ( ! empty( $entry->parent_entry ) ) {
1841 - $form = $entry->parent_entry->form_id;
1842 - }
1843 -
1844 1561 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1845 1562 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1846 1563
1847 1564 return $content;
@@ -1851,11 +1568,11 @@
1851 1568 * Replace any [form_name] shortcodes in a string.
1852 1569 *
1853 1570 * @since 5.5
1854 1571 *
1855 - * @param array|string $string
1856 - * @param int|stdClass|string $form
1857 - * @return array|string
1572 + * @param string|array $string
1573 + * @param stdClass|string|int $form
1574 + * @return string|array
1858 1575 */
1859 1576 public static function replace_form_name_shortcodes( $string, $form ) {
1860 1577 if ( ! is_string( $string ) ) {
1861 1578 return $string;
@@ -1873,9 +1590,9 @@
1873 1590 return str_replace( '[form_name]', $form_name, $string );
1874 1591 }
1875 1592
1876 1593 /**
1877 - * @param false|int|stdClass|string $entry
1594 + * @param stdClass|string|int|false $entry
1878 1595 * @return void
1879 1596 */
1880 1597 private static function get_entry_by_param( &$entry ) {
1881 1598 if ( ! $entry || ! is_object( $entry ) ) {
@@ -1890,12 +1607,8 @@
1890 1607 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1891 1608 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1892 1609 }
1893 1610
1894 - /**
1895 - * @param array $errors
1896 - * @return array
1897 - */
1898 1611 public static function process_bulk_form_actions( $errors ) {
1899 1612 if ( ! $_REQUEST ) {
1900 1613 return $errors;
1901 1614 }
@@ -1939,9 +1652,9 @@
1939 1652 case 'untrash':
1940 1653 $message = self::bulk_untrash( $ids );
1941 1654 }
1942 1655
1943 - if ( ! empty( $message ) ) {
1656 + if ( isset( $message ) && ! empty( $message ) ) {
1944 1657 $errors['message'] = $message;
1945 1658 }
1946 1659
1947 1660 return $errors;
@@ -1946,26 +1659,13 @@
1946 1659
1947 1660 return $errors;
1948 1661 }
1949 1662
1950 - /**
1951 - * Includes html that shows a message when the device is too small to use Formidable Forms admin pages.
1952 - *
1953 - * @since 6.20
1954 - * @return void
1955 - */
1956 - public static function include_device_too_small_message() {
1957 - if ( ! FrmAppHelper::is_formidable_admin() ) {
1958 - return;
1959 - }
1960 -
1961 - include FrmAppHelper::plugin_path() . '/classes/views/shared/small-device-message.php';
1962 - }
1963 -
1964 1663 public static function route() {
1965 1664 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1966 1665 $vars = array();
1967 1666 FrmAppHelper::include_svg();
1667 +
1968 1668 if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1969 1669 FrmAppHelper::permission_check( 'frm_edit_forms' );
1970 1670
1971 1671 // Javascript needs to be allowed in some field settings.
@@ -1974,9 +1674,9 @@
1974 1674 $json_vars = json_decode( $json_vars, true );
1975 1675 if ( empty( $json_vars ) ) {
1976 1676 // json decoding failed so we should return an error message.
1977 1677 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1978 - if ( 'edit' === $action ) {
1678 + if ( 'edit' == $action ) {
1979 1679 $action = 'update';
1980 1680 }
1981 1681
1982 1682 add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
@@ -1998,8 +1698,10 @@
1998 1698 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1999 1699 FrmAppHelper::trigger_hook_load( 'form' );
2000 1700
2001 1701 switch ( $action ) {
1702 + case 'new':
1703 + return self::new_form( $vars );
2002 1704 case 'create':
2003 1705 case 'edit':
2004 1706 case 'update':
2005 1707 case 'trash':
@@ -2008,13 +1710,11 @@
2008 1710 case 'settings':
2009 1711 case 'update_settings':
2010 1712 return self::$action( $vars );
2011 1713 case 'lite-reports':
2012 - self::no_reports( $vars );
2013 - return;
1714 + return self::no_reports( $vars );
2014 1715 case 'views':
2015 - self::no_views( $vars );
2016 - return;
1716 + return self::no_views( $vars );
2017 1717 default:
2018 1718 do_action( 'frm_form_action_' . $action );
2019 1719 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
2020 1720 return;
@@ -2069,32 +1769,12 @@
2069 1769 // Get posted data
2070 1770 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2071 1771 $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2072 1772
2073 - $form = FrmForm::getOne( $form_id );
2074 - if ( ! $form ) {
2075 - wp_send_json_error( __( 'Form not found', 'formidable' ) );
2076 - }
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' ) );
2077 1776
2078 - if ( $name === $form->name ) {
2079 - // Nothing to change so exit early.
2080 - wp_send_json_success();
2081 - }
2082 -
2083 - $to_update = array(
2084 - 'name' => $name,
2085 - );
2086 -
2087 - if ( '' !== $name ) {
2088 - // Only update form_key if name is not empty.
2089 - $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
2090 - $to_update['form_key'] = $form_key;
2091 - } else {
2092 - $form_key = $form->form_key;
2093 - }
2094 -
2095 - FrmForm::update( $form_id, $to_update );
2096 -
2097 1777 wp_send_json_success( compact( 'form_key' ) );
2098 1778 }
2099 1779
2100 1780 public static function json_error( $errors ) {
@@ -2103,13 +1783,20 @@
2103 1783 return $errors;
2104 1784 }
2105 1785
2106 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 + /**
2107 1796 * Add education about views.
2108 1797 *
2109 1798 * @since 4.07
2110 - *
2111 - * @return void
2112 1799 */
2113 1800 public static function no_views( $values = array() ) {
2114 1801 FrmAppHelper::include_svg();
2115 1802 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -2121,10 +1808,8 @@
2121 1808 /**
2122 1809 * Add education about reports.
2123 1810 *
2124 1811 * @since 4.07
2125 - *
2126 - * @return void
2127 1812 */
2128 1813 public static function no_reports( $values = array() ) {
2129 1814 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
2130 1815 $form = $id ? FrmForm::getOne( $id ) : false;
@@ -2209,9 +1894,9 @@
2209 1894 $wp_admin_bar->add_node(
2210 1895 array(
2211 1896 'parent' => 'frm-forms',
2212 1897 'id' => 'edit_form_' . $form_id,
2213 - 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name,
1898 + 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
2214 1899 'href' => FrmForm::get_edit_link( $form_id ),
2215 1900 )
2216 1901 );
2217 1902 }
@@ -2224,10 +1909,10 @@
2224 1909 * @return string
2225 1910 */
2226 1911 public static function get_form_shortcode( $atts ) {
2227 1912 global $frm_vars;
2228 - if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2229 - $sc = '[formidable';
1913 + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1914 + $sc = '[formidable';
2230 1915 $sc .= FrmAppHelper::array_to_html_params( $atts );
2231 1916 return $sc . ']';
2232 1917 }
2233 1918
@@ -2252,11 +1937,11 @@
2252 1937
2253 1938 /**
2254 1939 * @since 5.2.01
2255 1940 *
2256 - * @param false|int|string $id
2257 - * @param false|string $key
2258 - * @return false|stdClass
1941 + * @param string|int|false $id
1942 + * @param string|false $key
1943 + * @return stdClass|false
2259 1944 */
2260 1945 private static function maybe_get_form_by_id_or_key( $id, $key ) {
2261 1946 if ( ! $id ) {
2262 1947 $id = $key;
@@ -2264,12 +1949,12 @@
2264 1949 return self::maybe_get_form_to_show( $id );
2265 1950 }
2266 1951
2267 1952 /**
2268 - * @param false|int|string $id
2269 - * @param false|string $key
2270 - * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2271 - * @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.
2272 1957 * @param array $atts
2273 1958 * @return string
2274 1959 */
2275 1960 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
@@ -2317,10 +2002,10 @@
2317 2002 return $form;
2318 2003 }
2319 2004
2320 2005 /**
2321 - * @param false|int|string $id
2322 - * @return false|stdClass
2006 + * @param string|int|false $id
2007 + * @return stdClass|false
2323 2008 */
2324 2009 private static function maybe_get_form_to_show( $id ) {
2325 2010 $form = false;
2326 2011
@@ -2384,11 +2069,11 @@
2384 2069
2385 2070 do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
2386 2071
2387 2072 if ( apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
2388 - $entry_id = self::just_created_entry( $form->id );
2389 - $pass_args['entry_id'] = $entry_id;
2390 - $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;
2391 2076
2392 2077 self::run_on_submit_actions( $pass_args );
2393 2078
2394 2079 do_action(
@@ -2432,9 +2117,9 @@
2432 2117 */
2433 2118 public static function just_created_entry( $form_id ) {
2434 2119 global $frm_vars;
2435 2120
2436 - 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;
2437 2122 }
2438 2123
2439 2124 /**
2440 2125 * Gets confirmation method.
@@ -2447,14 +2132,14 @@
2447 2132 *
2448 2133 * @type object $form Form object.
2449 2134 * @type int $entry_id Entry ID.
2450 2135 * }
2451 - * @return array|string
2136 + * @return string|array
2452 2137 */
2453 2138 private static function get_confirmation_method( $atts ) {
2454 2139 $action = FrmOnSubmitHelper::current_event( $atts );
2455 2140 $opt = 'update' === $action ? 'edit_action' : 'success_action';
2456 - $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';
2457 2142
2458 2143 if ( ! empty( $atts['entry_id'] ) ) {
2459 2144 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2460 2145 if ( $met_actions ) {
@@ -2463,9 +2148,9 @@
2463 2148 }
2464 2149
2465 2150 $method = apply_filters( 'frm_success_filter', $method, $atts['form'], $action );
2466 2151
2467 - if ( $method !== 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2152 + if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2468 2153 $method = 'message';
2469 2154 }
2470 2155
2471 2156 return $method;
@@ -2499,9 +2184,9 @@
2499 2184 * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}.
2500 2185 */
2501 2186 public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) {
2502 2187 if ( is_array( $conf_method ) && 1 === count( $conf_method ) ) {
2503 - 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] ) ) {
2504 2189 $event = FrmOnSubmitHelper::current_event( $params );
2505 2190 FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event );
2506 2191 $conf_method = 'redirect';
2507 2192 }
@@ -2550,9 +2235,9 @@
2550 2235 unset( $extra_args['form'] );
2551 2236
2552 2237 do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
2553 2238
2554 - $opt = ! isset( $args['action'] ) || $args['action'] === 'create' ? 'success' : 'edit';
2239 + $opt = ( ! isset( $args['action'] ) || $args['action'] === 'create' ) ? 'success' : 'edit';
2555 2240
2556 2241 $args['success_opt'] = $opt;
2557 2242 $args['ajax'] = ! empty( $frm_vars['ajax'] );
2558 2243
@@ -2578,16 +2263,16 @@
2578 2263 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
2579 2264 return array();
2580 2265 }
2581 2266
2582 - // 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.
2583 2268 if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) {
2584 2269 return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) );
2585 2270 }
2586 2271
2587 - $entry = FrmEntry::getOne( $args['entry_id'], true );
2588 - $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2589 - $met_actions = array();
2272 + $entry = FrmEntry::getOne( $args['entry_id'], true );
2273 + $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2274 + $met_actions = array();
2590 2275 $has_redirect = false;
2591 2276
2592 2277 foreach ( $actions as $action ) {
2593 2278 if ( ! in_array( $event, $action->post_content['event'], true ) ) {
@@ -2836,9 +2521,9 @@
2836 2521 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
2837 2522 wp_die();
2838 2523 }
2839 2524
2840 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) {
2525 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) {
2841 2526 // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2842 2527 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2843 2528 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
2844 2529 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
@@ -2883,46 +2568,28 @@
2883 2568 * @param array $args See {@see FrmFormsController::run_success_action()}.
2884 2569 * @return array
2885 2570 */
2886 2571 private static function get_ajax_redirect_response_data( $args ) {
2887 - $response_data = array(
2888 - 'redirect' => $args['success_url'],
2889 - 'content' => '',
2890 - );
2891 - $unset_content = true;
2572 + $response_data = array( 'redirect' => $args['success_url'] );
2892 2573
2893 - if ( ! empty( $args['form']->options['redirect_delay'] ) ) {
2894 - $response_data['delay'] = $args['form']->options['redirect_delay_time'];
2895 - $response_data['content'] .= self::get_redirect_message( $args['success_url'], $args['form']->options['redirect_delay_msg'], $args );
2896 - $unset_content = false;
2897 - }
2898 -
2899 2574 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2900 2575 $response_data['openInNewTab'] = 1;
2901 2576
2902 - // Only show open in new tab text if there is no delay.
2903 - if ( empty( $response_data['content'] ) ) {
2904 - $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2577 + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2905 2578
2906 - $args['form']->options['success_msg'] = $args['message'];
2907 - $args['form']->options['edit_msg'] = $args['message'];
2908 - if ( ! isset( $args['fields'] ) ) {
2909 - $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2910 - }
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 + }
2911 2584
2912 - $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 );
2913 2586
2914 - ob_start();
2915 - self::show_lone_success_message( $args );
2916 - $response_data['content'] .= ob_get_clean();
2917 - $unset_content = false;
2918 - }//end if
2587 + ob_start();
2588 + self::show_lone_success_messsage( $args );
2589 + $response_data['content'] = ob_get_clean();
2919 2590
2920 2591 $response_data['fallbackMsg'] = self::get_redirect_fallback_message( $args['success_url'], $args );
2921 - }//end if
2922 -
2923 - if ( $unset_content && '' === $response_data['content'] ) {
2924 - unset( $response_data['content'] );
2925 2592 }
2926 2593
2927 2594 return $response_data;
2928 2595 }
@@ -2934,9 +2601,9 @@
2934 2601 *
2935 2602 * @param array $args See {@see FrmFormsController::run_success_action()}.
2936 2603 */
2937 2604 private static function redirect_after_submit_using_js( $args ) {
2938 - $success_msg = $args['form']->options['redirect_delay_msg'];
2605 + $success_msg = FrmOnSubmitHelper::get_default_redirect_msg();
2939 2606 $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args );
2940 2607 $success_url = esc_url_raw( $args['success_url'] );
2941 2608
2942 2609 /**
@@ -2943,11 +2610,11 @@
2943 2610 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
2944 2611 *
2945 2612 * @since 6.0
2946 2613 *
2947 - * @param int $delay_time Delay time in milliseconds.
2614 + * @param int $delay_time Delay time in miliseconds.
2948 2615 */
2949 - $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 );
2950 2617
2951 2618 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2952 2619 $redirect_js = 'window.open("' . $success_url . '", "_blank")';
2953 2620 } else {
@@ -2976,10 +2643,8 @@
2976 2643 * @param string $success_msg
2977 2644 * @param array $args
2978 2645 */
2979 2646 private static function get_redirect_message( $success_url, $success_msg, $args ) {
2980 - $success_msg = apply_filters( 'frm_content', $success_msg, $args['form'], $args['entry_id'] );
2981 - $success_msg = do_shortcode( FrmAppHelper::use_wpautop( $success_msg ) );
2982 2647 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
2983 2648 self::get_redirect_fallback_message( $success_url, $args ) .
2984 2649 '</div></div>';
2985 2650
@@ -3035,9 +2700,9 @@
3035 2700 } else {
3036 2701 self::show_form_after_submit( $atts );
3037 2702 }
3038 2703 } else {
3039 - self::show_lone_success_message( $atts );
2704 + self::show_lone_success_messsage( $atts );
3040 2705 }
3041 2706 }
3042 2707
3043 2708 /**
@@ -3065,9 +2730,9 @@
3065 2730
3066 2731 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
3067 2732
3068 2733 $frm_settings = FrmAppHelper::get_settings();
3069 - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value;
2734 + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
3070 2735
3071 2736 global $frm_vars;
3072 2737 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
3073 2738
@@ -3076,10 +2741,11 @@
3076 2741 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
3077 2742 }
3078 2743
3079 2744 /**
2745 + * @return string - 'before', 'after', or 'submit'
2746 + *
3080 2747 * @since 4.05.02
3081 - * @return string - 'before', 'after', or 'submit'
3082 2748 */
3083 2749 private static function message_placement( $form, $message ) {
3084 2750 $place = 'before';
3085 2751
@@ -3091,10 +2757,11 @@
3091 2757 }
3092 2758 }
3093 2759
3094 2760 /**
2761 + * @return string - 'before' or 'after'
2762 + *
3095 2763 * @since 4.05.02
3096 - * @return string - 'before' or 'after'
3097 2764 */
3098 2765 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
3099 2766 }
3100 2767
@@ -3128,9 +2795,9 @@
3128 2795 * Show the success message without the form
3129 2796 *
3130 2797 * @since 2.05
3131 2798 */
3132 - private static function show_lone_success_message( $atts ) {
2799 + private static function show_lone_success_messsage( $atts ) {
3133 2800 global $frm_vars;
3134 2801 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
3135 2802 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
3136 2803
@@ -3139,9 +2806,9 @@
3139 2806 $errors = array();
3140 2807 $form = $atts['form'];
3141 2808 $message = $atts['message'];
3142 2809
3143 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
2810 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
3144 2811 }
3145 2812
3146 2813 /**
3147 2814 * Prepare the success message before it's shown
@@ -3155,12 +2822,12 @@
3155 2822 * @return string
3156 2823 */
3157 2824 private static function prepare_submit_message( $form, $entry_id, $args = array() ) {
3158 2825 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
3159 - $opt = $args['success_opt'] ?? 'success';
2826 + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
3160 2827
3161 2828 if ( $entry_id && is_numeric( $entry_id ) ) {
3162 - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg;
2829 + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
3163 2830 $class = 'frm_message';
3164 2831 } else {
3165 2832 $message = $frm_settings->failed_msg;
3166 2833 $class = FrmFormsHelper::form_error_class();
@@ -3261,13 +2928,11 @@
3261 2928 global $frm_vars;
3262 2929
3263 2930 FrmStylesController::enqueue_css();
3264 2931
3265 - if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
2932 + if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3266 2933 // load formidable js
3267 2934 wp_enqueue_script( 'formidable' );
3268 -
3269 - FrmHoneypot::maybe_print_honeypot_js();
3270 2935 }
3271 2936 }
3272 2937
3273 2938 /**
@@ -3281,12 +2946,12 @@
3281 2946 }
3282 2947
3283 2948 /**
3284 2949 * @since 2.0.8
3285 - * @return bool
2950 + * @return boolean
3286 2951 */
3287 2952 private static function is_minification_on( $atts ) {
3288 - return ! empty( $atts['minimize'] );
2953 + return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
3289 2954 }
3290 2955
3291 2956 /**
3292 2957 * @since 5.0.16
@@ -3384,9 +3049,9 @@
3384 3049
3385 3050 check_ajax_referer( 'frm_ajax', 'nonce' );
3386 3051
3387 3052 $html = FrmAppHelper::clip(
3388 - function () {
3053 + function() {
3389 3054 FrmAppHelper::maybe_autocomplete_pages_options(
3390 3055 array(
3391 3056 'field_name' => 'frm_page_dropdown',
3392 3057 'page_id' => '',
@@ -3406,8 +3071,15 @@
3406 3071
3407 3072 /**
3408 3073 * @deprecated 4.0
3409 3074 */
3075 + public static function new_form( $values = array() ) {
3076 + FrmDeprecated::new_form( $values );
3077 + }
3078 +
3079 + /**
3080 + * @deprecated 4.0
3081 + */
3410 3082 public static function create( $values = array() ) {
3411 3083 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3412 3084 self::update( $values );
3413 3085 }
@@ -3412,16 +3084,75 @@
3412 3084 self::update( $values );
3413 3085 }
3414 3086
3415 3087 /**
3416 - * 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
3417 3121 *
3418 - * @since 4.05
3419 - * @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
3420 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 + *
3421 3144 * @return void
3422 3145 */
3423 - public static function add_form_style_tab_options() {
3424 - _deprecated_function( __METHOD__, '6.16.3' );
3425 - 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' );
3426 3157 }
3427 3158 }