PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
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 +310 -653 6.25.16.7 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 - );
232 + return self::get_edit_vars( $id, array(), $message );
312 233 }
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 );
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,42 +294,27 @@
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 - *
424 - * @return void
425 314 */
426 315 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
316 + echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
437 317 }
438 318
439 319 /**
440 320 * @return void
@@ -445,17 +325,8 @@
445 325
446 326 global $frm_vars;
447 327 $frm_vars['preview'] = true;
448 328
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 329 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
459 330 if ( $include_theme ) {
460 331 self::set_preview_query();
461 332 self::load_theme_preview();
@@ -490,13 +361,8 @@
490 361 return;
491 362 }
492 363
493 364 $random_page = reset( $random_page );
494 - if ( ! is_a( $random_page, 'WP_Post' ) ) {
495 - // The return type can also be int.
496 - return;
497 - }
498 -
499 365 query_posts(
500 366 array(
501 367 'post_type' => 'page',
502 368 'page_id' => $random_page->ID,
@@ -512,9 +378,9 @@
512 378 * Set the WP $post global object. Used for in-theme preview when defining a page.
513 379 *
514 380 * @since 5.5.2
515 381 *
516 - * @param WP_Post $page The page object.
382 + * @param WP_Post $post
517 383 * @return void
518 384 */
519 385 private static function set_post_global( $page ) {
520 386 global $post;
@@ -522,10 +388,8 @@
522 388 }
523 389
524 390 /**
525 391 * @since 3.0
526 - *
527 - * @return void
528 392 */
529 393 private static function load_theme_preview() {
530 394 add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
531 395 add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
@@ -557,16 +421,13 @@
557 421
558 422 /**
559 423 * Not every theme supports get_template_part( 'page' ).
560 424 * When this is not supported, false is returned, and we can handle a fallback.
561 - *
562 - * @return void
563 425 */
564 426 private static function fallback_when_page_template_part_is_not_supported_by_theme() {
565 427 if ( have_posts() ) {
566 428 the_post();
567 - self::get_template( 'header' );
568 -
429 + get_header( '' );
569 430 // add some generic class names to the container to add some natural padding to the content.
570 431 // .entry-content catches the WordPress TwentyTwenty theme.
571 432 // .container catches Customizr content.
572 433 echo '<div class="container entry-content">';
@@ -571,58 +432,13 @@
571 432 // .container catches Customizr content.
572 433 echo '<div class="container entry-content">';
573 434 the_content();
574 435 echo '</div>';
575 -
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 - self::get_template( 'footer' );
436 + get_footer();
581 437 }
582 438 }
583 439
584 440 /**
585 - * 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.
587 - *
588 - * @since 6.7.1
589 - * @param string $template
590 - * @return void
591 - */
592 - private static function get_template( $template ) {
593 - if ( self::should_try_getting_template( $template ) ) {
594 - call_user_func( 'get_' . $template );
595 - return;
596 - }
597 -
598 - if ( 'header' === $template ) {
599 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/header.php';
600 - return;
601 - }
602 -
603 - if ( 'footer' === $template ) {
604 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/footer.php';
605 - }
606 - }
607 -
608 - /**
609 - * Returns true if calling a template function doesn't trigger deprecation warnings.
610 - *
611 - * @since 6.7.1
612 - * @param string $template
613 - * @return bool
614 - */
615 - private static function should_try_getting_template( $template ) {
616 - $stylesheet_path = get_stylesheet_directory();
617 - $template_path = get_template_directory();
618 - $is_child_theme = $stylesheet_path !== $template_path;
619 - $template_name = $template . '.php';
620 -
621 - return file_exists( $stylesheet_path . '/' . $template_name ) || $is_child_theme && file_exists( $template_path . '/' . $template_name );
622 - }
623 -
624 - /**
625 441 * Set the page title for the theme preview page
626 442 *
627 443 * @since 3.0
628 444 */
@@ -634,14 +450,11 @@
634 450 return $title;
635 451 }
636 452
637 453 /**
638 - * Set the page title for the theme preview page.
454 + * Set the page title for the theme preview page
639 455 *
640 456 * @since 3.0
641 - *
642 - * @param string $title
643 - * @return string
644 457 */
645 458 public static function preview_title( $title ) {
646 459 return __( 'Form Preview', 'formidable' );
647 460 }
@@ -646,20 +459,15 @@
646 459 return __( 'Form Preview', 'formidable' );
647 460 }
648 461
649 462 /**
650 - * Set the page content for the theme preview page.
463 + * Set the page content for the theme preview page
651 464 *
652 465 * @since 3.0
653 - *
654 - * @param string $content
655 - * @return string
656 466 */
657 467 public static function preview_content( $content ) {
658 468 if ( in_the_loop() ) {
659 - self::show_page_preview();
660 - // Clear the content for the page we're using.
661 - $content = '';
469 + $content = self::show_page_preview();
662 470 }
663 471
664 472 return $content;
665 473 }
@@ -667,88 +475,23 @@
667 475 /**
668 476 * @since 3.0
669 477 */
670 478 private static function load_direct_preview() {
479 + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
480 +
671 481 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
672 482 if ( $key == '' ) {
673 483 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
674 484 }
675 485
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 486 $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 - );
487 + if ( empty( $form ) ) {
488 + $form = FrmForm::getAll( array(), '', 1 );
695 489 }
696 490
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';
491 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
702 492 }
703 493
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 494 public static function untrash() {
752 495 self::change_form_status( 'untrash' );
753 496 }
754 497
@@ -811,14 +554,14 @@
811 554 FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
812 555
813 556 $params = FrmForm::list_page_params();
814 557
815 - // Check nonce url.
558 + //check nonce url
816 559 check_admin_referer( $status . '_form_' . $params['id'] );
817 560
818 561 $count = 0;
819 562 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
820 - ++$count;
563 + $count ++;
821 564 }
822 565
823 566 $form_type = FrmAppHelper::get_simple_request(
824 567 array(
@@ -830,9 +573,9 @@
830 573 /* translators: %1$s: Number of forms */
831 574 $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
832 575
833 576 /* 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>' );
577 + $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 578
836 579 $message = $available_status[ $status ]['message'];
837 580
838 581 self::display_forms_list( $params, $message );
@@ -837,12 +580,8 @@
837 580
838 581 self::display_forms_list( $params, $message );
839 582 }
840 583
841 - /**
842 - * @param array $ids
843 - * @return string
844 - */
845 584 public static function bulk_trash( $ids ) {
846 585 FrmAppHelper::permission_check( 'frm_delete_forms' );
847 586
848 587 $count = 0;
@@ -847,16 +586,12 @@
847 586
848 587 $count = 0;
849 588 foreach ( $ids as $id ) {
850 589 if ( FrmForm::trash( $id ) ) {
851 - ++$count;
590 + $count ++;
852 591 }
853 592 }
854 593
855 - if ( ! $count ) {
856 - return '';
857 - }
858 -
859 594 $current_page = FrmAppHelper::get_simple_request(
860 595 array(
861 596 'param' => 'form_type',
862 597 'type' => 'request',
@@ -882,9 +617,9 @@
882 617 check_admin_referer( 'destroy_form_' . $params['id'] );
883 618
884 619 $count = 0;
885 620 if ( FrmForm::destroy( $params['id'] ) ) {
886 - ++$count;
621 + $count ++;
887 622 }
888 623
889 624 /* translators: %1$s: Number of forms */
890 625 $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count );
@@ -891,12 +626,8 @@
891 626
892 627 self::display_forms_list( $params, $message );
893 628 }
894 629
895 - /**
896 - * @param array $ids
897 - * @return string
898 - */
899 630 public static function bulk_destroy( $ids ) {
900 631 FrmAppHelper::permission_check( 'frm_delete_forms' );
901 632
902 633 $count = 0;
@@ -902,24 +633,19 @@
902 633 $count = 0;
903 634 foreach ( $ids as $id ) {
904 635 $d = FrmForm::destroy( $id );
905 636 if ( $d ) {
906 - ++$count;
637 + $count ++;
907 638 }
908 639 }
909 640
910 - if ( $count ) {
911 - /* translators: %1$s: Number of forms */
912 - return sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
913 - }
641 + /* translators: %1$s: Number of forms */
642 + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
914 643
915 - return '';
644 + return $message;
916 645 }
917 646
918 - /**
919 - * @since 6.7.1 Function went from private to public.
920 - */
921 - public static function delete_all() {
647 + private static function delete_all() {
922 648 // Check nonce url.
923 649 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
924 650 if ( $permission_error !== false ) {
925 651 self::display_forms_list( array(), '', array( $permission_error ) );
@@ -926,15 +652,14 @@
926 652
927 653 return;
928 654 }
929 655
930 - $count = FrmForm::scheduled_delete( time() );
931 - $url = remove_query_arg( array( 'delete_all' ) );
656 + $count = FrmForm::scheduled_delete( time() );
932 657
933 - $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
658 + /* translators: %1$s: Number of forms */
659 + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
934 660
935 - wp_safe_redirect( $url );
936 - die();
661 + self::display_forms_list( array(), $message );
937 662 }
938 663
939 664 /**
940 665 * Create a new form from the modal.
@@ -947,9 +672,9 @@
947 672
948 673 $new_values = self::get_modal_values();
949 674 $new_values['form_key'] = $new_values['name'];
950 675 $new_values['options'] = array(
951 - 'antispam' => 1,
676 + 'antispam' => 1,
952 677 'on_submit_migrated' => 1,
953 678 );
954 679
955 680 /**
@@ -968,9 +693,8 @@
968 693 * @param int $form_id
969 694 */
970 695 do_action( 'frm_build_new_form', $form_id );
971 696
972 - self::create_submit_button_field( $form_id );
973 697 self::create_default_on_submit_action( $form_id );
974 698 self::create_default_email_action( $form_id );
975 699
976 700 $response = array(
@@ -984,10 +708,8 @@
984 708 /**
985 709 * Before creating a new form, get the name and description from the modal.
986 710 *
987 711 * @since 4.0
988 - *
989 - * @return array<string,string>
990 712 */
991 713 public static function get_modal_values() {
992 714 $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
993 715 $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
@@ -1002,24 +724,17 @@
1002 724 * Inserts Formidable button
1003 725 * Hook exists since 2.5.0
1004 726 *
1005 727 * @since 2.0.15
1006 - *
1007 - * @return void
1008 728 */
1009 729 public static function insert_form_button() {
1010 730 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
731 + FrmAppHelper::load_admin_wide_js();
732 + $menu_name = FrmAppHelper::get_menu_name();
733 + $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
734 + 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' ) . '">' .
735 + FrmAppHelper::kses( $icon, 'all' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
736 + ' ' . esc_html( $menu_name ) . '</a>';
1022 737 }
1023 738 }
1024 739
1025 740 /**
@@ -1107,9 +822,9 @@
1107 822 $form_id = $opts['form_id'];
1108 823 unset( $opts['form_id'] );
1109 824 }
1110 825
1111 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php';
826 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
1112 827
1113 828 echo '</div>';
1114 829
1115 830 wp_die();
@@ -1149,14 +864,8 @@
1149 864 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
1150 865 die();
1151 866 }
1152 867
1153 - $inbox = new FrmInbox();
1154 - $error = $inbox->check_for_error();
1155 - if ( $error ) {
1156 - $show_messages = array( $error['subject'] . '. ' . $error['message'] );
1157 - }
1158 -
1159 868 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php';
1160 869 }
1161 870
1162 871 /**
@@ -1163,16 +872,14 @@
1163 872 * @param array<string,string> $columns
1164 873 * @return array<string,string>
1165 874 */
1166 875 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 - }
876 + $columns['cb'] = '<input type="checkbox" />';
877 + $columns['name'] = esc_html__( 'Form Title', 'formidable' );
878 + $columns['entries'] = esc_html__( 'Entries', 'formidable' );
879 + $columns['id'] = 'ID';
880 + $columns['form_key'] = esc_html__( 'Key', 'formidable' );
881 + $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1175 882 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
1176 883
1177 884 add_screen_option(
1178 885 'per_page',
@@ -1185,11 +892,8 @@
1185 892
1186 893 return $columns;
1187 894 }
1188 895
1189 - /**
1190 - * @return array<string,string>
1191 - */
1192 896 public static function get_sortable_columns() {
1193 897 return array(
1194 898 'id' => 'id',
1195 899 'name' => 'name',
@@ -1223,9 +927,9 @@
1223 927 return $hidden_columns;
1224 928 }
1225 929
1226 930 public static function save_per_page( $save, $option, $value ) {
1227 - if ( $option === 'formidable_page_formidable_per_page' ) {
931 + if ( $option == 'formidable_page_formidable_per_page' ) {
1228 932 $save = (int) $value;
1229 933 }
1230 934
1231 935 return $save;
@@ -1230,23 +934,16 @@
1230 934
1231 935 return $save;
1232 936 }
1233 937
1234 - /**
1235 - * @param int|string $id
1236 - * @param array $errors
1237 - * @param string $message
1238 - * @param bool $create_link
1239 - * @return void
1240 - */
1241 938 private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1242 939 global $frm_vars;
1243 940
1244 - $form = FrmForm::getOne( $id );
941 + $form = FrmForm::getOne( $id );
1245 942 $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' ),
943 + 'title' => __( 'You can\'t edit the form', 'formidable' ),
944 + 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
945 + 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
1249 946 'continue_url' => add_query_arg(
1250 947 array(
1251 948 'page' => 'formidable',
1252 949 )
@@ -1257,10 +954,10 @@
1257 954 return;
1258 955 }
1259 956
1260 957 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(
958 + $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
959 + $error_args['continue_url'] = add_query_arg(
1263 960 array(
1264 961 'page' => 'formidable',
1265 962 '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ),
1266 963 'form_type' => 'trash',
@@ -1284,9 +981,8 @@
1284 981
1285 982 // Automatically add end section fields if they don't exist (2.0 migration).
1286 983 $reset_fields = false;
1287 984 FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
1288 - FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields );
1289 985
1290 986 if ( $reset_fields ) {
1291 987 $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
1292 988 }
@@ -1312,21 +1008,18 @@
1312 1008 }
1313 1009
1314 1010 self::maybe_update_form_builder_message( $message );
1315 1011
1316 - $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1012 + $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
1013 + $has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] );
1317 1014
1318 1015 if ( defined( 'DOING_AJAX' ) ) {
1319 1016 wp_die();
1017 + } else {
1018 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
1320 1019 }
1321 -
1322 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php';
1323 1020 }
1324 1021
1325 - /**
1326 - * @param array $fields
1327 - * @return array
1328 - */
1329 1022 public static function update_form_builder_fields( $fields, $form ) {
1330 1023 foreach ( $fields as $field ) {
1331 1024 $field->do_not_include_icons = true;
1332 1025 }
@@ -1338,21 +1031,13 @@
1338 1031 $message = __( 'Form was Successfully Copied', 'formidable' );
1339 1032 }
1340 1033 }
1341 1034
1342 - /**
1343 - * @param int|string $id
1344 - * @param array $errors
1345 - * @param array|string $args
1346 - * @return void
1347 - */
1348 1035 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1349 1036 FrmAppHelper::permission_check( 'frm_edit_forms' );
1350 1037
1351 1038 global $frm_vars;
1352 1039
1353 - self::maybe_print_media_templates();
1354 -
1355 1040 if ( ! is_array( $args ) ) {
1356 1041 // For reverse compatibility.
1357 1042 $args = array(
1358 1043 'message' => $args,
@@ -1385,38 +1070,17 @@
1385 1070
1386 1071 $sections = self::get_settings_tabs( $values );
1387 1072 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' );
1388 1073
1389 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php';
1074 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
1390 1075 }
1391 1076
1392 1077 /**
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 1078 * @since 4.0
1415 1079 */
1416 1080 public static function form_publish_button( $atts ) {
1417 1081 $values = $atts['values'];
1418 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
1082 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
1419 1083 }
1420 1084
1421 1085 /**
1422 1086 * Get a list of all the settings tabs for the form settings page.
@@ -1430,9 +1094,9 @@
1430 1094 $sections = array(
1431 1095 'advanced' => array(
1432 1096 'name' => __( 'General', 'formidable' ),
1433 1097 'title' => __( 'General Form Settings', 'formidable' ),
1434 - 'function' => array( self::class, 'advanced_settings' ),
1098 + 'function' => array( __CLASS__, 'advanced_settings' ),
1435 1099 'icon' => 'frm_icon_font frm_settings_icon',
1436 1100 ),
1437 1101 'email' => array(
1438 1102 'name' => __( 'Actions & Notifications', 'formidable' ),
@@ -1441,9 +1105,9 @@
1441 1105 'icon' => 'frm_icon_font frm_mail_bulk_icon',
1442 1106 ),
1443 1107 'permissions' => array(
1444 1108 'name' => __( 'Form Permissions', 'formidable' ),
1445 - 'icon' => 'frm_icon_font frm_lock_closed_icon',
1109 + 'icon' => 'frm_icon_font frm_lock_icon',
1446 1110 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1447 1111 'data' => array(
1448 1112 'medium' => 'permissions',
1449 1113 'upgrade' => __( 'Form Permissions', 'formidable' ),
@@ -1450,9 +1114,9 @@
1450 1114 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1451 1115 'screenshot' => 'permissions.png',
1452 1116 ),
1453 1117 ),
1454 - 'scheduling' => array(
1118 + 'scheduling' => array(
1455 1119 'name' => __( 'Form Scheduling', 'formidable' ),
1456 1120 'icon' => 'frm_icon_font frm_calendar_icon',
1457 1121 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1458 1122 'data' => array(
@@ -1462,9 +1126,9 @@
1462 1126 ),
1463 1127 ),
1464 1128 'buttons' => array(
1465 1129 'name' => __( 'Buttons', 'formidable' ),
1466 - 'class' => self::class,
1130 + 'class' => __CLASS__,
1467 1131 'function' => 'buttons_settings',
1468 1132 'icon' => 'frm_icon_font frm_button_icon',
1469 1133 ),
1470 1134 'landing' => array(
@@ -1485,9 +1149,9 @@
1485 1149 'screenshot' => 'chat.png',
1486 1150 )
1487 1151 ),
1488 1152 ),
1489 - 'abandonment' => array(
1153 + 'abandonment' => array(
1490 1154 'name' => __( 'Form Abandonment', 'formidable' ),
1491 1155 'icon' => 'frm_icon_font frm_abandoned_icon',
1492 1156 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1493 1157 'data' => FrmAppHelper::get_upgrade_data_params(
@@ -1500,18 +1164,14 @@
1500 1164 ),
1501 1165 ),
1502 1166 'html' => array(
1503 1167 'name' => __( 'Customize HTML', 'formidable' ),
1504 - 'class' => self::class,
1168 + 'class' => __CLASS__,
1505 1169 'function' => 'html_settings',
1506 1170 'icon' => 'frm_icon_font frm_code_icon',
1507 1171 ),
1508 1172 );
1509 1173
1510 - if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1511 - unset( $sections['buttons'] );
1512 - }
1513 -
1514 1174 foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1515 1175 if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1516 1176 unset( $sections[ $feature ] );
1517 1177 }
@@ -1518,8 +1178,13 @@
1518 1178 }
1519 1179
1520 1180 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1521 1181
1182 + if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
1183 + // Prevent settings from showing in 2 spots.
1184 + unset( $sections['permissions'], $sections['scheduling'] );
1185 + }
1186 +
1522 1187 foreach ( $sections as $key => $section ) {
1523 1188 $defaults = array(
1524 1189 'html_class' => '',
1525 1190 'name' => ucfirst( $key ),
@@ -1541,9 +1206,9 @@
1541 1206 $section['id'] = $section['anchor'];
1542 1207 }
1543 1208
1544 1209 $sections[ $key ] = $section;
1545 - }//end foreach
1210 + }
1546 1211
1547 1212 return $sections;
1548 1213 }
1549 1214
@@ -1550,9 +1215,8 @@
1550 1215 /**
1551 1216 * @since 4.0
1552 1217 *
1553 1218 * @param array $values
1554 - * @return void
1555 1219 */
1556 1220 public static function advanced_settings( $values ) {
1557 1221 $first_h3 = 'frm_first_h3';
1558 1222
@@ -1560,15 +1224,14 @@
1560 1224 }
1561 1225
1562 1226 /**
1563 1227 * @param array $values
1564 - * @return void
1565 1228 */
1566 1229 public static function render_spam_settings( $values ) {
1567 1230 if ( function_exists( 'akismet_http_post' ) ) {
1568 1231 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
1569 1232 }
1570 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/stopforumspam.php';
1233 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/honeypot.php';
1571 1234 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php';
1572 1235 }
1573 1236
1574 1237 /**
@@ -1574,12 +1237,16 @@
1574 1237 /**
1575 1238 * @since 4.0
1576 1239 *
1577 1240 * @param array $values
1578 - * @return void
1579 1241 */
1580 1242 public static function buttons_settings( $values ) {
1581 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
1243 + $styles = apply_filters( 'frm_get_style_opts', array() );
1244 +
1245 + $frm_settings = FrmAppHelper::get_settings();
1246 + $no_global_style = $frm_settings->load_style === 'none';
1247 +
1248 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php' );
1582 1249 }
1583 1250
1584 1251 /**
1585 1252 * @since 4.0
@@ -1584,12 +1251,11 @@
1584 1251 /**
1585 1252 * @since 4.0
1586 1253 *
1587 1254 * @param array $values
1588 - * @return void
1589 1255 */
1590 1256 public static function html_settings( $values ) {
1591 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
1257 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' );
1592 1258 }
1593 1259
1594 1260 /**
1595 1261 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -1595,10 +1261,9 @@
1595 1261 * Replace old Submit Button href with new href to avoid errors in Chrome
1596 1262 *
1597 1263 * @since 2.03.08
1598 1264 *
1599 - * @param array|bool $values
1600 - * @return void
1265 + * @param array|boolean $values
1601 1266 */
1602 1267 private static function clean_submit_html( &$values ) {
1603 1268 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
1604 1269 $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
@@ -1619,13 +1284,8 @@
1619 1284
1620 1285 return $classes;
1621 1286 }
1622 1287
1623 - /**
1624 - * @param int|string $form_id
1625 - * @param string $class
1626 - * @return void
1627 - */
1628 1288 public static function mb_tags_box( $form_id, $class = '' ) {
1629 1289 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1630 1290
1631 1291 /**
@@ -1638,9 +1298,9 @@
1638 1298 */
1639 1299 $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) );
1640 1300 $linked_forms = array();
1641 1301 $col = 'one';
1642 - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' );
1302 + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
1643 1303
1644 1304 $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
1645 1305 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1646 1306
@@ -1645,9 +1305,9 @@
1645 1305 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1646 1306
1647 1307 $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
1648 1308
1649 - include FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php';
1309 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
1650 1310 }
1651 1311
1652 1312 /**
1653 1313 * @since 3.04.01
@@ -1660,9 +1320,9 @@
1660 1320 ),
1661 1321 );
1662 1322
1663 1323 $user_fields = self::user_shortcodes();
1664 - if ( $user_fields ) {
1324 + if ( ! empty( $user_fields ) ) {
1665 1325 $user_helpers = array();
1666 1326 foreach ( $user_fields as $uk => $uf ) {
1667 1327 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1668 1328 unset( $uk, $uf );
@@ -1668,9 +1328,9 @@
1668 1328 unset( $uk, $uf );
1669 1329 }
1670 1330
1671 1331 $advanced_helpers['user_id'] = array(
1672 - 'codes' => $user_helpers,
1332 + 'codes' => $user_helpers,
1673 1333 );
1674 1334 }
1675 1335
1676 1336 /**
@@ -1747,16 +1407,21 @@
1747 1407 'updated-at' => __( 'Entry updated', 'formidable' ),
1748 1408 '' => '',
1749 1409 'siteurl' => __( 'Site URL', 'formidable' ),
1750 1410 'sitename' => __( 'Site Name', 'formidable' ),
1751 - 'form_name' => __( 'Form Name', 'formidable' ),
1752 1411 );
1753 1412
1754 - $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1755 1413 if ( ! FrmAppHelper::pro_is_installed() ) {
1756 1414 unset( $entry_shortcodes['post_id'] );
1757 1415 }
1758 1416
1417 + if ( $settings_tab ) {
1418 + $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1419 + $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1420 + $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1421 + $entry_shortcodes['form_name'] = __( 'Form Name', 'formidable' );
1422 + }
1423 +
1759 1424 /**
1760 1425 * Use this hook to add or remove buttons in the helpers section
1761 1426 * in the customization panel
1762 1427 *
@@ -1782,9 +1447,9 @@
1782 1447 echo ' frm_js_validate ';
1783 1448 self::add_js_validate_form_to_global_vars( $form );
1784 1449 }
1785 1450
1786 - if ( FrmForm::is_ajax_on( $form ) ) {
1451 + if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) {
1787 1452 echo ' frm_ajax_submit ';
1788 1453 }
1789 1454 }
1790 1455
@@ -1806,11 +1471,11 @@
1806 1471 check_ajax_referer( 'frm_ajax', 'nonce' );
1807 1472
1808 1473 echo FrmEntriesController::show_entry_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1809 1474 array(
1810 - 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1475 + 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
1811 1476 'default_email' => true,
1812 - 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1477 + 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
1813 1478 )
1814 1479 );
1815 1480 wp_die();
1816 1481 }
@@ -1816,10 +1481,10 @@
1816 1481 }
1817 1482
1818 1483 /**
1819 1484 * @param string $content
1820 - * @param int|stdClass|string $form
1821 - * @param false|int|stdClass|string $entry
1485 + * @param stdClass|string|int $form
1486 + * @param stdClass|string|int|false $entry
1822 1487 * @return string
1823 1488 */
1824 1489 public static function filter_content( $content, $form, $entry = false ) {
1825 1490 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1832,16 +1497,8 @@
1832 1497 if ( is_object( $form ) ) {
1833 1498 $form = $form->id;
1834 1499 }
1835 1500
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 1501 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1845 1502 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1846 1503
1847 1504 return $content;
@@ -1851,11 +1508,11 @@
1851 1508 * Replace any [form_name] shortcodes in a string.
1852 1509 *
1853 1510 * @since 5.5
1854 1511 *
1855 - * @param array|string $string
1856 - * @param int|stdClass|string $form
1857 - * @return array|string
1512 + * @param string|array $string
1513 + * @param stdClass|string|int $form
1514 + * @return string|array
1858 1515 */
1859 1516 public static function replace_form_name_shortcodes( $string, $form ) {
1860 1517 if ( ! is_string( $string ) ) {
1861 1518 return $string;
@@ -1873,9 +1530,9 @@
1873 1530 return str_replace( '[form_name]', $form_name, $string );
1874 1531 }
1875 1532
1876 1533 /**
1877 - * @param false|int|stdClass|string $entry
1534 + * @param stdClass|string|int|false $entry
1878 1535 * @return void
1879 1536 */
1880 1537 private static function get_entry_by_param( &$entry ) {
1881 1538 if ( ! $entry || ! is_object( $entry ) ) {
@@ -1890,12 +1547,8 @@
1890 1547 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1891 1548 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1892 1549 }
1893 1550
1894 - /**
1895 - * @param array $errors
1896 - * @return array
1897 - */
1898 1551 public static function process_bulk_form_actions( $errors ) {
1899 1552 if ( ! $_REQUEST ) {
1900 1553 return $errors;
1901 1554 }
@@ -1939,9 +1592,9 @@
1939 1592 case 'untrash':
1940 1593 $message = self::bulk_untrash( $ids );
1941 1594 }
1942 1595
1943 - if ( ! empty( $message ) ) {
1596 + if ( isset( $message ) && ! empty( $message ) ) {
1944 1597 $errors['message'] = $message;
1945 1598 }
1946 1599
1947 1600 return $errors;
@@ -1946,26 +1599,13 @@
1946 1599
1947 1600 return $errors;
1948 1601 }
1949 1602
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 1603 public static function route() {
1965 1604 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1966 1605 $vars = array();
1967 1606 FrmAppHelper::include_svg();
1607 +
1968 1608 if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1969 1609 FrmAppHelper::permission_check( 'frm_edit_forms' );
1970 1610
1971 1611 // Javascript needs to be allowed in some field settings.
@@ -1974,9 +1614,9 @@
1974 1614 $json_vars = json_decode( $json_vars, true );
1975 1615 if ( empty( $json_vars ) ) {
1976 1616 // json decoding failed so we should return an error message.
1977 1617 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1978 - if ( 'edit' === $action ) {
1618 + if ( 'edit' == $action ) {
1979 1619 $action = 'update';
1980 1620 }
1981 1621
1982 1622 add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
@@ -1992,14 +1632,16 @@
1992 1632 if ( isset( $_REQUEST['delete_all'] ) ) {
1993 1633 // Override the action for this page.
1994 1634 $action = 'delete_all';
1995 1635 }
1996 - }//end if
1636 + }
1997 1637
1998 1638 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1999 1639 FrmAppHelper::trigger_hook_load( 'form' );
2000 1640
2001 1641 switch ( $action ) {
1642 + case 'new':
1643 + return self::new_form( $vars );
2002 1644 case 'create':
2003 1645 case 'edit':
2004 1646 case 'update':
2005 1647 case 'trash':
@@ -2004,17 +1646,16 @@
2004 1646 case 'update':
2005 1647 case 'trash':
2006 1648 case 'untrash':
2007 1649 case 'destroy':
1650 + case 'delete_all':
2008 1651 case 'settings':
2009 1652 case 'update_settings':
2010 1653 return self::$action( $vars );
2011 1654 case 'lite-reports':
2012 - self::no_reports( $vars );
2013 - return;
1655 + return self::no_reports( $vars );
2014 1656 case 'views':
2015 - self::no_views( $vars );
2016 - return;
1657 + return self::no_views( $vars );
2017 1658 default:
2018 1659 do_action( 'frm_form_action_' . $action );
2019 1660 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
2020 1661 return;
@@ -2037,20 +1678,12 @@
2037 1678 self::display_forms_list( array(), '', array( __( 'There was a problem duplicating the form', 'formidable' ) ) );
2038 1679 return;
2039 1680 }
2040 1681
2041 - if ( 'forms_permanently_deleted' === $message ) {
2042 - $count = FrmAppHelper::get_param( 'forms_deleted', 0, 'get', 'absint' );
2043 - /* translators: %1$s: Number of forms */
2044 - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
2045 - self::display_forms_list( array(), $message, '' );
2046 - return;
2047 - }
2048 -
2049 1682 self::display_forms_list();
2050 1683
2051 1684 return;
2052 - }//end switch
1685 + }
2053 1686 }
2054 1687
2055 1688 /**
2056 1689 * Rename a form.
@@ -2069,32 +1702,12 @@
2069 1702 // Get posted data
2070 1703 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2071 1704 $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2072 1705
2073 - $form = FrmForm::getOne( $form_id );
2074 - if ( ! $form ) {
2075 - wp_send_json_error( __( 'Form not found', 'formidable' ) );
2076 - }
1706 + // Update the form name and form key.
1707 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
1708 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
2077 1709
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 1710 wp_send_json_success( compact( 'form_key' ) );
2098 1711 }
2099 1712
2100 1713 public static function json_error( $errors ) {
@@ -2103,13 +1716,20 @@
2103 1716 return $errors;
2104 1717 }
2105 1718
2106 1719 /**
1720 + * Education for premium features.
1721 + *
1722 + * @since 4.05
1723 + */
1724 + public static function add_form_style_tab_options() {
1725 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' );
1726 + }
1727 +
1728 + /**
2107 1729 * Add education about views.
2108 1730 *
2109 1731 * @since 4.07
2110 - *
2111 - * @return void
2112 1732 */
2113 1733 public static function no_views( $values = array() ) {
2114 1734 FrmAppHelper::include_svg();
2115 1735 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -2121,10 +1741,8 @@
2121 1741 /**
2122 1742 * Add education about reports.
2123 1743 *
2124 1744 * @since 4.07
2125 - *
2126 - * @return void
2127 1745 */
2128 1746 public static function no_reports( $values = array() ) {
2129 1747 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
2130 1748 $form = $id ? FrmForm::getOne( $id ) : false;
@@ -2131,11 +1749,9 @@
2131 1749
2132 1750 include FrmAppHelper::plugin_path() . '/classes/views/shared/reports-info.php';
2133 1751 }
2134 1752
2135 - /**
2136 - * FRONT-END FORMS.
2137 - */
1753 + /* FRONT-END FORMS */
2138 1754 public static function admin_bar_css() {
2139 1755 if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
2140 1756 return;
2141 1757 }
@@ -2209,9 +1825,9 @@
2209 1825 $wp_admin_bar->add_node(
2210 1826 array(
2211 1827 'parent' => 'frm-forms',
2212 1828 'id' => 'edit_form_' . $form_id,
2213 - 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name,
1829 + 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
2214 1830 'href' => FrmForm::get_edit_link( $form_id ),
2215 1831 )
2216 1832 );
2217 1833 }
@@ -2224,10 +1840,10 @@
2224 1840 * @return string
2225 1841 */
2226 1842 public static function get_form_shortcode( $atts ) {
2227 1843 global $frm_vars;
2228 - if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2229 - $sc = '[formidable';
1844 + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1845 + $sc = '[formidable';
2230 1846 $sc .= FrmAppHelper::array_to_html_params( $atts );
2231 1847 return $sc . ']';
2232 1848 }
2233 1849
@@ -2252,11 +1868,11 @@
2252 1868
2253 1869 /**
2254 1870 * @since 5.2.01
2255 1871 *
2256 - * @param false|int|string $id
2257 - * @param false|string $key
2258 - * @return false|stdClass
1872 + * @param string|int|false $id
1873 + * @param string|false $key
1874 + * @return stdClass|false
2259 1875 */
2260 1876 private static function maybe_get_form_by_id_or_key( $id, $key ) {
2261 1877 if ( ! $id ) {
2262 1878 $id = $key;
@@ -2264,12 +1880,12 @@
2264 1880 return self::maybe_get_form_to_show( $id );
2265 1881 }
2266 1882
2267 1883 /**
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.
1884 + * @param string|int|false $id
1885 + * @param string|false $key
1886 + * @param string|int|bool $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1887 + * @param string|int|bool $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2272 1888 * @param array $atts
2273 1889 * @return string
2274 1890 */
2275 1891 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
@@ -2317,16 +1933,15 @@
2317 1933 return $form;
2318 1934 }
2319 1935
2320 1936 /**
2321 - * @param false|int|string $id
2322 - * @return false|stdClass
1937 + * @param string|int|false $id
1938 + * @return stdClass|false
2323 1939 */
2324 1940 private static function maybe_get_form_to_show( $id ) {
2325 1941 $form = false;
2326 1942
2327 - if ( ! empty( $id ) ) {
2328 - // Form id or key is set.
1943 + if ( ! empty( $id ) ) { // form id or key is set
2329 1944 $form = FrmForm::getOne( $id );
2330 1945 if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) {
2331 1946 $form = false;
2332 1947 }
@@ -2384,11 +1999,11 @@
2384 1999
2385 2000 do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
2386 2001
2387 2002 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;
2003 + $entry_id = self::just_created_entry( $form->id );
2004 + $pass_args['entry_id'] = $entry_id;
2005 + $pass_args['reset'] = true;
2391 2006
2392 2007 self::run_on_submit_actions( $pass_args );
2393 2008
2394 2009 do_action(
@@ -2398,9 +2013,9 @@
2398 2013 'form' => $form,
2399 2014 )
2400 2015 );
2401 2016 }
2402 - }//end if
2017 + }
2403 2018 }
2404 2019
2405 2020 /**
2406 2021 * If the form was processed earlier (init), get the generated errors
@@ -2432,9 +2047,9 @@
2432 2047 */
2433 2048 public static function just_created_entry( $form_id ) {
2434 2049 global $frm_vars;
2435 2050
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;
2051 + 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 2052 }
2438 2053
2439 2054 /**
2440 2055 * Gets confirmation method.
@@ -2447,14 +2062,14 @@
2447 2062 *
2448 2063 * @type object $form Form object.
2449 2064 * @type int $entry_id Entry ID.
2450 2065 * }
2451 - * @return array|string
2066 + * @return string|array
2452 2067 */
2453 2068 private static function get_confirmation_method( $atts ) {
2454 2069 $action = FrmOnSubmitHelper::current_event( $atts );
2455 2070 $opt = 'update' === $action ? 'edit_action' : 'success_action';
2456 - $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2071 + $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
2457 2072
2458 2073 if ( ! empty( $atts['entry_id'] ) ) {
2459 2074 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2460 2075 if ( $met_actions ) {
@@ -2463,9 +2078,9 @@
2463 2078 }
2464 2079
2465 2080 $method = apply_filters( 'frm_success_filter', $method, $atts['form'], $action );
2466 2081
2467 - if ( $method !== 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2082 + if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2468 2083 $method = 'message';
2469 2084 }
2470 2085
2471 2086 return $method;
@@ -2499,9 +2114,9 @@
2499 2114 * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}.
2500 2115 */
2501 2116 public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) {
2502 2117 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'] ) ) {
2118 + if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) ) {
2504 2119 $event = FrmOnSubmitHelper::current_event( $params );
2505 2120 FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event );
2506 2121 $conf_method = 'redirect';
2507 2122 }
@@ -2550,9 +2165,9 @@
2550 2165 unset( $extra_args['form'] );
2551 2166
2552 2167 do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
2553 2168
2554 - $opt = ! isset( $args['action'] ) || $args['action'] === 'create' ? 'success' : 'edit';
2169 + $opt = ( ! isset( $args['action'] ) || $args['action'] === 'create' ) ? 'success' : 'edit';
2555 2170
2556 2171 $args['success_opt'] = $opt;
2557 2172 $args['ajax'] = ! empty( $frm_vars['ajax'] );
2558 2173
@@ -2578,16 +2193,16 @@
2578 2193 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
2579 2194 return array();
2580 2195 }
2581 2196
2582 - // If a redirect action has already opened the URL in a new tab, we show the default message in the current tab.
2197 + // If a redirect action has already opened the URL in a new tab, we show the default message in the currect tab.
2583 2198 if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) {
2584 2199 return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) );
2585 2200 }
2586 2201
2587 - $entry = FrmEntry::getOne( $args['entry_id'], true );
2588 - $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2589 - $met_actions = array();
2202 + $entry = FrmEntry::getOne( $args['entry_id'], true );
2203 + $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2204 + $met_actions = array();
2590 2205 $has_redirect = false;
2591 2206
2592 2207 foreach ( $actions as $action ) {
2593 2208 if ( ! in_array( $event, $action->post_content['event'], true ) ) {
@@ -2600,10 +2215,9 @@
2600 2215
2601 2216 $action_type = FrmOnSubmitHelper::get_action_type( $action );
2602 2217
2603 2218 if ( 'redirect' === $action_type ) {
2604 - if ( $has_redirect ) {
2605 - // Do not process because we run the first redirect action only.
2219 + if ( $has_redirect ) { // Do not process because we run the first redirect action only.
2606 2220 continue;
2607 2221 }
2608 2222 }
2609 2223
@@ -2616,9 +2230,9 @@
2616 2230 }
2617 2231
2618 2232 $met_actions[] = $action;
2619 2233 unset( $action );
2620 - }//end foreach
2234 + }
2621 2235
2622 2236 $args['event'] = $event;
2623 2237
2624 2238 /**
@@ -2807,9 +2421,9 @@
2807 2421 add_filter( 'the_content', 'FrmFormsController::preview_content', 9999 );
2808 2422 }
2809 2423
2810 2424 $post = $old_post;
2811 - }//end if
2425 + }
2812 2426 }
2813 2427
2814 2428 /**
2815 2429 * @since 3.0
@@ -2830,16 +2444,14 @@
2830 2444 $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args );
2831 2445
2832 2446 $doing_ajax = FrmAppHelper::doing_ajax();
2833 2447
2834 - if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) {
2835 - // Is AJAX submit and there is just one Redirect action runs.
2448 + if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) { // Is AJAX submit and there is just one Redirect action runs.
2836 2449 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
2837 2450 wp_die();
2838 2451 }
2839 2452
2840 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) {
2841 - // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2453 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) { // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2842 2454 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2843 2455 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
2844 2456 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
2845 2457 return;
@@ -2845,10 +2457,9 @@
2845 2457 return;
2846 2458 }
2847 2459
2848 2460 wp_redirect( esc_url_raw( $success_url ) );
2849 - // Do not use wp_die or redirect fails.
2850 - die();
2461 + die(); // do not use wp_die or redirect fails
2851 2462 }
2852 2463
2853 2464 // Redirect with a delay.
2854 2465 self::redirect_after_submit_using_js( $args + compact( 'success_url', 'doing_ajax' ) );
@@ -2883,46 +2494,28 @@
2883 2494 * @param array $args See {@see FrmFormsController::run_success_action()}.
2884 2495 * @return array
2885 2496 */
2886 2497 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;
2498 + $response_data = array( 'redirect' => $args['success_url'] );
2892 2499
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 2500 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2900 2501 $response_data['openInNewTab'] = 1;
2901 2502
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();
2503 + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2905 2504
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 - }
2505 + $args['form']->options['success_msg'] = $args['message'];
2506 + $args['form']->options['edit_msg'] = $args['message'];
2507 + if ( ! isset( $args['fields'] ) ) {
2508 + $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2509 + }
2911 2510
2912 - $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2511 + $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2913 2512
2914 - ob_start();
2915 - self::show_lone_success_message( $args );
2916 - $response_data['content'] .= ob_get_clean();
2917 - $unset_content = false;
2918 - }//end if
2513 + ob_start();
2514 + self::show_lone_success_messsage( $args );
2515 + $response_data['content'] = ob_get_clean();
2919 2516
2920 2517 $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 2518 }
2926 2519
2927 2520 return $response_data;
2928 2521 }
@@ -2934,9 +2527,9 @@
2934 2527 *
2935 2528 * @param array $args See {@see FrmFormsController::run_success_action()}.
2936 2529 */
2937 2530 private static function redirect_after_submit_using_js( $args ) {
2938 - $success_msg = $args['form']->options['redirect_delay_msg'];
2531 + $success_msg = FrmOnSubmitHelper::get_default_redirect_msg();
2939 2532 $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args );
2940 2533 $success_url = esc_url_raw( $args['success_url'] );
2941 2534
2942 2535 /**
@@ -2943,11 +2536,11 @@
2943 2536 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
2944 2537 *
2945 2538 * @since 6.0
2946 2539 *
2947 - * @param int $delay_time Delay time in milliseconds.
2540 + * @param int $delay_time Delay time in miliseconds.
2948 2541 */
2949 - $delay_time = apply_filters( 'frm_redirect_delay_time', 1000 * $args['form']->options['redirect_delay_time'] );
2542 + $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
2950 2543
2951 2544 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2952 2545 $redirect_js = 'window.open("' . $success_url . '", "_blank")';
2953 2546 } else {
@@ -2957,10 +2550,9 @@
2957 2550 add_filter( 'frm_use_wpautop', '__return_true' );
2958 2551
2959 2552 echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2960 2553 echo '<script>';
2961 - if ( empty( $args['doing_ajax'] ) ) {
2962 - // Not AJAX submit, delay JS until window.load.
2554 + if ( empty( $args['doing_ajax'] ) ) { // Not AJAX submit, delay JS until window.load.
2963 2555 echo 'window.onload=function(){';
2964 2556 }
2965 2557 echo 'setTimeout(function(){' . $redirect_js . '}, ' . intval( $delay_time ) . ');'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2966 2558 if ( empty( $args['doing_ajax'] ) ) {
@@ -2973,13 +2565,11 @@
2973 2565 * @since 3.0
2974 2566 *
2975 2567 * @param string $success_url
2976 2568 * @param string $success_msg
2977 - * @param array $args
2569 + * @param array $args
2978 2570 */
2979 2571 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 2572 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
2983 2573 self::get_redirect_fallback_message( $success_url, $args ) .
2984 2574 '</div></div>';
2985 2575
@@ -3035,9 +2625,9 @@
3035 2625 } else {
3036 2626 self::show_form_after_submit( $atts );
3037 2627 }
3038 2628 } else {
3039 - self::show_lone_success_message( $atts );
2629 + self::show_lone_success_messsage( $atts );
3040 2630 }
3041 2631 }
3042 2632
3043 2633 /**
@@ -3065,9 +2655,9 @@
3065 2655
3066 2656 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
3067 2657
3068 2658 $frm_settings = FrmAppHelper::get_settings();
3069 - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value;
2659 + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
3070 2660
3071 2661 global $frm_vars;
3072 2662 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
3073 2663
@@ -3076,10 +2666,11 @@
3076 2666 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
3077 2667 }
3078 2668
3079 2669 /**
2670 + * @return string - 'before', 'after', or 'submit'
2671 + *
3080 2672 * @since 4.05.02
3081 - * @return string - 'before', 'after', or 'submit'
3082 2673 */
3083 2674 private static function message_placement( $form, $message ) {
3084 2675 $place = 'before';
3085 2676
@@ -3091,10 +2682,11 @@
3091 2682 }
3092 2683 }
3093 2684
3094 2685 /**
2686 + * @return string - 'before' or 'after'
2687 + *
3095 2688 * @since 4.05.02
3096 - * @return string - 'before' or 'after'
3097 2689 */
3098 2690 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
3099 2691 }
3100 2692
@@ -3128,9 +2720,9 @@
3128 2720 * Show the success message without the form
3129 2721 *
3130 2722 * @since 2.05
3131 2723 */
3132 - private static function show_lone_success_message( $atts ) {
2724 + private static function show_lone_success_messsage( $atts ) {
3133 2725 global $frm_vars;
3134 2726 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
3135 2727 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
3136 2728
@@ -3139,9 +2731,9 @@
3139 2731 $errors = array();
3140 2732 $form = $atts['form'];
3141 2733 $message = $atts['message'];
3142 2734
3143 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
2735 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
3144 2736 }
3145 2737
3146 2738 /**
3147 2739 * Prepare the success message before it's shown
@@ -3155,12 +2747,12 @@
3155 2747 * @return string
3156 2748 */
3157 2749 private static function prepare_submit_message( $form, $entry_id, $args = array() ) {
3158 2750 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
3159 - $opt = $args['success_opt'] ?? 'success';
2751 + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
3160 2752
3161 2753 if ( $entry_id && is_numeric( $entry_id ) ) {
3162 - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg;
2754 + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
3163 2755 $class = 'frm_message';
3164 2756 } else {
3165 2757 $message = $frm_settings->failed_msg;
3166 2758 $class = FrmFormsHelper::form_error_class();
@@ -3261,13 +2853,11 @@
3261 2853 global $frm_vars;
3262 2854
3263 2855 FrmStylesController::enqueue_css();
3264 2856
3265 - if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
2857 + if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3266 2858 // load formidable js
3267 2859 wp_enqueue_script( 'formidable' );
3268 -
3269 - FrmHoneypot::maybe_print_honeypot_js();
3270 2860 }
3271 2861 }
3272 2862
3273 2863 /**
@@ -3281,12 +2871,12 @@
3281 2871 }
3282 2872
3283 2873 /**
3284 2874 * @since 2.0.8
3285 - * @return bool
2875 + * @return boolean
3286 2876 */
3287 2877 private static function is_minification_on( $atts ) {
3288 - return ! empty( $atts['minimize'] );
2878 + return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
3289 2879 }
3290 2880
3291 2881 /**
3292 2882 * @since 5.0.16
@@ -3314,9 +2904,9 @@
3314 2904 * Create a page with an embedded formidable Gutenberg block.
3315 2905 *
3316 2906 * @since 5.2
3317 2907 *
3318 - * @return void
2908 + * @return never
3319 2909 */
3320 2910 public static function create_page_with_shortcode() {
3321 2911 if ( ! current_user_can( 'publish_posts' ) ) {
3322 2912 die( 0 );
@@ -3361,9 +2951,10 @@
3361 2951
3362 2952 /**
3363 2953 * @since 5.3
3364 2954 *
3365 - * @param int $form_id
2955 + * @param string $content
2956 + * @param int $form_id
3366 2957 * @return string
3367 2958 */
3368 2959 private static function get_page_shortcode_content_for_form( $form_id ) {
3369 2960 $shortcode = '[formidable id="' . $form_id . '"]';
@@ -3374,9 +2965,9 @@
3374 2965
3375 2966 /**
3376 2967 * Get page dropdown for AJAX request for embedding form in an existing page.
3377 2968 *
3378 - * @return void
2969 + * @return never
3379 2970 */
3380 2971 public static function get_page_dropdown() {
3381 2972 if ( ! current_user_can( 'publish_posts' ) ) {
3382 2973 die( 0 );
@@ -3384,9 +2975,9 @@
3384 2975
3385 2976 check_ajax_referer( 'frm_ajax', 'nonce' );
3386 2977
3387 2978 $html = FrmAppHelper::clip(
3388 - function () {
2979 + function() {
3389 2980 FrmAppHelper::maybe_autocomplete_pages_options(
3390 2981 array(
3391 2982 'field_name' => 'frm_page_dropdown',
3392 2983 'page_id' => '',
@@ -3406,8 +2997,15 @@
3406 2997
3407 2998 /**
3408 2999 * @deprecated 4.0
3409 3000 */
3001 + public static function new_form( $values = array() ) {
3002 + FrmDeprecated::new_form( $values );
3003 + }
3004 +
3005 + /**
3006 + * @deprecated 4.0
3007 + */
3410 3008 public static function create( $values = array() ) {
3411 3009 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3412 3010 self::update( $values );
3413 3011 }
@@ -3412,16 +3010,75 @@
3412 3010 self::update( $values );
3413 3011 }
3414 3012
3415 3013 /**
3416 - * Education for premium features.
3014 + * @deprecated 3.0
3015 + * @codeCoverageIgnore
3016 + */
3017 + public static function bulk_create_template( $ids ) {
3018 + return FrmDeprecated::bulk_create_template( $ids );
3019 + }
3020 +
3021 + /**
3022 + * @deprecated 3.0
3023 + * @codeCoverageIgnore
3024 + */
3025 + public static function edit_key() {
3026 + FrmDeprecated::edit_key();
3027 + }
3028 +
3029 + /**
3030 + * @deprecated 3.0
3031 + * @codeCoverageIgnore
3032 + */
3033 + public static function edit_description() {
3034 + FrmDeprecated::edit_description();
3035 + }
3036 +
3037 + /**
3038 + * @deprecated 4.08
3039 + * @since 3.06
3040 + */
3041 + public static function add_new() {
3042 + _deprecated_function( __FUNCTION__, '4.08' );
3043 + }
3044 +
3045 + /**
3046 + * Create a custom template from a form
3417 3047 *
3418 - * @since 4.05
3419 - * @deprecated 6.16.3
3048 + * @since 3.06
3049 + * @deprecated x.x
3050 + */
3051 + public static function build_template() {
3052 + _deprecated_function( __METHOD__, 'x.x' );
3053 + }
3054 +
3055 + /**
3056 + * @deprecated x.x
3420 3057 *
3058 + * @return bool
3059 + */
3060 + public static function expired() {
3061 + _deprecated_function( __METHOD__, 'x.x' );
3062 + return FrmAddonsController::is_license_expired();
3063 + }
3064 +
3065 + /**
3066 + * Get data from api before rendering it so that we can flag the modal as expired
3067 + *
3068 + * @deprecated x.x
3069 + *
3421 3070 * @return void
3422 3071 */
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';
3072 + public static function before_list_templates() {
3073 + _deprecated_function( __METHOD__, 'x.x' );
3074 + }
3075 +
3076 + /**
3077 + * @deprecated x.x
3078 + *
3079 + * @return void
3080 + */
3081 + public static function list_templates() {
3082 + _deprecated_function( __METHOD__, 'x.x' );
3426 3083 }
3427 3084 }