PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.3
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 +520 -397 6.5.36.16.3 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 );
@@ -103,8 +113,11 @@
103 113 FrmForm::maybe_get_form( $form );
104 114 $create_email = apply_filters( 'frm_create_default_email_action', true, $form );
105 115
106 116 if ( $create_email ) {
117 + /**
118 + * @var FrmFormAction
119 + */
107 120 $action_control = FrmFormActionsController::get_form_actions( 'email' );
108 121 $action_control->create( $form->id );
109 122 }
110 123 }
@@ -113,9 +126,9 @@
113 126 * Create the default On submit action
114 127 *
115 128 * @since 6.0.0
116 129 *
117 - * @param object|int $form Form object or ID.
130 + * @param int|object $form Form object or ID.
118 131 */
119 132 private static function create_default_on_submit_action( $form ) {
120 133 FrmForm::maybe_get_form( $form );
121 134
@@ -129,21 +142,61 @@
129 142 */
130 143 $create = apply_filters( 'frm_create_default_on_submit_action', true, $form );
131 144
132 145 if ( $create ) {
146 + /**
147 + * @var FrmFormAction
148 + */
133 149 $action_control = FrmFormActionsController::get_form_actions( FrmOnSubmitAction::$slug );
134 150 $action_control->create( $form->id );
135 151 }
136 152 }
137 153
154 + /**
155 + * Creates submit button field.
156 + *
157 + * @since 6.9
158 + *
159 + * @param int|object $form Form ID or object.
160 + */
161 + private static function create_submit_button_field( $form ) {
162 + FrmForm::maybe_get_form( $form );
163 +
164 + if ( FrmSubmitHelper::get_submit_field( $form->id ) ) {
165 + // Do not create submit button field if it exists.
166 + return;
167 + }
168 +
169 + FrmField::create(
170 + array(
171 + 'type' => FrmSubmitHelper::FIELD_TYPE,
172 + 'name' => __( 'Submit', 'formidable' ),
173 + 'field_order' => FrmSubmitHelper::DEFAULT_ORDER,
174 + 'form_id' => $form->id,
175 + 'field_options' => FrmFieldsHelper::get_default_field_options( FrmSubmitHelper::FIELD_TYPE ),
176 + 'description' => '',
177 + 'default_value' => '',
178 + 'options' => array(),
179 + )
180 + );
181 + }
182 +
183 + /**
184 + * @return void
185 + */
138 186 public static function edit( $values = false ) {
139 187 FrmAppHelper::permission_check( 'frm_edit_forms' );
140 188
141 189 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
142 190
143 - return self::get_edit_vars( $id );
191 + self::get_edit_vars( $id );
144 192 }
145 193
194 + /**
195 + * @param mixed $id
196 + * @param string $message
197 + * @return void
198 + */
146 199 public static function settings( $id = false, $message = '' ) {
147 200 FrmAppHelper::permission_check( 'frm_edit_forms' );
148 201
149 202 if ( ! $id || ! is_numeric( $id ) ) {
@@ -151,21 +204,34 @@
151 204 }
152 205
153 206 FrmOnSubmitHelper::maybe_migrate_submit_settings_to_action( $id );
154 207
155 - return self::get_settings_vars( $id, array(), $message );
208 + self::get_settings_vars( $id, array(), $message );
156 209 }
157 210
158 211 public static function update_settings() {
159 212 FrmAppHelper::permission_check( 'frm_edit_forms' );
213 + $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
160 214
215 + if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
216 + $frm_settings = FrmAppHelper::get_settings();
217 + $error_args = array(
218 + 'title' => __( 'Verification failed', 'formidable' ),
219 + 'body' => $frm_settings->admin_permission,
220 + 'cancel_text' => __( 'Cancel', 'formidable' ),
221 + );
222 + FrmAppController::show_error_modal( $error_args );
223 + return;
224 + }
225 +
161 226 $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
162 227
163 - $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
228 + $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
164 229 $warnings = FrmFormsHelper::check_for_warnings( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
165 230
166 231 if ( count( $errors ) > 0 ) {
167 - return self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
232 + self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
233 + return;
168 234 }
169 235
170 236 do_action( 'frm_before_update_form_settings', $id );
171 237
@@ -179,9 +245,9 @@
179 245 }
180 246
181 247 $message = __( 'Settings Successfully Updated', 'formidable' );
182 248
183 - return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
249 + self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
184 250 }
185 251
186 252 /**
187 253 * @param int $form_id
@@ -191,8 +257,11 @@
191 257 $form = FrmForm::getOne( $form_id );
192 258 return ! empty( $form->options['antispam'] );
193 259 }
194 260
261 + /**
262 + * @return void
263 + */
195 264 public static function update( $values = array() ) {
196 265 if ( empty( $values ) ) {
197 266 $values = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing
198 267 }
@@ -210,65 +279,74 @@
210 279
211 280 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
212 281
213 282 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' );
283 + self::get_edit_vars( $id, $errors );
284 + return;
285 + }
218 286
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 - }
287 + self::maybe_remove_draft_option_from_fields( $id );
227 288
228 - if ( defined( 'DOING_AJAX' ) ) {
229 - wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
230 - }
289 + FrmForm::update( $id, $values );
290 + $message = __( 'Form was successfully updated.', 'formidable' );
231 291
232 - return self::get_edit_vars( $id, array(), $message );
292 + if ( self::is_too_long( $values ) ) {
293 + $message .= '<br/> ' . sprintf(
294 + /* translators: %1$s: Start link HTML, %2$s: end link HTML */
295 + __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
296 + '<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">',
297 + '</a>'
298 + );
233 299 }
300 +
301 + if ( defined( 'DOING_AJAX' ) ) {
302 + wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
303 + }
304 +
305 + self::get_edit_vars( $id, array(), $message );
234 306 }
235 307
236 308 /**
309 + * Remove the draft flag from any new fields from this current session.
310 + *
311 + * @since 6.8
312 + *
313 + * @param int $form_id
314 + * @return void
315 + */
316 + private static function maybe_remove_draft_option_from_fields( $form_id ) {
317 + $draft_field_ids_csv = FrmAppHelper::get_post_param( 'draft_fields', '', 'sanitize_text_field' );
318 + if ( ! $draft_field_ids_csv ) {
319 + // If the draft_fields input is empty there are no new fields in the session.
320 + return;
321 + }
322 +
323 + $draft_field_ids = array_filter( explode( ',', $draft_field_ids_csv ), 'is_numeric' );
324 + if ( ! $draft_field_ids ) {
325 + // Exit early if the draft fields input is invalid. It should be a CSV of integer values.
326 + return;
327 + }
328 +
329 + $draft_field_rows = FrmFieldsHelper::get_draft_field_results( $form_id, $draft_field_ids );
330 + foreach ( $draft_field_rows as $row ) {
331 + $row->field_options['draft'] = 0;
332 + FrmField::update( $row->id, array( 'field_options' => $row->field_options ) );
333 + }
334 + }
335 +
336 + /**
237 337 * Check if the value at the end of the form was included.
238 338 * If it's missing, it means other values at the end of the form
239 339 * were likely not saved either.
240 340 *
241 341 * @since 3.06.01
342 + *
343 + * @return bool
242 344 */
243 345 private static function is_too_long( $values ) {
244 - return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] );
346 + return empty( $values['frm_end'] );
245 347 }
246 348
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 349 public static function duplicate() {
272 350 FrmAppHelper::permission_check( 'frm_edit_forms' );
273 351 $nonce = FrmAppHelper::simple_get( '_wpnonce' );
274 352
@@ -282,10 +360,11 @@
282 360 $url = admin_url( 'admin.php?page=formidable' );
283 361 $message = 'form_duplicate_error';
284 362
285 363 if ( $form ) {
286 - $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) );
287 - $message = 'form_duplicated';
364 + $new_template = FrmAppHelper::simple_get( 'new_template' ) ? '&new_template=true' : '';
365 + $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
366 + $message = 'form_duplicated';
288 367 }
289 368
290 369 $url .= '&message=' . $message;
291 370
@@ -293,24 +372,28 @@
293 372 exit();
294 373 }
295 374
296 375 /**
297 - * @return string
376 + * @return string|null
298 377 */
299 378 public static function page_preview() {
300 379 $params = FrmForm::list_page_params();
301 380 if ( ! $params['form'] ) {
302 - return;
381 + return null;
303 382 }
304 383
305 384 $form = FrmForm::getOne( $params['form'] );
306 - if ( $form ) {
307 - return self::show_form( $form->id, '', 'auto', 'auto' );
385 + if ( ! $form ) {
386 + return null;
308 387 }
388 +
389 + return self::show_form( $form->id, '', 'auto', 'auto' );
309 390 }
310 391
311 392 /**
312 393 * @since 3.0
394 + *
395 + * @return void
313 396 */
314 397 public static function show_page_preview() {
315 398 echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
316 399 }
@@ -360,8 +443,13 @@
360 443 return;
361 444 }
362 445
363 446 $random_page = reset( $random_page );
447 + if ( ! is_a( $random_page, 'WP_Post' ) ) {
448 + // The return type can also be int.
449 + return;
450 + }
451 +
364 452 query_posts(
365 453 array(
366 454 'post_type' => 'page',
367 455 'page_id' => $random_page->ID,
@@ -377,9 +465,9 @@
377 465 * Set the WP $post global object. Used for in-theme preview when defining a page.
378 466 *
379 467 * @since 5.5.2
380 468 *
381 - * @param WP_Post $post
469 + * @param WP_Post $page The page object.
382 470 * @return void
383 471 */
384 472 private static function set_post_global( $page ) {
385 473 global $post;
@@ -387,8 +475,10 @@
387 475 }
388 476
389 477 /**
390 478 * @since 3.0
479 + *
480 + * @return void
391 481 */
392 482 private static function load_theme_preview() {
393 483 add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
394 484 add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
@@ -420,13 +510,16 @@
420 510
421 511 /**
422 512 * Not every theme supports get_template_part( 'page' ).
423 513 * When this is not supported, false is returned, and we can handle a fallback.
514 + *
515 + * @return void
424 516 */
425 517 private static function fallback_when_page_template_part_is_not_supported_by_theme() {
426 518 if ( have_posts() ) {
427 519 the_post();
428 - get_header( '' );
520 + self::get_template( 'header' );
521 +
429 522 // add some generic class names to the container to add some natural padding to the content.
430 523 // .entry-content catches the WordPress TwentyTwenty theme.
431 524 // .container catches Customizr content.
432 525 echo '<div class="container entry-content">';
@@ -431,13 +524,54 @@
431 524 // .container catches Customizr content.
432 525 echo '<div class="container entry-content">';
433 526 the_content();
434 527 echo '</div>';
435 - get_footer();
528 +
529 + self::get_template( 'footer' );
436 530 }
437 531 }
438 532
439 533 /**
534 + * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call
535 + * and renders required html fragments calling required functions.
536 + *
537 + * @since 6.7.1
538 + * @param string $template
539 + * @return void
540 + */
541 + private static function get_template( $template ) {
542 + if ( self::should_try_getting_template( $template ) ) {
543 + call_user_func( 'get_' . $template );
544 + return;
545 + }
546 +
547 + if ( 'header' === $template ) {
548 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/header.php';
549 + return;
550 + }
551 +
552 + if ( 'footer' === $template ) {
553 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/footer.php';
554 + }
555 + }
556 +
557 + /**
558 + * Returns true if calling a template function doesn't trigger deprecation warnings.
559 + *
560 + * @since 6.7.1
561 + * @param string $template
562 + * @return bool
563 + */
564 + private static function should_try_getting_template( $template ) {
565 + $stylesheet_path = get_stylesheet_directory();
566 + $template_path = get_template_directory();
567 + $is_child_theme = $stylesheet_path !== $template_path;
568 + $template_name = $template . '.php';
569 +
570 + return file_exists( $stylesheet_path . '/' . $template_name ) || $is_child_theme && file_exists( $template_path . '/' . $template_name );
571 + }
572 +
573 + /**
440 574 * Set the page title for the theme preview page
441 575 *
442 576 * @since 3.0
443 577 */
@@ -449,11 +583,14 @@
449 583 return $title;
450 584 }
451 585
452 586 /**
453 - * Set the page title for the theme preview page
587 + * Set the page title for the theme preview page.
454 588 *
455 589 * @since 3.0
590 + *
591 + * @param string $title
592 + * @return string
456 593 */
457 594 public static function preview_title( $title ) {
458 595 return __( 'Form Preview', 'formidable' );
459 596 }
@@ -458,15 +595,20 @@
458 595 return __( 'Form Preview', 'formidable' );
459 596 }
460 597
461 598 /**
462 - * Set the page content for the theme preview page
599 + * Set the page content for the theme preview page.
463 600 *
464 601 * @since 3.0
602 + *
603 + * @param string $content
604 + * @return string
465 605 */
466 606 public static function preview_content( $content ) {
467 607 if ( in_the_loop() ) {
468 - $content = self::show_page_preview();
608 + self::show_page_preview();
609 + // Clear the content for the page we're using.
610 + $content = '';
469 611 }
470 612
471 613 return $content;
472 614 }
@@ -476,8 +618,11 @@
476 618 */
477 619 private static function load_direct_preview() {
478 620 header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
479 621
622 + // print_emoji_styles is deprecated.
623 + remove_action( 'wp_print_styles', 'print_emoji_styles' );
624 +
480 625 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
481 626 if ( $key == '' ) {
482 627 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
483 628 }
@@ -486,11 +631,38 @@
486 631 if ( empty( $form ) ) {
487 632 $form = FrmForm::getAll( array(), '', 1 );
488 633 }
489 634
490 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
635 + self::fix_deprecated_null_param_warning();
636 +
637 + require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
491 638 }
492 639
640 + /**
641 + * Some themes have a null $src value.
642 + * This function adds a filter to ensure that $src is not null.
643 + * WP will call str_starts_with with the null value triggering a deprecated message otherwise.
644 + *
645 + * @since 6.10
646 + *
647 + * @return void
648 + */
649 + private static function fix_deprecated_null_param_warning() {
650 + add_filter(
651 + 'script_loader_src',
652 + /**
653 + * @param string|null $src
654 + * @return string
655 + */
656 + function ( $src ) {
657 + if ( is_null( $src ) ) {
658 + $src = '';
659 + }
660 + return $src;
661 + }
662 + );
663 + }
664 +
493 665 public static function untrash() {
494 666 self::change_form_status( 'untrash' );
495 667 }
496 668
@@ -553,14 +725,14 @@
553 725 FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
554 726
555 727 $params = FrmForm::list_page_params();
556 728
557 - //check nonce url
729 + // Check nonce url.
558 730 check_admin_referer( $status . '_form_' . $params['id'] );
559 731
560 732 $count = 0;
561 733 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
562 - $count ++;
734 + ++$count;
563 735 }
564 736
565 737 $form_type = FrmAppHelper::get_simple_request(
566 738 array(
@@ -572,9 +744,9 @@
572 744 /* translators: %1$s: Number of forms */
573 745 $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
574 746
575 747 /* 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>' );
748 + $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 749
578 750 $message = $available_status[ $status ]['message'];
579 751
580 752 self::display_forms_list( $params, $message );
@@ -579,8 +751,12 @@
579 751
580 752 self::display_forms_list( $params, $message );
581 753 }
582 754
755 + /**
756 + * @param array $ids
757 + * @return string
758 + */
583 759 public static function bulk_trash( $ids ) {
584 760 FrmAppHelper::permission_check( 'frm_delete_forms' );
585 761
586 762 $count = 0;
@@ -585,12 +761,16 @@
585 761
586 762 $count = 0;
587 763 foreach ( $ids as $id ) {
588 764 if ( FrmForm::trash( $id ) ) {
589 - $count ++;
765 + ++$count;
590 766 }
591 767 }
592 768
769 + if ( ! $count ) {
770 + return '';
771 + }
772 +
593 773 $current_page = FrmAppHelper::get_simple_request(
594 774 array(
595 775 'param' => 'form_type',
596 776 'type' => 'request',
@@ -616,9 +796,9 @@
616 796 check_admin_referer( 'destroy_form_' . $params['id'] );
617 797
618 798 $count = 0;
619 799 if ( FrmForm::destroy( $params['id'] ) ) {
620 - $count ++;
800 + ++$count;
621 801 }
622 802
623 803 /* translators: %1$s: Number of forms */
624 804 $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count );
@@ -625,8 +805,12 @@
625 805
626 806 self::display_forms_list( $params, $message );
627 807 }
628 808
809 + /**
810 + * @param array $ids
811 + * @return string
812 + */
629 813 public static function bulk_destroy( $ids ) {
630 814 FrmAppHelper::permission_check( 'frm_delete_forms' );
631 815
632 816 $count = 0;
@@ -632,19 +816,24 @@
632 816 $count = 0;
633 817 foreach ( $ids as $id ) {
634 818 $d = FrmForm::destroy( $id );
635 819 if ( $d ) {
636 - $count ++;
820 + ++$count;
637 821 }
638 822 }
639 823
640 - /* translators: %1$s: Number of forms */
641 - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
824 + if ( $count ) {
825 + /* translators: %1$s: Number of forms */
826 + return sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
827 + }
642 828
643 - return $message;
829 + return '';
644 830 }
645 831
646 - private static function delete_all() {
832 + /**
833 + * @since 6.7.1 Function went from private to public.
834 + */
835 + public static function delete_all() {
647 836 // Check nonce url.
648 837 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
649 838 if ( $permission_error !== false ) {
650 839 self::display_forms_list( array(), '', array( $permission_error ) );
@@ -651,14 +840,15 @@
651 840
652 841 return;
653 842 }
654 843
655 - $count = FrmForm::scheduled_delete( time() );
844 + $count = FrmForm::scheduled_delete( time() );
845 + $url = remove_query_arg( array( 'delete_all' ) );
656 846
657 - /* translators: %1$s: Number of forms */
658 - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
847 + $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
659 848
660 - self::display_forms_list( array(), $message );
849 + wp_safe_redirect( $url );
850 + die();
661 851 }
662 852
663 853 /**
664 854 * Create a new form from the modal.
@@ -671,9 +861,9 @@
671 861
672 862 $new_values = self::get_modal_values();
673 863 $new_values['form_key'] = $new_values['name'];
674 864 $new_values['options'] = array(
675 - 'antispam' => 1,
865 + 'antispam' => 1,
676 866 'on_submit_migrated' => 1,
677 867 );
678 868
679 869 /**
@@ -692,13 +882,14 @@
692 882 * @param int $form_id
693 883 */
694 884 do_action( 'frm_build_new_form', $form_id );
695 885
886 + self::create_submit_button_field( $form_id );
696 887 self::create_default_on_submit_action( $form_id );
697 888 self::create_default_email_action( $form_id );
698 889
699 890 $response = array(
700 - 'redirect' => FrmForm::get_edit_link( $form_id ),
891 + 'redirect' => FrmForm::get_edit_link( $form_id ) . '&new_template=true',
701 892 );
702 893
703 894 echo wp_json_encode( $response );
704 895 wp_die();
@@ -704,46 +895,15 @@
704 895 wp_die();
705 896 }
706 897
707 898 /**
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 899 * Before creating a new form, get the name and description from the modal.
742 900 *
743 901 * @since 4.0
902 + *
903 + * @return array<string,string>
744 904 */
745 - private static function get_modal_values() {
905 + public static function get_modal_values() {
746 906 $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
747 907 $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
748 908
749 909 return array(
@@ -756,17 +916,24 @@
756 916 * Inserts Formidable button
757 917 * Hook exists since 2.5.0
758 918 *
759 919 * @since 2.0.15
920 + *
921 + * @return void
760 922 */
761 923 public static function insert_form_button() {
762 924 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>';
925 + // Store the result in memory and re-use it when this function is called multiple times.
926 + // This helps speed up the form builder when there are a lot of HTML fields, where this
927 + // button is inserted once per HTML field.
928 + // In a form with 66 HTML fields, this saves 0.5 seconds on page load time, tested locally.
929 + if ( ! isset( self::$formidable_tinymce_button ) ) {
930 + FrmAppHelper::load_admin_wide_js();
931 + $menu_name = FrmAppHelper::get_menu_name();
932 + $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
933 + 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>';
934 + }
935 + echo self::$formidable_tinymce_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
769 936 }
770 937 }
771 938
772 939 /**
@@ -854,9 +1021,9 @@
854 1021 $form_id = $opts['form_id'];
855 1022 unset( $opts['form_id'] );
856 1023 }
857 1024
858 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
1025 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php';
859 1026
860 1027 echo '</div>';
861 1028
862 1029 wp_die();
@@ -924,8 +1091,11 @@
924 1091
925 1092 return $columns;
926 1093 }
927 1094
1095 + /**
1096 + * @return array<string,string>
1097 + */
928 1098 public static function get_sortable_columns() {
929 1099 return array(
930 1100 'id' => 'id',
931 1101 'name' => 'name',
@@ -959,9 +1129,9 @@
959 1129 return $hidden_columns;
960 1130 }
961 1131
962 1132 public static function save_per_page( $save, $option, $value ) {
963 - if ( $option == 'formidable_page_formidable_per_page' ) {
1133 + if ( $option === 'formidable_page_formidable_per_page' ) {
964 1134 $save = (int) $value;
965 1135 }
966 1136
967 1137 return $save;
@@ -967,146 +1137,49 @@
967 1137 return $save;
968 1138 }
969 1139
970 1140 /**
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 - *
1141 + * @param int|string $id
1142 + * @param array $errors
1143 + * @param string $message
1144 + * @param bool $create_link
981 1145 * @return void
982 1146 */
983 - public static function before_list_templates() {
984 - global $frm_templates;
985 - global $frm_expired;
986 - global $frm_license_type;
1147 + private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1148 + global $frm_vars;
987 1149
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 - }
1150 + $form = FrmForm::getOne( $id );
1151 + $error_args = array(
1152 + 'title' => __( 'You can\'t edit the form', 'formidable' ),
1153 + 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
1154 + 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
1155 + 'continue_url' => add_query_arg(
1156 + array(
1157 + 'page' => 'formidable',
1158 + )
1159 + ),
1045 1160 );
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 - }
1161 + if ( ! $form ) {
1162 + FrmAppController::show_error_modal( $error_args );
1163 + return;
1072 1164 }
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 1165
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,
1166 + if ( 'trash' === $form->status ) {
1167 + $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
1168 + $error_args['continue_url'] = add_query_arg(
1169 + array(
1170 + 'page' => 'formidable',
1171 + '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ),
1172 + 'form_type' => 'trash',
1173 + 'frm_action' => 'untrash',
1174 + 'id' => $id,
1175 + )
1095 1176 );
1096 - array_unshift( $templates, $template );
1097 - unset( $template );
1177 + $error_args['continue_text'] = __( 'Restore form', 'formidable' );
1178 + FrmAppController::show_error_modal( $error_args );
1179 + return;
1098 1180 }
1099 - }
1100 1181
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 1182 if ( $form->parent_form_id ) {
1110 1183 /* translators: %1$s: Start link HTML, %2$s: End link HTML */
1111 1184 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 1185 }
@@ -1117,8 +1190,9 @@
1117 1190
1118 1191 // Automatically add end section fields if they don't exist (2.0 migration).
1119 1192 $reset_fields = false;
1120 1193 FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
1194 + FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields );
1121 1195
1122 1196 if ( $reset_fields ) {
1123 1197 $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
1124 1198 }
@@ -1144,18 +1218,21 @@
1144 1218 }
1145 1219
1146 1220 self::maybe_update_form_builder_message( $message );
1147 1221
1148 - $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
1149 - $has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] );
1222 + $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1150 1223
1151 1224 if ( defined( 'DOING_AJAX' ) ) {
1152 1225 wp_die();
1153 - } else {
1154 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
1155 1226 }
1227 +
1228 + require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php';
1156 1229 }
1157 1230
1231 + /**
1232 + * @param array $fields
1233 + * @return array
1234 + */
1158 1235 public static function update_form_builder_fields( $fields, $form ) {
1159 1236 foreach ( $fields as $field ) {
1160 1237 $field->do_not_include_icons = true;
1161 1238 }
@@ -1167,13 +1244,21 @@
1167 1244 $message = __( 'Form was Successfully Copied', 'formidable' );
1168 1245 }
1169 1246 }
1170 1247
1248 + /**
1249 + * @param int|string $id
1250 + * @param array $errors
1251 + * @param array|string $args
1252 + * @return void
1253 + */
1171 1254 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1172 1255 FrmAppHelper::permission_check( 'frm_edit_forms' );
1173 1256
1174 1257 global $frm_vars;
1175 1258
1259 + self::maybe_print_media_templates();
1260 +
1176 1261 if ( ! is_array( $args ) ) {
1177 1262 // For reverse compatibility.
1178 1263 $args = array(
1179 1264 'message' => $args,
@@ -1206,17 +1291,38 @@
1206 1291
1207 1292 $sections = self::get_settings_tabs( $values );
1208 1293 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' );
1209 1294
1210 - require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
1295 + require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php';
1211 1296 }
1212 1297
1213 1298 /**
1299 + * 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.
1300 + *
1301 + * @since 6.10
1302 + *
1303 + * @return void
1304 + */
1305 + private static function maybe_print_media_templates() {
1306 + if ( FrmAppHelper::pro_is_included() ) {
1307 + // This issue does not exist when Pro is active so exit early.
1308 + return;
1309 + }
1310 +
1311 + add_action(
1312 + 'wp_enqueue_editor',
1313 + function () {
1314 + wp_print_media_templates();
1315 + }
1316 + );
1317 + }
1318 +
1319 + /**
1214 1320 * @since 4.0
1215 1321 */
1216 1322 public static function form_publish_button( $atts ) {
1217 1323 $values = $atts['values'];
1218 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
1324 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
1219 1325 }
1220 1326
1221 1327 /**
1222 1328 * Get a list of all the settings tabs for the form settings page.
@@ -1241,9 +1347,9 @@
1241 1347 'icon' => 'frm_icon_font frm_mail_bulk_icon',
1242 1348 ),
1243 1349 'permissions' => array(
1244 1350 'name' => __( 'Form Permissions', 'formidable' ),
1245 - 'icon' => 'frm_icon_font frm_lock_icon',
1351 + 'icon' => 'frm_icon_font frm_lock_closed_icon',
1246 1352 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1247 1353 'data' => array(
1248 1354 'medium' => 'permissions',
1249 1355 'upgrade' => __( 'Form Permissions', 'formidable' ),
@@ -1250,9 +1356,9 @@
1250 1356 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1251 1357 'screenshot' => 'permissions.png',
1252 1358 ),
1253 1359 ),
1254 - 'scheduling' => array(
1360 + 'scheduling' => array(
1255 1361 'name' => __( 'Form Scheduling', 'formidable' ),
1256 1362 'icon' => 'frm_icon_font frm_calendar_icon',
1257 1363 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1258 1364 'data' => array(
@@ -1285,9 +1391,9 @@
1285 1391 'screenshot' => 'chat.png',
1286 1392 )
1287 1393 ),
1288 1394 ),
1289 - 'abandonment' => array(
1395 + 'abandonment' => array(
1290 1396 'name' => __( 'Form Abandonment', 'formidable' ),
1291 1397 'icon' => 'frm_icon_font frm_abandoned_icon',
1292 1398 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1293 1399 'data' => FrmAppHelper::get_upgrade_data_params(
@@ -1306,8 +1412,12 @@
1306 1412 'icon' => 'frm_icon_font frm_code_icon',
1307 1413 ),
1308 1414 );
1309 1415
1416 + if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1417 + unset( $sections['buttons'] );
1418 + }
1419 +
1310 1420 foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1311 1421 if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1312 1422 unset( $sections[ $feature ] );
1313 1423 }
@@ -1314,13 +1424,8 @@
1314 1424 }
1315 1425
1316 1426 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1317 1427
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 1428 foreach ( $sections as $key => $section ) {
1324 1429 $defaults = array(
1325 1430 'html_class' => '',
1326 1431 'name' => ucfirst( $key ),
@@ -1342,9 +1447,9 @@
1342 1447 $section['id'] = $section['anchor'];
1343 1448 }
1344 1449
1345 1450 $sections[ $key ] = $section;
1346 - }
1451 + }//end foreach
1347 1452
1348 1453 return $sections;
1349 1454 }
1350 1455
@@ -1351,8 +1456,9 @@
1351 1456 /**
1352 1457 * @since 4.0
1353 1458 *
1354 1459 * @param array $values
1460 + * @return void
1355 1461 */
1356 1462 public static function advanced_settings( $values ) {
1357 1463 $first_h3 = 'frm_first_h3';
1358 1464
@@ -1360,8 +1466,9 @@
1360 1466 }
1361 1467
1362 1468 /**
1363 1469 * @param array $values
1470 + * @return void
1364 1471 */
1365 1472 public static function render_spam_settings( $values ) {
1366 1473 if ( function_exists( 'akismet_http_post' ) ) {
1367 1474 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
@@ -1373,16 +1480,12 @@
1373 1480 /**
1374 1481 * @since 4.0
1375 1482 *
1376 1483 * @param array $values
1484 + * @return void
1377 1485 */
1378 1486 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' );
1487 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
1385 1488 }
1386 1489
1387 1490 /**
1388 1491 * @since 4.0
@@ -1387,11 +1490,12 @@
1387 1490 /**
1388 1491 * @since 4.0
1389 1492 *
1390 1493 * @param array $values
1494 + * @return void
1391 1495 */
1392 1496 public static function html_settings( $values ) {
1393 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' );
1497 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
1394 1498 }
1395 1499
1396 1500 /**
1397 1501 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -1397,9 +1501,10 @@
1397 1501 * Replace old Submit Button href with new href to avoid errors in Chrome
1398 1502 *
1399 1503 * @since 2.03.08
1400 1504 *
1401 - * @param array|boolean $values
1505 + * @param array|bool $values
1506 + * @return void
1402 1507 */
1403 1508 private static function clean_submit_html( &$values ) {
1404 1509 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
1405 1510 $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
@@ -1420,8 +1525,13 @@
1420 1525
1421 1526 return $classes;
1422 1527 }
1423 1528
1529 + /**
1530 + * @param int|string $form_id
1531 + * @param string $class
1532 + * @return void
1533 + */
1424 1534 public static function mb_tags_box( $form_id, $class = '' ) {
1425 1535 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1426 1536
1427 1537 /**
@@ -1434,9 +1544,9 @@
1434 1544 */
1435 1545 $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) );
1436 1546 $linked_forms = array();
1437 1547 $col = 'one';
1438 - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
1548 + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' );
1439 1549
1440 1550 $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
1441 1551 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1442 1552
@@ -1441,9 +1551,9 @@
1441 1551 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1442 1552
1443 1553 $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
1444 1554
1445 - include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
1555 + include FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php';
1446 1556 }
1447 1557
1448 1558 /**
1449 1559 * @since 3.04.01
@@ -1456,9 +1566,9 @@
1456 1566 ),
1457 1567 );
1458 1568
1459 1569 $user_fields = self::user_shortcodes();
1460 - if ( ! empty( $user_fields ) ) {
1570 + if ( $user_fields ) {
1461 1571 $user_helpers = array();
1462 1572 foreach ( $user_fields as $uk => $uf ) {
1463 1573 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1464 1574 unset( $uk, $uf );
@@ -1464,9 +1574,9 @@
1464 1574 unset( $uk, $uf );
1465 1575 }
1466 1576
1467 1577 $advanced_helpers['user_id'] = array(
1468 - 'codes' => $user_helpers,
1578 + 'codes' => $user_helpers,
1469 1579 );
1470 1580 }
1471 1581
1472 1582 /**
@@ -1543,21 +1653,16 @@
1543 1653 'updated-at' => __( 'Entry updated', 'formidable' ),
1544 1654 '' => '',
1545 1655 'siteurl' => __( 'Site URL', 'formidable' ),
1546 1656 'sitename' => __( 'Site Name', 'formidable' ),
1657 + 'form_name' => __( 'Form Name', 'formidable' ),
1547 1658 );
1548 1659
1660 + $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1549 1661 if ( ! FrmAppHelper::pro_is_installed() ) {
1550 1662 unset( $entry_shortcodes['post_id'] );
1551 1663 }
1552 1664
1553 - if ( $settings_tab ) {
1554 - $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1555 - $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1556 - $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1557 - $entry_shortcodes['form_name'] = __( 'Form Name', 'formidable' );
1558 - }
1559 -
1560 1665 /**
1561 1666 * Use this hook to add or remove buttons in the helpers section
1562 1667 * in the customization panel
1563 1668 *
@@ -1607,11 +1712,11 @@
1607 1712 check_ajax_referer( 'frm_ajax', 'nonce' );
1608 1713
1609 1714 echo FrmEntriesController::show_entry_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1610 1715 array(
1611 - 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
1716 + 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1612 1717 'default_email' => true,
1613 - 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
1718 + 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1614 1719 )
1615 1720 );
1616 1721 wp_die();
1617 1722 }
@@ -1617,10 +1722,10 @@
1617 1722 }
1618 1723
1619 1724 /**
1620 1725 * @param string $content
1621 - * @param stdClass|string|int $form
1622 - * @param stdClass|string|int|false $entry
1726 + * @param int|stdClass|string $form
1727 + * @param false|int|stdClass|string $entry
1623 1728 * @return string
1624 1729 */
1625 1730 public static function filter_content( $content, $form, $entry = false ) {
1626 1731 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1633,8 +1738,16 @@
1633 1738 if ( is_object( $form ) ) {
1634 1739 $form = $form->id;
1635 1740 }
1636 1741
1742 + /*
1743 + * Repeater actions adds `parent_entry` to `$entry` store the parent entry data. If `parent_entry` is not empty,
1744 + * use the parent form ID instead of repeater form ID to fix the parent form field shortcodes doesn't work.
1745 + */
1746 + if ( ! empty( $entry->parent_entry ) ) {
1747 + $form = $entry->parent_entry->form_id;
1748 + }
1749 +
1637 1750 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1638 1751 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1639 1752
1640 1753 return $content;
@@ -1644,11 +1757,11 @@
1644 1757 * Replace any [form_name] shortcodes in a string.
1645 1758 *
1646 1759 * @since 5.5
1647 1760 *
1648 - * @param string|array $string
1649 - * @param stdClass|string|int $form
1650 - * @return string|array
1761 + * @param array|string $string
1762 + * @param int|stdClass|string $form
1763 + * @return array|string
1651 1764 */
1652 1765 public static function replace_form_name_shortcodes( $string, $form ) {
1653 1766 if ( ! is_string( $string ) ) {
1654 1767 return $string;
@@ -1666,9 +1779,9 @@
1666 1779 return str_replace( '[form_name]', $form_name, $string );
1667 1780 }
1668 1781
1669 1782 /**
1670 - * @param stdClass|string|int|false $entry
1783 + * @param false|int|stdClass|string $entry
1671 1784 * @return void
1672 1785 */
1673 1786 private static function get_entry_by_param( &$entry ) {
1674 1787 if ( ! $entry || ! is_object( $entry ) ) {
@@ -1683,8 +1796,12 @@
1683 1796 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1684 1797 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1685 1798 }
1686 1799
1800 + /**
1801 + * @param array $errors
1802 + * @return array
1803 + */
1687 1804 public static function process_bulk_form_actions( $errors ) {
1688 1805 if ( ! $_REQUEST ) {
1689 1806 return $errors;
1690 1807 }
@@ -1728,9 +1845,9 @@
1728 1845 case 'untrash':
1729 1846 $message = self::bulk_untrash( $ids );
1730 1847 }
1731 1848
1732 - if ( isset( $message ) && ! empty( $message ) ) {
1849 + if ( ! empty( $message ) ) {
1733 1850 $errors['message'] = $message;
1734 1851 }
1735 1852
1736 1853 return $errors;
@@ -1750,9 +1867,9 @@
1750 1867 $json_vars = json_decode( $json_vars, true );
1751 1868 if ( empty( $json_vars ) ) {
1752 1869 // json decoding failed so we should return an error message.
1753 1870 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1754 - if ( 'edit' == $action ) {
1871 + if ( 'edit' === $action ) {
1755 1872 $action = 'update';
1756 1873 }
1757 1874
1758 1875 add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
@@ -1768,16 +1885,14 @@
1768 1885 if ( isset( $_REQUEST['delete_all'] ) ) {
1769 1886 // Override the action for this page.
1770 1887 $action = 'delete_all';
1771 1888 }
1772 - }
1889 + }//end if
1773 1890
1774 1891 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1775 1892 FrmAppHelper::trigger_hook_load( 'form' );
1776 1893
1777 1894 switch ( $action ) {
1778 - case 'new':
1779 - return self::new_form( $vars );
1780 1895 case 'create':
1781 1896 case 'edit':
1782 1897 case 'update':
1783 1898 case 'trash':
@@ -1782,16 +1897,17 @@
1782 1897 case 'update':
1783 1898 case 'trash':
1784 1899 case 'untrash':
1785 1900 case 'destroy':
1786 - case 'delete_all':
1787 1901 case 'settings':
1788 1902 case 'update_settings':
1789 1903 return self::$action( $vars );
1790 1904 case 'lite-reports':
1791 - return self::no_reports( $vars );
1905 + self::no_reports( $vars );
1906 + return;
1792 1907 case 'views':
1793 - return self::no_views( $vars );
1908 + self::no_views( $vars );
1909 + return;
1794 1910 default:
1795 1911 do_action( 'frm_form_action_' . $action );
1796 1912 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
1797 1913 return;
@@ -1814,14 +1930,47 @@
1814 1930 self::display_forms_list( array(), '', array( __( 'There was a problem duplicating the form', 'formidable' ) ) );
1815 1931 return;
1816 1932 }
1817 1933
1934 + if ( 'forms_permanently_deleted' === $message ) {
1935 + $count = FrmAppHelper::get_param( 'forms_deleted', 0, 'get', 'absint' );
1936 + /* translators: %1$s: Number of forms */
1937 + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
1938 + self::display_forms_list( array(), $message, '' );
1939 + return;
1940 + }
1941 +
1818 1942 self::display_forms_list();
1819 1943
1820 1944 return;
1821 - }
1945 + }//end switch
1822 1946 }
1823 1947
1948 + /**
1949 + * Rename a form.
1950 + *
1951 + * Handles the AJAX request for renaming a form.
1952 + *
1953 + * @since 6.7
1954 + *
1955 + * @return void
1956 + */
1957 + public static function rename_form() {
1958 + // Check permission and nonce
1959 + FrmAppHelper::permission_check( 'frm_edit_forms' );
1960 + check_ajax_referer( 'frm_ajax', 'nonce' );
1961 +
1962 + // Get posted data
1963 + $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
1964 + $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
1965 +
1966 + // Update the form name and form key.
1967 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
1968 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
1969 +
1970 + wp_send_json_success( compact( 'form_key' ) );
1971 + }
1972 +
1824 1973 public static function json_error( $errors ) {
1825 1974 $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1826 1975
1827 1976 return $errors;
@@ -1827,20 +1976,13 @@
1827 1976 return $errors;
1828 1977 }
1829 1978
1830 1979 /**
1831 - * Education for premium features.
1832 - *
1833 - * @since 4.05
1834 - */
1835 - public static function add_form_style_tab_options() {
1836 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' );
1837 - }
1838 -
1839 - /**
1840 1980 * Add education about views.
1841 1981 *
1842 1982 * @since 4.07
1983 + *
1984 + * @return void
1843 1985 */
1844 1986 public static function no_views( $values = array() ) {
1845 1987 FrmAppHelper::include_svg();
1846 1988 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -1852,8 +1994,10 @@
1852 1994 /**
1853 1995 * Add education about reports.
1854 1996 *
1855 1997 * @since 4.07
1998 + *
1999 + * @return void
1856 2000 */
1857 2001 public static function no_reports( $values = array() ) {
1858 2002 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
1859 2003 $form = $id ? FrmForm::getOne( $id ) : false;
@@ -1860,9 +2004,11 @@
1860 2004
1861 2005 include FrmAppHelper::plugin_path() . '/classes/views/shared/reports-info.php';
1862 2006 }
1863 2007
1864 - /* FRONT-END FORMS */
2008 + /**
2009 + * FRONT-END FORMS.
2010 + */
1865 2011 public static function admin_bar_css() {
1866 2012 if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
1867 2013 return;
1868 2014 }
@@ -1936,9 +2082,9 @@
1936 2082 $wp_admin_bar->add_node(
1937 2083 array(
1938 2084 'parent' => 'frm-forms',
1939 2085 'id' => 'edit_form_' . $form_id,
1940 - 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
2086 + 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name,
1941 2087 'href' => FrmForm::get_edit_link( $form_id ),
1942 2088 )
1943 2089 );
1944 2090 }
@@ -1951,10 +2097,10 @@
1951 2097 * @return string
1952 2098 */
1953 2099 public static function get_form_shortcode( $atts ) {
1954 2100 global $frm_vars;
1955 - if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1956 - $sc = '[formidable';
2101 + if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2102 + $sc = '[formidable';
1957 2103 $sc .= FrmAppHelper::array_to_html_params( $atts );
1958 2104 return $sc . ']';
1959 2105 }
1960 2106
@@ -1979,11 +2125,11 @@
1979 2125
1980 2126 /**
1981 2127 * @since 5.2.01
1982 2128 *
1983 - * @param string|int|false $id
1984 - * @param string|false $key
1985 - * @return stdClass|false
2129 + * @param false|int|string $id
2130 + * @param false|string $key
2131 + * @return false|stdClass
1986 2132 */
1987 2133 private static function maybe_get_form_by_id_or_key( $id, $key ) {
1988 2134 if ( ! $id ) {
1989 2135 $id = $key;
@@ -1991,12 +2137,12 @@
1991 2137 return self::maybe_get_form_to_show( $id );
1992 2138 }
1993 2139
1994 2140 /**
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.
2141 + * @param false|int|string $id
2142 + * @param false|string $key
2143 + * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2144 + * @param bool|int|string $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1999 2145 * @param array $atts
2000 2146 * @return string
2001 2147 */
2002 2148 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
@@ -2044,15 +2190,16 @@
2044 2190 return $form;
2045 2191 }
2046 2192
2047 2193 /**
2048 - * @param string|int|false $id
2049 - * @return stdClass|false
2194 + * @param false|int|string $id
2195 + * @return false|stdClass
2050 2196 */
2051 2197 private static function maybe_get_form_to_show( $id ) {
2052 2198 $form = false;
2053 2199
2054 - if ( ! empty( $id ) ) { // form id or key is set
2200 + if ( ! empty( $id ) ) {
2201 + // Form id or key is set.
2055 2202 $form = FrmForm::getOne( $id );
2056 2203 if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) {
2057 2204 $form = false;
2058 2205 }
@@ -2110,11 +2257,11 @@
2110 2257
2111 2258 do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
2112 2259
2113 2260 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;
2261 + $entry_id = self::just_created_entry( $form->id );
2262 + $pass_args['entry_id'] = $entry_id;
2263 + $pass_args['reset'] = true;
2117 2264
2118 2265 self::run_on_submit_actions( $pass_args );
2119 2266
2120 2267 do_action(
@@ -2124,9 +2271,9 @@
2124 2271 'form' => $form,
2125 2272 )
2126 2273 );
2127 2274 }
2128 - }
2275 + }//end if
2129 2276 }
2130 2277
2131 2278 /**
2132 2279 * If the form was processed earlier (init), get the generated errors
@@ -2158,9 +2305,9 @@
2158 2305 */
2159 2306 public static function just_created_entry( $form_id ) {
2160 2307 global $frm_vars;
2161 2308
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;
2309 + 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 2310 }
2164 2311
2165 2312 /**
2166 2313 * Gets confirmation method.
@@ -2173,14 +2320,14 @@
2173 2320 *
2174 2321 * @type object $form Form object.
2175 2322 * @type int $entry_id Entry ID.
2176 2323 * }
2177 - * @return string|array
2324 + * @return array|string
2178 2325 */
2179 2326 private static function get_confirmation_method( $atts ) {
2180 2327 $action = FrmOnSubmitHelper::current_event( $atts );
2181 2328 $opt = 'update' === $action ? 'edit_action' : 'success_action';
2182 - $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
2329 + $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2183 2330
2184 2331 if ( ! empty( $atts['entry_id'] ) ) {
2185 2332 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2186 2333 if ( $met_actions ) {
@@ -2189,9 +2336,9 @@
2189 2336 }
2190 2337
2191 2338 $method = apply_filters( 'frm_success_filter', $method, $atts['form'], $action );
2192 2339
2193 - if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2340 + if ( $method !== 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2194 2341 $method = 'message';
2195 2342 }
2196 2343
2197 2344 return $method;
@@ -2276,9 +2423,9 @@
2276 2423 unset( $extra_args['form'] );
2277 2424
2278 2425 do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
2279 2426
2280 - $opt = ( ! isset( $args['action'] ) || $args['action'] === 'create' ) ? 'success' : 'edit';
2427 + $opt = ! isset( $args['action'] ) || $args['action'] === 'create' ? 'success' : 'edit';
2281 2428
2282 2429 $args['success_opt'] = $opt;
2283 2430 $args['ajax'] = ! empty( $frm_vars['ajax'] );
2284 2431
@@ -2304,16 +2451,16 @@
2304 2451 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
2305 2452 return array();
2306 2453 }
2307 2454
2308 - // If a redirect action has already opened the URL in a new tab, we show the default message in the currect tab.
2455 + // If a redirect action has already opened the URL in a new tab, we show the default message in the current tab.
2309 2456 if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) {
2310 2457 return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) );
2311 2458 }
2312 2459
2313 - $entry = FrmEntry::getOne( $args['entry_id'], true );
2314 - $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2315 - $met_actions = array();
2460 + $entry = FrmEntry::getOne( $args['entry_id'], true );
2461 + $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2462 + $met_actions = array();
2316 2463 $has_redirect = false;
2317 2464
2318 2465 foreach ( $actions as $action ) {
2319 2466 if ( ! in_array( $event, $action->post_content['event'], true ) ) {
@@ -2326,9 +2473,10 @@
2326 2473
2327 2474 $action_type = FrmOnSubmitHelper::get_action_type( $action );
2328 2475
2329 2476 if ( 'redirect' === $action_type ) {
2330 - if ( $has_redirect ) { // Do not process because we run the first redirect action only.
2477 + if ( $has_redirect ) {
2478 + // Do not process because we run the first redirect action only.
2331 2479 continue;
2332 2480 }
2333 2481 }
2334 2482
@@ -2341,9 +2489,9 @@
2341 2489 }
2342 2490
2343 2491 $met_actions[] = $action;
2344 2492 unset( $action );
2345 - }
2493 + }//end foreach
2346 2494
2347 2495 $args['event'] = $event;
2348 2496
2349 2497 /**
@@ -2532,9 +2680,9 @@
2532 2680 add_filter( 'the_content', 'FrmFormsController::preview_content', 9999 );
2533 2681 }
2534 2682
2535 2683 $post = $old_post;
2536 - }
2684 + }//end if
2537 2685 }
2538 2686
2539 2687 /**
2540 2688 * @since 3.0
@@ -2555,14 +2703,16 @@
2555 2703 $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args );
2556 2704
2557 2705 $doing_ajax = FrmAppHelper::doing_ajax();
2558 2706
2559 - if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) { // Is AJAX submit and there is just one Redirect action runs.
2707 + if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) {
2708 + // Is AJAX submit and there is just one Redirect action runs.
2560 2709 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
2561 2710 wp_die();
2562 2711 }
2563 2712
2564 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) { // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2713 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) {
2714 + // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2565 2715 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2566 2716 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
2567 2717 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
2568 2718 return;
@@ -2568,9 +2718,10 @@
2568 2718 return;
2569 2719 }
2570 2720
2571 2721 wp_redirect( esc_url_raw( $success_url ) );
2572 - die(); // do not use wp_die or redirect fails
2722 + // Do not use wp_die or redirect fails.
2723 + die();
2573 2724 }
2574 2725
2575 2726 // Redirect with a delay.
2576 2727 self::redirect_after_submit_using_js( $args + compact( 'success_url', 'doing_ajax' ) );
@@ -2621,9 +2772,9 @@
2621 2772
2622 2773 $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2623 2774
2624 2775 ob_start();
2625 - self::show_lone_success_messsage( $args );
2776 + self::show_lone_success_message( $args );
2626 2777 $response_data['content'] = ob_get_clean();
2627 2778
2628 2779 $response_data['fallbackMsg'] = self::get_redirect_fallback_message( $args['success_url'], $args );
2629 2780 }
@@ -2647,9 +2798,9 @@
2647 2798 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
2648 2799 *
2649 2800 * @since 6.0
2650 2801 *
2651 - * @param int $delay_time Delay time in miliseconds.
2802 + * @param int $delay_time Delay time in milliseconds.
2652 2803 */
2653 2804 $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
2654 2805
2655 2806 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
@@ -2661,9 +2812,10 @@
2661 2812 add_filter( 'frm_use_wpautop', '__return_true' );
2662 2813
2663 2814 echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2664 2815 echo '<script>';
2665 - if ( empty( $args['doing_ajax'] ) ) { // Not AJAX submit, delay JS until window.load.
2816 + if ( empty( $args['doing_ajax'] ) ) {
2817 + // Not AJAX submit, delay JS until window.load.
2666 2818 echo 'window.onload=function(){';
2667 2819 }
2668 2820 echo 'setTimeout(function(){' . $redirect_js . '}, ' . intval( $delay_time ) . ');'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2669 2821 if ( empty( $args['doing_ajax'] ) ) {
@@ -2676,9 +2828,9 @@
2676 2828 * @since 3.0
2677 2829 *
2678 2830 * @param string $success_url
2679 2831 * @param string $success_msg
2680 - * @param array $args
2832 + * @param array $args
2681 2833 */
2682 2834 private static function get_redirect_message( $success_url, $success_msg, $args ) {
2683 2835 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
2684 2836 self::get_redirect_fallback_message( $success_url, $args ) .
@@ -2736,9 +2888,9 @@
2736 2888 } else {
2737 2889 self::show_form_after_submit( $atts );
2738 2890 }
2739 2891 } else {
2740 - self::show_lone_success_messsage( $atts );
2892 + self::show_lone_success_message( $atts );
2741 2893 }
2742 2894 }
2743 2895
2744 2896 /**
@@ -2777,11 +2929,10 @@
2777 2929 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
2778 2930 }
2779 2931
2780 2932 /**
2933 + * @since 4.05.02
2781 2934 * @return string - 'before', 'after', or 'submit'
2782 - *
2783 - * @since 4.05.02
2784 2935 */
2785 2936 private static function message_placement( $form, $message ) {
2786 2937 $place = 'before';
2787 2938
@@ -2793,11 +2944,10 @@
2793 2944 }
2794 2945 }
2795 2946
2796 2947 /**
2948 + * @since 4.05.02
2797 2949 * @return string - 'before' or 'after'
2798 - *
2799 - * @since 4.05.02
2800 2950 */
2801 2951 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
2802 2952 }
2803 2953
@@ -2831,9 +2981,9 @@
2831 2981 * Show the success message without the form
2832 2982 *
2833 2983 * @since 2.05
2834 2984 */
2835 - private static function show_lone_success_messsage( $atts ) {
2985 + private static function show_lone_success_message( $atts ) {
2836 2986 global $frm_vars;
2837 2987 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
2838 2988 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
2839 2989
@@ -2842,9 +2992,9 @@
2842 2992 $errors = array();
2843 2993 $form = $atts['form'];
2844 2994 $message = $atts['message'];
2845 2995
2846 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
2996 + include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
2847 2997 }
2848 2998
2849 2999 /**
2850 3000 * Prepare the success message before it's shown
@@ -2964,9 +3114,9 @@
2964 3114 global $frm_vars;
2965 3115
2966 3116 FrmStylesController::enqueue_css();
2967 3117
2968 - if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3118 + if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
2969 3119 // load formidable js
2970 3120 wp_enqueue_script( 'formidable' );
2971 3121 }
2972 3122 }
@@ -2982,12 +3132,12 @@
2982 3132 }
2983 3133
2984 3134 /**
2985 3135 * @since 2.0.8
2986 - * @return boolean
3136 + * @return bool
2987 3137 */
2988 3138 private static function is_minification_on( $atts ) {
2989 - return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
3139 + return ! empty( $atts['minimize'] );
2990 3140 }
2991 3141
2992 3142 /**
2993 3143 * @since 5.0.16
@@ -3015,9 +3165,9 @@
3015 3165 * Create a page with an embedded formidable Gutenberg block.
3016 3166 *
3017 3167 * @since 5.2
3018 3168 *
3019 - * @return never
3169 + * @return void
3020 3170 */
3021 3171 public static function create_page_with_shortcode() {
3022 3172 if ( ! current_user_can( 'publish_posts' ) ) {
3023 3173 die( 0 );
@@ -3062,10 +3212,9 @@
3062 3212
3063 3213 /**
3064 3214 * @since 5.3
3065 3215 *
3066 - * @param string $content
3067 - * @param int $form_id
3216 + * @param int $form_id
3068 3217 * @return string
3069 3218 */
3070 3219 private static function get_page_shortcode_content_for_form( $form_id ) {
3071 3220 $shortcode = '[formidable id="' . $form_id . '"]';
@@ -3076,9 +3225,9 @@
3076 3225
3077 3226 /**
3078 3227 * Get page dropdown for AJAX request for embedding form in an existing page.
3079 3228 *
3080 - * @return never
3229 + * @return void
3081 3230 */
3082 3231 public static function get_page_dropdown() {
3083 3232 if ( ! current_user_can( 'publish_posts' ) ) {
3084 3233 die( 0 );
@@ -3086,9 +3235,9 @@
3086 3235
3087 3236 check_ajax_referer( 'frm_ajax', 'nonce' );
3088 3237
3089 3238 $html = FrmAppHelper::clip(
3090 - function() {
3239 + function () {
3091 3240 FrmAppHelper::maybe_autocomplete_pages_options(
3092 3241 array(
3093 3242 'field_name' => 'frm_page_dropdown',
3094 3243 'page_id' => '',
@@ -3108,15 +3257,8 @@
3108 3257
3109 3258 /**
3110 3259 * @deprecated 4.0
3111 3260 */
3112 - public static function new_form( $values = array() ) {
3113 - FrmDeprecated::new_form( $values );
3114 - }
3115 -
3116 - /**
3117 - * @deprecated 4.0
3118 - */
3119 3261 public static function create( $values = array() ) {
3120 3262 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3121 3263 self::update( $values );
3122 3264 }
@@ -3121,35 +3263,16 @@
3121 3263 self::update( $values );
3122 3264 }
3123 3265
3124 3266 /**
3125 - * @deprecated 3.0
3126 - * @codeCoverageIgnore
3267 + * Education for premium features.
3268 + *
3269 + * @since 4.05
3270 + * @deprecated 6.16.3
3271 + *
3272 + * @return void
3127 3273 */
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' );
3274 + public static function add_form_style_tab_options() {
3275 + _deprecated_function( __METHOD__, '6.16.3' );
3276 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php';
3154 3277 }
3155 3278 }