PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmFormsController.php +314 -643 6.256.7 View file →
@@ -6,9 +6,9 @@
6 6 class FrmFormsController {
7 7
8 8 /**
9 9 * Track the form that opened the redirect URL in a new tab. This is used to check if we should show the default
10 - * message in the current tab.
10 + * message in the currect tab.
11 11 *
12 12 * @since 6.2
13 13 *
14 14 * @var array Keys are form IDs and values are 1.
@@ -14,18 +14,8 @@
14 14 * @var array Keys are form IDs and values are 1.
15 15 */
16 16 private static $redirected_in_new_tab = array();
17 17
18 - /**
19 - * The HTML for the Formdiable TinyMCE button (That triggers a popup to insert shortcodes)
20 - * is stored here and re-used as an optimization.
21 - *
22 - * @since 6.11
23 - *
24 - * @var string|null
25 - */
26 - private static $formidable_tinymce_button;
27 -
28 18 public static function menu() {
29 19 $menu_label = __( 'Forms', 'formidable' );
30 20 if ( ! FrmAppHelper::pro_is_installed() ) {
31 21 $menu_label .= ' (Lite)';
@@ -64,12 +54,12 @@
64 54 */
65 55 public static function logic_tip() {
66 56 $images_url = FrmAppHelper::plugin_url() . '/images/';
67 57 $data_message = __( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' );
68 - $data_message .= ' <img src="' . esc_url( $images_url ) . '/survey-logic.png" srcset="' . esc_url( $images_url ) . 'survey-logic@2x.png 2x" alt="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '"/>';
58 + $data_message .= ' <img src="' . esc_attr( $images_url ) . '/survey-logic.png" srcset="' . esc_attr( $images_url ) . 'survey-logic@2x.png 2x" alt="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '"/>';
69 59 echo '<a href="javascript:void(0)" class="frm_noallow frm_show_upgrade frm_add_logic_link frm-collapsed frm-flex-justify" data-upgrade="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '" data-message="' . esc_attr( $data_message ) . '" data-medium="builder" data-content="logic">';
70 60 esc_html_e( 'Conditional Logic', 'formidable' );
71 - FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon', array( 'aria-hidden' => 'true' ) );
61 + FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown6_icon', array( 'aria-hidden' => 'true' ) );
72 62 echo '</a>';
73 63 }
74 64
75 65 /**
@@ -106,23 +96,15 @@
106 96 * Create the default email action
107 97 *
108 98 * @since 2.02.11
109 99 *
110 - * @param int|object $form
111 - * @return void
100 + * @param object|int $form
112 101 */
113 102 private static function create_default_email_action( $form ) {
114 103 FrmForm::maybe_get_form( $form );
115 - if ( ! is_object( $form ) ) {
116 - return;
117 - }
118 -
119 104 $create_email = apply_filters( 'frm_create_default_email_action', true, $form );
120 105
121 106 if ( $create_email ) {
122 - /**
123 - * @var FrmFormAction
124 - */
125 107 $action_control = FrmFormActionsController::get_form_actions( 'email' );
126 108 $action_control->create( $form->id );
127 109 }
128 110 }
@@ -131,16 +113,12 @@
131 113 * Create the default On submit action
132 114 *
133 115 * @since 6.0.0
134 116 *
135 - * @param int|object $form Form object or ID.
136 - * @return void
117 + * @param object|int $form Form object or ID.
137 118 */
138 119 private static function create_default_on_submit_action( $form ) {
139 120 FrmForm::maybe_get_form( $form );
140 - if ( ! is_object( $form ) ) {
141 - return;
142 - }
143 121
144 122 /**
145 123 * Enable or disable the default On Submit action.
146 124 *
@@ -151,65 +129,21 @@
151 129 */
152 130 $create = apply_filters( 'frm_create_default_on_submit_action', true, $form );
153 131
154 132 if ( $create ) {
155 - /**
156 - * @var FrmFormAction
157 - */
158 133 $action_control = FrmFormActionsController::get_form_actions( FrmOnSubmitAction::$slug );
159 134 $action_control->create( $form->id );
160 135 }
161 136 }
162 137
163 - /**
164 - * Creates submit button field.
165 - *
166 - * @since 6.9
167 - *
168 - * @param int|object $form Form ID or object.
169 - * @return void
170 - */
171 - private static function create_submit_button_field( $form ) {
172 - FrmForm::maybe_get_form( $form );
173 - if ( ! is_object( $form ) ) {
174 - return;
175 - }
176 -
177 - if ( FrmSubmitHelper::get_submit_field( $form->id ) ) {
178 - // Do not create submit button field if it exists.
179 - return;
180 - }
181 -
182 - FrmField::create(
183 - array(
184 - 'type' => FrmSubmitHelper::FIELD_TYPE,
185 - 'name' => __( 'Submit', 'formidable' ),
186 - 'field_order' => FrmSubmitHelper::DEFAULT_ORDER,
187 - 'form_id' => $form->id,
188 - 'field_options' => FrmFieldsHelper::get_default_field_options( FrmSubmitHelper::FIELD_TYPE ),
189 - 'description' => '',
190 - 'default_value' => '',
191 - 'options' => array(),
192 - )
193 - );
194 - }
195 -
196 - /**
197 - * @return void
198 - */
199 138 public static function edit( $values = false ) {
200 139 FrmAppHelper::permission_check( 'frm_edit_forms' );
201 140
202 141 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
203 142
204 - self::get_edit_vars( $id );
143 + return self::get_edit_vars( $id );
205 144 }
206 145
207 - /**
208 - * @param mixed $id
209 - * @param string $message
210 - * @return void
211 - */
212 146 public static function settings( $id = false, $message = '' ) {
213 147 FrmAppHelper::permission_check( 'frm_edit_forms' );
214 148
215 149 if ( ! $id || ! is_numeric( $id ) ) {
@@ -217,34 +151,21 @@
217 151 }
218 152
219 153 FrmOnSubmitHelper::maybe_migrate_submit_settings_to_action( $id );
220 154
221 - self::get_settings_vars( $id, array(), $message );
155 + return self::get_settings_vars( $id, array(), $message );
222 156 }
223 157
224 158 public static function update_settings() {
225 159 FrmAppHelper::permission_check( 'frm_edit_forms' );
226 - $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' );
227 160
228 - if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) {
229 - $frm_settings = FrmAppHelper::get_settings();
230 - $error_args = array(
231 - 'title' => __( 'Verification failed', 'formidable' ),
232 - 'body' => $frm_settings->admin_permission,
233 - 'cancel_text' => __( 'Cancel', 'formidable' ),
234 - );
235 - FrmAppController::show_error_modal( $error_args );
236 - return;
237 - }
238 -
239 161 $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
240 162
241 - $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
163 + $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
242 164 $warnings = FrmFormsHelper::check_for_warnings( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
243 165
244 166 if ( count( $errors ) > 0 ) {
245 - self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
246 - return;
167 + return self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
247 168 }
248 169
249 170 do_action( 'frm_before_update_form_settings', $id );
250 171
@@ -258,9 +179,9 @@
258 179 }
259 180
260 181 $message = __( 'Settings Successfully Updated', 'formidable' );
261 182
262 - self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
183 + return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
263 184 }
264 185
265 186 /**
266 187 * @param int $form_id
@@ -270,11 +191,8 @@
270 191 $form = FrmForm::getOne( $form_id );
271 192 return ! empty( $form->options['antispam'] );
272 193 }
273 194
274 - /**
275 - * @return void
276 - */
277 195 public static function update( $values = array() ) {
278 196 if ( empty( $values ) ) {
279 197 $values = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing
280 198 }
@@ -292,72 +210,63 @@
292 210
293 211 $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
294 212
295 213 if ( count( $errors ) > 0 ) {
296 - self::get_edit_vars( $id, $errors );
297 - return;
298 - }
214 + return self::get_edit_vars( $id, $errors );
215 + } else {
216 + FrmForm::update( $id, $values );
217 + $message = __( 'Form was successfully updated.', 'formidable' );
299 218
300 - self::maybe_remove_draft_option_from_fields( $id );
219 + if ( self::is_too_long( $values ) ) {
220 + $message .= '<br/> ' . sprintf(
221 + /* translators: %1$s: Start link HTML, %2$s: end link HTML */
222 + __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
223 + '<a href="https://formidableforms.com/knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/?utm_source=WordPress&utm_medium=builder&utm_campaign=liteplugin" target="_blank" rel="noopener">',
224 + '</a>'
225 + );
226 + }
301 227
302 - FrmForm::update( $id, $values );
303 - $message = __( 'Form was successfully updated.', 'formidable' );
228 + if ( defined( 'DOING_AJAX' ) ) {
229 + wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
230 + }
304 231
305 - if ( self::is_too_long( $values ) ) {
306 - $message .= '<br/> ' . sprintf(
307 - /* translators: %1$s: Start link HTML, %2$s: end link HTML */
308 - __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
309 - '<a href="https://formidableforms.com/knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/?utm_source=WordPress&utm_medium=builder&utm_campaign=liteplugin" target="_blank" rel="noopener">',
310 - '</a>'
311 - );
232 + return self::get_edit_vars( $id, array(), $message );
312 233 }
234 + }
313 235
314 - if ( defined( 'DOING_AJAX' ) ) {
315 - wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
316 - }
317 -
318 - self::get_edit_vars( $id, array(), $message );
236 + /**
237 + * Check if the value at the end of the form was included.
238 + * If it's missing, it means other values at the end of the form
239 + * were likely not saved either.
240 + *
241 + * @since 3.06.01
242 + */
243 + private static function is_too_long( $values ) {
244 + return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] );
319 245 }
320 246
321 247 /**
322 - * Remove the draft flag from any new fields from this current session.
248 + * Redirect to the url for creating from a template
249 + * Also delete the current form
323 250 *
324 - * @since 6.8
325 - *
326 - * @param int $form_id
327 - * @return void
251 + * @since 2.0
252 + * @deprecated 3.06
328 253 */
329 - private static function maybe_remove_draft_option_from_fields( $form_id ) {
330 - $draft_field_ids_csv = FrmAppHelper::get_post_param( 'draft_fields', '', 'sanitize_text_field' );
331 - if ( ! $draft_field_ids_csv ) {
332 - // If the draft_fields input is empty there are no new fields in the session.
333 - return;
334 - }
254 + public static function _create_from_template() {
255 + _deprecated_function( __FUNCTION__, '3.06' );
335 256
336 - $draft_field_ids = array_filter( explode( ',', $draft_field_ids_csv ), 'is_numeric' );
337 - if ( ! $draft_field_ids ) {
338 - // Exit early if the draft fields input is invalid. It should be a CSV of integer values.
339 - return;
340 - }
257 + FrmAppHelper::permission_check( 'frm_edit_forms' );
258 + check_ajax_referer( 'frm_ajax', 'nonce' );
341 259
342 - $draft_field_rows = FrmFieldsHelper::get_draft_field_results( $form_id, $draft_field_ids );
343 - foreach ( $draft_field_rows as $row ) {
344 - $row->field_options['draft'] = 0;
345 - FrmField::update( $row->id, array( 'field_options' => $row->field_options ) );
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 );
346 265 }
347 - }
348 266
349 - /**
350 - * Check if the value at the end of the form was included.
351 - * If it's missing, it means other values at the end of the form
352 - * were likely not saved either.
353 - *
354 - * @since 3.06.01
355 - *
356 - * @return bool
357 - */
358 - private static function is_too_long( $values ) {
359 - return empty( $values['frm_end'] );
267 + echo esc_url_raw( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template_id ) ) );
268 + wp_die();
360 269 }
361 270
362 271 public static function duplicate() {
363 272 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -374,10 +283,10 @@
374 283 $message = 'form_duplicate_error';
375 284
376 285 if ( $form ) {
377 286 $new_template = FrmAppHelper::simple_get( 'new_template' ) ? '&new_template=true' : '';
378 - $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
379 - $message = 'form_duplicated';
287 + $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template );
288 + $message = 'form_duplicated';
380 289 }
381 290
382 291 $url .= '&message=' . $message;
383 292
@@ -385,42 +294,27 @@
385 294 exit();
386 295 }
387 296
388 297 /**
389 - * @return string|null
298 + * @return string
390 299 */
391 300 public static function page_preview() {
392 301 $params = FrmForm::list_page_params();
393 - if ( ! $params['form'] || is_numeric( $params['form'] ) ) {
394 - return null;
302 + if ( ! $params['form'] ) {
303 + return;
395 304 }
396 305
397 - self::maybe_block_preview( $params['form'] );
398 -
399 306 $form = FrmForm::getOne( $params['form'] );
400 - if ( ! $form ) {
401 - return null;
307 + if ( $form ) {
308 + return self::show_form( $form->id, '', 'auto', 'auto' );
402 309 }
403 -
404 - return self::show_form( $form->id, '', 'auto', 'auto' );
405 310 }
406 311
407 312 /**
408 313 * @since 3.0
409 - *
410 - * @return void
411 314 */
412 315 public static function show_page_preview() {
413 - $preview = self::page_preview();
414 - if ( is_null( $preview ) ) {
415 - wp_die(
416 - '<h1>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</h1>',
417 - '<p>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</p>',
418 - 404
419 - );
420 - }
421 -
422 - echo $preview; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
316 + echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
423 317 }
424 318
425 319 /**
426 320 * @return void
@@ -431,17 +325,8 @@
431 325
432 326 global $frm_vars;
433 327 $frm_vars['preview'] = true;
434 328
435 - // print_emoji_styles is deprecated.
436 - remove_action( 'wp_print_styles', 'print_emoji_styles' );
437 -
438 - if ( FrmTestModeController::should_add_test_mode_container() ) {
439 - do_action( 'frm_test_mode_init' );
440 - add_action( 'wp_enqueue_scripts', 'FrmTestModeController::register_and_enqueue_required_scripts' );
441 - add_filter( 'frm_filter_final_form', 'FrmTestModeController::maybe_add_test_mode_container', 99 );
442 - }
443 -
444 329 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
445 330 if ( $include_theme ) {
446 331 self::set_preview_query();
447 332 self::load_theme_preview();
@@ -476,13 +361,8 @@
476 361 return;
477 362 }
478 363
479 364 $random_page = reset( $random_page );
480 - if ( ! is_a( $random_page, 'WP_Post' ) ) {
481 - // The return type can also be int.
482 - return;
483 - }
484 -
485 365 query_posts(
486 366 array(
487 367 'post_type' => 'page',
488 368 'page_id' => $random_page->ID,
@@ -498,9 +378,9 @@
498 378 * Set the WP $post global object. Used for in-theme preview when defining a page.
499 379 *
500 380 * @since 5.5.2
501 381 *
502 - * @param WP_Post $page The page object.
382 + * @param WP_Post $post
503 383 * @return void
504 384 */
505 385 private static function set_post_global( $page ) {
506 386 global $post;
@@ -508,10 +388,8 @@
508 388 }
509 389
510 390 /**
511 391 * @since 3.0
512 - *
513 - * @return void
514 392 */
515 393 private static function load_theme_preview() {
516 394 add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
517 395 add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 );
@@ -543,16 +421,13 @@
543 421
544 422 /**
545 423 * Not every theme supports get_template_part( 'page' ).
546 424 * When this is not supported, false is returned, and we can handle a fallback.
547 - *
548 - * @return void
549 425 */
550 426 private static function fallback_when_page_template_part_is_not_supported_by_theme() {
551 427 if ( have_posts() ) {
552 428 the_post();
553 - self::get_template( 'header' );
554 -
429 + get_header( '' );
555 430 // add some generic class names to the container to add some natural padding to the content.
556 431 // .entry-content catches the WordPress TwentyTwenty theme.
557 432 // .container catches Customizr content.
558 433 echo '<div class="container entry-content">';
@@ -557,58 +432,13 @@
557 432 // .container catches Customizr content.
558 433 echo '<div class="container entry-content">';
559 434 the_content();
560 435 echo '</div>';
561 -
562 - // Prevent extra unexpected forms in the footer.
563 - // For some reason this happens in the Twenty Twenty Five theme.
564 - add_filter( 'frm_filter_final_form', '__return_empty_string' );
565 -
566 - self::get_template( 'footer' );
436 + get_footer();
567 437 }
568 438 }
569 439
570 440 /**
571 - * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call
572 - * and renders required html fragments calling required functions.
573 - *
574 - * @since 6.7.1
575 - * @param string $template
576 - * @return void
577 - */
578 - private static function get_template( $template ) {
579 - if ( self::should_try_getting_template( $template ) ) {
580 - call_user_func( 'get_' . $template );
581 - return;
582 - }
583 -
584 - if ( 'header' === $template ) {
585 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/header.php';
586 - return;
587 - }
588 -
589 - if ( 'footer' === $template ) {
590 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/footer.php';
591 - }
592 - }
593 -
594 - /**
595 - * Returns true if calling a template function doesn't trigger deprecation warnings.
596 - *
597 - * @since 6.7.1
598 - * @param string $template
599 - * @return bool
600 - */
601 - private static function should_try_getting_template( $template ) {
602 - $stylesheet_path = get_stylesheet_directory();
603 - $template_path = get_template_directory();
604 - $is_child_theme = $stylesheet_path !== $template_path;
605 - $template_name = $template . '.php';
606 -
607 - return file_exists( $stylesheet_path . '/' . $template_name ) || $is_child_theme && file_exists( $template_path . '/' . $template_name );
608 - }
609 -
610 - /**
611 441 * Set the page title for the theme preview page
612 442 *
613 443 * @since 3.0
614 444 */
@@ -620,14 +450,11 @@
620 450 return $title;
621 451 }
622 452
623 453 /**
624 - * Set the page title for the theme preview page.
454 + * Set the page title for the theme preview page
625 455 *
626 456 * @since 3.0
627 - *
628 - * @param string $title
629 - * @return string
630 457 */
631 458 public static function preview_title( $title ) {
632 459 return __( 'Form Preview', 'formidable' );
633 460 }
@@ -632,20 +459,15 @@
632 459 return __( 'Form Preview', 'formidable' );
633 460 }
634 461
635 462 /**
636 - * Set the page content for the theme preview page.
463 + * Set the page content for the theme preview page
637 464 *
638 465 * @since 3.0
639 - *
640 - * @param string $content
641 - * @return string
642 466 */
643 467 public static function preview_content( $content ) {
644 468 if ( in_the_loop() ) {
645 - self::show_page_preview();
646 - // Clear the content for the page we're using.
647 - $content = '';
469 + $content = self::show_page_preview();
648 470 }
649 471
650 472 return $content;
651 473 }
@@ -653,88 +475,23 @@
653 475 /**
654 476 * @since 3.0
655 477 */
656 478 private static function load_direct_preview() {
479 + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
480 +
657 481 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
658 482 if ( $key == '' ) {
659 483 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
660 484 }
661 485
662 - if ( ! $key ) {
663 - $error = __( 'Form key is missing', 'formidable' );
664 - wp_die(
665 - '<h1>' . esc_html( $error ) . '</h1>',
666 - '<p>' . esc_html( $error ) . '</p>',
667 - 404
668 - );
669 - }
670 -
671 - self::maybe_block_preview( $key );
672 -
673 486 $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
674 - if ( ! $form ) {
675 - $error = __( 'Form does not exist', 'formidable' );
676 - wp_die(
677 - '<h1>' . esc_html( $error ) . '</h1>',
678 - '<p>' . esc_html( $error ) . '</p>',
679 - 404
680 - );
487 + if ( empty( $form ) ) {
488 + $form = FrmForm::getAll( array(), '', 1 );
681 489 }
682 490
683 - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
684 -
685 - self::fix_deprecated_null_param_warning();
686 -
687 - require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
491 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
688 492 }
689 493
690 - /**
691 - * Block the form preview for the contact form by default if the user cannot view forms.
692 - * This is to prevent the contact form being exploited.
693 - * Since this form is added by default and every site uses the same key, it is too easy
694 - * to guess this form.
695 - *
696 - * @since 6.20
697 - *
698 - * @param string $form_key Form key.
699 - * @return void
700 - */
701 - public static function maybe_block_preview( $form_key ) {
702 - if ( FrmFormsHelper::should_block_preview( $form_key ) ) {
703 - $error = __( 'You do not have permission to view this form', 'formidable' );
704 - wp_die(
705 - '<h1>' . esc_html( $error ) . '</h1>',
706 - '<p>' . esc_html( $error ) . '</p>',
707 - 403
708 - );
709 - }
710 - }
711 -
712 - /**
713 - * Some themes have a null $src value.
714 - * This function adds a filter to ensure that $src is not null.
715 - * WP will call str_starts_with with the null value triggering a deprecated message otherwise.
716 - *
717 - * @since 6.10
718 - *
719 - * @return void
720 - */
721 - private static function fix_deprecated_null_param_warning() {
722 - add_filter(
723 - 'script_loader_src',
724 - /**
725 - * @param string|null $src
726 - * @return string
727 - */
728 - function ( $src ) {
729 - if ( is_null( $src ) ) {
730 - $src = '';
731 - }
732 - return $src;
733 - }
734 - );
735 - }
736 -
737 494 public static function untrash() {
738 495 self::change_form_status( 'untrash' );
739 496 }
740 497
@@ -797,14 +554,14 @@
797 554 FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
798 555
799 556 $params = FrmForm::list_page_params();
800 557
801 - // Check nonce url.
558 + //check nonce url
802 559 check_admin_referer( $status . '_form_' . $params['id'] );
803 560
804 561 $count = 0;
805 562 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
806 - ++$count;
563 + $count ++;
807 564 }
808 565
809 566 $form_type = FrmAppHelper::get_simple_request(
810 567 array(
@@ -816,9 +573,9 @@
816 573 /* translators: %1$s: Number of forms */
817 574 $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
818 575
819 576 /* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */
820 - $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
577 + $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
821 578
822 579 $message = $available_status[ $status ]['message'];
823 580
824 581 self::display_forms_list( $params, $message );
@@ -823,12 +580,8 @@
823 580
824 581 self::display_forms_list( $params, $message );
825 582 }
826 583
827 - /**
828 - * @param array $ids
829 - * @return string
830 - */
831 584 public static function bulk_trash( $ids ) {
832 585 FrmAppHelper::permission_check( 'frm_delete_forms' );
833 586
834 587 $count = 0;
@@ -833,16 +586,12 @@
833 586
834 587 $count = 0;
835 588 foreach ( $ids as $id ) {
836 589 if ( FrmForm::trash( $id ) ) {
837 - ++$count;
590 + $count ++;
838 591 }
839 592 }
840 593
841 - if ( ! $count ) {
842 - return '';
843 - }
844 -
845 594 $current_page = FrmAppHelper::get_simple_request(
846 595 array(
847 596 'param' => 'form_type',
848 597 'type' => 'request',
@@ -868,9 +617,9 @@
868 617 check_admin_referer( 'destroy_form_' . $params['id'] );
869 618
870 619 $count = 0;
871 620 if ( FrmForm::destroy( $params['id'] ) ) {
872 - ++$count;
621 + $count ++;
873 622 }
874 623
875 624 /* translators: %1$s: Number of forms */
876 625 $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count );
@@ -877,12 +626,8 @@
877 626
878 627 self::display_forms_list( $params, $message );
879 628 }
880 629
881 - /**
882 - * @param array $ids
883 - * @return string
884 - */
885 630 public static function bulk_destroy( $ids ) {
886 631 FrmAppHelper::permission_check( 'frm_delete_forms' );
887 632
888 633 $count = 0;
@@ -888,24 +633,19 @@
888 633 $count = 0;
889 634 foreach ( $ids as $id ) {
890 635 $d = FrmForm::destroy( $id );
891 636 if ( $d ) {
892 - ++$count;
637 + $count ++;
893 638 }
894 639 }
895 640
896 - if ( $count ) {
897 - /* translators: %1$s: Number of forms */
898 - return sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
899 - }
641 + /* translators: %1$s: Number of forms */
642 + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
900 643
901 - return '';
644 + return $message;
902 645 }
903 646
904 - /**
905 - * @since 6.7.1 Function went from private to public.
906 - */
907 - public static function delete_all() {
647 + private static function delete_all() {
908 648 // Check nonce url.
909 649 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
910 650 if ( $permission_error !== false ) {
911 651 self::display_forms_list( array(), '', array( $permission_error ) );
@@ -912,15 +652,14 @@
912 652
913 653 return;
914 654 }
915 655
916 - $count = FrmForm::scheduled_delete( time() );
917 - $url = remove_query_arg( array( 'delete_all' ) );
656 + $count = FrmForm::scheduled_delete( time() );
918 657
919 - $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count;
658 + /* translators: %1$s: Number of forms */
659 + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
920 660
921 - wp_safe_redirect( $url );
922 - die();
661 + self::display_forms_list( array(), $message );
923 662 }
924 663
925 664 /**
926 665 * Create a new form from the modal.
@@ -933,9 +672,9 @@
933 672
934 673 $new_values = self::get_modal_values();
935 674 $new_values['form_key'] = $new_values['name'];
936 675 $new_values['options'] = array(
937 - 'antispam' => 1,
676 + 'antispam' => 1,
938 677 'on_submit_migrated' => 1,
939 678 );
940 679
941 680 /**
@@ -954,9 +693,8 @@
954 693 * @param int $form_id
955 694 */
956 695 do_action( 'frm_build_new_form', $form_id );
957 696
958 - self::create_submit_button_field( $form_id );
959 697 self::create_default_on_submit_action( $form_id );
960 698 self::create_default_email_action( $form_id );
961 699
962 700 $response = array(
@@ -970,10 +708,8 @@
970 708 /**
971 709 * Before creating a new form, get the name and description from the modal.
972 710 *
973 711 * @since 4.0
974 - *
975 - * @return array<string,string>
976 712 */
977 713 public static function get_modal_values() {
978 714 $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
979 715 $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
@@ -988,24 +724,17 @@
988 724 * Inserts Formidable button
989 725 * Hook exists since 2.5.0
990 726 *
991 727 * @since 2.0.15
992 - *
993 - * @return void
994 728 */
995 729 public static function insert_form_button() {
996 730 if ( current_user_can( 'frm_view_forms' ) ) {
997 - // Store the result in memory and re-use it when this function is called multiple times.
998 - // This helps speed up the form builder when there are a lot of HTML fields, where this
999 - // button is inserted once per HTML field.
1000 - // In a form with 66 HTML fields, this saves 0.5 seconds on page load time, tested locally.
1001 - if ( ! isset( self::$formidable_tinymce_button ) ) {
1002 - FrmAppHelper::load_admin_wide_js();
1003 - $menu_name = FrmAppHelper::get_menu_name();
1004 - $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
1005 - 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>';
1006 - }
1007 - echo self::$formidable_tinymce_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
731 + FrmAppHelper::load_admin_wide_js();
732 + $menu_name = FrmAppHelper::get_menu_name();
733 + $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
734 + echo '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">' .
735 + FrmAppHelper::kses( $icon, 'all' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
736 + ' ' . esc_html( $menu_name ) . '</a>';
1008 737 }
1009 738 }
1010 739
1011 740 /**
@@ -1093,9 +822,9 @@
1093 822 $form_id = $opts['form_id'];
1094 823 unset( $opts['form_id'] );
1095 824 }
1096 825
1097 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php';
826 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
1098 827
1099 828 echo '</div>';
1100 829
1101 830 wp_die();
@@ -1135,14 +864,8 @@
1135 864 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
1136 865 die();
1137 866 }
1138 867
1139 - $inbox = new FrmInbox();
1140 - $error = $inbox->check_for_error();
1141 - if ( $error ) {
1142 - $show_messages = array( $error['subject'] . '. ' . $error['message'] );
1143 - }
1144 -
1145 868 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php';
1146 869 }
1147 870
1148 871 /**
@@ -1149,16 +872,14 @@
1149 872 * @param array<string,string> $columns
1150 873 * @return array<string,string>
1151 874 */
1152 875 public static function get_columns( $columns ) {
1153 - $columns['cb'] = '<input type="checkbox" />';
1154 - $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1155 - $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1156 - $columns['id'] = 'ID';
1157 - $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1158 - if ( 'trash' !== FrmAppHelper::simple_get( 'form_type' ) ) {
1159 - $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1160 - }
876 + $columns['cb'] = '<input type="checkbox" />';
877 + $columns['name'] = esc_html__( 'Form Title', 'formidable' );
878 + $columns['entries'] = esc_html__( 'Entries', 'formidable' );
879 + $columns['id'] = 'ID';
880 + $columns['form_key'] = esc_html__( 'Key', 'formidable' );
881 + $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1161 882 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
1162 883
1163 884 add_screen_option(
1164 885 'per_page',
@@ -1171,11 +892,8 @@
1171 892
1172 893 return $columns;
1173 894 }
1174 895
1175 - /**
1176 - * @return array<string,string>
1177 - */
1178 896 public static function get_sortable_columns() {
1179 897 return array(
1180 898 'id' => 'id',
1181 899 'name' => 'name',
@@ -1209,9 +927,9 @@
1209 927 return $hidden_columns;
1210 928 }
1211 929
1212 930 public static function save_per_page( $save, $option, $value ) {
1213 - if ( $option === 'formidable_page_formidable_per_page' ) {
931 + if ( $option == 'formidable_page_formidable_per_page' ) {
1214 932 $save = (int) $value;
1215 933 }
1216 934
1217 935 return $save;
@@ -1216,23 +934,16 @@
1216 934
1217 935 return $save;
1218 936 }
1219 937
1220 - /**
1221 - * @param int|string $id
1222 - * @param array $errors
1223 - * @param string $message
1224 - * @param bool $create_link
1225 - * @return void
1226 - */
1227 938 private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1228 939 global $frm_vars;
1229 940
1230 - $form = FrmForm::getOne( $id );
941 + $form = FrmForm::getOne( $id );
1231 942 $error_args = array(
1232 - 'title' => __( 'You can\'t edit the form', 'formidable' ),
1233 - 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
1234 - 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
943 + 'title' => __( 'You can\'t edit the form', 'formidable' ),
944 + 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ),
945 + 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
1235 946 'continue_url' => add_query_arg(
1236 947 array(
1237 948 'page' => 'formidable',
1238 949 )
@@ -1243,10 +954,10 @@
1243 954 return;
1244 955 }
1245 956
1246 957 if ( 'trash' === $form->status ) {
1247 - $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
1248 - $error_args['continue_url'] = add_query_arg(
958 + $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' );
959 + $error_args['continue_url'] = add_query_arg(
1249 960 array(
1250 961 'page' => 'formidable',
1251 962 '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ),
1252 963 'form_type' => 'trash',
@@ -1270,9 +981,8 @@
1270 981
1271 982 // Automatically add end section fields if they don't exist (2.0 migration).
1272 983 $reset_fields = false;
1273 984 FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
1274 - FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields );
1275 985
1276 986 if ( $reset_fields ) {
1277 987 $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
1278 988 }
@@ -1298,21 +1008,18 @@
1298 1008 }
1299 1009
1300 1010 self::maybe_update_form_builder_message( $message );
1301 1011
1302 - $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
1012 + $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
1013 + $has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] );
1303 1014
1304 1015 if ( defined( 'DOING_AJAX' ) ) {
1305 1016 wp_die();
1017 + } else {
1018 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
1306 1019 }
1307 -
1308 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php';
1309 1020 }
1310 1021
1311 - /**
1312 - * @param array $fields
1313 - * @return array
1314 - */
1315 1022 public static function update_form_builder_fields( $fields, $form ) {
1316 1023 foreach ( $fields as $field ) {
1317 1024 $field->do_not_include_icons = true;
1318 1025 }
@@ -1324,21 +1031,13 @@
1324 1031 $message = __( 'Form was Successfully Copied', 'formidable' );
1325 1032 }
1326 1033 }
1327 1034
1328 - /**
1329 - * @param int|string $id
1330 - * @param array $errors
1331 - * @param array|string $args
1332 - * @return void
1333 - */
1334 1035 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1335 1036 FrmAppHelper::permission_check( 'frm_edit_forms' );
1336 1037
1337 1038 global $frm_vars;
1338 1039
1339 - self::maybe_print_media_templates();
1340 -
1341 1040 if ( ! is_array( $args ) ) {
1342 1041 // For reverse compatibility.
1343 1042 $args = array(
1344 1043 'message' => $args,
@@ -1371,38 +1070,17 @@
1371 1070
1372 1071 $sections = self::get_settings_tabs( $values );
1373 1072 $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' );
1374 1073
1375 - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php';
1074 + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
1376 1075 }
1377 1076
1378 1077 /**
1379 - * 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.
1380 - *
1381 - * @since 6.10
1382 - *
1383 - * @return void
1384 - */
1385 - private static function maybe_print_media_templates() {
1386 - if ( FrmAppHelper::pro_is_included() ) {
1387 - // This issue does not exist when Pro is active so exit early.
1388 - return;
1389 - }
1390 -
1391 - add_action(
1392 - 'wp_enqueue_editor',
1393 - function () {
1394 - wp_print_media_templates();
1395 - }
1396 - );
1397 - }
1398 -
1399 - /**
1400 1078 * @since 4.0
1401 1079 */
1402 1080 public static function form_publish_button( $atts ) {
1403 1081 $values = $atts['values'];
1404 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
1082 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' );
1405 1083 }
1406 1084
1407 1085 /**
1408 1086 * Get a list of all the settings tabs for the form settings page.
@@ -1416,9 +1094,9 @@
1416 1094 $sections = array(
1417 1095 'advanced' => array(
1418 1096 'name' => __( 'General', 'formidable' ),
1419 1097 'title' => __( 'General Form Settings', 'formidable' ),
1420 - 'function' => array( self::class, 'advanced_settings' ),
1098 + 'function' => array( __CLASS__, 'advanced_settings' ),
1421 1099 'icon' => 'frm_icon_font frm_settings_icon',
1422 1100 ),
1423 1101 'email' => array(
1424 1102 'name' => __( 'Actions & Notifications', 'formidable' ),
@@ -1427,9 +1105,9 @@
1427 1105 'icon' => 'frm_icon_font frm_mail_bulk_icon',
1428 1106 ),
1429 1107 'permissions' => array(
1430 1108 'name' => __( 'Form Permissions', 'formidable' ),
1431 - 'icon' => 'frm_icon_font frm_lock_closed_icon',
1109 + 'icon' => 'frm_icon_font frm_lock_icon',
1432 1110 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1433 1111 'data' => array(
1434 1112 'medium' => 'permissions',
1435 1113 'upgrade' => __( 'Form Permissions', 'formidable' ),
@@ -1436,9 +1114,9 @@
1436 1114 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1437 1115 'screenshot' => 'permissions.png',
1438 1116 ),
1439 1117 ),
1440 - 'scheduling' => array(
1118 + 'scheduling' => array(
1441 1119 'name' => __( 'Form Scheduling', 'formidable' ),
1442 1120 'icon' => 'frm_icon_font frm_calendar_icon',
1443 1121 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1444 1122 'data' => array(
@@ -1448,9 +1126,9 @@
1448 1126 ),
1449 1127 ),
1450 1128 'buttons' => array(
1451 1129 'name' => __( 'Buttons', 'formidable' ),
1452 - 'class' => self::class,
1130 + 'class' => __CLASS__,
1453 1131 'function' => 'buttons_settings',
1454 1132 'icon' => 'frm_icon_font frm_button_icon',
1455 1133 ),
1456 1134 'landing' => array(
@@ -1471,9 +1149,9 @@
1471 1149 'screenshot' => 'chat.png',
1472 1150 )
1473 1151 ),
1474 1152 ),
1475 - 'abandonment' => array(
1153 + 'abandonment' => array(
1476 1154 'name' => __( 'Form Abandonment', 'formidable' ),
1477 1155 'icon' => 'frm_icon_font frm_abandoned_icon',
1478 1156 'html_class' => 'frm_show_upgrade_tab frm_noallow',
1479 1157 'data' => FrmAppHelper::get_upgrade_data_params(
@@ -1486,18 +1164,14 @@
1486 1164 ),
1487 1165 ),
1488 1166 'html' => array(
1489 1167 'name' => __( 'Customize HTML', 'formidable' ),
1490 - 'class' => self::class,
1168 + 'class' => __CLASS__,
1491 1169 'function' => 'html_settings',
1492 1170 'icon' => 'frm_icon_font frm_code_icon',
1493 1171 ),
1494 1172 );
1495 1173
1496 - if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1497 - unset( $sections['buttons'] );
1498 - }
1499 -
1500 1174 foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1501 1175 if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1502 1176 unset( $sections[ $feature ] );
1503 1177 }
@@ -1504,8 +1178,13 @@
1504 1178 }
1505 1179
1506 1180 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1507 1181
1182 + if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) {
1183 + // Prevent settings from showing in 2 spots.
1184 + unset( $sections['permissions'], $sections['scheduling'] );
1185 + }
1186 +
1508 1187 foreach ( $sections as $key => $section ) {
1509 1188 $defaults = array(
1510 1189 'html_class' => '',
1511 1190 'name' => ucfirst( $key ),
@@ -1527,9 +1206,9 @@
1527 1206 $section['id'] = $section['anchor'];
1528 1207 }
1529 1208
1530 1209 $sections[ $key ] = $section;
1531 - }//end foreach
1210 + }
1532 1211
1533 1212 return $sections;
1534 1213 }
1535 1214
@@ -1536,9 +1215,8 @@
1536 1215 /**
1537 1216 * @since 4.0
1538 1217 *
1539 1218 * @param array $values
1540 - * @return void
1541 1219 */
1542 1220 public static function advanced_settings( $values ) {
1543 1221 $first_h3 = 'frm_first_h3';
1544 1222
@@ -1546,15 +1224,14 @@
1546 1224 }
1547 1225
1548 1226 /**
1549 1227 * @param array $values
1550 - * @return void
1551 1228 */
1552 1229 public static function render_spam_settings( $values ) {
1553 1230 if ( function_exists( 'akismet_http_post' ) ) {
1554 1231 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
1555 1232 }
1556 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/stopforumspam.php';
1233 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/honeypot.php';
1557 1234 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php';
1558 1235 }
1559 1236
1560 1237 /**
@@ -1560,12 +1237,16 @@
1560 1237 /**
1561 1238 * @since 4.0
1562 1239 *
1563 1240 * @param array $values
1564 - * @return void
1565 1241 */
1566 1242 public static function buttons_settings( $values ) {
1567 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
1243 + $styles = apply_filters( 'frm_get_style_opts', array() );
1244 +
1245 + $frm_settings = FrmAppHelper::get_settings();
1246 + $no_global_style = $frm_settings->load_style === 'none';
1247 +
1248 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php' );
1568 1249 }
1569 1250
1570 1251 /**
1571 1252 * @since 4.0
@@ -1570,12 +1251,11 @@
1570 1251 /**
1571 1252 * @since 4.0
1572 1253 *
1573 1254 * @param array $values
1574 - * @return void
1575 1255 */
1576 1256 public static function html_settings( $values ) {
1577 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
1257 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' );
1578 1258 }
1579 1259
1580 1260 /**
1581 1261 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -1581,10 +1261,9 @@
1581 1261 * Replace old Submit Button href with new href to avoid errors in Chrome
1582 1262 *
1583 1263 * @since 2.03.08
1584 1264 *
1585 - * @param array|bool $values
1586 - * @return void
1265 + * @param array|boolean $values
1587 1266 */
1588 1267 private static function clean_submit_html( &$values ) {
1589 1268 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
1590 1269 $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] );
@@ -1605,13 +1284,8 @@
1605 1284
1606 1285 return $classes;
1607 1286 }
1608 1287
1609 - /**
1610 - * @param int|string $form_id
1611 - * @param string $class
1612 - * @return void
1613 - */
1614 1288 public static function mb_tags_box( $form_id, $class = '' ) {
1615 1289 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
1616 1290
1617 1291 /**
@@ -1624,9 +1298,9 @@
1624 1298 */
1625 1299 $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) );
1626 1300 $linked_forms = array();
1627 1301 $col = 'one';
1628 - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' );
1302 + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
1629 1303
1630 1304 $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
1631 1305 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1632 1306
@@ -1631,9 +1305,9 @@
1631 1305 $entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
1632 1306
1633 1307 $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
1634 1308
1635 - include FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php';
1309 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
1636 1310 }
1637 1311
1638 1312 /**
1639 1313 * @since 3.04.01
@@ -1646,9 +1320,9 @@
1646 1320 ),
1647 1321 );
1648 1322
1649 1323 $user_fields = self::user_shortcodes();
1650 - if ( $user_fields ) {
1324 + if ( ! empty( $user_fields ) ) {
1651 1325 $user_helpers = array();
1652 1326 foreach ( $user_fields as $uk => $uf ) {
1653 1327 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1654 1328 unset( $uk, $uf );
@@ -1654,9 +1328,9 @@
1654 1328 unset( $uk, $uf );
1655 1329 }
1656 1330
1657 1331 $advanced_helpers['user_id'] = array(
1658 - 'codes' => $user_helpers,
1332 + 'codes' => $user_helpers,
1659 1333 );
1660 1334 }
1661 1335
1662 1336 /**
@@ -1733,16 +1407,21 @@
1733 1407 'updated-at' => __( 'Entry updated', 'formidable' ),
1734 1408 '' => '',
1735 1409 'siteurl' => __( 'Site URL', 'formidable' ),
1736 1410 'sitename' => __( 'Site Name', 'formidable' ),
1737 - 'form_name' => __( 'Form Name', 'formidable' ),
1738 1411 );
1739 1412
1740 - $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1741 1413 if ( ! FrmAppHelper::pro_is_installed() ) {
1742 1414 unset( $entry_shortcodes['post_id'] );
1743 1415 }
1744 1416
1417 + if ( $settings_tab ) {
1418 + $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' );
1419 + $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' );
1420 + $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' );
1421 + $entry_shortcodes['form_name'] = __( 'Form Name', 'formidable' );
1422 + }
1423 +
1745 1424 /**
1746 1425 * Use this hook to add or remove buttons in the helpers section
1747 1426 * in the customization panel
1748 1427 *
@@ -1768,9 +1447,9 @@
1768 1447 echo ' frm_js_validate ';
1769 1448 self::add_js_validate_form_to_global_vars( $form );
1770 1449 }
1771 1450
1772 - if ( FrmForm::is_ajax_on( $form ) ) {
1451 + if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) {
1773 1452 echo ' frm_ajax_submit ';
1774 1453 }
1775 1454 }
1776 1455
@@ -1792,11 +1471,11 @@
1792 1471 check_ajax_referer( 'frm_ajax', 'nonce' );
1793 1472
1794 1473 echo FrmEntriesController::show_entry_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1795 1474 array(
1796 - 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1475 + 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
1797 1476 'default_email' => true,
1798 - 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1477 + 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
1799 1478 )
1800 1479 );
1801 1480 wp_die();
1802 1481 }
@@ -1802,10 +1481,10 @@
1802 1481 }
1803 1482
1804 1483 /**
1805 1484 * @param string $content
1806 - * @param int|stdClass|string $form
1807 - * @param false|int|stdClass|string $entry
1485 + * @param stdClass|string|int $form
1486 + * @param stdClass|string|int|false $entry
1808 1487 * @return string
1809 1488 */
1810 1489 public static function filter_content( $content, $form, $entry = false ) {
1811 1490 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1818,16 +1497,8 @@
1818 1497 if ( is_object( $form ) ) {
1819 1498 $form = $form->id;
1820 1499 }
1821 1500
1822 - /*
1823 - * Repeater actions adds `parent_entry` to `$entry` store the parent entry data. If `parent_entry` is not empty,
1824 - * use the parent form ID instead of repeater form ID to fix the parent form field shortcodes doesn't work.
1825 - */
1826 - if ( ! empty( $entry->parent_entry ) ) {
1827 - $form = $entry->parent_entry->form_id;
1828 - }
1829 -
1830 1501 $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
1831 1502 $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
1832 1503
1833 1504 return $content;
@@ -1837,11 +1508,11 @@
1837 1508 * Replace any [form_name] shortcodes in a string.
1838 1509 *
1839 1510 * @since 5.5
1840 1511 *
1841 - * @param array|string $string
1842 - * @param int|stdClass|string $form
1843 - * @return array|string
1512 + * @param string|array $string
1513 + * @param stdClass|string|int $form
1514 + * @return string|array
1844 1515 */
1845 1516 public static function replace_form_name_shortcodes( $string, $form ) {
1846 1517 if ( ! is_string( $string ) ) {
1847 1518 return $string;
@@ -1859,9 +1530,9 @@
1859 1530 return str_replace( '[form_name]', $form_name, $string );
1860 1531 }
1861 1532
1862 1533 /**
1863 - * @param false|int|stdClass|string $entry
1534 + * @param stdClass|string|int|false $entry
1864 1535 * @return void
1865 1536 */
1866 1537 private static function get_entry_by_param( &$entry ) {
1867 1538 if ( ! $entry || ! is_object( $entry ) ) {
@@ -1876,12 +1547,8 @@
1876 1547 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
1877 1548 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
1878 1549 }
1879 1550
1880 - /**
1881 - * @param array $errors
1882 - * @return array
1883 - */
1884 1551 public static function process_bulk_form_actions( $errors ) {
1885 1552 if ( ! $_REQUEST ) {
1886 1553 return $errors;
1887 1554 }
@@ -1925,9 +1592,9 @@
1925 1592 case 'untrash':
1926 1593 $message = self::bulk_untrash( $ids );
1927 1594 }
1928 1595
1929 - if ( ! empty( $message ) ) {
1596 + if ( isset( $message ) && ! empty( $message ) ) {
1930 1597 $errors['message'] = $message;
1931 1598 }
1932 1599
1933 1600 return $errors;
@@ -1932,26 +1599,13 @@
1932 1599
1933 1600 return $errors;
1934 1601 }
1935 1602
1936 - /**
1937 - * Includes html that shows a message when the device is too small to use Formidable Forms admin pages.
1938 - *
1939 - * @since 6.20
1940 - * @return void
1941 - */
1942 - public static function include_device_too_small_message() {
1943 - if ( ! FrmAppHelper::is_formidable_admin() ) {
1944 - return;
1945 - }
1946 -
1947 - include FrmAppHelper::plugin_path() . '/classes/views/shared/small-device-message.php';
1948 - }
1949 -
1950 1603 public static function route() {
1951 1604 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1952 1605 $vars = array();
1953 1606 FrmAppHelper::include_svg();
1607 +
1954 1608 if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1955 1609 FrmAppHelper::permission_check( 'frm_edit_forms' );
1956 1610
1957 1611 // Javascript needs to be allowed in some field settings.
@@ -1960,9 +1614,9 @@
1960 1614 $json_vars = json_decode( $json_vars, true );
1961 1615 if ( empty( $json_vars ) ) {
1962 1616 // json decoding failed so we should return an error message.
1963 1617 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1964 - if ( 'edit' === $action ) {
1618 + if ( 'edit' == $action ) {
1965 1619 $action = 'update';
1966 1620 }
1967 1621
1968 1622 add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
@@ -1978,14 +1632,16 @@
1978 1632 if ( isset( $_REQUEST['delete_all'] ) ) {
1979 1633 // Override the action for this page.
1980 1634 $action = 'delete_all';
1981 1635 }
1982 - }//end if
1636 + }
1983 1637
1984 1638 add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1985 1639 FrmAppHelper::trigger_hook_load( 'form' );
1986 1640
1987 1641 switch ( $action ) {
1642 + case 'new':
1643 + return self::new_form( $vars );
1988 1644 case 'create':
1989 1645 case 'edit':
1990 1646 case 'update':
1991 1647 case 'trash':
@@ -1990,17 +1646,16 @@
1990 1646 case 'update':
1991 1647 case 'trash':
1992 1648 case 'untrash':
1993 1649 case 'destroy':
1650 + case 'delete_all':
1994 1651 case 'settings':
1995 1652 case 'update_settings':
1996 1653 return self::$action( $vars );
1997 1654 case 'lite-reports':
1998 - self::no_reports( $vars );
1999 - return;
1655 + return self::no_reports( $vars );
2000 1656 case 'views':
2001 - self::no_views( $vars );
2002 - return;
1657 + return self::no_views( $vars );
2003 1658 default:
2004 1659 do_action( 'frm_form_action_' . $action );
2005 1660 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
2006 1661 return;
@@ -2023,20 +1678,12 @@
2023 1678 self::display_forms_list( array(), '', array( __( 'There was a problem duplicating the form', 'formidable' ) ) );
2024 1679 return;
2025 1680 }
2026 1681
2027 - if ( 'forms_permanently_deleted' === $message ) {
2028 - $count = FrmAppHelper::get_param( 'forms_deleted', 0, 'get', 'absint' );
2029 - /* translators: %1$s: Number of forms */
2030 - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
2031 - self::display_forms_list( array(), $message, '' );
2032 - return;
2033 - }
2034 -
2035 1682 self::display_forms_list();
2036 1683
2037 1684 return;
2038 - }//end switch
1685 + }
2039 1686 }
2040 1687
2041 1688 /**
2042 1689 * Rename a form.
@@ -2055,32 +1702,12 @@
2055 1702 // Get posted data
2056 1703 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2057 1704 $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2058 1705
2059 - $form = FrmForm::getOne( $form_id );
2060 - if ( ! $form ) {
2061 - wp_send_json_error( __( 'Form not found', 'formidable' ) );
2062 - }
1706 + // Update the form name and form key.
1707 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
1708 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
2063 1709
2064 - if ( $name === $form->name ) {
2065 - // Nothing to change so exit early.
2066 - wp_send_json_success();
2067 - }
2068 -
2069 - $to_update = array(
2070 - 'name' => $name,
2071 - );
2072 -
2073 - if ( '' !== $name ) {
2074 - // Only update form_key if name is not empty.
2075 - $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
2076 - $to_update['form_key'] = $form_key;
2077 - } else {
2078 - $form_key = $form->form_key;
2079 - }
2080 -
2081 - FrmForm::update( $form_id, $to_update );
2082 -
2083 1710 wp_send_json_success( compact( 'form_key' ) );
2084 1711 }
2085 1712
2086 1713 public static function json_error( $errors ) {
@@ -2089,13 +1716,20 @@
2089 1716 return $errors;
2090 1717 }
2091 1718
2092 1719 /**
1720 + * Education for premium features.
1721 + *
1722 + * @since 4.05
1723 + */
1724 + public static function add_form_style_tab_options() {
1725 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' );
1726 + }
1727 +
1728 + /**
2093 1729 * Add education about views.
2094 1730 *
2095 1731 * @since 4.07
2096 - *
2097 - * @return void
2098 1732 */
2099 1733 public static function no_views( $values = array() ) {
2100 1734 FrmAppHelper::include_svg();
2101 1735 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -2107,10 +1741,8 @@
2107 1741 /**
2108 1742 * Add education about reports.
2109 1743 *
2110 1744 * @since 4.07
2111 - *
2112 - * @return void
2113 1745 */
2114 1746 public static function no_reports( $values = array() ) {
2115 1747 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
2116 1748 $form = $id ? FrmForm::getOne( $id ) : false;
@@ -2117,11 +1749,9 @@
2117 1749
2118 1750 include FrmAppHelper::plugin_path() . '/classes/views/shared/reports-info.php';
2119 1751 }
2120 1752
2121 - /**
2122 - * FRONT-END FORMS.
2123 - */
1753 + /* FRONT-END FORMS */
2124 1754 public static function admin_bar_css() {
2125 1755 if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
2126 1756 return;
2127 1757 }
@@ -2195,9 +1825,9 @@
2195 1825 $wp_admin_bar->add_node(
2196 1826 array(
2197 1827 'parent' => 'frm-forms',
2198 1828 'id' => 'edit_form_' . $form_id,
2199 - 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name,
1829 + 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
2200 1830 'href' => FrmForm::get_edit_link( $form_id ),
2201 1831 )
2202 1832 );
2203 1833 }
@@ -2210,10 +1840,10 @@
2210 1840 * @return string
2211 1841 */
2212 1842 public static function get_form_shortcode( $atts ) {
2213 1843 global $frm_vars;
2214 - if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2215 - $sc = '[formidable';
1844 + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1845 + $sc = '[formidable';
2216 1846 $sc .= FrmAppHelper::array_to_html_params( $atts );
2217 1847 return $sc . ']';
2218 1848 }
2219 1849
@@ -2238,11 +1868,11 @@
2238 1868
2239 1869 /**
2240 1870 * @since 5.2.01
2241 1871 *
2242 - * @param false|int|string $id
2243 - * @param false|string $key
2244 - * @return false|stdClass
1872 + * @param string|int|false $id
1873 + * @param string|false $key
1874 + * @return stdClass|false
2245 1875 */
2246 1876 private static function maybe_get_form_by_id_or_key( $id, $key ) {
2247 1877 if ( ! $id ) {
2248 1878 $id = $key;
@@ -2250,12 +1880,12 @@
2250 1880 return self::maybe_get_form_to_show( $id );
2251 1881 }
2252 1882
2253 1883 /**
2254 - * @param false|int|string $id
2255 - * @param false|string $key
2256 - * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2257 - * @param bool|int|string $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1884 + * @param string|int|false $id
1885 + * @param string|false $key
1886 + * @param string|int|bool $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
1887 + * @param string|int|bool $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2258 1888 * @param array $atts
2259 1889 * @return string
2260 1890 */
2261 1891 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
@@ -2303,16 +1933,15 @@
2303 1933 return $form;
2304 1934 }
2305 1935
2306 1936 /**
2307 - * @param false|int|string $id
2308 - * @return false|stdClass
1937 + * @param string|int|false $id
1938 + * @return stdClass|false
2309 1939 */
2310 1940 private static function maybe_get_form_to_show( $id ) {
2311 1941 $form = false;
2312 1942
2313 - if ( ! empty( $id ) ) {
2314 - // Form id or key is set.
1943 + if ( ! empty( $id ) ) { // form id or key is set
2315 1944 $form = FrmForm::getOne( $id );
2316 1945 if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) {
2317 1946 $form = false;
2318 1947 }
@@ -2370,11 +1999,11 @@
2370 1999
2371 2000 do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );
2372 2001
2373 2002 if ( apply_filters( 'frm_continue_to_create', true, $form->id ) ) {
2374 - $entry_id = self::just_created_entry( $form->id );
2375 - $pass_args['entry_id'] = $entry_id;
2376 - $pass_args['reset'] = true;
2003 + $entry_id = self::just_created_entry( $form->id );
2004 + $pass_args['entry_id'] = $entry_id;
2005 + $pass_args['reset'] = true;
2377 2006
2378 2007 self::run_on_submit_actions( $pass_args );
2379 2008
2380 2009 do_action(
@@ -2384,9 +2013,9 @@
2384 2013 'form' => $form,
2385 2014 )
2386 2015 );
2387 2016 }
2388 - }//end if
2017 + }
2389 2018 }
2390 2019
2391 2020 /**
2392 2021 * If the form was processed earlier (init), get the generated errors
@@ -2418,9 +2047,9 @@
2418 2047 */
2419 2048 public static function just_created_entry( $form_id ) {
2420 2049 global $frm_vars;
2421 2050
2422 - return isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
2051 + return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
2423 2052 }
2424 2053
2425 2054 /**
2426 2055 * Gets confirmation method.
@@ -2433,14 +2062,14 @@
2433 2062 *
2434 2063 * @type object $form Form object.
2435 2064 * @type int $entry_id Entry ID.
2436 2065 * }
2437 - * @return array|string
2066 + * @return string|array
2438 2067 */
2439 2068 private static function get_confirmation_method( $atts ) {
2440 2069 $action = FrmOnSubmitHelper::current_event( $atts );
2441 2070 $opt = 'update' === $action ? 'edit_action' : 'success_action';
2442 - $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2071 + $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
2443 2072
2444 2073 if ( ! empty( $atts['entry_id'] ) ) {
2445 2074 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2446 2075 if ( $met_actions ) {
@@ -2449,9 +2078,9 @@
2449 2078 }
2450 2079
2451 2080 $method = apply_filters( 'frm_success_filter', $method, $atts['form'], $action );
2452 2081
2453 - if ( $method !== 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2082 + if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
2454 2083 $method = 'message';
2455 2084 }
2456 2085
2457 2086 return $method;
@@ -2485,9 +2114,9 @@
2485 2114 * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}.
2486 2115 */
2487 2116 public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) {
2488 2117 if ( is_array( $conf_method ) && 1 === count( $conf_method ) ) {
2489 - if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) && empty( $conf_method[0]->post_content['redirect_delay'] ) ) {
2118 + if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) ) {
2490 2119 $event = FrmOnSubmitHelper::current_event( $params );
2491 2120 FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event );
2492 2121 $conf_method = 'redirect';
2493 2122 }
@@ -2536,9 +2165,9 @@
2536 2165 unset( $extra_args['form'] );
2537 2166
2538 2167 do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args );
2539 2168
2540 - $opt = ! isset( $args['action'] ) || $args['action'] === 'create' ? 'success' : 'edit';
2169 + $opt = ( ! isset( $args['action'] ) || $args['action'] === 'create' ) ? 'success' : 'edit';
2541 2170
2542 2171 $args['success_opt'] = $opt;
2543 2172 $args['ajax'] = ! empty( $frm_vars['ajax'] );
2544 2173
@@ -2564,16 +2193,16 @@
2564 2193 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
2565 2194 return array();
2566 2195 }
2567 2196
2568 - // If a redirect action has already opened the URL in a new tab, we show the default message in the current tab.
2197 + // If a redirect action has already opened the URL in a new tab, we show the default message in the currect tab.
2569 2198 if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) {
2570 2199 return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) );
2571 2200 }
2572 2201
2573 - $entry = FrmEntry::getOne( $args['entry_id'], true );
2574 - $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2575 - $met_actions = array();
2202 + $entry = FrmEntry::getOne( $args['entry_id'], true );
2203 + $actions = FrmOnSubmitHelper::get_actions( $args['form']->id );
2204 + $met_actions = array();
2576 2205 $has_redirect = false;
2577 2206
2578 2207 foreach ( $actions as $action ) {
2579 2208 if ( ! in_array( $event, $action->post_content['event'], true ) ) {
@@ -2586,10 +2215,9 @@
2586 2215
2587 2216 $action_type = FrmOnSubmitHelper::get_action_type( $action );
2588 2217
2589 2218 if ( 'redirect' === $action_type ) {
2590 - if ( $has_redirect ) {
2591 - // Do not process because we run the first redirect action only.
2219 + if ( $has_redirect ) { // Do not process because we run the first redirect action only.
2592 2220 continue;
2593 2221 }
2594 2222 }
2595 2223
@@ -2602,9 +2230,9 @@
2602 2230 }
2603 2231
2604 2232 $met_actions[] = $action;
2605 2233 unset( $action );
2606 - }//end foreach
2234 + }
2607 2235
2608 2236 $args['event'] = $event;
2609 2237
2610 2238 /**
@@ -2793,9 +2421,9 @@
2793 2421 add_filter( 'the_content', 'FrmFormsController::preview_content', 9999 );
2794 2422 }
2795 2423
2796 2424 $post = $old_post;
2797 - }//end if
2425 + }
2798 2426 }
2799 2427
2800 2428 /**
2801 2429 * @since 3.0
@@ -2816,16 +2444,14 @@
2816 2444 $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args );
2817 2445
2818 2446 $doing_ajax = FrmAppHelper::doing_ajax();
2819 2447
2820 - if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) {
2821 - // Is AJAX submit and there is just one Redirect action runs.
2448 + if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) { // Is AJAX submit and there is just one Redirect action runs.
2822 2449 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
2823 2450 wp_die();
2824 2451 }
2825 2452
2826 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) {
2827 - // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2453 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) { // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2828 2454 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2829 2455 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
2830 2456 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
2831 2457 return;
@@ -2831,10 +2457,9 @@
2831 2457 return;
2832 2458 }
2833 2459
2834 2460 wp_redirect( esc_url_raw( $success_url ) );
2835 - // Do not use wp_die or redirect fails.
2836 - die();
2461 + die(); // do not use wp_die or redirect fails
2837 2462 }
2838 2463
2839 2464 // Redirect with a delay.
2840 2465 self::redirect_after_submit_using_js( $args + compact( 'success_url', 'doing_ajax' ) );
@@ -2869,46 +2494,28 @@
2869 2494 * @param array $args See {@see FrmFormsController::run_success_action()}.
2870 2495 * @return array
2871 2496 */
2872 2497 private static function get_ajax_redirect_response_data( $args ) {
2873 - $response_data = array(
2874 - 'redirect' => $args['success_url'],
2875 - 'content' => '',
2876 - );
2877 - $unset_content = true;
2498 + $response_data = array( 'redirect' => $args['success_url'] );
2878 2499
2879 - if ( ! empty( $args['form']->options['redirect_delay'] ) ) {
2880 - $response_data['delay'] = $args['form']->options['redirect_delay_time'];
2881 - $response_data['content'] .= self::get_redirect_message( $args['success_url'], $args['form']->options['redirect_delay_msg'], $args );
2882 - $unset_content = false;
2883 - }
2884 -
2885 2500 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2886 2501 $response_data['openInNewTab'] = 1;
2887 2502
2888 - // Only show open in new tab text if there is no delay.
2889 - if ( empty( $response_data['content'] ) ) {
2890 - $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2503 + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2891 2504
2892 - $args['form']->options['success_msg'] = $args['message'];
2893 - $args['form']->options['edit_msg'] = $args['message'];
2894 - if ( ! isset( $args['fields'] ) ) {
2895 - $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2896 - }
2505 + $args['form']->options['success_msg'] = $args['message'];
2506 + $args['form']->options['edit_msg'] = $args['message'];
2507 + if ( ! isset( $args['fields'] ) ) {
2508 + $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2509 + }
2897 2510
2898 - $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2511 + $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2899 2512
2900 - ob_start();
2901 - self::show_lone_success_message( $args );
2902 - $response_data['content'] .= ob_get_clean();
2903 - $unset_content = false;
2904 - }//end if
2513 + ob_start();
2514 + self::show_lone_success_messsage( $args );
2515 + $response_data['content'] = ob_get_clean();
2905 2516
2906 2517 $response_data['fallbackMsg'] = self::get_redirect_fallback_message( $args['success_url'], $args );
2907 - }//end if
2908 -
2909 - if ( $unset_content && '' === $response_data['content'] ) {
2910 - unset( $response_data['content'] );
2911 2518 }
2912 2519
2913 2520 return $response_data;
2914 2521 }
@@ -2920,9 +2527,9 @@
2920 2527 *
2921 2528 * @param array $args See {@see FrmFormsController::run_success_action()}.
2922 2529 */
2923 2530 private static function redirect_after_submit_using_js( $args ) {
2924 - $success_msg = $args['form']->options['redirect_delay_msg'];
2531 + $success_msg = FrmOnSubmitHelper::get_default_redirect_msg();
2925 2532 $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args );
2926 2533 $success_url = esc_url_raw( $args['success_url'] );
2927 2534
2928 2535 /**
@@ -2929,11 +2536,11 @@
2929 2536 * Filters the delay time before redirecting when On Submit Redirect action is delayed.
2930 2537 *
2931 2538 * @since 6.0
2932 2539 *
2933 - * @param int $delay_time Delay time in milliseconds.
2540 + * @param int $delay_time Delay time in miliseconds.
2934 2541 */
2935 - $delay_time = apply_filters( 'frm_redirect_delay_time', 1000 * $args['form']->options['redirect_delay_time'] );
2542 + $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
2936 2543
2937 2544 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2938 2545 $redirect_js = 'window.open("' . $success_url . '", "_blank")';
2939 2546 } else {
@@ -2943,10 +2550,9 @@
2943 2550 add_filter( 'frm_use_wpautop', '__return_true' );
2944 2551
2945 2552 echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2946 2553 echo '<script>';
2947 - if ( empty( $args['doing_ajax'] ) ) {
2948 - // Not AJAX submit, delay JS until window.load.
2554 + if ( empty( $args['doing_ajax'] ) ) { // Not AJAX submit, delay JS until window.load.
2949 2555 echo 'window.onload=function(){';
2950 2556 }
2951 2557 echo 'setTimeout(function(){' . $redirect_js . '}, ' . intval( $delay_time ) . ');'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2952 2558 if ( empty( $args['doing_ajax'] ) ) {
@@ -2959,13 +2565,11 @@
2959 2565 * @since 3.0
2960 2566 *
2961 2567 * @param string $success_url
2962 2568 * @param string $success_msg
2963 - * @param array $args
2569 + * @param array $args
2964 2570 */
2965 2571 private static function get_redirect_message( $success_url, $success_msg, $args ) {
2966 - $success_msg = apply_filters( 'frm_content', $success_msg, $args['form'], $args['entry_id'] );
2967 - $success_msg = do_shortcode( FrmAppHelper::use_wpautop( $success_msg ) );
2968 2572 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
2969 2573 self::get_redirect_fallback_message( $success_url, $args ) .
2970 2574 '</div></div>';
2971 2575
@@ -3021,9 +2625,9 @@
3021 2625 } else {
3022 2626 self::show_form_after_submit( $atts );
3023 2627 }
3024 2628 } else {
3025 - self::show_lone_success_message( $atts );
2629 + self::show_lone_success_messsage( $atts );
3026 2630 }
3027 2631 }
3028 2632
3029 2633 /**
@@ -3051,9 +2655,9 @@
3051 2655
3052 2656 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
3053 2657
3054 2658 $frm_settings = FrmAppHelper::get_settings();
3055 - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value;
2659 + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
3056 2660
3057 2661 global $frm_vars;
3058 2662 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
3059 2663
@@ -3062,10 +2666,11 @@
3062 2666 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
3063 2667 }
3064 2668
3065 2669 /**
2670 + * @return string - 'before', 'after', or 'submit'
2671 + *
3066 2672 * @since 4.05.02
3067 - * @return string - 'before', 'after', or 'submit'
3068 2673 */
3069 2674 private static function message_placement( $form, $message ) {
3070 2675 $place = 'before';
3071 2676
@@ -3077,10 +2682,11 @@
3077 2682 }
3078 2683 }
3079 2684
3080 2685 /**
2686 + * @return string - 'before' or 'after'
2687 + *
3081 2688 * @since 4.05.02
3082 - * @return string - 'before' or 'after'
3083 2689 */
3084 2690 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
3085 2691 }
3086 2692
@@ -3114,9 +2720,9 @@
3114 2720 * Show the success message without the form
3115 2721 *
3116 2722 * @since 2.05
3117 2723 */
3118 - private static function show_lone_success_message( $atts ) {
2724 + private static function show_lone_success_messsage( $atts ) {
3119 2725 global $frm_vars;
3120 2726 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
3121 2727 self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] );
3122 2728
@@ -3125,9 +2731,9 @@
3125 2731 $errors = array();
3126 2732 $form = $atts['form'];
3127 2733 $message = $atts['message'];
3128 2734
3129 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
2735 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' );
3130 2736 }
3131 2737
3132 2738 /**
3133 2739 * Prepare the success message before it's shown
@@ -3141,12 +2747,12 @@
3141 2747 * @return string
3142 2748 */
3143 2749 private static function prepare_submit_message( $form, $entry_id, $args = array() ) {
3144 2750 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
3145 - $opt = $args['success_opt'] ?? 'success';
2751 + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
3146 2752
3147 2753 if ( $entry_id && is_numeric( $entry_id ) ) {
3148 - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg;
2754 + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
3149 2755 $class = 'frm_message';
3150 2756 } else {
3151 2757 $message = $frm_settings->failed_msg;
3152 2758 $class = FrmFormsHelper::form_error_class();
@@ -3247,13 +2853,11 @@
3247 2853 global $frm_vars;
3248 2854
3249 2855 FrmStylesController::enqueue_css();
3250 2856
3251 - if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
2857 + if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3252 2858 // load formidable js
3253 2859 wp_enqueue_script( 'formidable' );
3254 -
3255 - FrmHoneypot::maybe_print_honeypot_js();
3256 2860 }
3257 2861 }
3258 2862
3259 2863 /**
@@ -3267,12 +2871,12 @@
3267 2871 }
3268 2872
3269 2873 /**
3270 2874 * @since 2.0.8
3271 - * @return bool
2875 + * @return boolean
3272 2876 */
3273 2877 private static function is_minification_on( $atts ) {
3274 - return ! empty( $atts['minimize'] );
2878 + return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] );
3275 2879 }
3276 2880
3277 2881 /**
3278 2882 * @since 5.0.16
@@ -3300,9 +2904,9 @@
3300 2904 * Create a page with an embedded formidable Gutenberg block.
3301 2905 *
3302 2906 * @since 5.2
3303 2907 *
3304 - * @return void
2908 + * @return never
3305 2909 */
3306 2910 public static function create_page_with_shortcode() {
3307 2911 if ( ! current_user_can( 'publish_posts' ) ) {
3308 2912 die( 0 );
@@ -3347,9 +2951,10 @@
3347 2951
3348 2952 /**
3349 2953 * @since 5.3
3350 2954 *
3351 - * @param int $form_id
2955 + * @param string $content
2956 + * @param int $form_id
3352 2957 * @return string
3353 2958 */
3354 2959 private static function get_page_shortcode_content_for_form( $form_id ) {
3355 2960 $shortcode = '[formidable id="' . $form_id . '"]';
@@ -3360,9 +2965,9 @@
3360 2965
3361 2966 /**
3362 2967 * Get page dropdown for AJAX request for embedding form in an existing page.
3363 2968 *
3364 - * @return void
2969 + * @return never
3365 2970 */
3366 2971 public static function get_page_dropdown() {
3367 2972 if ( ! current_user_can( 'publish_posts' ) ) {
3368 2973 die( 0 );
@@ -3370,9 +2975,9 @@
3370 2975
3371 2976 check_ajax_referer( 'frm_ajax', 'nonce' );
3372 2977
3373 2978 $html = FrmAppHelper::clip(
3374 - function () {
2979 + function() {
3375 2980 FrmAppHelper::maybe_autocomplete_pages_options(
3376 2981 array(
3377 2982 'field_name' => 'frm_page_dropdown',
3378 2983 'page_id' => '',
@@ -3392,8 +2997,15 @@
3392 2997
3393 2998 /**
3394 2999 * @deprecated 4.0
3395 3000 */
3001 + public static function new_form( $values = array() ) {
3002 + FrmDeprecated::new_form( $values );
3003 + }
3004 +
3005 + /**
3006 + * @deprecated 4.0
3007 + */
3396 3008 public static function create( $values = array() ) {
3397 3009 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3398 3010 self::update( $values );
3399 3011 }
@@ -3398,16 +3010,75 @@
3398 3010 self::update( $values );
3399 3011 }
3400 3012
3401 3013 /**
3402 - * Education for premium features.
3014 + * @deprecated 3.0
3015 + * @codeCoverageIgnore
3016 + */
3017 + public static function bulk_create_template( $ids ) {
3018 + return FrmDeprecated::bulk_create_template( $ids );
3019 + }
3020 +
3021 + /**
3022 + * @deprecated 3.0
3023 + * @codeCoverageIgnore
3024 + */
3025 + public static function edit_key() {
3026 + FrmDeprecated::edit_key();
3027 + }
3028 +
3029 + /**
3030 + * @deprecated 3.0
3031 + * @codeCoverageIgnore
3032 + */
3033 + public static function edit_description() {
3034 + FrmDeprecated::edit_description();
3035 + }
3036 +
3037 + /**
3038 + * @deprecated 4.08
3039 + * @since 3.06
3040 + */
3041 + public static function add_new() {
3042 + _deprecated_function( __FUNCTION__, '4.08' );
3043 + }
3044 +
3045 + /**
3046 + * Create a custom template from a form
3403 3047 *
3404 - * @since 4.05
3405 - * @deprecated 6.16.3
3048 + * @since 3.06
3049 + * @deprecated x.x
3050 + */
3051 + public static function build_template() {
3052 + _deprecated_function( __METHOD__, 'x.x' );
3053 + }
3054 +
3055 + /**
3056 + * @deprecated x.x
3406 3057 *
3058 + * @return bool
3059 + */
3060 + public static function expired() {
3061 + _deprecated_function( __METHOD__, 'x.x' );
3062 + return FrmAddonsController::is_license_expired();
3063 + }
3064 +
3065 + /**
3066 + * Get data from api before rendering it so that we can flag the modal as expired
3067 + *
3068 + * @deprecated x.x
3069 + *
3407 3070 * @return void
3408 3071 */
3409 - public static function add_form_style_tab_options() {
3410 - _deprecated_function( __METHOD__, '6.16.3' );
3411 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php';
3072 + public static function before_list_templates() {
3073 + _deprecated_function( __METHOD__, 'x.x' );
3074 + }
3075 +
3076 + /**
3077 + * @deprecated x.x
3078 + *
3079 + * @return void
3080 + */
3081 + public static function list_templates() {
3082 + _deprecated_function( __METHOD__, 'x.x' );
3412 3083 }
3413 3084 }