PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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 +502 -380 6.5.36.13 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 currect tab.
10 + * message in the current tab.
11 11 *
12 12 * @since 6.2
13 13 *
14 14 * @var array Keys are form IDs and values are 1.
@@ -14,8 +14,18 @@
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 +
18 28 public static function menu() {
19 29 $menu_label = __( 'Forms', 'formidable' );
20 30 if ( ! FrmAppHelper::pro_is_installed() ) {
21 31 $menu_label .= ' (Lite)';
@@ -54,9 +64,9 @@
54 64 */
55 65 public static function logic_tip() {
56 66 $images_url = FrmAppHelper::plugin_url() . '/images/';
57 67 $data_message = __( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', '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' ) . '"/>';
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' ) . '"/>';
59 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">';
60 70 esc_html_e( 'Conditional Logic', 'formidable' );
61 71 FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown6_icon', array( 'aria-hidden' => 'true' ) );
62 72 echo '</a>';
@@ -96,9 +106,9 @@
96 106 * Create the default email action
97 107 *
98 108 * @since 2.02.11
99 109 *
100 - * @param object|int $form
110 + * @param int|object $form
101 111 */
102 112 private static function create_default_email_action( $form ) {
103 113 FrmForm::maybe_get_form( $form );
104 114 $create_email = apply_filters( 'frm_create_default_email_action', true, $form );
@@ -113,9 +123,9 @@
113 123 * Create the default On submit action
114 124 *
115 125 * @since 6.0.0
116 126 *
117 - * @param object|int $form Form object or ID.
127 + * @param int|object $form Form object or ID.
118 128 */
119 129 private static function create_default_on_submit_action( $form ) {
120 130 FrmForm::maybe_get_form( $form );
121 131
@@ -134,16 +144,53 @@
134 144 $action_control->create( $form->id );
135 145 }
136 146 }
137 147
148 + /**
149 + * Creates submit button field.
150 + *
151 + * @since 6.9
152 + *
153 + * @param int|object $form Form ID or object.
154 + */
155 + private static function create_submit_button_field( $form ) {
156 + FrmForm::maybe_get_form( $form );
157 +
158 + if ( FrmSubmitHelper::get_submit_field( $form->id ) ) {
159 + // Do not create submit button field if it exists.
160 + return;
161 + }
162 +
163 + FrmField::create(
164 + array(
165 + 'type' => FrmSubmitHelper::FIELD_TYPE,
166 + 'name' => __( 'Submit', 'formidable' ),
167 + 'field_order' => 9999,
168 + 'form_id' => $form->id,
169 + 'field_options' => FrmFieldsHelper::get_default_field_options( FrmSubmitHelper::FIELD_TYPE ),
170 + 'description' => '',
171 + 'default_value' => '',
172 + 'options' => array(),
173 + )
174 + );
175 + }
176 +
177 + /**
178 + * @return void
179 + */
138 180 public static function edit( $values = false ) {
139 181 FrmAppHelper::permission_check( 'frm_edit_forms' );
140 182
141 183 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
142 184
143 - return self::get_edit_vars( $id );
185 + self::get_edit_vars( $id );
144 186 }
145 187
188 + /**
189 + * @param mixed $id
190 + * @param string $message
191 + * @return void
192 + */
146 193 public static function settings( $id = false, $message = '' ) {
147 194 FrmAppHelper::permission_check( 'frm_edit_forms' );
148 195
149 196 if ( ! $id || ! is_numeric( $id ) ) {
@@ -151,21 +198,34 @@
151 198 }
152 199
153 200 FrmOnSubmitHelper::maybe_migrate_submit_settings_to_action( $id );
154 201
155 - return self::get_settings_vars( $id, array(), $message );
202 + self::get_settings_vars( $id, array(), $message );
156 203 }
157 204
158 205 public static function update_settings() {
159 206 FrmAppHelper::permission_check( 'frm_edit_forms' );
207 + $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
160 208
209 + if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
210 + $frm_settings = FrmAppHelper::get_settings();
211 + $error_args = array(
212 + 'title' => __( 'Verification failed', 'formidable' ),
213 + 'body' => $frm_settings->admin_permission,
214 + 'cancel_text' => __( 'Cancel', 'formidable' ),
215 + );
216 + FrmAppController::show_error_modal( $error_args );
217 + return;
218 + }
219 +
161 220 $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
162 221
163 - $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
222 + $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
164 223 $warnings = FrmFormsHelper::check_for_warnings( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
165 224
166 225 if ( count( $errors ) > 0 ) {
167 - return self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
226 + self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
227 + return;
168 228 }
169 229
170 230 do_action( 'frm_before_update_form_settings', $id );
171 231
@@ -179,9 +239,9 @@
179 239 }
180 240
181 241 $message = __( 'Settings Successfully Updated', 'formidable' );
182 242
183 - return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
243 + self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
184 244 }
185 245
186 246 /**
187 247 * @param int $form_id
@@ -191,8 +251,11 @@
191 251 $form = FrmForm::getOne( $form_id );
192 252 return ! empty( $form->options['antispam'] );
193 253 }
194 254
255 + /**
256 + * @return void
257 + */
195 258 public static function update( $values = array() ) {
196 259 if ( empty( $values ) ) {
197 260 $values = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing
198 261 }
@@ -210,65 +273,74 @@
210 273
211 274 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
212 275
213 276 if ( count( $errors ) > 0 ) {
214 - return self::get_edit_vars( $id, $errors );
215 - } else {
216 - FrmForm::update( $id, $values );
217 - $message = __( 'Form was successfully updated.', 'formidable' );
277 + self::get_edit_vars( $id, $errors );
278 + return;
279 + }
218 280
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 - }
281 + self::maybe_remove_draft_option_from_fields( $id );
227 282
228 - if ( defined( 'DOING_AJAX' ) ) {
229 - wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
230 - }
283 + FrmForm::update( $id, $values );
284 + $message = __( 'Form was successfully updated.', 'formidable' );
231 285
232 - return self::get_edit_vars( $id, array(), $message );
286 + if ( self::is_too_long( $values ) ) {
287 + $message .= '<br/> ' . sprintf(
288 + /* translators: %1$s: Start link HTML, %2$s: end link HTML */
289 + __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
290 + '<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">',
291 + '</a>'
292 + );
233 293 }
294 +
295 + if ( defined( 'DOING_AJAX' ) ) {
296 + wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
297 + }
298 +
299 + self::get_edit_vars( $id, array(), $message );
234 300 }
235 301
236 302 /**
303 + * Remove the draft flag from any new fields from this current session.
304 + *
305 + * @since 6.8
306 + *
307 + * @param int $form_id
308 + * @return void
309 + */
310 + private static function maybe_remove_draft_option_from_fields( $form_id ) {
311 + $draft_field_ids_csv = FrmAppHelper::get_post_param( 'draft_fields', '', 'sanitize_text_field' );
312 + if ( ! $draft_field_ids_csv ) {
313 + // If the draft_fields input is empty there are no new fields in the session.
314 + return;
315 + }
316 +
317 + $draft_field_ids = array_filter( explode( ',', $draft_field_ids_csv ), 'is_numeric' );
318 + if ( ! $draft_field_ids ) {
319 + // Exit early if the draft fields input is invalid. It should be a CSV of integer values.
320 + return;
321 + }
322 +
323 + $draft_field_rows = FrmFieldsHelper::get_draft_field_results( $form_id, $draft_field_ids );
324 + foreach ( $draft_field_rows as $row ) {
325 + $row->field_options['draft'] = 0;
326 + FrmField::update( $row->id, array( 'field_options' => $row->field_options ) );
327 + }
328 + }
329 +
330 + /**
237 331 * Check if the value at the end of the form was included.
238 332 * If it's missing, it means other values at the end of the form
239 333 * were likely not saved either.
240 334 *
241 335 * @since 3.06.01
336 + *
337 + * @return bool
242 338 */
243 339 private static function is_too_long( $values ) {
244 - return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] );
340 + return empty( $values['frm_end'] );
245 341 }
246 342
247 - /**
248 - * Redirect to the url for creating from a template
249 - * Also delete the current form
250 - *
251 - * @since 2.0
252 - * @deprecated 3.06
253 - */
254 - public static function _create_from_template() {
255 - _deprecated_function( __FUNCTION__, '3.06' );
256 -
257 - FrmAppHelper::permission_check( 'frm_edit_forms' );
258 - check_ajax_referer( 'frm_ajax', 'nonce' );
259 -
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 );
265 - }
266 -
267 - echo esc_url_raw( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template_id ) ) );
268 - wp_die();
269 - }
270 -
271 343 public static function duplicate() {
272 344 FrmAppHelper::permission_check( 'frm_edit_forms' );
273 345 $nonce = FrmAppHelper::simple_get( '_wpnonce' );
274 346
@@ -282,10 +354,11 @@
282 354 $url = admin_url( 'admin.php?page=formidable' );
283 355 $message = 'form_duplicate_error';
284 356
285 357 if ( $form ) {
286 - $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) );
287 - $message = 'form_duplicated';
358 + $new_template = FrmAppHelper::simple_get( 'new_template' ) ? '&new_template=true' : '';
359 + $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
360 + $message = 'form_duplicated';
288 361 }
289 362
290 363 $url .= '&message=' . $message;
291 364
@@ -293,24 +366,28 @@
293 366 exit();
294 367 }
295 368
296 369 /**
297 - * @return string
370 + * @return string|null
298 371 */
299 372 public static function page_preview() {
300 373 $params = FrmForm::list_page_params();
301 374 if ( ! $params['form'] ) {
302 - return;
375 + return null;
303 376 }
304 377
305 378 $form = FrmForm::getOne( $params['form'] );
306 - if ( $form ) {
307 - return self::show_form( $form->id, '', 'auto', 'auto' );
379 + if ( ! $form ) {
380 + return null;
308 381 }
382 +
383 + return self::show_form( $form->id, '', 'auto', 'auto' );
309 384 }
310 385
311 386 /**
312 387 * @since 3.0
388 + *
389 + * @return void
313 390 */
314 391 public static function show_page_preview() {
315 392 echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
316 393 }
@@ -360,8 +437,13 @@
360 437 return;
361 438 }
362 439
363 440 $random_page = reset( $random_page );
441 + if ( ! is_a( $random_page, 'WP_Post' ) ) {
442 + // The return type can also be int.
443 + return;
444 + }
445 +
364 446 query_posts(
365 447 array(
366 448 'post_type' => 'page',
367 449 'page_id' => $random_page->ID,
@@ -377,9 +459,9 @@
377 459 * Set the WP $post global object. Used for in-theme preview when defining a page.
378 460 *
379 461 * @since 5.5.2
380 462 *
381 - * @param WP_Post $post
463 + * @param WP_Post $page The page object.
382 464 * @return void
383 465 */
384 466 private static function set_post_global( $page ) {
385 467 global $post;
@@ -387,8 +469,10 @@
387 469 }
388 470
389 471 /**
390 472 * @since 3.0
473 + *
474 + * @return void
391 475 */
392 476 private static function load_theme_preview() {
393 477 add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
394 478 add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
@@ -420,13 +504,16 @@
420 504
421 505 /**
422 506 * Not every theme supports get_template_part( 'page' ).
423 507 * When this is not supported, false is returned, and we can handle a fallback.
508 + *
509 + * @return void
424 510 */
425 511 private static function fallback_when_page_template_part_is_not_supported_by_theme() {
426 512 if ( have_posts() ) {
427 513 the_post();
428 - get_header( '' );
514 + self::get_template( 'header' );
515 +
429 516 // add some generic class names to the container to add some natural padding to the content.
430 517 // .entry-content catches the WordPress TwentyTwenty theme.
431 518 // .container catches Customizr content.
432 519 echo '<div class="container entry-content">';
@@ -431,13 +518,54 @@
431 518 // .container catches Customizr content.
432 519 echo '<div class="container entry-content">';
433 520 the_content();
434 521 echo '</div>';
435 - get_footer();
522 +
523 + self::get_template( 'footer' );
436 524 }
437 525 }
438 526
439 527 /**
528 + * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call
529 + * and renders required html fragments calling required functions.
530 + *
531 + * @since 6.7.1
532 + * @param string $template
533 + * @return void
534 + */
535 + private static function get_template( $template ) {
536 + if ( self::should_try_getting_template( $template ) ) {
537 + call_user_func( 'get_' . $template );
538 + return;
539 + }
540 +
541 + if ( 'header' === $template ) {
542 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/header.php';
543 + return;
544 + }
545 +
546 + if ( 'footer' === $template ) {
547 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/footer.php';
548 + }
549 + }
550 +
551 + /**
552 + * Returns true if calling a template function doesn't trigger deprecation warnings.
553 + *
554 + * @since 6.7.1
555 + * @param string $template
556 + * @return bool
557 + */
558 + private static function should_try_getting_template( $template ) {
559 + $stylesheet_path = get_stylesheet_directory();
560 + $template_path = get_template_directory();
561 + $is_child_theme = $stylesheet_path !== $template_path;
562 + $template_name = $template . '.php';
563 +
564 + return file_exists( $stylesheet_path . '/' . $template_name ) || $is_child_theme && file_exists( $template_path . '/' . $template_name );
565 + }
566 +
567 + /**
440 568 * Set the page title for the theme preview page
441 569 *
442 570 * @since 3.0
443 571 */
@@ -449,11 +577,14 @@
449 577 return $title;
450 578 }
451 579
452 580 /**
453 - * Set the page title for the theme preview page
581 + * Set the page title for the theme preview page.
454 582 *
455 583 * @since 3.0
584 + *
585 + * @param string $title
586 + * @return string
456 587 */
457 588 public static function preview_title( $title ) {
458 589 return __( 'Form Preview', 'formidable' );
459 590 }
@@ -458,15 +589,20 @@
458 589 return __( 'Form Preview', 'formidable' );
459 590 }
460 591
461 592 /**
462 - * Set the page content for the theme preview page
593 + * Set the page content for the theme preview page.
463 594 *
464 595 * @since 3.0
596 + *
597 + * @param string $content
598 + * @return string
465 599 */
466 600 public static function preview_content( $content ) {
467 601 if ( in_the_loop() ) {
468 - $content = self::show_page_preview();
602 + self::show_page_preview();
603 + // Clear the content for the page we're using.
604 + $content = '';
469 605 }
470 606
471 607 return $content;
472 608 }
@@ -476,8 +612,11 @@
476 612 */
477 613 private static function load_direct_preview() {
478 614 header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
479 615
616 + // print_emoji_styles is deprecated.
617 + remove_action( 'wp_print_styles', 'print_emoji_styles' );
618 +
480 619 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
481 620 if ( $key == '' ) {
482 621 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
483 622 }
@@ -486,11 +625,38 @@
486 625 if ( empty( $form ) ) {
487 626 $form = FrmForm::getAll( array(), '', 1 );
488 627 }
489 628
490 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
629 + self::fix_deprecated_null_param_warning();
630 +
631 + require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
491 632 }
492 633
634 + /**
635 + * Some themes have a null $src value.
636 + * This function adds a filter to ensure that $src is not null.
637 + * WP will call str_starts_with with the null value triggering a deprecated message otherwise.
638 + *
639 + * @since 6.10
640 + *
641 + * @return void
642 + */
643 + private static function fix_deprecated_null_param_warning() {
644 + add_filter(
645 + 'script_loader_src',
646 + /**
647 + * @param string|null $src
648 + * @return string
649 + */
650 + function ( $src ) {
651 + if ( is_null( $src ) ) {
652 + $src = '';
653 + }
654 + return $src;
655 + }
656 + );
657 + }
658 +
493 659 public static function untrash() {
494 660 self::change_form_status( 'untrash' );
495 661 }
496 662
@@ -553,14 +719,14 @@
553 719 FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
554 720
555 721 $params = FrmForm::list_page_params();
556 722
557 - //check nonce url
723 + // Check nonce url.
558 724 check_admin_referer( $status . '_form_' . $params['id'] );
559 725
560 726 $count = 0;
561 727 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
562 - $count ++;
728 + ++$count;
563 729 }
564 730
565 731 $form_type = FrmAppHelper::get_simple_request(
566 732 array(
@@ -572,9 +738,9 @@
572 738 /* translators: %1$s: Number of forms */
573 739 $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
574 740
575 741 /* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */
576 - $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>' );
742 + $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 743
578 744 $message = $available_status[ $status ]['message'];
579 745
580 746 self::display_forms_list( $params, $message );
@@ -579,8 +745,12 @@
579 745
580 746 self::display_forms_list( $params, $message );
581 747 }
582 748
749 + /**
750 + * @param array $ids
751 + * @return string
752 + */
583 753 public static function bulk_trash( $ids ) {
584 754 FrmAppHelper::permission_check( 'frm_delete_forms' );
585 755
586 756 $count = 0;
@@ -585,9 +755,9 @@
585 755
586 756 $count = 0;
587 757 foreach ( $ids as $id ) {
588 758 if ( FrmForm::trash( $id ) ) {
589 - $count ++;
759 + ++$count;
590 760 }
591 761 }
592 762
593 763 $current_page = FrmAppHelper::get_simple_request(
@@ -616,9 +786,9 @@
616 786 check_admin_referer( 'destroy_form_' . $params['id'] );
617 787
618 788 $count = 0;
619 789 if ( FrmForm::destroy( $params['id'] ) ) {
620 - $count ++;
790 + ++$count;
621 791 }
622 792
623 793 /* translators: %1$s: Number of forms */
624 794 $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count );
@@ -625,8 +795,12 @@
625 795
626 796 self::display_forms_list( $params, $message );
627 797 }
628 798
799 + /**
800 + * @param array $ids
801 + * @return string
802 + */
629 803 public static function bulk_destroy( $ids ) {
630 804 FrmAppHelper::permission_check( 'frm_delete_forms' );
631 805
632 806 $count = 0;
@@ -632,19 +806,24 @@
632 806 $count = 0;
633 807 foreach ( $ids as $id ) {
634 808 $d = FrmForm::destroy( $id );
635 809 if ( $d ) {
636 - $count ++;
810 + ++$count;
637 811 }
638 812 }
639 813
640 - /* translators: %1$s: Number of forms */
641 - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
814 + if ( $count ) {
815 + /* translators: %1$s: Number of forms */
816 + return sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
817 + }
642 818
643 - return $message;
819 + return '';
644 820 }
645 821
646 - private static function delete_all() {
822 + /**
823 + * @since 6.7.1 Function went from private to public.
824 + */
825 + public static function delete_all() {
647 826 // Check nonce url.
648 827 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
649 828 if ( $permission_error !== false ) {
650 829 self::display_forms_list( array(), '', array( $permission_error ) );
@@ -651,14 +830,15 @@
651 830
652 831 return;
653 832 }
654 833
655 - $count = FrmForm::scheduled_delete( time() );
834 + $count = FrmForm::scheduled_delete( time() );
835 + $url = remove_query_arg( array( 'delete_all' ) );
656 836
657 - /* translators: %1$s: Number of forms */
658 - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
837 + $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
659 838
660 - self::display_forms_list( array(), $message );
839 + wp_safe_redirect( $url );
840 + die();
661 841 }
662 842
663 843 /**
664 844 * Create a new form from the modal.
@@ -671,9 +851,9 @@
671 851
672 852 $new_values = self::get_modal_values();
673 853 $new_values['form_key'] = $new_values['name'];
674 854 $new_values['options'] = array(
675 - 'antispam' => 1,
855 + 'antispam' => 1,
676 856 'on_submit_migrated' => 1,
677 857 );
678 858
679 859 /**
@@ -692,13 +872,14 @@
692 872 * @param int $form_id
693 873 */
694 874 do_action( 'frm_build_new_form', $form_id );
695 875
876 + self::create_submit_button_field( $form_id );
696 877 self::create_default_on_submit_action( $form_id );
697 878 self::create_default_email_action( $form_id );
698 879
699 880 $response = array(
700 - 'redirect' => FrmForm::get_edit_link( $form_id ),
881 + 'redirect' => FrmForm::get_edit_link( $form_id ) . '&new_template=true',
701 882 );
702 883
703 884 echo wp_json_encode( $response );
704 885 wp_die();
@@ -704,46 +885,15 @@
704 885 wp_die();
705 886 }
706 887
707 888 /**
708 - * Create a custom template from a form
709 - *
710 - * @since 3.06
711 - */
712 - public static function build_template() {
713 - global $wpdb;
714 -
715 - FrmAppHelper::permission_check( 'frm_edit_forms' );
716 - check_ajax_referer( 'frm_ajax', 'nonce' );
717 -
718 - $form_id = FrmAppHelper::get_param( 'xml', '', 'post', 'absint' );
719 - $new_form_id = FrmForm::duplicate( $form_id, 1, true );
720 - if ( ! $new_form_id ) {
721 - $response = array(
722 - 'message' => __( 'There was an error creating a template.', 'formidable' ),
723 - );
724 - } else {
725 - $new_values = self::get_modal_values();
726 - $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $new_form_id ) );
727 - if ( $query_results ) {
728 - FrmForm::clear_form_cache();
729 - }
730 -
731 - $response = array(
732 - 'redirect' => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . $new_form_id ) . '&_wpnonce=' . wp_create_nonce(),
733 - );
734 - }
735 -
736 - echo wp_json_encode( $response );
737 - wp_die();
738 - }
739 -
740 - /**
741 889 * Before creating a new form, get the name and description from the modal.
742 890 *
743 891 * @since 4.0
892 + *
893 + * @return array<string,string>
744 894 */
745 - private static function get_modal_values() {
895 + public static function get_modal_values() {
746 896 $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
747 897 $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
748 898
749 899 return array(
@@ -756,17 +906,24 @@
756 906 * Inserts Formidable button
757 907 * Hook exists since 2.5.0
758 908 *
759 909 * @since 2.0.15
910 + *
911 + * @return void
760 912 */
761 913 public static function insert_form_button() {
762 914 if ( current_user_can( 'frm_view_forms' ) ) {
763 - FrmAppHelper::load_admin_wide_js();
764 - $menu_name = FrmAppHelper::get_menu_name();
765 - $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
766 - 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' ) . '">' .
767 - FrmAppHelper::kses( $icon, 'all' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
768 - ' ' . esc_html( $menu_name ) . '</a>';
915 + // Store the result in memory and re-use it when this function is called multiple times.
916 + // This helps speed up the form builder when there are a lot of HTML fields, where this
917 + // button is inserted once per HTML field.
918 + // In a form with 66 HTML fields, this saves 0.5 seconds on page load time, tested locally.
919 + if ( ! isset( self::$formidable_tinymce_button ) ) {
920 + FrmAppHelper::load_admin_wide_js();
921 + $menu_name = FrmAppHelper::get_menu_name();
922 + $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
923 + 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>';
924 + }
925 + echo self::$formidable_tinymce_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
769 926 }
770 927 }
771 928
772 929 /**
@@ -854,9 +1011,9 @@
854 1011 $form_id = $opts['form_id'];
855 1012 unset( $opts['form_id'] );
856 1013 }
857 1014
858 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
1015 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php';
859 1016
860 1017 echo '</div>';
861 1018
862 1019 wp_die();
@@ -924,8 +1081,11 @@
924 1081
925 1082 return $columns;
926 1083 }
927 1084
1085 + /**
1086 + * @return array<string,string>
1087 + */
928 1088 public static function get_sortable_columns() {
929 1089 return array(
930 1090 'id' => 'id',
931 1091 'name' => 'name',
@@ -959,9 +1119,9 @@
959 1119 return $hidden_columns;
960 1120 }
961 1121
962 1122 public static function save_per_page( $save, $option, $value ) {
963 - if ( $option == 'formidable_page_formidable_per_page' ) {
1123 + if ( $option === 'formidable_page_formidable_per_page' ) {
964 1124 $save = (int) $value;
965 1125 }
966 1126
967 1127 return $save;
@@ -967,146 +1127,49 @@
967 1127 return $save;
968 1128 }
969 1129
970 1130 /**
971 - * @return bool
972 - */
973 - public static function expired() {
974 - global $frm_expired;
975 - return $frm_expired;
976 - }
977 -
978 - /**
979 - * Get data from api before rendering it so that we can flag the modal as expired
980 - *
1131 + * @param int|string $id
1132 + * @param array $errors
1133 + * @param string $message
1134 + * @param bool $create_link
981 1135 * @return void
982 1136 */
983 - public static function before_list_templates() {
984 - global $frm_templates;
985 - global $frm_expired;
986 - global $frm_license_type;
1137 + private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1138 + global $frm_vars;
987 1139
988 - $api = new FrmFormTemplateApi();
989 - $frm_templates = $api->get_api_info();
990 - $expired = false;
991 - $license_type = '';
992 - if ( isset( $frm_templates['error'] ) ) {
993 - $error = $frm_templates['error']['message'];
994 - $error = str_replace( 'utm_medium=addons', 'utm_medium=form-templates', $error );
995 - $expired = 'expired' === $frm_templates['error']['code'];
996 - $license_type = isset( $frm_templates['error']['type'] ) ? $frm_templates['error']['type'] : '';
997 - unset( $frm_templates['error'] );
998 - }
999 -
1000 - $frm_expired = $expired;
1001 - $frm_license_type = $license_type;
1002 - }
1003 -
1004 - /**
1005 - * @return void
1006 - */
1007 - public static function list_templates() {
1008 - global $frm_templates;
1009 - global $frm_license_type;
1010 -
1011 - $templates = $frm_templates;
1012 - $custom_templates = array();
1013 - $templates_by_category = array();
1014 -
1015 - self::add_user_templates( $custom_templates );
1016 -
1017 - foreach ( $templates as $template ) {
1018 - if ( ! isset( $template['categories'] ) ) {
1019 - continue;
1020 - }
1021 -
1022 - foreach ( $template['categories'] as $category ) {
1023 - if ( ! isset( $templates_by_category[ $category ] ) ) {
1024 - $templates_by_category[ $category ] = array();
1025 - }
1026 -
1027 - $templates_by_category[ $category ][] = $template;
1028 - }
1029 - }
1030 - unset( $template );
1031 -
1032 - // Subcategories that are included elsewhere.
1033 - $redundant_cats = array( 'PayPal', 'Stripe', 'Twilio' );
1034 -
1035 - $categories = array_keys( $templates_by_category );
1036 - $categories = array_diff( $categories, FrmFormsHelper::ignore_template_categories() );
1037 - $categories = array_diff( $categories, $redundant_cats );
1038 - sort( $categories );
1039 -
1040 - array_walk(
1041 - $custom_templates,
1042 - function( &$template ) {
1043 - $template['custom'] = true;
1044 - }
1140 + $form = FrmForm::getOne( $id );
1141 + $error_args = array(
1142 + 'title' => __( 'You can\'t edit the form', 'formidable' ),
1143 + 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
1144 + 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
1145 + 'continue_url' => add_query_arg(
1146 + array(
1147 + 'page' => 'formidable',
1148 + )
1149 + ),
1045 1150 );
1046 -
1047 - $my_templates_translation = __( 'My Templates', 'formidable' );
1048 - $categories = array_merge( array( $my_templates_translation ), $categories );
1049 - $pricing = FrmAppHelper::admin_upgrade_link( 'form-templates' );
1050 - $license_type = $frm_license_type;
1051 - $args = compact( 'pricing', 'license_type' );
1052 - $where = apply_filters( 'frm_forms_dropdown', array(), '' );
1053 - $forms = FrmForm::get_published_forms( $where );
1054 - $view_path = FrmAppHelper::plugin_path() . '/classes/views/frm-forms/';
1055 -
1056 - $templates_by_category[ $my_templates_translation ] = $custom_templates;
1057 -
1058 - unset( $pricing, $license_type, $where );
1059 - wp_enqueue_script( 'accordion' ); // register accordion for template groups
1060 - require $view_path . 'list-templates.php';
1061 - }
1062 -
1063 - /**
1064 - * @since 4.03.01
1065 - */
1066 - private static function get_template_categories( $templates ) {
1067 - $categories = array();
1068 - foreach ( $templates as $template ) {
1069 - if ( isset( $template['categories'] ) ) {
1070 - $categories = array_merge( $categories, $template['categories'] );
1071 - }
1151 + if ( ! $form ) {
1152 + FrmAppController::show_error_modal( $error_args );
1153 + return;
1072 1154 }
1073 - $exclude_cats = FrmFormsHelper::ignore_template_categories();
1074 - $categories = array_unique( $categories );
1075 - $categories = array_diff( $categories, $exclude_cats );
1076 - sort( $categories );
1077 - return $categories;
1078 - }
1079 1155
1080 - private static function add_user_templates( &$templates ) {
1081 - $user_templates = array(
1082 - 'is_template' => 1,
1083 - 'default_template' => 0,
1084 - );
1085 - $user_templates = FrmForm::getAll( $user_templates, 'name' );
1086 - foreach ( $user_templates as $template ) {
1087 - $template = array(
1088 - 'id' => $template->id,
1089 - 'name' => $template->name,
1090 - 'key' => $template->form_key,
1091 - 'description' => $template->description,
1092 - 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template->id ) ) ),
1093 - 'released' => $template->created_at,
1094 - 'installed' => 1,
1156 + if ( 'trash' === $form->status ) {
1157 + $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
1158 + $error_args['continue_url'] = add_query_arg(
1159 + array(
1160 + 'page' => 'formidable',
1161 + '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ),
1162 + 'form_type' => 'trash',
1163 + 'frm_action' => 'untrash',
1164 + 'id' => $id,
1165 + )
1095 1166 );
1096 - array_unshift( $templates, $template );
1097 - unset( $template );
1167 + $error_args['continue_text'] = __( 'Restore form', 'formidable' );
1168 + FrmAppController::show_error_modal( $error_args );
1169 + return;
1098 1170 }
1099 - }
1100 1171
1101 - private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1102 - global $frm_vars;
1103 -
1104 - $form = FrmForm::getOne( $id );
1105 - if ( ! $form ) {
1106 - wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
1107 - }
1108 -
1109 1172 if ( $form->parent_form_id ) {
1110 1173 /* translators: %1$s: Start link HTML, %2$s: End link HTML */
1111 1174 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>' ) );
1112 1175 }
@@ -1117,8 +1180,9 @@
1117 1180
1118 1181 // Automatically add end section fields if they don't exist (2.0 migration).
1119 1182 $reset_fields = false;
1120 1183 FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
1184 + FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields );
1121 1185
1122 1186 if ( $reset_fields ) {
1123 1187 $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
1124 1188 }
@@ -1145,17 +1209,21 @@
1145 1209
1146 1210 self::maybe_update_form_builder_message( $message );
1147 1211
1148 1212 $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
1149 - $has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] );
1213 + $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1150 1214
1151 1215 if ( defined( 'DOING_AJAX' ) ) {
1152 1216 wp_die();
1153 - } else {
1154 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
1155 1217 }
1218 +
1219 + require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php';
1156 1220 }
1157 1221
1222 + /**
1223 + * @param array $fields
1224 + * @return array
1225 + */
1158 1226 public static function update_form_builder_fields( $fields, $form ) {
1159 1227 foreach ( $fields as $field ) {
1160 1228 $field->do_not_include_icons = true;
1161 1229 }
@@ -1167,13 +1235,21 @@
1167 1235 $message = __( 'Form was Successfully Copied', 'formidable' );
1168 1236 }
1169 1237 }
1170 1238
1239 + /**
1240 + * @param int|string $id
1241 + * @param array $errors
1242 + * @param array|string $args
1243 + * @return void
1244 + */
1171 1245 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1172 1246 FrmAppHelper::permission_check( 'frm_edit_forms' );
1173 1247
1174 1248 global $frm_vars;
1175 1249
1250 + self::maybe_print_media_templates();
1251 +
1176 1252 if ( ! is_array( $args ) ) {
1177 1253 // For reverse compatibility.
1178 1254 $args = array(
1179 1255 'message' => $args,
@@ -1206,17 +1282,38 @@
1206 1282
1207 1283 $sections = self::get_settings_tabs( $values );
1208 1284 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' );
1209 1285
1210 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
1286 + require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php';
1211 1287 }
1212 1288
1213 1289 /**
1290 + * 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.
1291 + *
1292 + * @since 6.10
1293 + *
1294 + * @return void
1295 + */
1296 + private static function maybe_print_media_templates() {
1297 + if ( FrmAppHelper::pro_is_included() ) {
1298 + // This issue does not exist when Pro is active so exit early.
1299 + return;
1300 + }
1301 +
1302 + add_action(
1303 + 'wp_enqueue_editor',
1304 + function () {
1305 + wp_print_media_templates();
1306 + }
1307 + );
1308 + }
1309 +
1310 + /**
1214 1311 * @since 4.0
1215 1312 */
1216 1313 public static function form_publish_button( $atts ) {
1217 1314 $values = $atts['values'];
1218 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
1315 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
1219 1316 }
1220 1317
1221 1318 /**
1222 1319 * Get a list of all the settings tabs for the form settings page.
@@ -1241,9 +1338,9 @@
1241 1338 'icon' => 'frm_icon_font frm_mail_bulk_icon',
1242 1339 ),
1243 1340 'permissions' => array(
1244 1341 'name' => __( 'Form Permissions', 'formidable' ),
1245 - 'icon' => 'frm_icon_font frm_lock_icon',
1342 + 'icon' => 'frm_icon_font frm_lock_closed_icon',
1246 1343 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1247 1344 'data' => array(
1248 1345 'medium' => 'permissions',
1249 1346 'upgrade' => __( 'Form Permissions', 'formidable' ),
@@ -1250,9 +1347,9 @@
1250 1347 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1251 1348 'screenshot' => 'permissions.png',
1252 1349 ),
1253 1350 ),
1254 - 'scheduling' => array(
1351 + 'scheduling' => array(
1255 1352 'name' => __( 'Form Scheduling', 'formidable' ),
1256 1353 'icon' => 'frm_icon_font frm_calendar_icon',
1257 1354 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1258 1355 'data' => array(
@@ -1285,9 +1382,9 @@
1285 1382 'screenshot' => 'chat.png',
1286 1383 )
1287 1384 ),
1288 1385 ),
1289 - 'abandonment' => array(
1386 + 'abandonment' => array(
1290 1387 'name' => __( 'Form Abandonment', 'formidable' ),
1291 1388 'icon' => 'frm_icon_font frm_abandoned_icon',
1292 1389 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1293 1390 'data' => FrmAppHelper::get_upgrade_data_params(
@@ -1314,13 +1411,8 @@
1314 1411 }
1315 1412
1316 1413 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1317 1414
1318 - if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
1319 - // Prevent settings from showing in 2 spots.
1320 - unset( $sections['permissions'], $sections['scheduling'] );
1321 - }
1322 -
1323 1415 foreach ( $sections as $key => $section ) {
1324 1416 $defaults = array(
1325 1417 'html_class' => '',
1326 1418 'name' => ucfirst( $key ),
@@ -1342,9 +1434,9 @@
1342 1434 $section['id'] = $section['anchor'];
1343 1435 }
1344 1436
1345 1437 $sections[ $key ] = $section;
1346 - }
1438 + }//end foreach
1347 1439
1348 1440 return $sections;
1349 1441 }
1350 1442
@@ -1351,8 +1443,9 @@
1351 1443 /**
1352 1444 * @since 4.0
1353 1445 *
1354 1446 * @param array $values
1447 + * @return void
1355 1448 */
1356 1449 public static function advanced_settings( $values ) {
1357 1450 $first_h3 = 'frm_first_h3';
1358 1451
@@ -1360,8 +1453,9 @@
1360 1453 }
1361 1454
1362 1455 /**
1363 1456 * @param array $values
1457 + * @return void
1364 1458 */
1365 1459 public static function render_spam_settings( $values ) {
1366 1460 if ( function_exists( 'akismet_http_post' ) ) {
1367 1461 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
@@ -1373,16 +1467,12 @@
1373 1467 /**
1374 1468 * @since 4.0
1375 1469 *
1376 1470 * @param array $values
1471 + * @return void
1377 1472 */
1378 1473 public static function buttons_settings( $values ) {
1379 - $styles = apply_filters( 'frm_get_style_opts', array() );
1380 -
1381 - $frm_settings = FrmAppHelper::get_settings();
1382 - $no_global_style = $frm_settings->load_style === 'none';
1383 -
1384 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php' );
1474 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
1385 1475 }
1386 1476
1387 1477 /**
1388 1478 * @since 4.0
@@ -1387,11 +1477,12 @@
1387 1477 /**
1388 1478 * @since 4.0
1389 1479 *
1390 1480 * @param array $values
1481 + * @return void
1391 1482 */
1392 1483 public static function html_settings( $values ) {
1393 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' );
1484 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
1394 1485 }
1395 1486
1396 1487 /**
1397 1488 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -1397,9 +1488,10 @@
1397 1488 * Replace old Submit Button href with new href to avoid errors in Chrome
1398 1489 *
1399 1490 * @since 2.03.08
1400 1491 *
1401 - * @param array|boolean $values
1492 + * @param array|bool $values
1493 + * @return void
1402 1494 */
1403 1495 private static function clean_submit_html( &$values ) {
1404 1496 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
1405 1497 $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
@@ -1420,8 +1512,13 @@
1420 1512
1421 1513 return $classes;
1422 1514 }
1423 1515
1516 + /**
1517 + * @param int|string $form_id
1518 + * @param string $class
1519 + * @return void
1520 + */
1424 1521 public static function mb_tags_box( $form_id, $class = '' ) {
1425 1522 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1426 1523
1427 1524 /**
@@ -1434,9 +1531,9 @@
1434 1531 */
1435 1532 $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) );
1436 1533 $linked_forms = array();
1437 1534 $col = 'one';
1438 - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
1535 + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' );
1439 1536
1440 1537 $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
1441 1538 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1442 1539
@@ -1441,9 +1538,9 @@
1441 1538 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1442 1539
1443 1540 $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
1444 1541
1445 - include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
1542 + include FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php';
1446 1543 }
1447 1544
1448 1545 /**
1449 1546 * @since 3.04.01
@@ -1456,9 +1553,9 @@
1456 1553 ),
1457 1554 );
1458 1555
1459 1556 $user_fields = self::user_shortcodes();
1460 - if ( ! empty( $user_fields ) ) {
1557 + if ( $user_fields ) {
1461 1558 $user_helpers = array();
1462 1559 foreach ( $user_fields as $uk => $uf ) {
1463 1560 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1464 1561 unset( $uk, $uf );
@@ -1464,9 +1561,9 @@
1464 1561 unset( $uk, $uf );
1465 1562 }
1466 1563
1467 1564 $advanced_helpers['user_id'] = array(
1468 - 'codes' => $user_helpers,
1565 + 'codes' => $user_helpers,
1469 1566 );
1470 1567 }
1471 1568
1472 1569 /**
@@ -1607,11 +1704,11 @@
1607 1704 check_ajax_referer( 'frm_ajax', 'nonce' );
1608 1705
1609 1706 echo FrmEntriesController::show_entry_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1610 1707 array(
1611 - 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
1708 + 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1612 1709 'default_email' => true,
1613 - 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
1710 + 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1614 1711 )
1615 1712 );
1616 1713 wp_die();
1617 1714 }
@@ -1617,10 +1714,10 @@
1617 1714 }
1618 1715
1619 1716 /**
1620 1717 * @param string $content
1621 - * @param stdClass|string|int $form
1622 - * @param stdClass|string|int|false $entry
1718 + * @param int|stdClass|string $form
1719 + * @param false|int|stdClass|string $entry
1623 1720 * @return string
1624 1721 */
1625 1722 public static function filter_content( $content, $form, $entry = false ) {
1626 1723 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1633,8 +1730,16 @@
1633 1730 if ( is_object( $form ) ) {
1634 1731 $form = $form->id;
1635 1732 }
1636 1733
1734 + /*
1735 + * Repeater actions adds `parent_entry` to `$entry` store the parent entry data. If `parent_entry` is not empty,
1736 + * use the parent form ID instead of repeater form ID to fix the parent form field shortcodes doesn't work.
1737 + */
1738 + if ( ! empty( $entry->parent_entry ) ) {
1739 + $form = $entry->parent_entry->form_id;
1740 + }
1741 +
1637 1742 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1638 1743 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1639 1744
1640 1745 return $content;
@@ -1644,11 +1749,11 @@
1644 1749 * Replace any [form_name] shortcodes in a string.
1645 1750 *
1646 1751 * @since 5.5
1647 1752 *
1648 - * @param string|array $string
1649 - * @param stdClass|string|int $form
1650 - * @return string|array
1753 + * @param array|string $string
1754 + * @param int|stdClass|string $form
1755 + * @return array|string
1651 1756 */
1652 1757 public static function replace_form_name_shortcodes( $string, $form ) {
1653 1758 if ( ! is_string( $string ) ) {
1654 1759 return $string;
@@ -1666,9 +1771,9 @@
1666 1771 return str_replace( '[form_name]', $form_name, $string );
1667 1772 }
1668 1773
1669 1774 /**
1670 - * @param stdClass|string|int|false $entry
1775 + * @param false|int|stdClass|string $entry
1671 1776 * @return void
1672 1777 */
1673 1778 private static function get_entry_by_param( &$entry ) {
1674 1779 if ( ! $entry || ! is_object( $entry ) ) {
@@ -1683,8 +1788,12 @@
1683 1788 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1684 1789 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1685 1790 }
1686 1791
1792 + /**
1793 + * @param array $errors
1794 + * @return array
1795 + */
1687 1796 public static function process_bulk_form_actions( $errors ) {
1688 1797 if ( ! $_REQUEST ) {
1689 1798 return $errors;
1690 1799 }
@@ -1728,9 +1837,9 @@
1728 1837 case 'untrash':
1729 1838 $message = self::bulk_untrash( $ids );
1730 1839 }
1731 1840
1732 - if ( isset( $message ) && ! empty( $message ) ) {
1841 + if ( ! empty( $message ) ) {
1733 1842 $errors['message'] = $message;
1734 1843 }
1735 1844
1736 1845 return $errors;
@@ -1750,9 +1859,9 @@
1750 1859 $json_vars = json_decode( $json_vars, true );
1751 1860 if ( empty( $json_vars ) ) {
1752 1861 // json decoding failed so we should return an error message.
1753 1862 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1754 - if ( 'edit' == $action ) {
1863 + if ( 'edit' === $action ) {
1755 1864 $action = 'update';
1756 1865 }
1757 1866
1758 1867 add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
@@ -1768,16 +1877,14 @@
1768 1877 if ( isset( $_REQUEST['delete_all'] ) ) {
1769 1878 // Override the action for this page.
1770 1879 $action = 'delete_all';
1771 1880 }
1772 - }
1881 + }//end if
1773 1882
1774 1883 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1775 1884 FrmAppHelper::trigger_hook_load( 'form' );
1776 1885
1777 1886 switch ( $action ) {
1778 - case 'new':
1779 - return self::new_form( $vars );
1780 1887 case 'create':
1781 1888 case 'edit':
1782 1889 case 'update':
1783 1890 case 'trash':
@@ -1782,16 +1889,17 @@
1782 1889 case 'update':
1783 1890 case 'trash':
1784 1891 case 'untrash':
1785 1892 case 'destroy':
1786 - case 'delete_all':
1787 1893 case 'settings':
1788 1894 case 'update_settings':
1789 1895 return self::$action( $vars );
1790 1896 case 'lite-reports':
1791 - return self::no_reports( $vars );
1897 + self::no_reports( $vars );
1898 + return;
1792 1899 case 'views':
1793 - return self::no_views( $vars );
1900 + self::no_views( $vars );
1901 + return;
1794 1902 default:
1795 1903 do_action( 'frm_form_action_' . $action );
1796 1904 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
1797 1905 return;
@@ -1814,14 +1922,47 @@
1814 1922 self::display_forms_list( array(), '', array( __( 'There was a problem duplicating the form', 'formidable' ) ) );
1815 1923 return;
1816 1924 }
1817 1925
1926 + if ( 'forms_permanently_deleted' === $message ) {
1927 + $count = FrmAppHelper::get_param( 'forms_deleted', 0, 'get', 'absint' );
1928 + /* translators: %1$s: Number of forms */
1929 + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
1930 + self::display_forms_list( array(), $message, '' );
1931 + return;
1932 + }
1933 +
1818 1934 self::display_forms_list();
1819 1935
1820 1936 return;
1821 - }
1937 + }//end switch
1822 1938 }
1823 1939
1940 + /**
1941 + * Rename a form.
1942 + *
1943 + * Handles the AJAX request for renaming a form.
1944 + *
1945 + * @since 6.7
1946 + *
1947 + * @return void
1948 + */
1949 + public static function rename_form() {
1950 + // Check permission and nonce
1951 + FrmAppHelper::permission_check( 'frm_edit_forms' );
1952 + check_ajax_referer( 'frm_ajax', 'nonce' );
1953 +
1954 + // Get posted data
1955 + $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
1956 + $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
1957 +
1958 + // Update the form name and form key.
1959 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
1960 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
1961 +
1962 + wp_send_json_success( compact( 'form_key' ) );
1963 + }
1964 +
1824 1965 public static function json_error( $errors ) {
1825 1966 $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1826 1967
1827 1968 return $errors;
@@ -1830,11 +1971,12 @@
1830 1971 /**
1831 1972 * Education for premium features.
1832 1973 *
1833 1974 * @since 4.05
1975 + * @return void
1834 1976 */
1835 1977 public static function add_form_style_tab_options() {
1836 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' );
1978 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php';
1837 1979 }
1838 1980
1839 1981 /**
1840 1982 * Add education about views.
@@ -1839,8 +1981,10 @@
1839 1981 /**
1840 1982 * Add education about views.
1841 1983 *
1842 1984 * @since 4.07
1985 + *
1986 + * @return void
1843 1987 */
1844 1988 public static function no_views( $values = array() ) {
1845 1989 FrmAppHelper::include_svg();
1846 1990 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -1852,8 +1996,10 @@
1852 1996 /**
1853 1997 * Add education about reports.
1854 1998 *
1855 1999 * @since 4.07
2000 + *
2001 + * @return void
1856 2002 */
1857 2003 public static function no_reports( $values = array() ) {
1858 2004 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
1859 2005 $form = $id ? FrmForm::getOne( $id ) : false;
@@ -1860,9 +2006,11 @@
1860 2006
1861 2007 include FrmAppHelper::plugin_path() . '/classes/views/shared/reports-info.php';
1862 2008 }
1863 2009
1864 - /* FRONT-END FORMS */
2010 + /**
2011 + * FRONT-END FORMS.
2012 + */
1865 2013 public static function admin_bar_css() {
1866 2014 if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
1867 2015 return;
1868 2016 }
@@ -1951,10 +2099,10 @@
1951 2099 * @return string
1952 2100 */
1953 2101 public static function get_form_shortcode( $atts ) {
1954 2102 global $frm_vars;
1955 - if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1956 - $sc = '[formidable';
2103 + if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2104 + $sc = '[formidable';
1957 2105 $sc .= FrmAppHelper::array_to_html_params( $atts );
1958 2106 return $sc . ']';
1959 2107 }
1960 2108
@@ -1979,11 +2127,11 @@
1979 2127
1980 2128 /**
1981 2129 * @since 5.2.01
1982 2130 *
1983 - * @param string|int|false $id
1984 - * @param string|false $key
1985 - * @return stdClass|false
2131 + * @param false|int|string $id
2132 + * @param false|string $key
2133 + * @return false|stdClass
1986 2134 */
1987 2135 private static function maybe_get_form_by_id_or_key( $id, $key ) {
1988 2136 if ( ! $id ) {
1989 2137 $id = $key;
@@ -1991,12 +2139,12 @@
1991 2139 return self::maybe_get_form_to_show( $id );
1992 2140 }
1993 2141
1994 2142 /**
1995 - * @param string|int|false $id
1996 - * @param string|false $key
1997 - * @param string|int|bool $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1998 - * @param string|int|bool $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2143 + * @param false|int|string $id
2144 + * @param false|string $key
2145 + * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2146 + * @param bool|int|string $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1999 2147 * @param array $atts
2000 2148 * @return string
2001 2149 */
2002 2150 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
@@ -2044,15 +2192,16 @@
2044 2192 return $form;
2045 2193 }
2046 2194
2047 2195 /**
2048 - * @param string|int|false $id
2049 - * @return stdClass|false
2196 + * @param false|int|string $id
2197 + * @return false|stdClass
2050 2198 */
2051 2199 private static function maybe_get_form_to_show( $id ) {
2052 2200 $form = false;
2053 2201
2054 - if ( ! empty( $id ) ) { // form id or key is set
2202 + if ( ! empty( $id ) ) {
2203 + // Form id or key is set.
2055 2204 $form = FrmForm::getOne( $id );
2056 2205 if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) {
2057 2206 $form = false;
2058 2207 }
@@ -2110,11 +2259,11 @@
2110 2259
2111 2260 do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
2112 2261
2113 2262 if ( apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
2114 - $entry_id = self::just_created_entry( $form->id );
2115 - $pass_args['entry_id'] = $entry_id;
2116 - $pass_args['reset'] = true;
2263 + $entry_id = self::just_created_entry( $form->id );
2264 + $pass_args['entry_id'] = $entry_id;
2265 + $pass_args['reset'] = true;
2117 2266
2118 2267 self::run_on_submit_actions( $pass_args );
2119 2268
2120 2269 do_action(
@@ -2124,9 +2273,9 @@
2124 2273 'form' => $form,
2125 2274 )
2126 2275 );
2127 2276 }
2128 - }
2277 + }//end if
2129 2278 }
2130 2279
2131 2280 /**
2132 2281 * If the form was processed earlier (init), get the generated errors
@@ -2158,9 +2307,9 @@
2158 2307 */
2159 2308 public static function just_created_entry( $form_id ) {
2160 2309 global $frm_vars;
2161 2310
2162 - 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;
2311 + return isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
2163 2312 }
2164 2313
2165 2314 /**
2166 2315 * Gets confirmation method.
@@ -2173,14 +2322,14 @@
2173 2322 *
2174 2323 * @type object $form Form object.
2175 2324 * @type int $entry_id Entry ID.
2176 2325 * }
2177 - * @return string|array
2326 + * @return array|string
2178 2327 */
2179 2328 private static function get_confirmation_method( $atts ) {
2180 2329 $action = FrmOnSubmitHelper::current_event( $atts );
2181 2330 $opt = 'update' === $action ? 'edit_action' : 'success_action';
2182 - $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
2331 + $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2183 2332
2184 2333 if ( ! empty( $atts['entry_id'] ) ) {
2185 2334 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2186 2335 if ( $met_actions ) {
@@ -2189,9 +2338,9 @@
2189 2338 }
2190 2339
2191 2340 $method = apply_filters( 'frm_success_filter', $method, $atts['form'], $action );
2192 2341
2193 - if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2342 + if ( $method !== 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2194 2343 $method = 'message';
2195 2344 }
2196 2345
2197 2346 return $method;
@@ -2276,9 +2425,9 @@
2276 2425 unset( $extra_args['form'] );
2277 2426
2278 2427 do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
2279 2428
2280 - $opt = ( ! isset( $args['action'] ) || $args['action'] === 'create' ) ? 'success' : 'edit';
2429 + $opt = ! isset( $args['action'] ) || $args['action'] === 'create' ? 'success' : 'edit';
2281 2430
2282 2431 $args['success_opt'] = $opt;
2283 2432 $args['ajax'] = ! empty( $frm_vars['ajax'] );
2284 2433
@@ -2304,16 +2453,16 @@
2304 2453 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
2305 2454 return array();
2306 2455 }
2307 2456
2308 - // If a redirect action has already opened the URL in a new tab, we show the default message in the currect tab.
2457 + // If a redirect action has already opened the URL in a new tab, we show the default message in the current tab.
2309 2458 if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) {
2310 2459 return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) );
2311 2460 }
2312 2461
2313 - $entry = FrmEntry::getOne( $args['entry_id'], true );
2314 - $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2315 - $met_actions = array();
2462 + $entry = FrmEntry::getOne( $args['entry_id'], true );
2463 + $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2464 + $met_actions = array();
2316 2465 $has_redirect = false;
2317 2466
2318 2467 foreach ( $actions as $action ) {
2319 2468 if ( ! in_array( $event, $action->post_content['event'], true ) ) {
@@ -2326,9 +2475,10 @@
2326 2475
2327 2476 $action_type = FrmOnSubmitHelper::get_action_type( $action );
2328 2477
2329 2478 if ( 'redirect' === $action_type ) {
2330 - if ( $has_redirect ) { // Do not process because we run the first redirect action only.
2479 + if ( $has_redirect ) {
2480 + // Do not process because we run the first redirect action only.
2331 2481 continue;
2332 2482 }
2333 2483 }
2334 2484
@@ -2341,9 +2491,9 @@
2341 2491 }
2342 2492
2343 2493 $met_actions[] = $action;
2344 2494 unset( $action );
2345 - }
2495 + }//end foreach
2346 2496
2347 2497 $args['event'] = $event;
2348 2498
2349 2499 /**
@@ -2532,9 +2682,9 @@
2532 2682 add_filter( 'the_content', 'FrmFormsController::preview_content', 9999 );
2533 2683 }
2534 2684
2535 2685 $post = $old_post;
2536 - }
2686 + }//end if
2537 2687 }
2538 2688
2539 2689 /**
2540 2690 * @since 3.0
@@ -2555,14 +2705,16 @@
2555 2705 $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args );
2556 2706
2557 2707 $doing_ajax = FrmAppHelper::doing_ajax();
2558 2708
2559 - if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) { // Is AJAX submit and there is just one Redirect action runs.
2709 + if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) {
2710 + // Is AJAX submit and there is just one Redirect action runs.
2560 2711 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
2561 2712 wp_die();
2562 2713 }
2563 2714
2564 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) { // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2715 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) {
2716 + // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2565 2717 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2566 2718 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
2567 2719 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
2568 2720 return;
@@ -2568,9 +2720,10 @@
2568 2720 return;
2569 2721 }
2570 2722
2571 2723 wp_redirect( esc_url_raw( $success_url ) );
2572 - die(); // do not use wp_die or redirect fails
2724 + // Do not use wp_die or redirect fails.
2725 + die();
2573 2726 }
2574 2727
2575 2728 // Redirect with a delay.
2576 2729 self::redirect_after_submit_using_js( $args + compact( 'success_url', 'doing_ajax' ) );
@@ -2621,9 +2774,9 @@
2621 2774
2622 2775 $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2623 2776
2624 2777 ob_start();
2625 - self::show_lone_success_messsage( $args );
2778 + self::show_lone_success_message( $args );
2626 2779 $response_data['content'] = ob_get_clean();
2627 2780
2628 2781 $response_data['fallbackMsg'] = self::get_redirect_fallback_message( $args['success_url'], $args );
2629 2782 }
@@ -2647,9 +2800,9 @@
2647 2800 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
2648 2801 *
2649 2802 * @since 6.0
2650 2803 *
2651 - * @param int $delay_time Delay time in miliseconds.
2804 + * @param int $delay_time Delay time in milliseconds.
2652 2805 */
2653 2806 $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
2654 2807
2655 2808 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
@@ -2661,9 +2814,10 @@
2661 2814 add_filter( 'frm_use_wpautop', '__return_true' );
2662 2815
2663 2816 echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2664 2817 echo '<script>';
2665 - if ( empty( $args['doing_ajax'] ) ) { // Not AJAX submit, delay JS until window.load.
2818 + if ( empty( $args['doing_ajax'] ) ) {
2819 + // Not AJAX submit, delay JS until window.load.
2666 2820 echo 'window.onload=function(){';
2667 2821 }
2668 2822 echo 'setTimeout(function(){' . $redirect_js . '}, ' . intval( $delay_time ) . ');'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2669 2823 if ( empty( $args['doing_ajax'] ) ) {
@@ -2676,9 +2830,9 @@
2676 2830 * @since 3.0
2677 2831 *
2678 2832 * @param string $success_url
2679 2833 * @param string $success_msg
2680 - * @param array $args
2834 + * @param array $args
2681 2835 */
2682 2836 private static function get_redirect_message( $success_url, $success_msg, $args ) {
2683 2837 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
2684 2838 self::get_redirect_fallback_message( $success_url, $args ) .
@@ -2736,9 +2890,9 @@
2736 2890 } else {
2737 2891 self::show_form_after_submit( $atts );
2738 2892 }
2739 2893 } else {
2740 - self::show_lone_success_messsage( $atts );
2894 + self::show_lone_success_message( $atts );
2741 2895 }
2742 2896 }
2743 2897
2744 2898 /**
@@ -2777,11 +2931,10 @@
2777 2931 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
2778 2932 }
2779 2933
2780 2934 /**
2935 + * @since 4.05.02
2781 2936 * @return string - 'before', 'after', or 'submit'
2782 - *
2783 - * @since 4.05.02
2784 2937 */
2785 2938 private static function message_placement( $form, $message ) {
2786 2939 $place = 'before';
2787 2940
@@ -2793,11 +2946,10 @@
2793 2946 }
2794 2947 }
2795 2948
2796 2949 /**
2950 + * @since 4.05.02
2797 2951 * @return string - 'before' or 'after'
2798 - *
2799 - * @since 4.05.02
2800 2952 */
2801 2953 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
2802 2954 }
2803 2955
@@ -2831,9 +2983,9 @@
2831 2983 * Show the success message without the form
2832 2984 *
2833 2985 * @since 2.05
2834 2986 */
2835 - private static function show_lone_success_messsage( $atts ) {
2987 + private static function show_lone_success_message( $atts ) {
2836 2988 global $frm_vars;
2837 2989 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
2838 2990 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
2839 2991
@@ -2842,9 +2994,9 @@
2842 2994 $errors = array();
2843 2995 $form = $atts['form'];
2844 2996 $message = $atts['message'];
2845 2997
2846 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
2998 + include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
2847 2999 }
2848 3000
2849 3001 /**
2850 3002 * Prepare the success message before it's shown
@@ -2964,9 +3116,9 @@
2964 3116 global $frm_vars;
2965 3117
2966 3118 FrmStylesController::enqueue_css();
2967 3119
2968 - if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3120 + if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
2969 3121 // load formidable js
2970 3122 wp_enqueue_script( 'formidable' );
2971 3123 }
2972 3124 }
@@ -2982,12 +3134,12 @@
2982 3134 }
2983 3135
2984 3136 /**
2985 3137 * @since 2.0.8
2986 - * @return boolean
3138 + * @return bool
2987 3139 */
2988 3140 private static function is_minification_on( $atts ) {
2989 - return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
3141 + return ! empty( $atts['minimize'] );
2990 3142 }
2991 3143
2992 3144 /**
2993 3145 * @since 5.0.16
@@ -3015,9 +3167,9 @@
3015 3167 * Create a page with an embedded formidable Gutenberg block.
3016 3168 *
3017 3169 * @since 5.2
3018 3170 *
3019 - * @return never
3171 + * @return void
3020 3172 */
3021 3173 public static function create_page_with_shortcode() {
3022 3174 if ( ! current_user_can( 'publish_posts' ) ) {
3023 3175 die( 0 );
@@ -3062,10 +3214,9 @@
3062 3214
3063 3215 /**
3064 3216 * @since 5.3
3065 3217 *
3066 - * @param string $content
3067 - * @param int $form_id
3218 + * @param int $form_id
3068 3219 * @return string
3069 3220 */
3070 3221 private static function get_page_shortcode_content_for_form( $form_id ) {
3071 3222 $shortcode = '[formidable id="' . $form_id . '"]';
@@ -3076,9 +3227,9 @@
3076 3227
3077 3228 /**
3078 3229 * Get page dropdown for AJAX request for embedding form in an existing page.
3079 3230 *
3080 - * @return never
3231 + * @return void
3081 3232 */
3082 3233 public static function get_page_dropdown() {
3083 3234 if ( ! current_user_can( 'publish_posts' ) ) {
3084 3235 die( 0 );
@@ -3086,9 +3237,9 @@
3086 3237
3087 3238 check_ajax_referer( 'frm_ajax', 'nonce' );
3088 3239
3089 3240 $html = FrmAppHelper::clip(
3090 - function() {
3241 + function () {
3091 3242 FrmAppHelper::maybe_autocomplete_pages_options(
3092 3243 array(
3093 3244 'field_name' => 'frm_page_dropdown',
3094 3245 'page_id' => '',
@@ -3108,15 +3259,8 @@
3108 3259
3109 3260 /**
3110 3261 * @deprecated 4.0
3111 3262 */
3112 - public static function new_form( $values = array() ) {
3113 - FrmDeprecated::new_form( $values );
3114 - }
3115 -
3116 - /**
3117 - * @deprecated 4.0
3118 - */
3119 3263 public static function create( $values = array() ) {
3120 3264 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3121 3265 self::update( $values );
3122 3266 }
@@ -3121,35 +3265,13 @@
3121 3265 self::update( $values );
3122 3266 }
3123 3267
3124 3268 /**
3125 - * @deprecated 3.0
3126 - * @codeCoverageIgnore
3269 + * @deprecated 6.7
3270 + *
3271 + * @return bool
3127 3272 */
3128 - public static function bulk_create_template( $ids ) {
3129 - return FrmDeprecated::bulk_create_template( $ids );
3130 - }
3131 -
3132 - /**
3133 - * @deprecated 3.0
3134 - * @codeCoverageIgnore
3135 - */
3136 - public static function edit_key() {
3137 - FrmDeprecated::edit_key();
3138 - }
3139 -
3140 - /**
3141 - * @deprecated 3.0
3142 - * @codeCoverageIgnore
3143 - */
3144 - public static function edit_description() {
3145 - FrmDeprecated::edit_description();
3146 - }
3147 -
3148 - /**
3149 - * @deprecated 4.08
3150 - * @since 3.06
3151 - */
3152 - public static function add_new() {
3153 - _deprecated_function( __FUNCTION__, '4.08' );
3273 + public static function expired() {
3274 + _deprecated_function( __METHOD__, '6.7' );
3275 + return FrmAddonsController::is_license_expired();
3154 3276 }
3155 3277 }