PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.23
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.23
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 +787 -417 6.36.23 View file →
@@ -4,8 +4,28 @@
4 4 }
5 5
6 6 class FrmFormsController {
7 7
8 + /**
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.
11 + *
12 + * @since 6.2
13 + *
14 + * @var array Keys are form IDs and values are 1.
15 + */
16 + private static $redirected_in_new_tab = array();
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 +
8 28 public static function menu() {
9 29 $menu_label = __( 'Forms', 'formidable' );
10 30 if ( ! FrmAppHelper::pro_is_installed() ) {
11 31 $menu_label .= ' (Lite)';
@@ -44,9 +64,9 @@
44 64 */
45 65 public static function logic_tip() {
46 66 $images_url = FrmAppHelper::plugin_url() . '/images/';
47 67 $data_message = __( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' );
48 - $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' ) . '"/>';
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' ) . '"/>';
49 69 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">';
50 70 esc_html_e( 'Conditional Logic', 'formidable' );
51 71 FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown6_icon', array( 'aria-hidden' => 'true' ) );
52 72 echo '</a>';
@@ -86,15 +106,23 @@
86 106 * Create the default email action
87 107 *
88 108 * @since 2.02.11
89 109 *
90 - * @param object|int $form
110 + * @param int|object $form
111 + * @return void
91 112 */
92 113 private static function create_default_email_action( $form ) {
93 114 FrmForm::maybe_get_form( $form );
115 + if ( ! is_object( $form ) ) {
116 + return;
117 + }
118 +
94 119 $create_email = apply_filters( 'frm_create_default_email_action', true, $form );
95 120
96 121 if ( $create_email ) {
122 + /**
123 + * @var FrmFormAction
124 + */
97 125 $action_control = FrmFormActionsController::get_form_actions( 'email' );
98 126 $action_control->create( $form->id );
99 127 }
100 128 }
@@ -103,12 +131,16 @@
103 131 * Create the default On submit action
104 132 *
105 133 * @since 6.0.0
106 134 *
107 - * @param object|int $form Form object or ID.
135 + * @param int|object $form Form object or ID.
136 + * @return void
108 137 */
109 138 private static function create_default_on_submit_action( $form ) {
110 139 FrmForm::maybe_get_form( $form );
140 + if ( ! is_object( $form ) ) {
141 + return;
142 + }
111 143
112 144 /**
113 145 * Enable or disable the default On Submit action.
114 146 *
@@ -119,21 +151,65 @@
119 151 */
120 152 $create = apply_filters( 'frm_create_default_on_submit_action', true, $form );
121 153
122 154 if ( $create ) {
155 + /**
156 + * @var FrmFormAction
157 + */
123 158 $action_control = FrmFormActionsController::get_form_actions( FrmOnSubmitAction::$slug );
124 159 $action_control->create( $form->id );
125 160 }
126 161 }
127 162
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 + */
128 199 public static function edit( $values = false ) {
129 200 FrmAppHelper::permission_check( 'frm_edit_forms' );
130 201
131 202 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
132 203
133 - return self::get_edit_vars( $id );
204 + self::get_edit_vars( $id );
134 205 }
135 206
207 + /**
208 + * @param mixed $id
209 + * @param string $message
210 + * @return void
211 + */
136 212 public static function settings( $id = false, $message = '' ) {
137 213 FrmAppHelper::permission_check( 'frm_edit_forms' );
138 214
139 215 if ( ! $id || ! is_numeric( $id ) ) {
@@ -141,21 +217,34 @@
141 217 }
142 218
143 219 FrmOnSubmitHelper::maybe_migrate_submit_settings_to_action( $id );
144 220
145 - return self::get_settings_vars( $id, array(), $message );
221 + self::get_settings_vars( $id, array(), $message );
146 222 }
147 223
148 224 public static function update_settings() {
149 225 FrmAppHelper::permission_check( 'frm_edit_forms' );
226 + $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
150 227
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 +
151 239 $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
152 240
153 - $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
241 + $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
154 242 $warnings = FrmFormsHelper::check_for_warnings( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
155 243
156 244 if ( count( $errors ) > 0 ) {
157 - return self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
245 + self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
246 + return;
158 247 }
159 248
160 249 do_action( 'frm_before_update_form_settings', $id );
161 250
@@ -169,9 +258,9 @@
169 258 }
170 259
171 260 $message = __( 'Settings Successfully Updated', 'formidable' );
172 261
173 - return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
262 + self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
174 263 }
175 264
176 265 /**
177 266 * @param int $form_id
@@ -181,8 +270,11 @@
181 270 $form = FrmForm::getOne( $form_id );
182 271 return ! empty( $form->options['antispam'] );
183 272 }
184 273
274 + /**
275 + * @return void
276 + */
185 277 public static function update( $values = array() ) {
186 278 if ( empty( $values ) ) {
187 279 $values = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing
188 280 }
@@ -200,65 +292,74 @@
200 292
201 293 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
202 294
203 295 if ( count( $errors ) > 0 ) {
204 - return self::get_edit_vars( $id, $errors );
205 - } else {
206 - FrmForm::update( $id, $values );
207 - $message = __( 'Form was successfully updated.', 'formidable' );
296 + self::get_edit_vars( $id, $errors );
297 + return;
298 + }
208 299
209 - if ( self::is_too_long( $values ) ) {
210 - $message .= '<br/> ' . sprintf(
211 - /* translators: %1$s: Start link HTML, %2$s: end link HTML */
212 - __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
213 - '<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">',
214 - '</a>'
215 - );
216 - }
300 + self::maybe_remove_draft_option_from_fields( $id );
217 301
218 - if ( defined( 'DOING_AJAX' ) ) {
219 - wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
220 - }
302 + FrmForm::update( $id, $values );
303 + $message = __( 'Form was successfully updated.', 'formidable' );
221 304
222 - return self::get_edit_vars( $id, array(), $message );
305 + if ( self::is_too_long( $values ) ) {
306 + $message .= '<br/> ' . sprintf(
307 + /* translators: %1$s: Start link HTML, %2$s: end link HTML */
308 + __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
309 + '<a href="https://formidableforms.com/knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/?utm_source=WordPress&utm_medium=builder&utm_campaign=liteplugin" target="_blank" rel="noopener">',
310 + '</a>'
311 + );
223 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 );
224 319 }
225 320
226 321 /**
322 + * Remove the draft flag from any new fields from this current session.
323 + *
324 + * @since 6.8
325 + *
326 + * @param int $form_id
327 + * @return void
328 + */
329 + private static function maybe_remove_draft_option_from_fields( $form_id ) {
330 + $draft_field_ids_csv = FrmAppHelper::get_post_param( 'draft_fields', '', 'sanitize_text_field' );
331 + if ( ! $draft_field_ids_csv ) {
332 + // If the draft_fields input is empty there are no new fields in the session.
333 + return;
334 + }
335 +
336 + $draft_field_ids = array_filter( explode( ',', $draft_field_ids_csv ), 'is_numeric' );
337 + if ( ! $draft_field_ids ) {
338 + // Exit early if the draft fields input is invalid. It should be a CSV of integer values.
339 + return;
340 + }
341 +
342 + $draft_field_rows = FrmFieldsHelper::get_draft_field_results( $form_id, $draft_field_ids );
343 + foreach ( $draft_field_rows as $row ) {
344 + $row->field_options['draft'] = 0;
345 + FrmField::update( $row->id, array( 'field_options' => $row->field_options ) );
346 + }
347 + }
348 +
349 + /**
227 350 * Check if the value at the end of the form was included.
228 351 * If it's missing, it means other values at the end of the form
229 352 * were likely not saved either.
230 353 *
231 354 * @since 3.06.01
355 + *
356 + * @return bool
232 357 */
233 358 private static function is_too_long( $values ) {
234 - return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] );
359 + return empty( $values['frm_end'] );
235 360 }
236 361
237 - /**
238 - * Redirect to the url for creating from a template
239 - * Also delete the current form
240 - *
241 - * @since 2.0
242 - * @deprecated 3.06
243 - */
244 - public static function _create_from_template() {
245 - _deprecated_function( __FUNCTION__, '3.06' );
246 -
247 - FrmAppHelper::permission_check( 'frm_edit_forms' );
248 - check_ajax_referer( 'frm_ajax', 'nonce' );
249 -
250 - $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
251 - $template_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
252 -
253 - if ( $current_form ) {
254 - FrmForm::destroy( $current_form );
255 - }
256 -
257 - echo esc_url_raw( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template_id ) ) );
258 - wp_die();
259 - }
260 -
261 362 public static function duplicate() {
262 363 FrmAppHelper::permission_check( 'frm_edit_forms' );
263 364 $nonce = FrmAppHelper::simple_get( '_wpnonce' );
264 365
@@ -272,10 +373,11 @@
272 373 $url = admin_url( 'admin.php?page=formidable' );
273 374 $message = 'form_duplicate_error';
274 375
275 376 if ( $form ) {
276 - $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) );
277 - $message = 'form_duplicated';
377 + $new_template = FrmAppHelper::simple_get( 'new_template' ) ? '&new_template=true' : '';
378 + $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
379 + $message = 'form_duplicated';
278 380 }
279 381
280 382 $url .= '&message=' . $message;
281 383
@@ -283,27 +385,42 @@
283 385 exit();
284 386 }
285 387
286 388 /**
287 - * @return string
389 + * @return string|null
288 390 */
289 391 public static function page_preview() {
290 392 $params = FrmForm::list_page_params();
291 - if ( ! $params['form'] ) {
292 - return;
393 + if ( ! $params['form'] || is_numeric( $params['form'] ) ) {
394 + return null;
293 395 }
294 396
397 + self::maybe_block_preview( $params['form'] );
398 +
295 399 $form = FrmForm::getOne( $params['form'] );
296 - if ( $form ) {
297 - return self::show_form( $form->id, '', 'auto', 'auto' );
400 + if ( ! $form ) {
401 + return null;
298 402 }
403 +
404 + return self::show_form( $form->id, '', 'auto', 'auto' );
299 405 }
300 406
301 407 /**
302 408 * @since 3.0
409 + *
410 + * @return void
303 411 */
304 412 public static function show_page_preview() {
305 - echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
413 + $preview = self::page_preview();
414 + if ( is_null( $preview ) ) {
415 + wp_die(
416 + '<h1>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</h1>',
417 + '<p>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</p>',
418 + 404
419 + );
420 + }
421 +
422 + echo $preview; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
306 423 }
307 424
308 425 /**
309 426 * @return void
@@ -314,8 +431,11 @@
314 431
315 432 global $frm_vars;
316 433 $frm_vars['preview'] = true;
317 434
435 + // print_emoji_styles is deprecated.
436 + remove_action( 'wp_print_styles', 'print_emoji_styles' );
437 +
318 438 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
319 439 if ( $include_theme ) {
320 440 self::set_preview_query();
321 441 self::load_theme_preview();
@@ -350,8 +470,13 @@
350 470 return;
351 471 }
352 472
353 473 $random_page = reset( $random_page );
474 + if ( ! is_a( $random_page, 'WP_Post' ) ) {
475 + // The return type can also be int.
476 + return;
477 + }
478 +
354 479 query_posts(
355 480 array(
356 481 'post_type' => 'page',
357 482 'page_id' => $random_page->ID,
@@ -367,9 +492,9 @@
367 492 * Set the WP $post global object. Used for in-theme preview when defining a page.
368 493 *
369 494 * @since 5.5.2
370 495 *
371 - * @param WP_Post $post
496 + * @param WP_Post $page The page object.
372 497 * @return void
373 498 */
374 499 private static function set_post_global( $page ) {
375 500 global $post;
@@ -377,8 +502,10 @@
377 502 }
378 503
379 504 /**
380 505 * @since 3.0
506 + *
507 + * @return void
381 508 */
382 509 private static function load_theme_preview() {
383 510 add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
384 511 add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
@@ -387,20 +514,39 @@
387 514 add_filter( 'is_active_sidebar', '__return_false' );
388 515 FrmStylesController::enqueue_css( 'enqueue', true );
389 516
390 517 if ( false === get_template_part( 'page' ) ) {
518 + if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
519 + add_filter( 'body_class', 'FrmFormsController::preview_block_theme_body_classnames' );
520 + }
391 521 self::fallback_when_page_template_part_is_not_supported_by_theme();
392 522 }
393 523 }
394 524
395 525 /**
526 + * Add padding to the body for block themes.
527 + *
528 + * @since 6.5.2
529 + *
530 + * @param array $classes The body classes list.
531 + * @return array
532 + */
533 + public static function preview_block_theme_body_classnames( $classes ) {
534 + $classes[] = 'has-global-padding';
535 + return $classes;
536 + }
537 +
538 + /**
396 539 * Not every theme supports get_template_part( 'page' ).
397 540 * When this is not supported, false is returned, and we can handle a fallback.
541 + *
542 + * @return void
398 543 */
399 544 private static function fallback_when_page_template_part_is_not_supported_by_theme() {
400 545 if ( have_posts() ) {
401 546 the_post();
402 - get_header( '' );
547 + self::get_template( 'header' );
548 +
403 549 // add some generic class names to the container to add some natural padding to the content.
404 550 // .entry-content catches the WordPress TwentyTwenty theme.
405 551 // .container catches Customizr content.
406 552 echo '<div class="container entry-content">';
@@ -405,13 +551,58 @@
405 551 // .container catches Customizr content.
406 552 echo '<div class="container entry-content">';
407 553 the_content();
408 554 echo '</div>';
409 - get_footer();
555 +
556 + // Prevent extra unexpected forms in the footer.
557 + // For some reason this happens in the Twenty Twenty Five theme.
558 + add_filter( 'frm_filter_final_form', '__return_empty_string' );
559 +
560 + self::get_template( 'footer' );
410 561 }
411 562 }
412 563
413 564 /**
565 + * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call
566 + * and renders required html fragments calling required functions.
567 + *
568 + * @since 6.7.1
569 + * @param string $template
570 + * @return void
571 + */
572 + private static function get_template( $template ) {
573 + if ( self::should_try_getting_template( $template ) ) {
574 + call_user_func( 'get_' . $template );
575 + return;
576 + }
577 +
578 + if ( 'header' === $template ) {
579 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/header.php';
580 + return;
581 + }
582 +
583 + if ( 'footer' === $template ) {
584 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/footer.php';
585 + }
586 + }
587 +
588 + /**
589 + * Returns true if calling a template function doesn't trigger deprecation warnings.
590 + *
591 + * @since 6.7.1
592 + * @param string $template
593 + * @return bool
594 + */
595 + private static function should_try_getting_template( $template ) {
596 + $stylesheet_path = get_stylesheet_directory();
597 + $template_path = get_template_directory();
598 + $is_child_theme = $stylesheet_path !== $template_path;
599 + $template_name = $template . '.php';
600 +
601 + return file_exists( $stylesheet_path . '/' . $template_name ) || $is_child_theme && file_exists( $template_path . '/' . $template_name );
602 + }
603 +
604 + /**
414 605 * Set the page title for the theme preview page
415 606 *
416 607 * @since 3.0
417 608 */
@@ -423,11 +614,14 @@
423 614 return $title;
424 615 }
425 616
426 617 /**
427 - * Set the page title for the theme preview page
618 + * Set the page title for the theme preview page.
428 619 *
429 620 * @since 3.0
621 + *
622 + * @param string $title
623 + * @return string
430 624 */
431 625 public static function preview_title( $title ) {
432 626 return __( 'Form Preview', 'formidable' );
433 627 }
@@ -432,15 +626,20 @@
432 626 return __( 'Form Preview', 'formidable' );
433 627 }
434 628
435 629 /**
436 - * Set the page content for the theme preview page
630 + * Set the page content for the theme preview page.
437 631 *
438 632 * @since 3.0
633 + *
634 + * @param string $content
635 + * @return string
439 636 */
440 637 public static function preview_content( $content ) {
441 638 if ( in_the_loop() ) {
442 - $content = self::show_page_preview();
639 + self::show_page_preview();
640 + // Clear the content for the page we're using.
641 + $content = '';
443 642 }
444 643
445 644 return $content;
446 645 }
@@ -448,23 +647,88 @@
448 647 /**
449 648 * @since 3.0
450 649 */
451 650 private static function load_direct_preview() {
452 - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
453 -
454 651 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
455 652 if ( $key == '' ) {
456 653 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
457 654 }
458 655
656 + if ( ! $key ) {
657 + $error = __( 'Form key is missing', 'formidable' );
658 + wp_die(
659 + '<h1>' . esc_html( $error ) . '</h1>',
660 + '<p>' . esc_html( $error ) . '</p>',
661 + 404
662 + );
663 + }
664 +
665 + self::maybe_block_preview( $key );
666 +
459 667 $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
460 - if ( empty( $form ) ) {
461 - $form = FrmForm::getAll( array(), '', 1 );
668 + if ( ! $form ) {
669 + $error = __( 'Form does not exist', 'formidable' );
670 + wp_die(
671 + '<h1>' . esc_html( $error ) . '</h1>',
672 + '<p>' . esc_html( $error ) . '</p>',
673 + 404
674 + );
462 675 }
463 676
464 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
677 + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
678 +
679 + self::fix_deprecated_null_param_warning();
680 +
681 + require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
465 682 }
466 683
684 + /**
685 + * Block the form preview for the contact form by default if the user cannot view forms.
686 + * This is to prevent the contact form being exploited.
687 + * Since this form is added by default and every site uses the same key, it is too easy
688 + * to guess this form.
689 + *
690 + * @since 6.20
691 + *
692 + * @param string $form_key Form key.
693 + * @return void
694 + */
695 + public static function maybe_block_preview( $form_key ) {
696 + if ( FrmFormsHelper::should_block_preview( $form_key ) ) {
697 + $error = __( 'You do not have permission to view this form', 'formidable' );
698 + wp_die(
699 + '<h1>' . esc_html( $error ) . '</h1>',
700 + '<p>' . esc_html( $error ) . '</p>',
701 + 403
702 + );
703 + }
704 + }
705 +
706 + /**
707 + * Some themes have a null $src value.
708 + * This function adds a filter to ensure that $src is not null.
709 + * WP will call str_starts_with with the null value triggering a deprecated message otherwise.
710 + *
711 + * @since 6.10
712 + *
713 + * @return void
714 + */
715 + private static function fix_deprecated_null_param_warning() {
716 + add_filter(
717 + 'script_loader_src',
718 + /**
719 + * @param string|null $src
720 + * @return string
721 + */
722 + function ( $src ) {
723 + if ( is_null( $src ) ) {
724 + $src = '';
725 + }
726 + return $src;
727 + }
728 + );
729 + }
730 +
467 731 public static function untrash() {
468 732 self::change_form_status( 'untrash' );
469 733 }
470 734
@@ -527,14 +791,14 @@
527 791 FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
528 792
529 793 $params = FrmForm::list_page_params();
530 794
531 - //check nonce url
795 + // Check nonce url.
532 796 check_admin_referer( $status . '_form_' . $params['id'] );
533 797
534 798 $count = 0;
535 799 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
536 - $count ++;
800 + ++$count;
537 801 }
538 802
539 803 $form_type = FrmAppHelper::get_simple_request(
540 804 array(
@@ -546,9 +810,9 @@
546 810 /* translators: %1$s: Number of forms */
547 811 $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
548 812
549 813 /* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */
550 - $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>' );
814 + $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>' );
551 815
552 816 $message = $available_status[ $status ]['message'];
553 817
554 818 self::display_forms_list( $params, $message );
@@ -553,8 +817,12 @@
553 817
554 818 self::display_forms_list( $params, $message );
555 819 }
556 820
821 + /**
822 + * @param array $ids
823 + * @return string
824 + */
557 825 public static function bulk_trash( $ids ) {
558 826 FrmAppHelper::permission_check( 'frm_delete_forms' );
559 827
560 828 $count = 0;
@@ -559,12 +827,16 @@
559 827
560 828 $count = 0;
561 829 foreach ( $ids as $id ) {
562 830 if ( FrmForm::trash( $id ) ) {
563 - $count ++;
831 + ++$count;
564 832 }
565 833 }
566 834
835 + if ( ! $count ) {
836 + return '';
837 + }
838 +
567 839 $current_page = FrmAppHelper::get_simple_request(
568 840 array(
569 841 'param' => 'form_type',
570 842 'type' => 'request',
@@ -590,9 +862,9 @@
590 862 check_admin_referer( 'destroy_form_' . $params['id'] );
591 863
592 864 $count = 0;
593 865 if ( FrmForm::destroy( $params['id'] ) ) {
594 - $count ++;
866 + ++$count;
595 867 }
596 868
597 869 /* translators: %1$s: Number of forms */
598 870 $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count );
@@ -599,8 +871,12 @@
599 871
600 872 self::display_forms_list( $params, $message );
601 873 }
602 874
875 + /**
876 + * @param array $ids
877 + * @return string
878 + */
603 879 public static function bulk_destroy( $ids ) {
604 880 FrmAppHelper::permission_check( 'frm_delete_forms' );
605 881
606 882 $count = 0;
@@ -606,19 +882,24 @@
606 882 $count = 0;
607 883 foreach ( $ids as $id ) {
608 884 $d = FrmForm::destroy( $id );
609 885 if ( $d ) {
610 - $count ++;
886 + ++$count;
611 887 }
612 888 }
613 889
614 - /* translators: %1$s: Number of forms */
615 - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
890 + if ( $count ) {
891 + /* translators: %1$s: Number of forms */
892 + return sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
893 + }
616 894
617 - return $message;
895 + return '';
618 896 }
619 897
620 - private static function delete_all() {
898 + /**
899 + * @since 6.7.1 Function went from private to public.
900 + */
901 + public static function delete_all() {
621 902 // Check nonce url.
622 903 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
623 904 if ( $permission_error !== false ) {
624 905 self::display_forms_list( array(), '', array( $permission_error ) );
@@ -625,14 +906,15 @@
625 906
626 907 return;
627 908 }
628 909
629 - $count = FrmForm::scheduled_delete( time() );
910 + $count = FrmForm::scheduled_delete( time() );
911 + $url = remove_query_arg( array( 'delete_all' ) );
630 912
631 - /* translators: %1$s: Number of forms */
632 - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
913 + $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
633 914
634 - self::display_forms_list( array(), $message );
915 + wp_safe_redirect( $url );
916 + die();
635 917 }
636 918
637 919 /**
638 920 * Create a new form from the modal.
@@ -645,9 +927,9 @@
645 927
646 928 $new_values = self::get_modal_values();
647 929 $new_values['form_key'] = $new_values['name'];
648 930 $new_values['options'] = array(
649 - 'antispam' => 1,
931 + 'antispam' => 1,
650 932 'on_submit_migrated' => 1,
651 933 );
652 934
653 935 /**
@@ -666,13 +948,14 @@
666 948 * @param int $form_id
667 949 */
668 950 do_action( 'frm_build_new_form', $form_id );
669 951
952 + self::create_submit_button_field( $form_id );
670 953 self::create_default_on_submit_action( $form_id );
671 954 self::create_default_email_action( $form_id );
672 955
673 956 $response = array(
674 - 'redirect' => FrmForm::get_edit_link( $form_id ),
957 + 'redirect' => FrmForm::get_edit_link( $form_id ) . '&new_template=true',
675 958 );
676 959
677 960 echo wp_json_encode( $response );
678 961 wp_die();
@@ -678,46 +961,15 @@
678 961 wp_die();
679 962 }
680 963
681 964 /**
682 - * Create a custom template from a form
683 - *
684 - * @since 3.06
685 - */
686 - public static function build_template() {
687 - global $wpdb;
688 -
689 - FrmAppHelper::permission_check( 'frm_edit_forms' );
690 - check_ajax_referer( 'frm_ajax', 'nonce' );
691 -
692 - $form_id = FrmAppHelper::get_param( 'xml', '', 'post', 'absint' );
693 - $new_form_id = FrmForm::duplicate( $form_id, 1, true );
694 - if ( ! $new_form_id ) {
695 - $response = array(
696 - 'message' => __( 'There was an error creating a template.', 'formidable' ),
697 - );
698 - } else {
699 - $new_values = self::get_modal_values();
700 - $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $new_form_id ) );
701 - if ( $query_results ) {
702 - FrmForm::clear_form_cache();
703 - }
704 -
705 - $response = array(
706 - 'redirect' => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . $new_form_id ) . '&_wpnonce=' . wp_create_nonce(),
707 - );
708 - }
709 -
710 - echo wp_json_encode( $response );
711 - wp_die();
712 - }
713 -
714 - /**
715 965 * Before creating a new form, get the name and description from the modal.
716 966 *
717 967 * @since 4.0
968 + *
969 + * @return array<string,string>
718 970 */
719 - private static function get_modal_values() {
971 + public static function get_modal_values() {
720 972 $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
721 973 $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
722 974
723 975 return array(
@@ -730,17 +982,24 @@
730 982 * Inserts Formidable button
731 983 * Hook exists since 2.5.0
732 984 *
733 985 * @since 2.0.15
986 + *
987 + * @return void
734 988 */
735 989 public static function insert_form_button() {
736 990 if ( current_user_can( 'frm_view_forms' ) ) {
737 - FrmAppHelper::load_admin_wide_js();
738 - $menu_name = FrmAppHelper::get_menu_name();
739 - $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
740 - 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' ) . '">' .
741 - FrmAppHelper::kses( $icon, 'all' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
742 - ' ' . esc_html( $menu_name ) . '</a>';
991 + // Store the result in memory and re-use it when this function is called multiple times.
992 + // This helps speed up the form builder when there are a lot of HTML fields, where this
993 + // button is inserted once per HTML field.
994 + // In a form with 66 HTML fields, this saves 0.5 seconds on page load time, tested locally.
995 + if ( ! isset( self::$formidable_tinymce_button ) ) {
996 + FrmAppHelper::load_admin_wide_js();
997 + $menu_name = FrmAppHelper::get_menu_name();
998 + $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
999 + 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>';
1000 + }
1001 + echo self::$formidable_tinymce_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
743 1002 }
744 1003 }
745 1004
746 1005 /**
@@ -828,9 +1087,9 @@
828 1087 $form_id = $opts['form_id'];
829 1088 unset( $opts['form_id'] );
830 1089 }
831 1090
832 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
1091 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php';
833 1092
834 1093 echo '</div>';
835 1094
836 1095 wp_die();
@@ -870,8 +1129,14 @@
870 1129 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
871 1130 die();
872 1131 }
873 1132
1133 + $inbox = new FrmInbox();
1134 + $error = $inbox->check_for_error();
1135 + if ( $error ) {
1136 + $show_messages = array( $error['subject'] . '. ' . $error['message'] );
1137 + }
1138 +
874 1139 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php';
875 1140 }
876 1141
877 1142 /**
@@ -878,15 +1143,17 @@
878 1143 * @param array<string,string> $columns
879 1144 * @return array<string,string>
880 1145 */
881 1146 public static function get_columns( $columns ) {
882 - $columns['cb'] = '<input type="checkbox" />';
883 - $columns['name'] = __( 'Form Title', 'formidable' );
884 - $columns['entries'] = __( 'Entries', 'formidable' );
885 - $columns['id'] = 'ID';
886 - $columns['form_key'] = __( 'Key', 'formidable' );
887 - $columns['shortcode'] = __( 'Actions', 'formidable' );
888 - $columns['created_at'] = __( 'Date', 'formidable' );
1147 + $columns['cb'] = '<input type="checkbox" />';
1148 + $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1149 + $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1150 + $columns['id'] = 'ID';
1151 + $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1152 + if ( 'trash' !== FrmAppHelper::simple_get( 'form_type' ) ) {
1153 + $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1154 + }
1155 + $columns['created_at'] = esc_html__( 'Date', 'formidable' );
889 1156
890 1157 add_screen_option(
891 1158 'per_page',
892 1159 array(
@@ -898,8 +1165,11 @@
898 1165
899 1166 return $columns;
900 1167 }
901 1168
1169 + /**
1170 + * @return array<string,string>
1171 + */
902 1172 public static function get_sortable_columns() {
903 1173 return array(
904 1174 'id' => 'id',
905 1175 'name' => 'name',
@@ -933,9 +1203,9 @@
933 1203 return $hidden_columns;
934 1204 }
935 1205
936 1206 public static function save_per_page( $save, $option, $value ) {
937 - if ( $option == 'formidable_page_formidable_per_page' ) {
1207 + if ( $option === 'formidable_page_formidable_per_page' ) {
938 1208 $save = (int) $value;
939 1209 }
940 1210
941 1211 return $save;
@@ -941,146 +1211,49 @@
941 1211 return $save;
942 1212 }
943 1213
944 1214 /**
945 - * @return bool
946 - */
947 - public static function expired() {
948 - global $frm_expired;
949 - return $frm_expired;
950 - }
951 -
952 - /**
953 - * Get data from api before rendering it so that we can flag the modal as expired
954 - *
1215 + * @param int|string $id
1216 + * @param array $errors
1217 + * @param string $message
1218 + * @param bool $create_link
955 1219 * @return void
956 1220 */
957 - public static function before_list_templates() {
958 - global $frm_templates;
959 - global $frm_expired;
960 - global $frm_license_type;
1221 + private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1222 + global $frm_vars;
961 1223
962 - $api = new FrmFormTemplateApi();
963 - $frm_templates = $api->get_api_info();
964 - $expired = false;
965 - $license_type = '';
966 - if ( isset( $frm_templates['error'] ) ) {
967 - $error = $frm_templates['error']['message'];
968 - $error = str_replace( 'utm_medium=addons', 'utm_medium=form-templates', $error );
969 - $expired = 'expired' === $frm_templates['error']['code'];
970 - $license_type = isset( $frm_templates['error']['type'] ) ? $frm_templates['error']['type'] : '';
971 - unset( $frm_templates['error'] );
972 - }
973 -
974 - $frm_expired = $expired;
975 - $frm_license_type = $license_type;
976 - }
977 -
978 - /**
979 - * @return void
980 - */
981 - public static function list_templates() {
982 - global $frm_templates;
983 - global $frm_license_type;
984 -
985 - $templates = $frm_templates;
986 - $custom_templates = array();
987 - $templates_by_category = array();
988 -
989 - self::add_user_templates( $custom_templates );
990 -
991 - foreach ( $templates as $template ) {
992 - if ( ! isset( $template['categories'] ) ) {
993 - continue;
994 - }
995 -
996 - foreach ( $template['categories'] as $category ) {
997 - if ( ! isset( $templates_by_category[ $category ] ) ) {
998 - $templates_by_category[ $category ] = array();
999 - }
1000 -
1001 - $templates_by_category[ $category ][] = $template;
1002 - }
1003 - }
1004 - unset( $template );
1005 -
1006 - // Subcategories that are included elsewhere.
1007 - $redundant_cats = array( 'PayPal', 'Stripe', 'Twilio' );
1008 -
1009 - $categories = array_keys( $templates_by_category );
1010 - $categories = array_diff( $categories, FrmFormsHelper::ignore_template_categories() );
1011 - $categories = array_diff( $categories, $redundant_cats );
1012 - sort( $categories );
1013 -
1014 - array_walk(
1015 - $custom_templates,
1016 - function( &$template ) {
1017 - $template['custom'] = true;
1018 - }
1224 + $form = FrmForm::getOne( $id );
1225 + $error_args = array(
1226 + 'title' => __( 'You can\'t edit the form', 'formidable' ),
1227 + 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
1228 + 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
1229 + 'continue_url' => add_query_arg(
1230 + array(
1231 + 'page' => 'formidable',
1232 + )
1233 + ),
1019 1234 );
1020 -
1021 - $my_templates_translation = __( 'My Templates', 'formidable' );
1022 - $categories = array_merge( array( $my_templates_translation ), $categories );
1023 - $pricing = FrmAppHelper::admin_upgrade_link( 'form-templates' );
1024 - $license_type = $frm_license_type;
1025 - $args = compact( 'pricing', 'license_type' );
1026 - $where = apply_filters( 'frm_forms_dropdown', array(), '' );
1027 - $forms = FrmForm::get_published_forms( $where );
1028 - $view_path = FrmAppHelper::plugin_path() . '/classes/views/frm-forms/';
1029 -
1030 - $templates_by_category[ $my_templates_translation ] = $custom_templates;
1031 -
1032 - unset( $pricing, $license_type, $where );
1033 - wp_enqueue_script( 'accordion' ); // register accordion for template groups
1034 - require $view_path . 'list-templates.php';
1035 - }
1036 -
1037 - /**
1038 - * @since 4.03.01
1039 - */
1040 - private static function get_template_categories( $templates ) {
1041 - $categories = array();
1042 - foreach ( $templates as $template ) {
1043 - if ( isset( $template['categories'] ) ) {
1044 - $categories = array_merge( $categories, $template['categories'] );
1045 - }
1235 + if ( ! $form ) {
1236 + FrmAppController::show_error_modal( $error_args );
1237 + return;
1046 1238 }
1047 - $exclude_cats = FrmFormsHelper::ignore_template_categories();
1048 - $categories = array_unique( $categories );
1049 - $categories = array_diff( $categories, $exclude_cats );
1050 - sort( $categories );
1051 - return $categories;
1052 - }
1053 1239
1054 - private static function add_user_templates( &$templates ) {
1055 - $user_templates = array(
1056 - 'is_template' => 1,
1057 - 'default_template' => 0,
1058 - );
1059 - $user_templates = FrmForm::getAll( $user_templates, 'name' );
1060 - foreach ( $user_templates as $template ) {
1061 - $template = array(
1062 - 'id' => $template->id,
1063 - 'name' => $template->name,
1064 - 'key' => $template->form_key,
1065 - 'description' => $template->description,
1066 - 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template->id ) ) ),
1067 - 'released' => $template->created_at,
1068 - 'installed' => 1,
1240 + if ( 'trash' === $form->status ) {
1241 + $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
1242 + $error_args['continue_url'] = add_query_arg(
1243 + array(
1244 + 'page' => 'formidable',
1245 + '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ),
1246 + 'form_type' => 'trash',
1247 + 'frm_action' => 'untrash',
1248 + 'id' => $id,
1249 + )
1069 1250 );
1070 - array_unshift( $templates, $template );
1071 - unset( $template );
1251 + $error_args['continue_text'] = __( 'Restore form', 'formidable' );
1252 + FrmAppController::show_error_modal( $error_args );
1253 + return;
1072 1254 }
1073 - }
1074 1255
1075 - private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1076 - global $frm_vars;
1077 -
1078 - $form = FrmForm::getOne( $id );
1079 - if ( ! $form ) {
1080 - wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
1081 - }
1082 -
1083 1256 if ( $form->parent_form_id ) {
1084 1257 /* translators: %1$s: Start link HTML, %2$s: End link HTML */
1085 1258 wp_die( sprintf( esc_html__( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( FrmForm::get_edit_link( $form->parent_form_id ) ) . '">', '</a>' ) );
1086 1259 }
@@ -1091,8 +1264,9 @@
1091 1264
1092 1265 // Automatically add end section fields if they don't exist (2.0 migration).
1093 1266 $reset_fields = false;
1094 1267 FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
1268 + FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields );
1095 1269
1096 1270 if ( $reset_fields ) {
1097 1271 $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
1098 1272 }
@@ -1118,18 +1292,21 @@
1118 1292 }
1119 1293
1120 1294 self::maybe_update_form_builder_message( $message );
1121 1295
1122 - $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
1123 - $has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] );
1296 + $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1124 1297
1125 1298 if ( defined( 'DOING_AJAX' ) ) {
1126 1299 wp_die();
1127 - } else {
1128 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
1129 1300 }
1301 +
1302 + require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php';
1130 1303 }
1131 1304
1305 + /**
1306 + * @param array $fields
1307 + * @return array
1308 + */
1132 1309 public static function update_form_builder_fields( $fields, $form ) {
1133 1310 foreach ( $fields as $field ) {
1134 1311 $field->do_not_include_icons = true;
1135 1312 }
@@ -1141,13 +1318,21 @@
1141 1318 $message = __( 'Form was Successfully Copied', 'formidable' );
1142 1319 }
1143 1320 }
1144 1321
1322 + /**
1323 + * @param int|string $id
1324 + * @param array $errors
1325 + * @param array|string $args
1326 + * @return void
1327 + */
1145 1328 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1146 1329 FrmAppHelper::permission_check( 'frm_edit_forms' );
1147 1330
1148 1331 global $frm_vars;
1149 1332
1333 + self::maybe_print_media_templates();
1334 +
1150 1335 if ( ! is_array( $args ) ) {
1151 1336 // For reverse compatibility.
1152 1337 $args = array(
1153 1338 'message' => $args,
@@ -1180,17 +1365,38 @@
1180 1365
1181 1366 $sections = self::get_settings_tabs( $values );
1182 1367 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' );
1183 1368
1184 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
1369 + require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php';
1185 1370 }
1186 1371
1187 1372 /**
1373 + * 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.
1374 + *
1375 + * @since 6.10
1376 + *
1377 + * @return void
1378 + */
1379 + private static function maybe_print_media_templates() {
1380 + if ( FrmAppHelper::pro_is_included() ) {
1381 + // This issue does not exist when Pro is active so exit early.
1382 + return;
1383 + }
1384 +
1385 + add_action(
1386 + 'wp_enqueue_editor',
1387 + function () {
1388 + wp_print_media_templates();
1389 + }
1390 + );
1391 + }
1392 +
1393 + /**
1188 1394 * @since 4.0
1189 1395 */
1190 1396 public static function form_publish_button( $atts ) {
1191 1397 $values = $atts['values'];
1192 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
1398 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
1193 1399 }
1194 1400
1195 1401 /**
1196 1402 * Get a list of all the settings tabs for the form settings page.
@@ -1215,9 +1421,9 @@
1215 1421 'icon' => 'frm_icon_font frm_mail_bulk_icon',
1216 1422 ),
1217 1423 'permissions' => array(
1218 1424 'name' => __( 'Form Permissions', 'formidable' ),
1219 - 'icon' => 'frm_icon_font frm_lock_icon',
1425 + 'icon' => 'frm_icon_font frm_lock_closed_icon',
1220 1426 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1221 1427 'data' => array(
1222 1428 'medium' => 'permissions',
1223 1429 'upgrade' => __( 'Form Permissions', 'formidable' ),
@@ -1224,9 +1430,9 @@
1224 1430 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1225 1431 'screenshot' => 'permissions.png',
1226 1432 ),
1227 1433 ),
1228 - 'scheduling' => array(
1434 + 'scheduling' => array(
1229 1435 'name' => __( 'Form Scheduling', 'formidable' ),
1230 1436 'icon' => 'frm_icon_font frm_calendar_icon',
1231 1437 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1232 1438 'data' => array(
@@ -1259,8 +1465,21 @@
1259 1465 'screenshot' => 'chat.png',
1260 1466 )
1261 1467 ),
1262 1468 ),
1469 + 'abandonment' => array(
1470 + 'name' => __( 'Form Abandonment', 'formidable' ),
1471 + 'icon' => 'frm_icon_font frm_abandoned_icon',
1472 + 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1473 + 'data' => FrmAppHelper::get_upgrade_data_params(
1474 + 'abandonment',
1475 + array(
1476 + 'upgrade' => __( 'Form abandonment settings', 'formidable' ),
1477 + 'message' => __( 'Unlock the power of data capture to boost lead generation and master the art of form optimization.', 'formidable' ),
1478 + 'screenshot' => 'abandonment.png',
1479 + )
1480 + ),
1481 + ),
1263 1482 'html' => array(
1264 1483 'name' => __( 'Customize HTML', 'formidable' ),
1265 1484 'class' => __CLASS__,
1266 1485 'function' => 'html_settings',
@@ -1267,9 +1486,13 @@
1267 1486 'icon' => 'frm_icon_font frm_code_icon',
1268 1487 ),
1269 1488 );
1270 1489
1271 - foreach ( array( 'landing', 'chat' ) as $feature ) {
1490 + if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1491 + unset( $sections['buttons'] );
1492 + }
1493 +
1494 + foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1272 1495 if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1273 1496 unset( $sections[ $feature ] );
1274 1497 }
1275 1498 }
@@ -1275,13 +1498,8 @@
1275 1498 }
1276 1499
1277 1500 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1278 1501
1279 - if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
1280 - // Prevent settings from showing in 2 spots.
1281 - unset( $sections['permissions'], $sections['scheduling'] );
1282 - }
1283 -
1284 1502 foreach ( $sections as $key => $section ) {
1285 1503 $defaults = array(
1286 1504 'html_class' => '',
1287 1505 'name' => ucfirst( $key ),
@@ -1303,9 +1521,9 @@
1303 1521 $section['id'] = $section['anchor'];
1304 1522 }
1305 1523
1306 1524 $sections[ $key ] = $section;
1307 - }
1525 + }//end foreach
1308 1526
1309 1527 return $sections;
1310 1528 }
1311 1529
@@ -1312,8 +1530,9 @@
1312 1530 /**
1313 1531 * @since 4.0
1314 1532 *
1315 1533 * @param array $values
1534 + * @return void
1316 1535 */
1317 1536 public static function advanced_settings( $values ) {
1318 1537 $first_h3 = 'frm_first_h3';
1319 1538
@@ -1321,14 +1540,15 @@
1321 1540 }
1322 1541
1323 1542 /**
1324 1543 * @param array $values
1544 + * @return void
1325 1545 */
1326 1546 public static function render_spam_settings( $values ) {
1327 1547 if ( function_exists( 'akismet_http_post' ) ) {
1328 1548 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
1329 1549 }
1330 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/honeypot.php';
1550 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/stopforumspam.php';
1331 1551 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php';
1332 1552 }
1333 1553
1334 1554 /**
@@ -1334,16 +1554,12 @@
1334 1554 /**
1335 1555 * @since 4.0
1336 1556 *
1337 1557 * @param array $values
1558 + * @return void
1338 1559 */
1339 1560 public static function buttons_settings( $values ) {
1340 - $styles = apply_filters( 'frm_get_style_opts', array() );
1341 -
1342 - $frm_settings = FrmAppHelper::get_settings();
1343 - $no_global_style = $frm_settings->load_style === 'none';
1344 -
1345 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php' );
1561 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
1346 1562 }
1347 1563
1348 1564 /**
1349 1565 * @since 4.0
@@ -1348,11 +1564,12 @@
1348 1564 /**
1349 1565 * @since 4.0
1350 1566 *
1351 1567 * @param array $values
1568 + * @return void
1352 1569 */
1353 1570 public static function html_settings( $values ) {
1354 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' );
1571 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
1355 1572 }
1356 1573
1357 1574 /**
1358 1575 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -1358,9 +1575,10 @@
1358 1575 * Replace old Submit Button href with new href to avoid errors in Chrome
1359 1576 *
1360 1577 * @since 2.03.08
1361 1578 *
1362 - * @param array|boolean $values
1579 + * @param array|bool $values
1580 + * @return void
1363 1581 */
1364 1582 private static function clean_submit_html( &$values ) {
1365 1583 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
1366 1584 $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
@@ -1381,8 +1599,13 @@
1381 1599
1382 1600 return $classes;
1383 1601 }
1384 1602
1603 + /**
1604 + * @param int|string $form_id
1605 + * @param string $class
1606 + * @return void
1607 + */
1385 1608 public static function mb_tags_box( $form_id, $class = '' ) {
1386 1609 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1387 1610
1388 1611 /**
@@ -1395,9 +1618,9 @@
1395 1618 */
1396 1619 $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) );
1397 1620 $linked_forms = array();
1398 1621 $col = 'one';
1399 - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
1622 + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' );
1400 1623
1401 1624 $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
1402 1625 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1403 1626
@@ -1402,9 +1625,9 @@
1402 1625 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1403 1626
1404 1627 $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
1405 1628
1406 - include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
1629 + include FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php';
1407 1630 }
1408 1631
1409 1632 /**
1410 1633 * @since 3.04.01
@@ -1417,9 +1640,9 @@
1417 1640 ),
1418 1641 );
1419 1642
1420 1643 $user_fields = self::user_shortcodes();
1421 - if ( ! empty( $user_fields ) ) {
1644 + if ( $user_fields ) {
1422 1645 $user_helpers = array();
1423 1646 foreach ( $user_fields as $uk => $uf ) {
1424 1647 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1425 1648 unset( $uk, $uf );
@@ -1425,9 +1648,9 @@
1425 1648 unset( $uk, $uf );
1426 1649 }
1427 1650
1428 1651 $advanced_helpers['user_id'] = array(
1429 - 'codes' => $user_helpers,
1652 + 'codes' => $user_helpers,
1430 1653 );
1431 1654 }
1432 1655
1433 1656 /**
@@ -1504,21 +1727,16 @@
1504 1727 'updated-at' => __( 'Entry updated', 'formidable' ),
1505 1728 '' => '',
1506 1729 'siteurl' => __( 'Site URL', 'formidable' ),
1507 1730 'sitename' => __( 'Site Name', 'formidable' ),
1731 + 'form_name' => __( 'Form Name', 'formidable' ),
1508 1732 );
1509 1733
1734 + $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1510 1735 if ( ! FrmAppHelper::pro_is_installed() ) {
1511 1736 unset( $entry_shortcodes['post_id'] );
1512 1737 }
1513 1738
1514 - if ( $settings_tab ) {
1515 - $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1516 - $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1517 - $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1518 - $entry_shortcodes['form_name'] = __( 'Form Name', 'formidable' );
1519 - }
1520 -
1521 1739 /**
1522 1740 * Use this hook to add or remove buttons in the helpers section
1523 1741 * in the customization panel
1524 1742 *
@@ -1544,9 +1762,9 @@
1544 1762 echo ' frm_js_validate ';
1545 1763 self::add_js_validate_form_to_global_vars( $form );
1546 1764 }
1547 1765
1548 - if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) {
1766 + if ( FrmForm::is_ajax_on( $form ) ) {
1549 1767 echo ' frm_ajax_submit ';
1550 1768 }
1551 1769 }
1552 1770
@@ -1568,11 +1786,11 @@
1568 1786 check_ajax_referer( 'frm_ajax', 'nonce' );
1569 1787
1570 1788 echo FrmEntriesController::show_entry_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1571 1789 array(
1572 - 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
1790 + 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1573 1791 'default_email' => true,
1574 - 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
1792 + 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1575 1793 )
1576 1794 );
1577 1795 wp_die();
1578 1796 }
@@ -1578,10 +1796,10 @@
1578 1796 }
1579 1797
1580 1798 /**
1581 1799 * @param string $content
1582 - * @param stdClass|string|int $form
1583 - * @param stdClass|string|int|false $entry
1800 + * @param int|stdClass|string $form
1801 + * @param false|int|stdClass|string $entry
1584 1802 * @return string
1585 1803 */
1586 1804 public static function filter_content( $content, $form, $entry = false ) {
1587 1805 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1594,8 +1812,16 @@
1594 1812 if ( is_object( $form ) ) {
1595 1813 $form = $form->id;
1596 1814 }
1597 1815
1816 + /*
1817 + * Repeater actions adds `parent_entry` to `$entry` store the parent entry data. If `parent_entry` is not empty,
1818 + * use the parent form ID instead of repeater form ID to fix the parent form field shortcodes doesn't work.
1819 + */
1820 + if ( ! empty( $entry->parent_entry ) ) {
1821 + $form = $entry->parent_entry->form_id;
1822 + }
1823 +
1598 1824 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1599 1825 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1600 1826
1601 1827 return $content;
@@ -1605,13 +1831,17 @@
1605 1831 * Replace any [form_name] shortcodes in a string.
1606 1832 *
1607 1833 * @since 5.5
1608 1834 *
1609 - * @param string $string
1610 - * @param stdClass|string|int $form
1611 - * @return string
1835 + * @param array|string $string
1836 + * @param int|stdClass|string $form
1837 + * @return array|string
1612 1838 */
1613 1839 public static function replace_form_name_shortcodes( $string, $form ) {
1840 + if ( ! is_string( $string ) ) {
1841 + return $string;
1842 + }
1843 +
1614 1844 if ( false === strpos( $string, '[form_name]' ) ) {
1615 1845 return $string;
1616 1846 }
1617 1847
@@ -1623,9 +1853,9 @@
1623 1853 return str_replace( '[form_name]', $form_name, $string );
1624 1854 }
1625 1855
1626 1856 /**
1627 - * @param stdClass|string|int|false $entry
1857 + * @param false|int|stdClass|string $entry
1628 1858 * @return void
1629 1859 */
1630 1860 private static function get_entry_by_param( &$entry ) {
1631 1861 if ( ! $entry || ! is_object( $entry ) ) {
@@ -1640,8 +1870,12 @@
1640 1870 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1641 1871 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1642 1872 }
1643 1873
1874 + /**
1875 + * @param array $errors
1876 + * @return array
1877 + */
1644 1878 public static function process_bulk_form_actions( $errors ) {
1645 1879 if ( ! $_REQUEST ) {
1646 1880 return $errors;
1647 1881 }
@@ -1685,9 +1919,9 @@
1685 1919 case 'untrash':
1686 1920 $message = self::bulk_untrash( $ids );
1687 1921 }
1688 1922
1689 - if ( isset( $message ) && ! empty( $message ) ) {
1923 + if ( ! empty( $message ) ) {
1690 1924 $errors['message'] = $message;
1691 1925 }
1692 1926
1693 1927 return $errors;
@@ -1692,13 +1926,26 @@
1692 1926
1693 1927 return $errors;
1694 1928 }
1695 1929
1930 + /**
1931 + * Includes html that shows a message when the device is too small to use Formidable Forms admin pages.
1932 + *
1933 + * @since 6.20
1934 + * @return void
1935 + */
1936 + public static function include_device_too_small_message() {
1937 + if ( ! FrmAppHelper::is_formidable_admin() ) {
1938 + return;
1939 + }
1940 +
1941 + include FrmAppHelper::plugin_path() . '/classes/views/shared/small-device-message.php';
1942 + }
1943 +
1696 1944 public static function route() {
1697 1945 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1698 1946 $vars = array();
1699 1947 FrmAppHelper::include_svg();
1700 -
1701 1948 if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1702 1949 FrmAppHelper::permission_check( 'frm_edit_forms' );
1703 1950
1704 1951 // Javascript needs to be allowed in some field settings.
@@ -1707,9 +1954,9 @@
1707 1954 $json_vars = json_decode( $json_vars, true );
1708 1955 if ( empty( $json_vars ) ) {
1709 1956 // json decoding failed so we should return an error message.
1710 1957 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1711 - if ( 'edit' == $action ) {
1958 + if ( 'edit' === $action ) {
1712 1959 $action = 'update';
1713 1960 }
1714 1961
1715 1962 add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
@@ -1725,16 +1972,14 @@
1725 1972 if ( isset( $_REQUEST['delete_all'] ) ) {
1726 1973 // Override the action for this page.
1727 1974 $action = 'delete_all';
1728 1975 }
1729 - }
1976 + }//end if
1730 1977
1731 1978 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1732 1979 FrmAppHelper::trigger_hook_load( 'form' );
1733 1980
1734 1981 switch ( $action ) {
1735 - case 'new':
1736 - return self::new_form( $vars );
1737 1982 case 'create':
1738 1983 case 'edit':
1739 1984 case 'update':
1740 1985 case 'trash':
@@ -1739,16 +1984,17 @@
1739 1984 case 'update':
1740 1985 case 'trash':
1741 1986 case 'untrash':
1742 1987 case 'destroy':
1743 - case 'delete_all':
1744 1988 case 'settings':
1745 1989 case 'update_settings':
1746 1990 return self::$action( $vars );
1747 1991 case 'lite-reports':
1748 - return self::no_reports( $vars );
1992 + self::no_reports( $vars );
1993 + return;
1749 1994 case 'views':
1750 - return self::no_views( $vars );
1995 + self::no_views( $vars );
1996 + return;
1751 1997 default:
1752 1998 do_action( 'frm_form_action_' . $action );
1753 1999 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
1754 2000 return;
@@ -1771,14 +2017,47 @@
1771 2017 self::display_forms_list( array(), '', array( __( 'There was a problem duplicating the form', 'formidable' ) ) );
1772 2018 return;
1773 2019 }
1774 2020
2021 + if ( 'forms_permanently_deleted' === $message ) {
2022 + $count = FrmAppHelper::get_param( 'forms_deleted', 0, 'get', 'absint' );
2023 + /* translators: %1$s: Number of forms */
2024 + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
2025 + self::display_forms_list( array(), $message, '' );
2026 + return;
2027 + }
2028 +
1775 2029 self::display_forms_list();
1776 2030
1777 2031 return;
1778 - }
2032 + }//end switch
1779 2033 }
1780 2034
2035 + /**
2036 + * Rename a form.
2037 + *
2038 + * Handles the AJAX request for renaming a form.
2039 + *
2040 + * @since 6.7
2041 + *
2042 + * @return void
2043 + */
2044 + public static function rename_form() {
2045 + // Check permission and nonce
2046 + FrmAppHelper::permission_check( 'frm_edit_forms' );
2047 + check_ajax_referer( 'frm_ajax', 'nonce' );
2048 +
2049 + // Get posted data
2050 + $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2051 + $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2052 +
2053 + // Update the form name and form key.
2054 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
2055 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
2056 +
2057 + wp_send_json_success( compact( 'form_key' ) );
2058 + }
2059 +
1781 2060 public static function json_error( $errors ) {
1782 2061 $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1783 2062
1784 2063 return $errors;
@@ -1784,20 +2063,13 @@
1784 2063 return $errors;
1785 2064 }
1786 2065
1787 2066 /**
1788 - * Education for premium features.
1789 - *
1790 - * @since 4.05
1791 - */
1792 - public static function add_form_style_tab_options() {
1793 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' );
1794 - }
1795 -
1796 - /**
1797 2067 * Add education about views.
1798 2068 *
1799 2069 * @since 4.07
2070 + *
2071 + * @return void
1800 2072 */
1801 2073 public static function no_views( $values = array() ) {
1802 2074 FrmAppHelper::include_svg();
1803 2075 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -1809,8 +2081,10 @@
1809 2081 /**
1810 2082 * Add education about reports.
1811 2083 *
1812 2084 * @since 4.07
2085 + *
2086 + * @return void
1813 2087 */
1814 2088 public static function no_reports( $values = array() ) {
1815 2089 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
1816 2090 $form = $id ? FrmForm::getOne( $id ) : false;
@@ -1817,9 +2091,11 @@
1817 2091
1818 2092 include FrmAppHelper::plugin_path() . '/classes/views/shared/reports-info.php';
1819 2093 }
1820 2094
1821 - /* FRONT-END FORMS */
2095 + /**
2096 + * FRONT-END FORMS.
2097 + */
1822 2098 public static function admin_bar_css() {
1823 2099 if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
1824 2100 return;
1825 2101 }
@@ -1893,9 +2169,9 @@
1893 2169 $wp_admin_bar->add_node(
1894 2170 array(
1895 2171 'parent' => 'frm-forms',
1896 2172 'id' => 'edit_form_' . $form_id,
1897 - 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
2173 + 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name,
1898 2174 'href' => FrmForm::get_edit_link( $form_id ),
1899 2175 )
1900 2176 );
1901 2177 }
@@ -1908,10 +2184,10 @@
1908 2184 * @return string
1909 2185 */
1910 2186 public static function get_form_shortcode( $atts ) {
1911 2187 global $frm_vars;
1912 - if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1913 - $sc = '[formidable';
2188 + if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2189 + $sc = '[formidable';
1914 2190 $sc .= FrmAppHelper::array_to_html_params( $atts );
1915 2191 return $sc . ']';
1916 2192 }
1917 2193
@@ -1936,11 +2212,11 @@
1936 2212
1937 2213 /**
1938 2214 * @since 5.2.01
1939 2215 *
1940 - * @param string|int|false $id
1941 - * @param string|false $key
1942 - * @return stdClass|false
2216 + * @param false|int|string $id
2217 + * @param false|string $key
2218 + * @return false|stdClass
1943 2219 */
1944 2220 private static function maybe_get_form_by_id_or_key( $id, $key ) {
1945 2221 if ( ! $id ) {
1946 2222 $id = $key;
@@ -1948,12 +2224,12 @@
1948 2224 return self::maybe_get_form_to_show( $id );
1949 2225 }
1950 2226
1951 2227 /**
1952 - * @param string|int|false $id
1953 - * @param string|false $key
1954 - * @param string|int|bool $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1955 - * @param string|int|bool $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2228 + * @param false|int|string $id
2229 + * @param false|string $key
2230 + * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2231 + * @param bool|int|string $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1956 2232 * @param array $atts
1957 2233 * @return string
1958 2234 */
1959 2235 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
@@ -2001,15 +2277,16 @@
2001 2277 return $form;
2002 2278 }
2003 2279
2004 2280 /**
2005 - * @param string|int|false $id
2006 - * @return stdClass|false
2281 + * @param false|int|string $id
2282 + * @return false|stdClass
2007 2283 */
2008 2284 private static function maybe_get_form_to_show( $id ) {
2009 2285 $form = false;
2010 2286
2011 - if ( ! empty( $id ) ) { // form id or key is set
2287 + if ( ! empty( $id ) ) {
2288 + // Form id or key is set.
2012 2289 $form = FrmForm::getOne( $id );
2013 2290 if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) {
2014 2291 $form = false;
2015 2292 }
@@ -2067,11 +2344,11 @@
2067 2344
2068 2345 do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
2069 2346
2070 2347 if ( apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
2071 - $entry_id = self::just_created_entry( $form->id );
2072 - $pass_args['entry_id'] = $entry_id;
2073 - $pass_args['reset'] = true;
2348 + $entry_id = self::just_created_entry( $form->id );
2349 + $pass_args['entry_id'] = $entry_id;
2350 + $pass_args['reset'] = true;
2074 2351
2075 2352 self::run_on_submit_actions( $pass_args );
2076 2353
2077 2354 do_action(
@@ -2081,9 +2358,9 @@
2081 2358 'form' => $form,
2082 2359 )
2083 2360 );
2084 2361 }
2085 - }
2362 + }//end if
2086 2363 }
2087 2364
2088 2365 /**
2089 2366 * If the form was processed earlier (init), get the generated errors
@@ -2115,9 +2392,9 @@
2115 2392 */
2116 2393 public static function just_created_entry( $form_id ) {
2117 2394 global $frm_vars;
2118 2395
2119 - 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;
2396 + 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;
2120 2397 }
2121 2398
2122 2399 /**
2123 2400 * Gets confirmation method.
@@ -2130,14 +2407,14 @@
2130 2407 *
2131 2408 * @type object $form Form object.
2132 2409 * @type int $entry_id Entry ID.
2133 2410 * }
2134 - * @return string|array
2411 + * @return array|string
2135 2412 */
2136 2413 private static function get_confirmation_method( $atts ) {
2137 2414 $action = FrmOnSubmitHelper::current_event( $atts );
2138 2415 $opt = 'update' === $action ? 'edit_action' : 'success_action';
2139 - $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
2416 + $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2140 2417
2141 2418 if ( ! empty( $atts['entry_id'] ) ) {
2142 2419 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2143 2420 if ( $met_actions ) {
@@ -2146,9 +2423,9 @@
2146 2423 }
2147 2424
2148 2425 $method = apply_filters( 'frm_success_filter', $method, $atts['form'], $action );
2149 2426
2150 - if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2427 + if ( $method !== 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2151 2428 $method = 'message';
2152 2429 }
2153 2430
2154 2431 return $method;
@@ -2182,9 +2459,9 @@
2182 2459 * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}.
2183 2460 */
2184 2461 public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) {
2185 2462 if ( is_array( $conf_method ) && 1 === count( $conf_method ) ) {
2186 - if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) ) {
2463 + if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) && empty( $conf_method[0]->post_content['redirect_delay'] ) ) {
2187 2464 $event = FrmOnSubmitHelper::current_event( $params );
2188 2465 FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event );
2189 2466 $conf_method = 'redirect';
2190 2467 }
@@ -2233,9 +2510,9 @@
2233 2510 unset( $extra_args['form'] );
2234 2511
2235 2512 do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
2236 2513
2237 - $opt = ( ! isset( $args['action'] ) || $args['action'] === 'create' ) ? 'success' : 'edit';
2514 + $opt = ! isset( $args['action'] ) || $args['action'] === 'create' ? 'success' : 'edit';
2238 2515
2239 2516 $args['success_opt'] = $opt;
2240 2517 $args['ajax'] = ! empty( $frm_vars['ajax'] );
2241 2518
@@ -2261,11 +2538,16 @@
2261 2538 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
2262 2539 return array();
2263 2540 }
2264 2541
2265 - $entry = FrmEntry::getOne( $args['entry_id'], true );
2266 - $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2267 - $met_actions = array();
2542 + // If a redirect action has already opened the URL in a new tab, we show the default message in the current tab.
2543 + if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) {
2544 + return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) );
2545 + }
2546 +
2547 + $entry = FrmEntry::getOne( $args['entry_id'], true );
2548 + $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2549 + $met_actions = array();
2268 2550 $has_redirect = false;
2269 2551
2270 2552 foreach ( $actions as $action ) {
2271 2553 if ( ! in_array( $event, $action->post_content['event'], true ) ) {
@@ -2278,9 +2560,10 @@
2278 2560
2279 2561 $action_type = FrmOnSubmitHelper::get_action_type( $action );
2280 2562
2281 2563 if ( 'redirect' === $action_type ) {
2282 - if ( $has_redirect ) { // Do not process because we run the first redirect action only.
2564 + if ( $has_redirect ) {
2565 + // Do not process because we run the first redirect action only.
2283 2566 continue;
2284 2567 }
2285 2568 }
2286 2569
@@ -2293,9 +2576,9 @@
2293 2576 }
2294 2577
2295 2578 $met_actions[] = $action;
2296 2579 unset( $action );
2297 - }
2580 + }//end foreach
2298 2581
2299 2582 $args['event'] = $event;
2300 2583
2301 2584 /**
@@ -2484,9 +2767,9 @@
2484 2767 add_filter( 'the_content', 'FrmFormsController::preview_content', 9999 );
2485 2768 }
2486 2769
2487 2770 $post = $old_post;
2488 - }
2771 + }//end if
2489 2772 }
2490 2773
2491 2774 /**
2492 2775 * @since 3.0
@@ -2507,16 +2790,25 @@
2507 2790 $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args );
2508 2791
2509 2792 $doing_ajax = FrmAppHelper::doing_ajax();
2510 2793
2511 - if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) { // Is AJAX submit and there is just one Redirect action runs.
2512 - echo json_encode( array( 'redirect' => $success_url ) );
2794 + if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) {
2795 + // Is AJAX submit and there is just one Redirect action runs.
2796 + echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
2513 2797 wp_die();
2514 2798 }
2515 2799
2516 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) { // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2800 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) {
2801 + // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2802 + if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2803 + self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
2804 + self::$redirected_in_new_tab[ $args['form']->id ] = 1;
2805 + return;
2806 + }
2807 +
2517 2808 wp_redirect( esc_url_raw( $success_url ) );
2518 - die(); // do not use wp_die or redirect fails
2809 + // Do not use wp_die or redirect fails.
2810 + die();
2519 2811 }
2520 2812
2521 2813 // Redirect with a delay.
2522 2814 self::redirect_after_submit_using_js( $args + compact( 'success_url', 'doing_ajax' ) );
@@ -2522,8 +2814,81 @@
2522 2814 self::redirect_after_submit_using_js( $args + compact( 'success_url', 'doing_ajax' ) );
2523 2815 }
2524 2816
2525 2817 /**
2818 + * Prints open in new tab js with fallback handler.
2819 + *
2820 + * @since 6.3.1
2821 + *
2822 + * @param string $success_url Success URL.
2823 + * @param array $args See {@see FrmFormsController::redirect_after_submit()}.
2824 + */
2825 + private static function print_open_in_new_tab_js_with_fallback_handler( $success_url, $args ) {
2826 + echo '<script>var newTab = window.open("' . esc_url_raw( $success_url ) . '", "_blank");';
2827 + echo 'if ( ! newTab ) {';
2828 +
2829 + $data = array(
2830 + 'formId' => intval( $args['form']->id ),
2831 + 'message' => self::get_redirect_fallback_message( $success_url, $args ),
2832 + );
2833 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2834 + echo 'frmShowNewTabFallback = ' . FrmAppHelper::maybe_json_encode( $data ) . ';';
2835 + echo '}</script>';
2836 + }
2837 +
2838 + /**
2839 + * Gets response data for redirect action when AJAX submitting.
2840 + *
2841 + * @since 6.3.1
2842 + *
2843 + * @param array $args See {@see FrmFormsController::run_success_action()}.
2844 + * @return array
2845 + */
2846 + private static function get_ajax_redirect_response_data( $args ) {
2847 + $response_data = array(
2848 + 'redirect' => $args['success_url'],
2849 + 'content' => '',
2850 + );
2851 + $unset_content = true;
2852 +
2853 + if ( ! empty( $args['form']->options['redirect_delay'] ) ) {
2854 + $response_data['delay'] = $args['form']->options['redirect_delay_time'];
2855 + $response_data['content'] .= self::get_redirect_message( $args['success_url'], $args['form']->options['redirect_delay_msg'], $args );
2856 + $unset_content = false;
2857 + }
2858 +
2859 + if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2860 + $response_data['openInNewTab'] = 1;
2861 +
2862 + // Only show open in new tab text if there is no delay.
2863 + if ( empty( $response_data['content'] ) ) {
2864 + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2865 +
2866 + $args['form']->options['success_msg'] = $args['message'];
2867 + $args['form']->options['edit_msg'] = $args['message'];
2868 + if ( ! isset( $args['fields'] ) ) {
2869 + $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2870 + }
2871 +
2872 + $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2873 +
2874 + ob_start();
2875 + self::show_lone_success_message( $args );
2876 + $response_data['content'] .= ob_get_clean();
2877 + $unset_content = false;
2878 + }//end if
2879 +
2880 + $response_data['fallbackMsg'] = self::get_redirect_fallback_message( $args['success_url'], $args );
2881 + }//end if
2882 +
2883 + if ( $unset_content && '' === $response_data['content'] ) {
2884 + unset( $response_data['content'] );
2885 + }
2886 +
2887 + return $response_data;
2888 + }
2889 +
2890 + /**
2526 2891 * Redirects after submitting using JS. This is used when showing message before redirecting.
2527 2892 *
2528 2893 * @since 6.0
2529 2894 *
@@ -2529,10 +2894,11 @@
2529 2894 *
2530 2895 * @param array $args See {@see FrmFormsController::run_success_action()}.
2531 2896 */
2532 2897 private static function redirect_after_submit_using_js( $args ) {
2533 - $success_msg = FrmOnSubmitHelper::get_default_redirect_msg();
2898 + $success_msg = $args['form']->options['redirect_delay_msg'];
2534 2899 $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args );
2900 + $success_url = esc_url_raw( $args['success_url'] );
2535 2901
2536 2902 /**
2537 2903 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
2538 2904 *
@@ -2537,20 +2903,27 @@
2537 2903 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
2538 2904 *
2539 2905 * @since 6.0
2540 2906 *
2541 - * @param int $delay_time Delay time in miliseconds.
2907 + * @param int $delay_time Delay time in milliseconds.
2542 2908 */
2543 - $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
2909 + $delay_time = apply_filters( 'frm_redirect_delay_time', 1000 * $args['form']->options['redirect_delay_time'] );
2544 2910
2911 + if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2912 + $redirect_js = 'window.open("' . $success_url . '", "_blank")';
2913 + } else {
2914 + $redirect_js = 'window.location="' . $success_url . '";';
2915 + }
2916 +
2545 2917 add_filter( 'frm_use_wpautop', '__return_true' );
2546 2918
2547 2919 echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2548 2920 echo '<script>';
2549 - if ( empty( $args['doing_ajax'] ) ) { // Not AJAX submit, delay JS until window.load.
2921 + if ( empty( $args['doing_ajax'] ) ) {
2922 + // Not AJAX submit, delay JS until window.load.
2550 2923 echo 'window.onload=function(){';
2551 2924 }
2552 - echo 'setTimeout(function(){window.location="' . esc_url_raw( $args['success_url'] ) . '";}, ' . intval( $delay_time ) . ');';
2925 + echo 'setTimeout(function(){' . $redirect_js . '}, ' . intval( $delay_time ) . ');'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2553 2926 if ( empty( $args['doing_ajax'] ) ) {
2554 2927 echo '};';
2555 2928 }
2556 2929 echo '</script>';
@@ -2560,14 +2933,15 @@
2560 2933 * @since 3.0
2561 2934 *
2562 2935 * @param string $success_url
2563 2936 * @param string $success_msg
2564 - * @param array $args
2937 + * @param array $args
2565 2938 */
2566 2939 private static function get_redirect_message( $success_url, $success_msg, $args ) {
2940 + $success_msg = apply_filters( 'frm_content', $success_msg, $args['form'], $args['entry_id'] );
2941 + $success_msg = do_shortcode( FrmAppHelper::use_wpautop( $success_msg ) );
2567 2942 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
2568 - /* translators: %1$s: Start link HTML, %2$s: End link HTML */
2569 - sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>' ) .
2943 + self::get_redirect_fallback_message( $success_url, $args ) .
2570 2944 '</div></div>';
2571 2945
2572 2946 $redirect_args = array(
2573 2947 'entry_id' => $args['entry_id'],
@@ -2578,8 +2952,31 @@
2578 2952 return apply_filters( 'frm_redirect_msg', $redirect_msg, $redirect_args );
2579 2953 }
2580 2954
2581 2955 /**
2956 + * Gets fallback message when redirecting failed.
2957 + *
2958 + * @since 6.3.1
2959 + *
2960 + * @param string $success_url Redirect URL.
2961 + * @param array $args Contains `form` object.
2962 + * @return string
2963 + */
2964 + private static function get_redirect_fallback_message( $success_url, $args ) {
2965 + $target = '';
2966 + if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2967 + $target = ' target="_blank"';
2968 + }
2969 +
2970 + return sprintf(
2971 + /* translators: %1$s: Start link HTML, %2$s: End link HTML */
2972 + __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ),
2973 + '<a href="' . esc_url( $success_url ) . '"' . $target . '>',
2974 + '</a>'
2975 + );
2976 + }
2977 +
2978 + /**
2582 2979 * Prepare to show the success message and empty form after submit
2583 2980 *
2584 2981 * @since 2.05
2585 2982 */
@@ -2598,9 +2995,9 @@
2598 2995 } else {
2599 2996 self::show_form_after_submit( $atts );
2600 2997 }
2601 2998 } else {
2602 - self::show_lone_success_messsage( $atts );
2999 + self::show_lone_success_message( $atts );
2603 3000 }
2604 3001 }
2605 3002
2606 3003 /**
@@ -2639,11 +3036,10 @@
2639 3036 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
2640 3037 }
2641 3038
2642 3039 /**
3040 + * @since 4.05.02
2643 3041 * @return string - 'before', 'after', or 'submit'
2644 - *
2645 - * @since 4.05.02
2646 3042 */
2647 3043 private static function message_placement( $form, $message ) {
2648 3044 $place = 'before';
2649 3045
@@ -2655,11 +3051,10 @@
2655 3051 }
2656 3052 }
2657 3053
2658 3054 /**
3055 + * @since 4.05.02
2659 3056 * @return string - 'before' or 'after'
2660 - *
2661 - * @since 4.05.02
2662 3057 */
2663 3058 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
2664 3059 }
2665 3060
@@ -2693,9 +3088,9 @@
2693 3088 * Show the success message without the form
2694 3089 *
2695 3090 * @since 2.05
2696 3091 */
2697 - private static function show_lone_success_messsage( $atts ) {
3092 + private static function show_lone_success_message( $atts ) {
2698 3093 global $frm_vars;
2699 3094 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
2700 3095 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
2701 3096
@@ -2704,9 +3099,9 @@
2704 3099 $errors = array();
2705 3100 $form = $atts['form'];
2706 3101 $message = $atts['message'];
2707 3102
2708 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
3103 + include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
2709 3104 }
2710 3105
2711 3106 /**
2712 3107 * Prepare the success message before it's shown
@@ -2826,11 +3221,13 @@
2826 3221 global $frm_vars;
2827 3222
2828 3223 FrmStylesController::enqueue_css();
2829 3224
2830 - if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3225 + if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
2831 3226 // load formidable js
2832 3227 wp_enqueue_script( 'formidable' );
3228 +
3229 + FrmHoneypot::maybe_print_honeypot_js();
2833 3230 }
2834 3231 }
2835 3232
2836 3233 /**
@@ -2844,12 +3241,12 @@
2844 3241 }
2845 3242
2846 3243 /**
2847 3244 * @since 2.0.8
2848 - * @return boolean
3245 + * @return bool
2849 3246 */
2850 3247 private static function is_minification_on( $atts ) {
2851 - return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
3248 + return ! empty( $atts['minimize'] );
2852 3249 }
2853 3250
2854 3251 /**
2855 3252 * @since 5.0.16
@@ -2877,9 +3274,9 @@
2877 3274 * Create a page with an embedded formidable Gutenberg block.
2878 3275 *
2879 3276 * @since 5.2
2880 3277 *
2881 - * @return never
3278 + * @return void
2882 3279 */
2883 3280 public static function create_page_with_shortcode() {
2884 3281 if ( ! current_user_can( 'publish_posts' ) ) {
2885 3282 die( 0 );
@@ -2924,10 +3321,9 @@
2924 3321
2925 3322 /**
2926 3323 * @since 5.3
2927 3324 *
2928 - * @param string $content
2929 - * @param int $form_id
3325 + * @param int $form_id
2930 3326 * @return string
2931 3327 */
2932 3328 private static function get_page_shortcode_content_for_form( $form_id ) {
2933 3329 $shortcode = '[formidable id="' . $form_id . '"]';
@@ -2938,9 +3334,9 @@
2938 3334
2939 3335 /**
2940 3336 * Get page dropdown for AJAX request for embedding form in an existing page.
2941 3337 *
2942 - * @return never
3338 + * @return void
2943 3339 */
2944 3340 public static function get_page_dropdown() {
2945 3341 if ( ! current_user_can( 'publish_posts' ) ) {
2946 3342 die( 0 );
@@ -2948,9 +3344,9 @@
2948 3344
2949 3345 check_ajax_referer( 'frm_ajax', 'nonce' );
2950 3346
2951 3347 $html = FrmAppHelper::clip(
2952 - function() {
3348 + function () {
2953 3349 FrmAppHelper::maybe_autocomplete_pages_options(
2954 3350 array(
2955 3351 'field_name' => 'frm_page_dropdown',
2956 3352 'page_id' => '',
@@ -2970,15 +3366,8 @@
2970 3366
2971 3367 /**
2972 3368 * @deprecated 4.0
2973 3369 */
2974 - public static function new_form( $values = array() ) {
2975 - FrmDeprecated::new_form( $values );
2976 - }
2977 -
2978 - /**
2979 - * @deprecated 4.0
2980 - */
2981 3370 public static function create( $values = array() ) {
2982 3371 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
2983 3372 self::update( $values );
2984 3373 }
@@ -2983,35 +3372,16 @@
2983 3372 self::update( $values );
2984 3373 }
2985 3374
2986 3375 /**
2987 - * @deprecated 3.0
2988 - * @codeCoverageIgnore
3376 + * Education for premium features.
3377 + *
3378 + * @since 4.05
3379 + * @deprecated 6.16.3
3380 + *
3381 + * @return void
2989 3382 */
2990 - public static function bulk_create_template( $ids ) {
2991 - return FrmDeprecated::bulk_create_template( $ids );
2992 - }
2993 -
2994 - /**
2995 - * @deprecated 3.0
2996 - * @codeCoverageIgnore
2997 - */
2998 - public static function edit_key() {
2999 - FrmDeprecated::edit_key();
3000 - }
3001 -
3002 - /**
3003 - * @deprecated 3.0
3004 - * @codeCoverageIgnore
3005 - */
3006 - public static function edit_description() {
3007 - FrmDeprecated::edit_description();
3008 - }
3009 -
3010 - /**
3011 - * @deprecated 4.08
3012 - * @since 3.06
3013 - */
3014 - public static function add_new() {
3015 - _deprecated_function( __FUNCTION__, '4.08' );
3383 + public static function add_form_style_tab_options() {
3384 + _deprecated_function( __METHOD__, '6.16.3' );
3385 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php';
3016 3386 }
3017 3387 }