PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmFormsHelper.php +58 -478 6.26.16.13 View file →
@@ -15,21 +15,13 @@
15 15 private static $field_type_data_for_insert_opt_html;
16 16
17 17 /**
18 18 * @since 2.2.10
19 - *
20 - * @return string
21 19 */
22 20 public static function form_error_class() {
23 21 return apply_filters( 'frm_form_error_class', 'frm_error_style' );
24 22 }
25 23
26 - /**
27 - * @param string $key
28 - * @param false|object $form
29 - *
30 - * @return string
31 - */
32 24 public static function get_direct_link( $key, $form = false ) {
33 25 $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
34 26 $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
35 27
@@ -35,15 +27,8 @@
35 27
36 28 return $target_url;
37 29 }
38 30
39 - /**
40 - * @param string $field_name
41 - * @param int|string $field_value
42 - * @param array $args
43 - *
44 - * @return void
45 - */
46 31 public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
47 32 $defaults = array(
48 33 'blank' => true,
49 34 'field_id' => false,
@@ -58,9 +43,8 @@
58 43 $args['field_id'] = $field_name;
59 44 }
60 45
61 46 $query = array();
62 -
63 47 if ( $args['exclude'] ) {
64 48 $query['id !'] = $args['exclude'];
65 49 }
66 50
@@ -78,9 +62,9 @@
78 62 <option value=""><?php echo $args['blank'] == 1 ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
79 63 <?php } ?>
80 64 <?php foreach ( $forms as $form ) { ?>
81 65 <option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>>
82 - <?php echo esc_html( '' === $form->name ? self::get_no_title_text() : FrmAppHelper::truncate( $form->name, 50 ) . ( $form->parent_form_id ? __( ' (child)', 'formidable' ) : '' ) ); ?>
66 + <?php echo esc_html( '' === $form->name ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $form->name, 50 ) . ( $form->parent_form_id ? __( ' (child)', 'formidable' ) : '' ) ); ?>
83 67 </option>
84 68 <?php } ?>
85 69 </select>
86 70 <?php
@@ -87,14 +71,11 @@
87 71 }
88 72
89 73 /**
90 74 * @since 2.0.6
91 - *
92 75 * @param string $class
93 76 * @param string $param
94 77 * @param array $add_html
95 - *
96 - * @return void
97 78 */
98 79 public static function add_html_attr( $class, $param, &$add_html ) {
99 80 if ( ! empty( $class ) ) {
100 81 $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
@@ -102,10 +83,8 @@
102 83 }
103 84
104 85 /**
105 86 * @param false|object|string $selected - The label for the placeholder, or the form object.
106 - *
107 - * @return void
108 87 */
109 88 public static function form_switcher( $selected = false ) {
110 89 $where = apply_filters( 'frm_forms_dropdown', array(), '' );
111 90 $forms = FrmForm::get_published_forms( $where );
@@ -113,9 +92,8 @@
113 92 $args = array(
114 93 'id' => 0,
115 94 'form' => 0,
116 95 );
117 -
118 96 if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
119 97 unset( $args['form'] );
120 98 } elseif ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
121 99 unset( $args['id'] );
@@ -121,9 +99,8 @@
121 99 unset( $args['id'] );
122 100 }
123 101
124 102 $frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
125 -
126 103 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy', 'destroy_all' ), true ) ) {
127 104 $args['frm_action'] = 'list';
128 105 $args['form'] = 0;
129 106 } elseif ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ), true ) ) {
@@ -133,21 +110,18 @@
133 110 unset( $args['id'] );
134 111 $query_args = array(
135 112 'page' => 'formidable-styles',
136 113 );
137 -
138 114 if ( $frm_action ) {
139 115 $query_args['frm_action'] = $frm_action;
140 116 }
141 -
142 117 $base = add_query_arg( $query_args, admin_url( 'admin.php' ) );
143 118 } elseif ( isset( $_GET['post'] ) ) {
144 119 $args['form'] = 0;
145 120 $base = admin_url( 'edit.php?post_type=frm_display' );
146 - }//end if
121 + }
147 122
148 123 $form_id = 0;
149 -
150 124 if ( is_object( $selected ) ) {
151 125 $form_id = $selected->id;
152 126 $selected = $selected->name;
153 127 }
@@ -152,9 +126,9 @@
152 126 $selected = $selected->name;
153 127 }
154 128
155 129 $name = $selected === false ? __( 'Switch Form', 'formidable' ) : $selected;
156 - $name = '' === $name || is_null( $name ) ? self::get_no_title_text() : strip_tags( $name );
130 + $name = '' === $name ? __( '(no title)', 'formidable' ) : strip_tags( $name );
157 131 $truncated_name = FrmAppHelper::truncate( $name, 25 );
158 132
159 133 if ( count( $forms ) < 2 ) {
160 134 ?>
@@ -203,15 +177,14 @@
203 177
204 178 if ( isset( $args['id'] ) ) {
205 179 $args['id'] = $form->id;
206 180 }
207 -
208 181 if ( isset( $args['form'] ) ) {
209 182 $args['form'] = $form->id;
210 183 }
211 184
212 185 $url = isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args );
213 - $form_name = empty( $form->name ) ? self::get_no_title_text() : $form->name;
186 + $form_name = empty( $form->name ) ? __( '(no title)', 'formidable' ) : $form->name;
214 187 ?>
215 188 <li class="frm-dropdown-form">
216 189 <a href="<?php echo esc_url( $url ); ?>" tabindex="-1" class="frm-justify-between">
217 190 <?php echo esc_html( $form_name ); ?>
@@ -235,15 +208,8 @@
235 208 </div>
236 209 <?php
237 210 }
238 211
239 - /**
240 - * @param string $col
241 - * @param string $sort_col
242 - * @param string $sort_dir
243 - *
244 - * @return void
245 - */
246 212 public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
247 213 echo $sort_col == $col ? 'sorted' : 'sortable';
248 214 echo $sort_col == $col && $sort_dir === 'desc' ? ' asc' : ' desc';
249 215 }
@@ -249,12 +215,8 @@
249 215 }
250 216
251 217 /**
252 218 * @since 3.0
253 - *
254 - * @param array|string $field_type
255 - *
256 - * @return string
257 219 */
258 220 public static function get_field_link_name( $field_type ) {
259 221 if ( is_array( $field_type ) ) {
260 222 $field_label = $field_type['name'];
@@ -266,12 +228,8 @@
266 228 }
267 229
268 230 /**
269 231 * @since 3.0
270 - *
271 - * @param array|string $field_type
272 - *
273 - * @return string
274 232 */
275 233 public static function get_field_link_icon( $field_type ) {
276 234 if ( is_array( $field_type ) && isset( $field_type['icon'] ) ) {
277 235 $icon = $field_type['icon'];
@@ -292,9 +250,8 @@
292 250 * @return string
293 251 */
294 252 public static function get_invalid_error_message( $args ) {
295 253 $settings_args = $args;
296 -
297 254 if ( isset( $args['form'] ) ) {
298 255 $settings_args['current_form'] = $args['form']->id;
299 256 }
300 257
@@ -311,34 +268,13 @@
311 268 * @type stdClass $form
312 269 * @type int $entry_id
313 270 * @type string $class
314 271 * }
315 - *
316 272 * @return string
317 273 */
318 274 public static function get_success_message( $atts ) {
319 275 $message = apply_filters( 'frm_content', $atts['message'], $atts['form'], $atts['entry_id'] );
320 -
321 - // Only autop if the message includes line breaks.
322 - $autop = strpos( $message, "\n" ) !== false;
323 -
324 - /**
325 - * Filters whether to autop the success message.
326 - * This is false by default if the message does not include line breaks.
327 - *
328 - * @since 6.23
329 - *
330 - * @param bool $autop
331 - * @param string $message
332 - * @param object $form
333 - */
334 - $autop = (bool) apply_filters( 'frm_wpautop_success_message', $autop, $message, $atts['form'] );
335 -
336 - if ( $autop ) {
337 - $message = FrmAppHelper::use_wpautop( $message );
338 - }
339 -
340 - $message = do_shortcode( $message );
276 + $message = do_shortcode( FrmAppHelper::use_wpautop( $message ) );
341 277 $message = '<div class="' . esc_attr( $atts['class'] ) . '" role="status">' . $message . '</div>';
342 278 return $message;
343 279 }
344 280
@@ -343,12 +279,8 @@
343 279 }
344 280
345 281 /**
346 282 * Used when a form is created
347 - *
348 - * @param array $values
349 - *
350 - * @return array
351 283 */
352 284 public static function setup_new_vars( $values = array() ) {
353 285 global $wpdb;
354 286
@@ -362,9 +294,8 @@
362 294 $defaults = array(
363 295 'name' => '',
364 296 'description' => '',
365 297 );
366 -
367 298 foreach ( $defaults as $var => $default ) {
368 299 if ( ! isset( $values[ $var ] ) ) {
369 300 $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
370 301 }
@@ -379,9 +310,8 @@
379 310 'is_template' => 0,
380 311 'status' => 'published',
381 312 'parent_form_id' => 0,
382 313 );
383 -
384 314 foreach ( $defaults as $var => $default ) {
385 315 if ( ! isset( $values[ $var ] ) ) {
386 316 $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
387 317 }
@@ -399,14 +329,8 @@
399 329 }
400 330
401 331 /**
402 332 * Used when editing a form
403 - *
404 - * @param array $values
405 - * @param object $record
406 - * @param array $post_values
407 - *
408 - * @return array
409 333 */
410 334 public static function setup_edit_vars( $values, $record, $post_values = array() ) {
411 335 if ( empty( $post_values ) ) {
412 336 $post_values = wp_unslash( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -411,10 +335,10 @@
411 335 if ( empty( $post_values ) ) {
412 336 $post_values = wp_unslash( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
413 337 }
414 338
415 - $values['form_key'] = $post_values['form_key'] ?? $record->form_key;
416 - $values['is_template'] = $post_values['is_template'] ?? $record->is_template;
339 + $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
340 + $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
417 341 $values['status'] = $record->status;
418 342
419 343 $values = self::fill_default_opts( $values, $record, $post_values );
420 344
@@ -420,19 +344,11 @@
420 344
421 345 return apply_filters( 'frm_setup_edit_form_vars', $values );
422 346 }
423 347
424 - /**
425 - * @param array $values
426 - * @param false|object $record
427 - * @param array|false $post_values
428 - *
429 - * @return array
430 - */
431 348 public static function fill_default_opts( $values, $record, $post_values ) {
432 349
433 350 $defaults = self::get_default_opts();
434 -
435 351 foreach ( $defaults as $var => $default ) {
436 352 if ( is_array( $default ) ) {
437 353 if ( ! isset( $values[ $var ] ) ) {
438 354 $values[ $var ] = $record && isset( $record->options[ $var ] ) ? $record->options[ $var ] : array();
@@ -471,9 +387,9 @@
471 387 'success_action' => 'message',
472 388 'success_msg' => $frm_settings->success_msg,
473 389 'show_form' => 0,
474 390 'akismet' => '',
475 - 'stopforumspam' => 0,
391 + 'honeypot' => 'basic',
476 392 'antispam' => 0,
477 393 'no_save' => 0,
478 394 'ajax_load' => 0,
479 395 'js_validate' => 0,
@@ -489,19 +405,15 @@
489 405 }
490 406
491 407 /**
492 408 * @since 2.0.6
493 - *
494 409 * @param array $options
495 410 * @param array $values
496 - *
497 - * @return void
498 411 */
499 412 public static function fill_form_options( &$options, $values ) {
500 413 $defaults = self::get_default_opts();
501 -
502 414 foreach ( $defaults as $var => $default ) {
503 - $options[ $var ] = $values['options'][ $var ] ?? $default;
415 + $options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
504 416 unset( $var, $default );
505 417 }
506 418 }
507 419
@@ -506,10 +418,8 @@
506 418 }
507 419
508 420 /**
509 421 * @param string $loc
510 - *
511 - * @return string
512 422 */
513 423 public static function get_default_html( $loc ) {
514 424 if ( $loc === 'submit' ) {
515 425 $draft_link = self::get_draft_link();
@@ -534,11 +444,8 @@
534 444
535 445 return $default_html;
536 446 }
537 447
538 - /**
539 - * @return string
540 - */
541 448 public static function get_draft_link() {
542 449 $link = '[if save_draft]<button class="frm_save_draft" [draft_hook]>[draft_label]</button>[/if save_draft]';
543 450
544 451 return $link;
@@ -554,20 +461,10 @@
554 461 public static function get_start_over_shortcode() {
555 462 return '[if start_over]<a href="#" tabindex="0" class="frm_start_over" [start_over_hook]>[start_over_label]</a>[/if start_over]';
556 463 }
557 464
558 - /**
559 - * @param string $html
560 - * @param object $form
561 - * @param string $submit
562 - * @param object|null $form_action
563 - * @param array $values
564 - *
565 - * @return void
566 - */
567 465 public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
568 466 $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
569 -
570 467 if ( ! strpos( $button, '[button_action]' ) ) {
571 468 echo FrmAppHelper::maybe_kses( $button ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
572 469 return;
573 470 }
@@ -575,21 +472,17 @@
575 472 /**
576 473 * @since 5.0.06
577 474 */
578 475 $button = apply_filters( 'frm_submit_button_html', $button, compact( 'form' ) );
579 -
580 476 if ( FrmAppHelper::should_never_allow_unfiltered_html() ) {
581 477 $button = FrmAppHelper::kses_submit_button( $button );
582 478 }
583 -
584 479 $button_parts = explode( '[button_action]', $button );
585 480
586 481 $classes = apply_filters( 'frm_submit_button_class', array(), $form );
587 -
588 482 if ( ! empty( $classes ) ) {
589 483 $classes = implode( ' ', $classes );
590 484 $button_class = 'frm_button_submit';
591 -
592 485 if ( preg_match( '/\bclass="[^"]*?\b' . preg_quote( $button_class, '/' ) . '\b[^"]*?"/', $button_parts[0] ) ) {
593 486 $button_parts[0] = str_replace( $button_class, $button_class . ' ' . esc_attr( $classes ), $button_parts[0] );
594 487 } else {
595 488 $button_parts[0] .= ' class="' . esc_attr( $classes ) . '"';
@@ -602,10 +495,8 @@
602 495 }
603 496
604 497 /**
605 498 * @since 4.0
606 - *
607 - * @return array
608 499 */
609 500 public static function html_shortcodes() {
610 501 $codes = array(
611 502 'id' => array(
@@ -692,15 +583,14 @@
692 583 /**
693 584 * @since 4.0
694 585 *
695 586 * @param array $args
696 - *
697 587 * @return void
698 588 */
699 589 public static function insert_opt_html( $args ) {
700 - $class = $args['class'] ?? '';
590 + $class = isset( $args['class'] ) ? $args['class'] : '';
701 591 $fields = self::get_field_type_data_for_insert_opt_html();
702 - $field = $fields[ $args['type'] ] ?? array();
592 + $field = isset( $fields[ $args['type'] ] ) ? $fields[ $args['type'] ] : array();
703 593
704 594 self::prepare_field_type( $field );
705 595
706 596 if ( ! isset( $field['icon'] ) ) {
@@ -707,9 +597,8 @@
707 597 $field['icon'] = 'frmfont frm_pencil_icon';
708 598 }
709 599
710 600 $possible_email_field = FrmFieldFactory::field_has_property( $args['type'], 'holds_email_values' );
711 -
712 601 if ( $possible_email_field ) {
713 602 $class .= ' show_frm_not_email_to';
714 603 }
715 604
@@ -717,9 +606,8 @@
717 606 $class .= ' frm_insert_url';
718 607 }
719 608
720 609 $truncated_name = FrmAppHelper::truncate( $args['name'], 60 );
721 -
722 610 if ( isset( $field['icon'] ) ) {
723 611 $icon = FrmAppHelper::icon_by_class(
724 612 $field['icon'],
725 613 array(
@@ -736,9 +624,9 @@
736 624 <?php
737 625 echo FrmAppHelper::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
738 626 echo esc_html( $truncated_name );
739 627 ?>
740 - <span>[<?php echo esc_attr( $args['id_label'] ?? $args['id'] ); ?>]</span>
628 + <span>[<?php echo esc_attr( isset( $args['id_label'] ) ? $args['id_label'] : $args['id'] ); ?>]</span>
741 629 </a>
742 630 <a href="javascript:void(0)" class="frmkeys frm_insert_code frm_hidden" data-code="<?php echo esc_attr( $args['key'] ); ?>">
743 631 <?php
744 632 echo FrmAppHelper::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -743,9 +631,9 @@
743 631 <?php
744 632 echo FrmAppHelper::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
745 633 echo esc_html( $truncated_name );
746 634 ?>
747 - <span>[<?php echo esc_attr( FrmAppHelper::truncate( $args['key_label'] ?? $args['key'], 7 ) ); ?>]</span>
635 + <span>[<?php echo esc_attr( FrmAppHelper::truncate( isset( $args['key_label'] ) ? $args['key_label'] : $args['key'], 7 ) ); ?>]</span>
748 636 </a>
749 637 </li>
750 638 <?php
751 639 }
@@ -766,12 +654,9 @@
766 654 }
767 655
768 656 /**
769 657 * @since 4.0
770 - *
771 658 * @param array $args
772 - *
773 - * @return void
774 659 */
775 660 public static function insert_code_html( $args ) {
776 661 $defaults = array(
777 662 'class' => '',
@@ -803,9 +688,8 @@
803 688 *
804 689 * @since 4.0
805 690 *
806 691 * @param array|string $field
807 - *
808 692 * @return void
809 693 */
810 694 public static function prepare_field_type( &$field ) {
811 695 if ( ! is_array( $field ) ) {
@@ -823,10 +707,8 @@
823 707 *
824 708 * @param object $form
825 709 * @param array $fields
826 710 * @param bool $reset_fields
827 - *
828 - * @return void
829 711 */
830 712 public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
831 713 if ( empty( $fields ) ) {
832 714 return;
@@ -836,9 +718,8 @@
836 718 $open = false;
837 719 $prev_order = false;
838 720 $add_order = 0;
839 721 $last_field = false;
840 -
841 722 foreach ( $fields as $field ) {
842 723 if ( $prev_order === $field->field_order ) {
843 724 ++$add_order;
844 725 }
@@ -881,17 +762,8 @@
881 762
882 763 /**
883 764 * Create end section field if it doesn't exist. This is for migration from < 2.0
884 765 * Fix any ordering that may be messed up
885 - *
886 - * @param bool $open
887 - * @param bool $reset_fields
888 - * @param int $add_order
889 - * @param array $end_section_values
890 - * @param object $field
891 - * @param string $move
892 - *
893 - * @return void
894 766 */
895 767 public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
896 768 if ( ! $open ) {
897 769 return;
@@ -910,17 +782,8 @@
910 782 $open = false;
911 783 $reset_fields = true;
912 784 }
913 785
914 - /**
915 - * @param string $html
916 - * @param object $form
917 - * @param bool $title
918 - * @param bool $description
919 - * @param array $values
920 - *
921 - * @return string
922 - */
923 786 public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
924 787 $codes = array(
925 788 'form_name' => $title,
926 789 'form_description' => $description,
@@ -925,9 +788,8 @@
925 788 'form_name' => $title,
926 789 'form_description' => $description,
927 790 'entry_key' => true,
928 791 );
929 -
930 792 foreach ( $codes as $code => $show ) {
931 793 if ( $code === 'form_name' ) {
932 794 $replace_with = $form->name;
933 795 } elseif ( $code === 'form_description' ) {
@@ -974,13 +836,8 @@
974 836
975 837 return $html;
976 838 }
977 839
978 - /**
979 - * @param string $submit
980 - *
981 - * @return string
982 - */
983 840 public static function submit_button_label( $submit ) {
984 841 if ( ! $submit ) {
985 842 $frm_settings = FrmAppHelper::get_settings();
986 843 $submit = $frm_settings->submit_value;
@@ -998,9 +855,8 @@
998 855 * @return void
999 856 */
1000 857 public static function maybe_hide_inline() {
1001 858 $frm_settings = FrmAppHelper::get_settings();
1002 -
1003 859 if ( $frm_settings->load_style === 'none' ) {
1004 860 echo ' style="display:none;"';
1005 861 } elseif ( $frm_settings->load_style === 'dynamic' ) {
1006 862 FrmStylesController::enqueue_style();
@@ -1007,10 +863,8 @@
1007 863 }
1008 864 }
1009 865
1010 866 /**
1011 - * @param array|bool|int|object|string $form
1012 - *
1013 867 * @return string|null
1014 868 */
1015 869 public static function get_form_style_class( $form = false ) {
1016 870 $style = self::get_form_style( $form );
@@ -1053,9 +907,8 @@
1053 907 *
1054 908 * @since 5.0.12
1055 909 *
1056 910 * @param array $form
1057 - *
1058 911 * @return bool
1059 912 */
1060 913 private static function form_should_be_inline_and_missing_class( $form ) {
1061 914 if ( isset( $form['form_class'] ) && false !== strpos( ' ' . $form['form_class'] . ' ', ' frm_inline_form ' ) ) {
@@ -1088,9 +941,8 @@
1088 941 return false;
1089 942 }
1090 943
1091 944 $fields = $form['fields'];
1092 -
1093 945 if ( count( $fields ) <= 0 ) {
1094 946 return false;
1095 947 }
1096 948
@@ -1095,13 +947,11 @@
1095 947 }
1096 948
1097 949 // Start from the fields closest to the submit button.
1098 950 $fields = array_reverse( $fields );
1099 -
1100 951 foreach ( $fields as $field ) {
1101 - $type = $field['original_type'] ?? $field['type'];
952 + $type = isset( $field['original_type'] ) ? $field['original_type'] : $field['type'];
1102 953 $has_input = FrmFieldFactory::field_has_property( $type, 'has_input' );
1103 -
1104 954 if ( $has_input ) {
1105 955 return self::field_has_top_label( $field, $form );
1106 956 }
1107 957 }
@@ -1123,15 +973,13 @@
1123 973 return in_array( $label_position, array( 'top', 'inside', 'hidden' ) );
1124 974 }
1125 975
1126 976 /**
1127 - * @param array|bool|int|object|string $form
1128 - *
977 + * @param array|bool|object|string $form
1129 978 * @return string
1130 979 */
1131 980 public static function get_form_style( $form ) {
1132 981 $style = 1;
1133 -
1134 982 if ( empty( $form ) || 'default' === $form ) {
1135 983 return $style;
1136 984 }
1137 985
@@ -1143,9 +991,9 @@
1143 991 } elseif ( is_array( $form ) && isset( $form['custom_style'] ) ) {
1144 992 $style = $form['custom_style'];
1145 993 }
1146 994
1147 - if ( $form && ( is_string( $form ) || is_int( $form ) ) ) {
995 + if ( $form && is_string( $form ) ) {
1148 996 $form = FrmForm::getOne( $form );
1149 997 }
1150 998
1151 999 $style = $form && is_object( $form ) && isset( $form->options['custom_style'] ) ? $form->options['custom_style'] : $style;
@@ -1156,12 +1004,9 @@
1156 1004 /**
1157 1005 * Display the validation error messages when an entry is submitted
1158 1006 *
1159 1007 * @since 2.0.6
1160 - *
1161 1008 * @param array $args Includes img, errors.
1162 - *
1163 - * @return void
1164 1009 */
1165 1010 public static function show_errors( $args ) {
1166 1011 $invalid_msg = self::get_invalid_error_message( $args );
1167 1012
@@ -1186,12 +1031,9 @@
1186 1031 * The image was removed from the styling settings, but it may still be set with a hook
1187 1032 * If the message in the global settings is empty, show every validation message in the error box
1188 1033 *
1189 1034 * @since 2.0.6
1190 - *
1191 1035 * @param array $args Includes img, errors, and show_img.
1192 - *
1193 - * @return void
1194 1036 */
1195 1037 public static function show_error( $args ) {
1196 1038 // remove any blank messages
1197 1039 $args['errors'] = array_filter( (array) $args['errors'] );
@@ -1196,9 +1038,8 @@
1196 1038 // remove any blank messages
1197 1039 $args['errors'] = array_filter( (array) $args['errors'] );
1198 1040
1199 1041 $line_break_first = $args['show_img'];
1200 -
1201 1042 foreach ( $args['errors'] as $error_key => $error ) {
1202 1043 if ( $line_break_first && ! is_numeric( $error_key ) && ( $error_key === 'cptch_number' || strpos( $error_key, 'field' ) === 0 ) ) {
1203 1044 continue;
1204 1045 }
@@ -1217,26 +1058,15 @@
1217 1058 echo '</div>';
1218 1059 }
1219 1060 }
1220 1061
1221 - /**
1222 - * @param int|string $id
1223 - *
1224 - * @return void
1225 - */
1226 1062 public static function maybe_get_scroll_js( $id ) {
1227 1063 $offset = apply_filters( 'frm_scroll_offset', 4, array( 'form_id' => $id ) );
1228 -
1229 1064 if ( $offset != - 1 ) {
1230 1065 self::get_scroll_js( $id );
1231 1066 }
1232 1067 }
1233 1068
1234 - /**
1235 - * @param int|string $form_id
1236 - *
1237 - * @return void
1238 - */
1239 1069 public static function get_scroll_js( $form_id ) {
1240 1070 echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
1241 1071 }
1242 1072
@@ -1241,13 +1071,8 @@
1241 1071 }
1242 1072
1243 1073 /**
1244 1074 * @since 3.0
1245 - *
1246 - * @param int|object|string $form_id
1247 - * @param mixed $form
1248 - *
1249 - * @return array
1250 1075 */
1251 1076 public static function get_action_links( $form_id, $form ) {
1252 1077 if ( ! is_object( $form ) ) {
1253 1078 $form = FrmForm::getOne( $form_id );
@@ -1254,9 +1079,8 @@
1254 1079 }
1255 1080
1256 1081 $actions = array();
1257 1082 $trash_links = self::delete_trash_links( $form_id );
1258 -
1259 1083 if ( 'trash' == $form->status ) {
1260 1084 $actions['restore'] = $trash_links['restore'];
1261 1085
1262 1086 if ( current_user_can( 'frm_delete_forms' ) ) {
@@ -1263,9 +1087,8 @@
1263 1087 $actions['trash'] = $trash_links['delete'];
1264 1088 }
1265 1089 } elseif ( current_user_can( 'frm_edit_forms' ) ) {
1266 1090 $duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $form_id;
1267 -
1268 1091 if ( $form->is_template ) {
1269 1092 $actions['frm_duplicate'] = array(
1270 1093 'url' => wp_nonce_url( $duplicate_link ),
1271 1094 'label' => __( 'Create Form from Template', 'formidable' ),
@@ -1284,13 +1107,8 @@
1284 1107
1285 1108 return $actions;
1286 1109 }
1287 1110
1288 - /**
1289 - * @param int|object|string $data
1290 - *
1291 - * @return string
1292 - */
1293 1111 public static function edit_form_link( $data ) {
1294 1112 $form_id = self::get_form_id_from_data( $data );
1295 1113
1296 1114 if ( ! $form_id ) {
@@ -1301,37 +1119,19 @@
1301 1119 $link = '<a href="' . esc_url( FrmForm::get_edit_link( $form_id ) ) . '">' . esc_html( $label ) . '</a>';
1302 1120 return $link;
1303 1121 }
1304 1122
1305 - /**
1306 - * Returns a text used when no title is set.
1307 - *
1308 - * @since 6.16.1
1309 - *
1310 - * @return string
1311 - */
1312 - public static function get_no_title_text() {
1313 - return __( '(no title)', 'formidable' );
1314 - }
1315 -
1316 - /**
1317 - * @param int|object|string $data
1318 - *
1319 - * @return string
1320 - */
1321 1123 public static function edit_form_link_label( $data ) {
1322 1124 $name = self::get_form_name_from_data( $data );
1323 -
1324 1125 if ( ! $name ) {
1325 - return self::get_no_title_text();
1126 + return __( '(no title)', 'formidable' );
1326 1127 }
1327 1128 return FrmAppHelper::truncate( $name, 40 );
1328 1129 }
1329 1130
1330 1131 /**
1331 - * @param int|object|string $data
1332 - *
1333 - * @return int|string
1132 + * @param mixed $data
1133 + * @return int
1334 1134 */
1335 1135 private static function get_form_id_from_data( $data ) {
1336 1136 if ( is_object( $data ) ) {
1337 1137 $form_id = $data->id;
@@ -1342,9 +1142,8 @@
1342 1142 }
1343 1143
1344 1144 /**
1345 1145 * @param mixed $data
1346 - *
1347 1146 * @return string
1348 1147 */
1349 1148 private static function get_form_name_from_data( $data ) {
1350 1149 if ( is_object( $data ) ) {
@@ -1355,15 +1154,8 @@
1355 1154 }
1356 1155 return $form_name;
1357 1156 }
1358 1157
1359 - /**
1360 - * @param int $id
1361 - * @param string $status
1362 - * @param string $length
1363 - *
1364 - * @return string
1365 - */
1366 1158 public static function delete_trash_link( $id, $status, $length = 'label' ) {
1367 1159 $link_details = self::delete_trash_info( $id, $status );
1368 1160
1369 1161 return self::format_link_html( $link_details, $length );
@@ -1370,20 +1162,13 @@
1370 1162 }
1371 1163
1372 1164 /**
1373 1165 * @since 3.0
1374 - *
1375 - * @param array $link_details
1376 - * @param string $length
1377 - *
1378 - * @return string
1379 1166 */
1380 1167 public static function format_link_html( $link_details, $length = 'label' ) {
1381 1168 $link = '';
1382 -
1383 1169 if ( ! empty( $link_details ) ) {
1384 1170 $link = '<a href="' . esc_url( $link_details['url'] ) . '" class="frm-trash-link"';
1385 -
1386 1171 if ( isset( $link_details['data'] ) ) {
1387 1172 foreach ( $link_details['data'] as $data => $value ) {
1388 1173 $link .= ' data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '"';
1389 1174 }
@@ -1390,10 +1175,9 @@
1390 1175 } elseif ( isset( $link_details['confirm'] ) ) {
1391 1176 $link .= ' onclick="return confirm(\'' . esc_attr( $link_details['confirm'] ) . '\')"';
1392 1177 }
1393 1178
1394 - $label = ( $link_details[ $length ] ?? $link_details['label'] );
1395 -
1179 + $label = ( isset( $link_details[ $length ] ) ? $link_details[ $length ] : $link_details['label'] );
1396 1180 if ( $length === 'icon' && isset( $link_details[ $length ] ) ) {
1397 1181 $label = '<span class="' . $label . '" title="' . esc_attr( $link_details['label'] ) . '" aria-hidden="true"></span>';
1398 1182 $link .= ' aria-label="' . esc_attr( $link_details['label'] ) . '"';
1399 1183 }
@@ -1405,13 +1189,8 @@
1405 1189 }
1406 1190
1407 1191 /**
1408 1192 * @since 3.0
1409 - *
1410 - * @param int $id
1411 - * @param string $status
1412 - *
1413 - * @return array
1414 1193 */
1415 1194 public static function delete_trash_info( $id, $status ) {
1416 1195 $labels = self::delete_trash_links( $id );
1417 1196
@@ -1431,12 +1210,8 @@
1431 1210 }
1432 1211
1433 1212 /**
1434 1213 * @since 3.0
1435 - *
1436 - * @param int $id
1437 - *
1438 - * @return array
1439 1214 */
1440 1215 public static function delete_trash_links( $id ) {
1441 1216 $current_page = FrmAppHelper::get_simple_request( array( 'param' => 'form_type' ) );
1442 1217 $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
@@ -1472,10 +1247,8 @@
1472 1247 }
1473 1248
1474 1249 /**
1475 1250 * @since 3.0
1476 - *
1477 - * @return array
1478 1251 */
1479 1252 public static function css_classes() {
1480 1253 $classes = array(
1481 1254 'frm_total' => array(
@@ -1510,11 +1283,8 @@
1510 1283
1511 1284 return apply_filters( 'frm_layout_classes', $classes );
1512 1285 }
1513 1286
1514 - /**
1515 - * @return array
1516 - */
1517 1287 public static function grid_classes() {
1518 1288 return array(
1519 1289 'frm_half' => '1/2',
1520 1290 'frm_third' => '1/3',
@@ -1528,17 +1298,11 @@
1528 1298 }
1529 1299
1530 1300 /**
1531 1301 * @since 3.0
1532 - *
1533 - * @param mixed $style
1534 - * @param string $class
1535 - *
1536 - * @return string
1537 1302 */
1538 1303 public static function style_class_label( $style, $class ) {
1539 1304 $label = '';
1540 -
1541 1305 if ( empty( $style ) ) {
1542 1306 $label = $class;
1543 1307 } elseif ( ! is_array( $style ) ) {
1544 1308 $label = $style;
@@ -1548,13 +1312,8 @@
1548 1312
1549 1313 return $label;
1550 1314 }
1551 1315
1552 - /**
1553 - * @param string $status
1554 - *
1555 - * @return string
1556 - */
1557 1316 public static function status_nice_name( $status ) {
1558 1317 $nice_names = array(
1559 1318 'draft' => __( 'Draft', 'formidable' ),
1560 1319 'trash' => __( 'Trash', 'formidable' ),
@@ -1575,9 +1334,8 @@
1575 1334 *
1576 1335 * @param array $categories The categories to render the icon for.
1577 1336 * @param array $atts {
1578 1337 * Optional. An array of attributes for rendering.
1579 - *
1580 1338 * @type string $html 'span' or 'div'. Default 'span'.
1581 1339 * @type bool $bg Whether to add a background color or not. Default false.
1582 1340 * }
1583 1341 *
@@ -1590,9 +1348,9 @@
1590 1348 );
1591 1349 $atts = array_merge( $defaults, $atts );
1592 1350
1593 1351 // Filter out ignored categories.
1594 - $ignore = self::get_license_types();
1352 + $ignore = self::ignore_template_categories();
1595 1353 $categories = array_diff( $categories, $ignore );
1596 1354
1597 1355 // Define icons mapping.
1598 1356 $icons = array(
@@ -1627,12 +1385,11 @@
1627 1385 );
1628 1386
1629 1387 // Determine the icon to be used.
1630 1388 $icon = $icons[''];
1631 -
1632 1389 if ( count( $categories ) === 1 ) {
1633 1390 $category = reset( $categories );
1634 - $icon = $icons[ $category ] ?? $icon;
1391 + $icon = isset( $icons[ $category ] ) ? $icons[ $category ] : $icon;
1635 1392 } elseif ( ! empty( $categories ) ) {
1636 1393 $icons = array_intersect_key( $icons, array_flip( $categories ) );
1637 1394 $icon = reset( $icons );
1638 1395 }
@@ -1638,13 +1395,12 @@
1638 1395 }
1639 1396
1640 1397 // Prepare variables for output.
1641 1398 $icon_name = $icon[0];
1642 - $bg_color = $icon[1] ?? '';
1399 + $bg_color = isset( $icon[1] ) ? $icon[1] : '';
1643 1400
1644 1401 // Render the icon.
1645 1402 echo '<span class="frm-category-icon frm-icon-wrapper"';
1646 -
1647 1403 if ( $bg_color && $atts['bg'] ) {
1648 1404 echo ' style="background-color:' . esc_attr( $bg_color ) . '"';
1649 1405 }
1650 1406 echo '>';
@@ -1652,8 +1408,19 @@
1652 1408 echo '</span>';
1653 1409 }
1654 1410
1655 1411 /**
1412 + * Retrieves the list of template categories to ignore.
1413 + *
1414 + * @since 4.03.01
1415 + *
1416 + * @return string[] Array of categories to ignore.
1417 + */
1418 + public static function ignore_template_categories() {
1419 + return array( 'Business', 'Elite', 'Personal', 'Creator', 'Basic', 'free' );
1420 + }
1421 +
1422 + /**
1656 1423 * Get template install link.
1657 1424 *
1658 1425 * @since 4.02
1659 1426 *
@@ -1658,9 +1425,8 @@
1658 1425 * @since 4.02
1659 1426 *
1660 1427 * @param array $template Template details.
1661 1428 * @param array $args Additional arguments.
1662 - *
1663 1429 * @return array The link attributes.
1664 1430 */
1665 1431 public static function get_template_install_link( $template, $args ) {
1666 1432 $defaults = array(
@@ -1676,8 +1442,13 @@
1676 1442 'class' => 'frm-install-template',
1677 1443 'href' => 'rel',
1678 1444 'atts' => '',
1679 1445 );
1446 + } elseif ( self::plan_is_allowed( $args ) ) {
1447 + $link = array(
1448 + 'url' => FrmAppHelper::admin_upgrade_link( 'addons', 'account/downloads/' ) . '&utm_content=' . $template['slug'],
1449 + 'label' => __( 'Renew', 'formidable' ),
1450 + );
1680 1451 } else {
1681 1452 $link = array(
1682 1453 'url' => $args['pricing'],
1683 1454 'label' => __( 'Upgrade', 'formidable' ),
@@ -1692,9 +1463,8 @@
1692 1463 *
1693 1464 * @since 4.02.02
1694 1465 *
1695 1466 * @param array $args
1696 - *
1697 1467 * @return bool
1698 1468 */
1699 1469 public static function plan_is_allowed( $args ) {
1700 1470 if ( empty( $args['license_type'] ) ) {
@@ -1713,9 +1483,8 @@
1713 1483 foreach ( $plans as $plan ) {
1714 1484 if ( $included || $plan === $license_type ) {
1715 1485 break;
1716 1486 }
1717 -
1718 1487 $included = $plan === $plan_required;
1719 1488 }
1720 1489
1721 1490 return $included;
@@ -1725,13 +1494,8 @@
1725 1494 * If a template or add-on cannot be installed, show a message
1726 1495 * about which plan is required.
1727 1496 *
1728 1497 * @since 4.0
1729 - *
1730 - * @param string $requires
1731 - * @param string $link
1732 - *
1733 - * @return void
1734 1498 */
1735 1499 public static function show_plan_required( $requires, $link ) {
1736 1500 if ( empty( $requires ) ) {
1737 1501 return;
@@ -1738,9 +1502,9 @@
1738 1502 }
1739 1503
1740 1504 ?>
1741 1505 <p class="frm_plan_required">
1742 - <?php esc_html_e( 'Plan required:', 'formidable' ); ?>
1506 + <?php esc_html_e( 'License plan required:', 'formidable' ); ?>
1743 1507 <a href="<?php echo esc_url( $link ); ?>" target="_blank" rel="noopener">
1744 1508 <?php echo esc_html( $requires ); ?>
1745 1509 </a>
1746 1510 </p>
@@ -1750,9 +1514,8 @@
1750 1514 /**
1751 1515 * @since 4.0
1752 1516 *
1753 1517 * @param array $item
1754 - *
1755 1518 * @return false|string
1756 1519 */
1757 1520 public static function get_plan_required( &$item ) {
1758 1521 if ( ! isset( $item['categories'] ) || ! is_array( $item['categories'] ) || ! empty( $item['url'] ) ) {
@@ -1758,15 +1521,18 @@
1758 1521 if ( ! isset( $item['categories'] ) || ! is_array( $item['categories'] ) || ! empty( $item['url'] ) ) {
1759 1522 return false;
1760 1523 }
1761 1524
1762 - $plans = self::get_license_types();
1525 + $plans = array( 'free', 'Basic', 'Personal', 'Plus', 'Creator', 'Business', 'Elite' );
1763 1526
1764 1527 foreach ( $item['categories'] as $k => $category ) {
1765 1528 if ( in_array( $category, $plans, true ) ) {
1766 1529 unset( $item['categories'][ $k ] );
1767 1530
1768 - $category = self::convert_legacy_package_names( $category );
1531 + if ( in_array( $category, array( 'Creator', 'Personal' ), true ) ) {
1532 + // Show the current package name.
1533 + $category = 'Plus';
1534 + }
1769 1535
1770 1536 return $category;
1771 1537 }
1772 1538 }
@@ -1774,54 +1540,8 @@
1774 1540 return false;
1775 1541 }
1776 1542
1777 1543 /**
1778 - * Converts legacy package names to the current standard package name.
1779 - *
1780 - * @since 6.15
1781 - *
1782 - * @param string $package_name
1783 - *
1784 - * @return string The updated package name.
1785 - */
1786 - public static function convert_legacy_package_names( $package_name ) {
1787 - if ( in_array( $package_name, array( 'Creator', 'Personal' ), true ) ) {
1788 - $package_name = 'Plus';
1789 - }
1790 -
1791 - return $package_name;
1792 - }
1793 -
1794 - /**
1795 - * Get the license types.
1796 - *
1797 - * @since 6.15
1798 - *
1799 - * @param array $args
1800 - *
1801 - * @return array
1802 - */
1803 - public static function get_license_types( $args = array() ) {
1804 - $defaults = array(
1805 - 'include_all' => true,
1806 - 'case_lower' => false,
1807 - );
1808 - $args = wp_parse_args( $args, $defaults );
1809 -
1810 - $license_types = array( 'Basic', 'Plus', 'Business', 'Elite' );
1811 -
1812 - if ( $args['include_all'] ) {
1813 - $license_types = array_merge( array( 'free', 'Personal', 'Creator' ), $license_types );
1814 - }
1815 -
1816 - if ( $args['case_lower'] ) {
1817 - $license_types = array_map( 'strtolower', $license_types );
1818 - }
1819 -
1820 - return $license_types;
1821 - }
1822 -
1823 - /**
1824 1544 * Checks for warnings to be displayed after form settings are saved.
1825 1545 *
1826 1546 * @since 4.04
1827 1547 *
@@ -1877,9 +1597,8 @@
1877 1597 * @return array An array of params whose names are reserved words or an empty array.
1878 1598 */
1879 1599 private static function get_unsafe_params( $url ) {
1880 1600 $redirect_components = parse_url( $url );
1881 -
1882 1601 if ( empty( $redirect_components['query'] ) ) {
1883 1602 return array();
1884 1603 }
1885 1604 parse_str( $redirect_components['query'], $redirect_params );
@@ -1984,9 +1703,8 @@
1984 1703 * @since 5.0.16
1985 1704 *
1986 1705 * @param string $url
1987 1706 * @param int $form_id
1988 - *
1989 1707 * @return string
1990 1708 */
1991 1709 public static function maybe_add_sanitize_url_attr( $url, $form_id ) {
1992 1710 if ( false === strpos( $url, '[' ) ) {
@@ -1994,9 +1712,8 @@
1994 1712 return $url;
1995 1713 }
1996 1714
1997 1715 $parsed = wp_parse_url( $url );
1998 -
1999 1716 if ( empty( $parsed['query'] ) ) {
2000 1717 // Do nothing if no query can be detected in the url string.
2001 1718 return $url;
2002 1719 }
@@ -2004,9 +1721,8 @@
2004 1721 $original_query = $parsed['query'];
2005 1722 $query = $parsed['query'];
2006 1723
2007 1724 $shortcodes = FrmFieldsHelper::get_shortcodes( $query, $form_id );
2008 -
2009 1725 if ( empty( $shortcodes[0] ) ) {
2010 1726 // No shortcodes found, do nothing.
2011 1727 return $url;
2012 1728 }
@@ -2024,13 +1740,11 @@
2024 1740 continue;
2025 1741 }
2026 1742
2027 1743 $new_shortcode = '[' . $shortcodes[2][ $key ];
2028 -
2029 1744 if ( $options ) {
2030 1745 $new_shortcode .= ' ' . $options;
2031 1746 }
2032 -
2033 1747 $new_shortcode .= ' sanitize_url=1]';
2034 1748
2035 1749 $query = str_replace( $shortcode, $new_shortcode, $query );
2036 1750 }//end foreach
@@ -2042,8 +1756,20 @@
2042 1756 return str_replace( $original_query, $query, $url );
2043 1757 }
2044 1758
2045 1759 /**
1760 + * Check if Pro isn't up to date yet.
1761 + * If Pro is active but using a version earlier than v6.2 fallback to Pro for AJAX submit (so things don't all happen twice).
1762 + *
1763 + * @since 6.2
1764 + *
1765 + * @return bool
1766 + */
1767 + public static function should_use_pro_for_ajax_submit() {
1768 + return is_callable( 'FrmProForm::is_ajax_on' ) && ! is_callable( 'FrmProFormsHelper::lite_supports_ajax_submit' );
1769 + }
1770 +
1771 + /**
2046 1772 * Outputs the appropriate button text in the publish box.
2047 1773 *
2048 1774 * @return void
2049 1775 */
@@ -2058,144 +1784,12 @@
2058 1784 }
2059 1785 }
2060 1786
2061 1787 /**
2062 - * Strip characters similar to the WordPress sanitize_html_class function, but allow for [ and ].
2063 - * This allows shortcodes inside of the layout classes setting.
2064 - *
2065 - * @since 6.16
2066 - *
2067 - * @param string $classname
2068 - *
2069 - * @return string
2070 - */
2071 - public static function sanitize_layout_class( $classname ) {
2072 - // Strip out any percent-encoded characters.
2073 - $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $classname );
2074 -
2075 - // Limit to A-Z, a-z, 0-9, '_', '-', '[', ']'.
2076 - $sanitized = preg_replace( '/[^A-Za-z0-9_\-\[\]]/', '', $sanitized );
2077 -
2078 - return $sanitized;
2079 - }
2080 -
2081 - /**
2082 - * Returns true if the preview should be blocked.
2083 - *
2084 - * @since 6.20
2085 - *
2086 - * @param string $form_key
2087 - *
2088 - * @return bool
2089 - */
2090 - public static function should_block_preview( $form_key ) {
2091 - $should_block = in_array( $form_key, array( 'contact-form', 'contact-us' ), true ) && ! current_user_can( 'frm_view_forms' );
2092 - /**
2093 - * Filters whether the form preview should be blocked.
2094 - *
2095 - * @since 6.20
2096 - *
2097 - * @param bool $should_block
2098 - * @param string $form_key
2099 - */
2100 - $should_block = (bool) apply_filters( 'frm_block_preview', $should_block, $form_key );
2101 - return $should_block;
2102 - }
2103 -
2104 - /**
2105 - * Checks if the form is loaded by API.
2106 - *
2107 - * @since 6.21
2108 - *
2109 - * @return bool
2110 - */
2111 - public static function form_is_loaded_by_api() {
2112 - global $frm_vars;
2113 -
2114 - if ( ! empty( $frm_vars['inplace_edit'] ) ) {
2115 - return true;
2116 - }
2117 - return self::is_formidable_api_form() || self::is_gutenberg_editor() || self::is_elementor_ajax() || self::is_visual_views_preview();
2118 - }
2119 -
2120 - /**
2121 - * @since 6.21
2122 - *
2123 - * @return bool
2124 - */
2125 - private static function is_visual_views_preview() {
2126 - return 'frm_views_process_box_preview' === FrmAppHelper::get_post_param( 'action' );
2127 - }
2128 -
2129 - /**
2130 - * @since 6.21
2131 - *
2132 - * @return bool
2133 - */
2134 - private static function is_elementor_ajax() {
2135 - return 'elementor_ajax' === FrmAppHelper::get_post_param( 'action' );
2136 - }
2137 -
2138 - /**
2139 - * @since 6.21
2140 - *
2141 - * @return bool
2142 - */
2143 - private static function is_gutenberg_editor() {
2144 - $url = FrmAppHelper::get_server_value( 'REQUEST_URI' );
2145 -
2146 - if ( false !== strpos( $url, '/wp-json/wp/v2/block-renderer/formidable/simple-form' ) ) {
2147 - return true;
2148 - }
2149 -
2150 - if ( false !== strpos( urldecode( $url ), 'rest_route=/wp/v2/block-renderer/formidable/' ) ) {
2151 - return true;
2152 - }
2153 -
2154 - global $pagenow;
2155 -
2156 - if ( 'post.php' === $pagenow ) {
2157 - return true;
2158 - }
2159 -
2160 - return false;
2161 - }
2162 -
2163 - /**
2164 - * @since 6.21
2165 - *
2166 - * @return bool
2167 - */
2168 - private static function is_formidable_api_form() {
2169 - if ( ! class_exists( 'FrmAPIAppController' ) ) {
2170 - return false;
2171 - }
2172 -
2173 - $url = FrmAppHelper::get_server_value( 'REQUEST_URI' );
2174 -
2175 - if ( false !== strpos( $url, '/wp-json/frm/v2/forms/' ) ) {
2176 - // Prevent the honeypot from appearing for an API loaded form.
2177 - // This is to prevent conflicts where the script is not working.
2178 - return true;
2179 - }
2180 -
2181 - if ( is_callable( 'FrmProFormState::get_from_request' ) ) {
2182 - $api = FrmProFormState::get_from_request( 'a', 0 );
2183 -
2184 - if ( $api ) {
2185 - return true;
2186 - }
2187 - }
2188 -
2189 - return false;
2190 - }
2191 -
2192 - /**
2193 1788 * @since 3.0
2194 1789 * @deprecated 6.11
2195 1790 *
2196 1791 * @param array $atts
2197 - *
2198 1792 * @return void
2199 1793 */
2200 1794 public static function actions_dropdown( $atts ) {
2201 1795 _deprecated_function( __METHOD__, '6.11' );
@@ -2204,24 +1798,10 @@
2204 1798 return;
2205 1799 }
2206 1800
2207 1801 $status = $atts['status'];
2208 - $form_id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
1802 + $form_id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
2209 1803 $trash_link = self::delete_trash_info( $form_id, $status );
2210 1804 $links = self::get_action_links( $form_id, $status );
2211 1805 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/actions-dropdown.php';
2212 - }
2213 -
2214 - /**
2215 - * Check if Pro isn't up to date yet.
2216 - * If Pro is active but using a version earlier than v6.2 fallback to Pro for AJAX submit (so things don't all happen twice).
2217 - *
2218 - * @since 6.2
2219 - * @deprecated 6.20
2220 - *
2221 - * @return bool
2222 - */
2223 - public static function should_use_pro_for_ajax_submit() {
2224 - _deprecated_function( __METHOD__, '6.20' );
2225 - return false;
2226 1806 }
2227 1807 }