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/helpers/FrmFormsHelper.php +211 -658 6.266.7 View file →
@@ -5,31 +5,14 @@
5 5
6 6 class FrmFormsHelper {
7 7
8 8 /**
9 - * Store and re-use field type data for the insert_opt_html function (to avoid multiple calls to FrmField::all_field_selection).
10 - *
11 - * @since 6.10
12 - *
13 - * @var array|null
14 - */
15 - private static $field_type_data_for_insert_opt_html;
16 -
17 - /**
18 9 * @since 2.2.10
19 - *
20 - * @return string
21 10 */
22 11 public static function form_error_class() {
23 12 return apply_filters( 'frm_form_error_class', 'frm_error_style' );
24 13 }
25 14
26 - /**
27 - * @param string $key
28 - * @param false|object $form
29 - *
30 - * @return string
31 - */
32 15 public static function get_direct_link( $key, $form = false ) {
33 16 $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
34 17 $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
35 18
@@ -35,15 +18,8 @@
35 18
36 19 return $target_url;
37 20 }
38 21
39 - /**
40 - * @param string $field_name
41 - * @param int|string $field_value
42 - * @param array $args
43 - *
44 - * @return void
45 - */
46 22 public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
47 23 $defaults = array(
48 24 'blank' => true,
49 25 'field_id' => false,
@@ -58,9 +34,8 @@
58 34 $args['field_id'] = $field_name;
59 35 }
60 36
61 37 $query = array();
62 -
63 38 if ( $args['exclude'] ) {
64 39 $query['id !'] = $args['exclude'];
65 40 }
66 41
@@ -74,13 +49,13 @@
74 49 <select name="<?php echo esc_attr( $field_name ); ?>"
75 50 id="<?php echo esc_attr( $args['field_id'] ); ?>"
76 51 <?php echo wp_strip_all_tags( implode( ' ', $add_html ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
77 52 <?php if ( $args['blank'] ) { ?>
78 - <option value=""><?php echo $args['blank'] == 1 ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
53 + <option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
79 54 <?php } ?>
80 55 <?php foreach ( $forms as $form ) { ?>
81 56 <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' ) : '' ) ); ?>
57 + <?php echo esc_html( '' === $form->name ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $form->name, 50 ) . ( $form->parent_form_id ? __( ' (child)', 'formidable' ) : '' ) ); ?>
83 58 </option>
84 59 <?php } ?>
85 60 </select>
86 61 <?php
@@ -86,15 +61,13 @@
86 61 <?php
87 62 }
88 63
89 64 /**
90 - * @since 2.0.6
91 - *
92 65 * @param string $class
93 66 * @param string $param
94 - * @param array $add_html
67 + * @param array $add_html
95 68 *
96 - * @return void
69 + * @since 2.0.6
97 70 */
98 71 public static function add_html_attr( $class, $param, &$add_html ) {
99 72 if ( ! empty( $class ) ) {
100 73 $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
@@ -101,11 +74,9 @@
101 74 }
102 75 }
103 76
104 77 /**
105 - * @param false|object|string $selected - The label for the placeholder, or the form object.
106 - *
107 - * @return void
78 + * @param string|object|false $selected - The label for the placeholder, or the form object.
108 79 */
109 80 public static function form_switcher( $selected = false ) {
110 81 $where = apply_filters( 'frm_forms_dropdown', array(), '' );
111 82 $forms = FrmForm::get_published_forms( $where );
@@ -113,9 +84,8 @@
113 84 $args = array(
114 85 'id' => 0,
115 86 'form' => 0,
116 87 );
117 -
118 88 if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
119 89 unset( $args['form'] );
120 90 } elseif ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
121 91 unset( $args['id'] );
@@ -121,40 +91,35 @@
121 91 unset( $args['id'] );
122 92 }
123 93
124 94 $frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
125 -
126 - if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy', 'destroy_all' ), true ) ) {
95 + if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy', 'destroy_all' ) ) ) {
127 96 $args['frm_action'] = 'list';
128 97 $args['form'] = 0;
129 - } elseif ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ), true ) ) {
98 + } elseif ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
130 99 $args['frm_action'] = 'edit';
131 100 } elseif ( FrmAppHelper::is_style_editor_page() ) {
132 - // Avoid passing style into form switcher on style page.
133 - unset( $args['id'] );
101 + unset( $args['id'] ); // Avoid passing style into form switcher on style page.
134 102 $query_args = array(
135 103 'page' => 'formidable-styles',
136 104 );
137 -
138 105 if ( $frm_action ) {
139 106 $query_args['frm_action'] = $frm_action;
140 107 }
141 -
142 108 $base = add_query_arg( $query_args, admin_url( 'admin.php' ) );
143 109 } elseif ( isset( $_GET['post'] ) ) {
144 110 $args['form'] = 0;
145 111 $base = admin_url( 'edit.php?post_type=frm_display' );
146 - }//end if
112 + }
147 113
148 114 $form_id = 0;
149 -
150 115 if ( is_object( $selected ) ) {
151 116 $form_id = $selected->id;
152 117 $selected = $selected->name;
153 118 }
154 119
155 - $name = $selected === false ? __( 'Switch Form', 'formidable' ) : $selected;
156 - $name = '' === $name || is_null( $name ) ? self::get_no_title_text() : strip_tags( $name );
120 + $name = ( $selected === false ) ? __( 'Switch Form', 'formidable' ) : $selected;
121 + $name = '' === $name ? __( '(no title)', 'formidable' ) : strip_tags( $name );
157 122 $truncated_name = FrmAppHelper::truncate( $name, 25 );
158 123
159 124 if ( count( $forms ) < 2 ) {
160 125 ?>
@@ -186,10 +151,8 @@
186 151 array(
187 152 'input_id' => 'dropform',
188 153 'placeholder' => __( 'Search Forms', 'formidable' ),
189 154 'tosearch' => 'frm-dropdown-form',
190 - // Specify a value to avoid the $_REQUEST['s'] default value.
191 - 'value' => '',
192 155 )
193 156 );
194 157 ?>
195 158 </li>
@@ -203,15 +166,14 @@
203 166
204 167 if ( isset( $args['id'] ) ) {
205 168 $args['id'] = $form->id;
206 169 }
207 -
208 170 if ( isset( $args['form'] ) ) {
209 171 $args['form'] = $form->id;
210 172 }
211 173
212 174 $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;
175 + $form_name = empty( $form->name ) ? __( '(no title)', 'formidable' ) : $form->name;
214 176 ?>
215 177 <li class="frm-dropdown-form">
216 178 <a href="<?php echo esc_url( $url ); ?>" tabindex="-1" class="frm-justify-between">
217 179 <?php echo esc_html( $form_name ); ?>
@@ -228,9 +190,9 @@
228 190 </a>
229 191 </li>
230 192 <?php
231 193 unset( $form );
232 - }//end foreach
194 + }
233 195 ?>
234 196 </ul>
235 197 </div>
236 198 <?php
@@ -236,25 +198,24 @@
236 198 <?php
237 199 }
238 200
239 201 /**
240 - * @param string $col
241 - * @param string $sort_col
242 - * @param string $sort_dir
202 + * @since 3.05
203 + * @deprecated 4.0
243 204 *
244 - * @return void
205 + * @param array $values - The form array
245 206 */
207 + public static function builder_submit_button( $values ) {
208 + FrmDeprecated::builder_submit_button( $values );
209 + }
210 +
246 211 public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
247 - echo $sort_col == $col ? 'sorted' : 'sortable';
248 - echo $sort_col == $col && $sort_dir === 'desc' ? ' asc' : ' desc';
212 + echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
213 + echo ( $sort_col == $col && $sort_dir === 'desc' ) ? ' asc' : ' desc';
249 214 }
250 215
251 216 /**
252 217 * @since 3.0
253 - *
254 - * @param array|string $field_type
255 - *
256 - * @return string
257 218 */
258 219 public static function get_field_link_name( $field_type ) {
259 220 if ( is_array( $field_type ) ) {
260 221 $field_label = $field_type['name'];
@@ -266,12 +227,8 @@
266 227 }
267 228
268 229 /**
269 230 * @since 3.0
270 - *
271 - * @param array|string $field_type
272 - *
273 - * @return string
274 231 */
275 232 public static function get_field_link_icon( $field_type ) {
276 233 if ( is_array( $field_type ) && isset( $field_type['icon'] ) ) {
277 234 $icon = $field_type['icon'];
@@ -292,53 +249,29 @@
292 249 * @return string
293 250 */
294 251 public static function get_invalid_error_message( $args ) {
295 252 $settings_args = $args;
296 -
297 253 if ( isset( $args['form'] ) ) {
298 254 $settings_args['current_form'] = $args['form']->id;
299 255 }
300 256
301 257 $frm_settings = FrmAppHelper::get_settings( $settings_args );
302 - $invalid_msg = do_shortcode( $frm_settings->invalid_msg );
258 + $invalid_msg = do_shortcode( $frm_settings->invalid_msg );
303 259 return apply_filters( 'frm_invalid_error_message', $invalid_msg, $args );
304 260 }
305 261
306 262 /**
307 263 * @param array $atts {
308 - * The success message details.
309 - *
310 264 * @type string $message
311 265 * @type stdClass $form
312 266 * @type int $entry_id
313 267 * @type string $class
314 268 * }
315 - *
316 269 * @return string
317 270 */
318 271 public static function get_success_message( $atts ) {
319 272 $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 );
273 + $message = do_shortcode( FrmAppHelper::use_wpautop( $message ) );
341 274 $message = '<div class="' . esc_attr( $atts['class'] ) . '" role="status">' . $message . '</div>';
342 275 return $message;
343 276 }
344 277
@@ -343,12 +276,8 @@
343 276 }
344 277
345 278 /**
346 279 * Used when a form is created
347 - *
348 - * @param array $values
349 - *
350 - * @return array
351 280 */
352 281 public static function setup_new_vars( $values = array() ) {
353 282 global $wpdb;
354 283
@@ -355,9 +284,9 @@
355 284 if ( ! empty( $values ) ) {
356 285 $post_values = $values;
357 286 } else {
358 287 $values = array();
359 - $post_values = ! empty( $_POST ) ? $_POST : array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
288 + $post_values = isset( $_POST ) ? $_POST : array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
360 289 }
361 290
362 291 $defaults = array(
363 292 'name' => '',
@@ -362,9 +291,8 @@
362 291 $defaults = array(
363 292 'name' => '',
364 293 'description' => '',
365 294 );
366 -
367 295 foreach ( $defaults as $var => $default ) {
368 296 if ( ! isset( $values[ $var ] ) ) {
369 297 $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
370 298 }
@@ -379,9 +307,8 @@
379 307 'is_template' => 0,
380 308 'status' => 'published',
381 309 'parent_form_id' => 0,
382 310 );
383 -
384 311 foreach ( $defaults as $var => $default ) {
385 312 if ( ! isset( $values[ $var ] ) ) {
386 313 $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
387 314 }
@@ -388,9 +315,9 @@
388 315 }
389 316 unset( $defaults );
390 317
391 318 if ( ! isset( $values['form_key'] ) ) {
392 - $values['form_key'] = $post_values && isset( $post_values['form_key'] ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
319 + $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
393 320 }
394 321
395 322 $values = self::fill_default_opts( $values, false, $post_values );
396 323 $values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
@@ -399,14 +326,8 @@
399 326 }
400 327
401 328 /**
402 329 * Used when editing a form
403 - *
404 - * @param array $values
405 - * @param object $record
406 - * @param array $post_values
407 - *
408 - * @return array
409 330 */
410 331 public static function setup_edit_vars( $values, $record, $post_values = array() ) {
411 332 if ( empty( $post_values ) ) {
412 333 $post_values = wp_unslash( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -411,10 +332,10 @@
411 332 if ( empty( $post_values ) ) {
412 333 $post_values = wp_unslash( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
413 334 }
414 335
415 - $values['form_key'] = $post_values['form_key'] ?? $record->form_key;
416 - $values['is_template'] = $post_values['is_template'] ?? $record->is_template;
336 + $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
337 + $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
417 338 $values['status'] = $record->status;
418 339
419 340 $values = self::fill_default_opts( $values, $record, $post_values );
420 341
@@ -420,31 +341,23 @@
420 341
421 342 return apply_filters( 'frm_setup_edit_form_vars', $values );
422 343 }
423 344
424 - /**
425 - * @param array $values
426 - * @param false|object $record
427 - * @param array|false $post_values
428 - *
429 - * @return array
430 - */
431 345 public static function fill_default_opts( $values, $record, $post_values ) {
432 346
433 347 $defaults = self::get_default_opts();
434 -
435 348 foreach ( $defaults as $var => $default ) {
436 349 if ( is_array( $default ) ) {
437 350 if ( ! isset( $values[ $var ] ) ) {
438 - $values[ $var ] = $record && isset( $record->options[ $var ] ) ? $record->options[ $var ] : array();
351 + $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
439 352 }
440 353
441 354 foreach ( $default as $k => $v ) {
442 - $values[ $var ][ $k ] = $post_values && isset( $post_values[ $var ][ $k ] ) ? $post_values[ $var ][ $k ] : ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ? $record->options[ $var ][ $k ] : $v );
355 + $values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v );
443 356
444 357 if ( is_array( $v ) ) {
445 358 foreach ( $v as $k1 => $v1 ) {
446 - $values[ $var ][ $k ][ $k1 ] = $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ? $post_values[ $var ][ $k ][ $k1 ] : ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
359 + $values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
447 360 unset( $k1, $v1 );
448 361 }
449 362 }
450 363
@@ -450,13 +363,13 @@
450 363
451 364 unset( $k, $v );
452 365 }
453 366 } else {
454 - $values[ $var ] = $post_values && isset( $post_values['options'][ $var ] ) ? $post_values['options'][ $var ] : ( $record && isset( $record->options[ $var ] ) ? $record->options[ $var ] : $default );
367 + $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
455 368 }
456 369
457 370 unset( $var, $default );
458 - }//end foreach
371 + }
459 372
460 373 return $values;
461 374 }
462 375
@@ -471,9 +384,9 @@
471 384 'success_action' => 'message',
472 385 'success_msg' => $frm_settings->success_msg,
473 386 'show_form' => 0,
474 387 'akismet' => '',
475 - 'stopforumspam' => 0,
388 + 'honeypot' => 'basic',
476 389 'antispam' => 0,
477 390 'no_save' => 0,
478 391 'ajax_load' => 0,
479 392 'js_validate' => 0,
@@ -488,20 +401,17 @@
488 401 );
489 402 }
490 403
491 404 /**
492 - * @since 2.0.6
493 - *
494 405 * @param array $options
495 406 * @param array $values
496 407 *
497 - * @return void
408 + * @since 2.0.6
498 409 */
499 410 public static function fill_form_options( &$options, $values ) {
500 411 $defaults = self::get_default_opts();
501 -
502 412 foreach ( $defaults as $var => $default ) {
503 - $options[ $var ] = $values['options'][ $var ] ?? $default;
413 + $options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
504 414 unset( $var, $default );
505 415 }
506 416 }
507 417
@@ -506,10 +416,8 @@
506 416 }
507 417
508 418 /**
509 419 * @param string $loc
510 - *
511 - * @return string
512 420 */
513 421 public static function get_default_html( $loc ) {
514 422 if ( $loc === 'submit' ) {
515 423 $draft_link = self::get_draft_link();
@@ -534,13 +442,10 @@
534 442
535 443 return $default_html;
536 444 }
537 445
538 - /**
539 - * @return string
540 - */
541 446 public static function get_draft_link() {
542 - $link = '[if save_draft]<button class="frm_save_draft" [draft_hook]>[draft_label]</button>[/if save_draft]';
447 + $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
543 448
544 449 return $link;
545 450 }
546 451
@@ -554,20 +459,10 @@
554 459 public static function get_start_over_shortcode() {
555 460 return '[if start_over]<a href="#" tabindex="0" class="frm_start_over" [start_over_hook]>[start_over_label]</a>[/if start_over]';
556 461 }
557 462
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 463 public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
568 464 $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
569 -
570 465 if ( ! strpos( $button, '[button_action]' ) ) {
571 466 echo FrmAppHelper::maybe_kses( $button ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
572 467 return;
573 468 }
@@ -575,22 +470,18 @@
575 470 /**
576 471 * @since 5.0.06
577 472 */
578 473 $button = apply_filters( 'frm_submit_button_html', $button, compact( 'form' ) );
579 -
580 474 if ( FrmAppHelper::should_never_allow_unfiltered_html() ) {
581 475 $button = FrmAppHelper::kses_submit_button( $button );
582 476 }
583 -
584 477 $button_parts = explode( '[button_action]', $button );
585 478
586 479 $classes = apply_filters( 'frm_submit_button_class', array(), $form );
587 -
588 480 if ( ! empty( $classes ) ) {
589 481 $classes = implode( ' ', $classes );
590 - $button_class = 'frm_button_submit';
591 -
592 - if ( preg_match( '/\bclass="[^"]*?\b' . preg_quote( $button_class, '/' ) . '\b[^"]*?"/', $button_parts[0] ) ) {
482 + $button_class = ' class="frm_button_submit';
483 + if ( strpos( $button_parts[0], $button_class ) !== false ) {
593 484 $button_parts[0] = str_replace( $button_class, $button_class . ' ' . esc_attr( $classes ), $button_parts[0] );
594 485 } else {
595 486 $button_parts[0] .= ' class="' . esc_attr( $classes ) . '"';
596 487 }
@@ -602,56 +493,54 @@
602 493 }
603 494
604 495 /**
605 496 * @since 4.0
606 - *
607 - * @return array
608 497 */
609 498 public static function html_shortcodes() {
610 499 $codes = array(
611 - 'id' => array(
500 + 'id' => array(
612 501 'label' => __( 'Field ID', 'formidable' ),
613 502 'class' => 'show_field_custom_html',
614 503 ),
615 - 'key' => array(
504 + 'key' => array(
616 505 'label' => __( 'Field Key', 'formidable' ),
617 506 'class' => 'show_field_custom_html',
618 507 ),
619 - 'field_name' => array(
508 + 'field_name' => array(
620 509 'label' => __( 'Field Name', 'formidable' ),
621 510 'class' => 'show_field_custom_html',
622 511 ),
623 - 'description' => array(
512 + 'description' => array(
624 513 'label' => __( 'Field Description', 'formidable' ),
625 514 'class' => 'show_field_custom_html',
626 515 ),
627 - 'label_position' => array(
516 + 'label_position' => array(
628 517 'label' => __( 'Label Position', 'formidable' ),
629 518 'class' => 'show_field_custom_html',
630 519 ),
631 - 'required_label' => array(
520 + 'required_label' => array(
632 521 'label' => __( 'Required Label', 'formidable' ),
633 522 'class' => 'show_field_custom_html',
634 523 ),
635 - 'input' => array(
524 + 'input' => array(
636 525 'label' => __( 'Input Field', 'formidable' ),
637 526 'class' => 'show_field_custom_html',
638 527 ),
639 - 'input opt=1' => array(
528 + 'input opt=1' => array(
640 529 'label' => __( 'Single Option', 'formidable' ),
641 530 'title' => __( 'Show a single radio or checkbox option by replacing 1 with the order of the option', 'formidable' ),
642 531 'class' => 'show_field_custom_html',
643 532 ),
644 - 'input label=0' => array(
533 + 'input label=0' => array(
645 534 'label' => __( 'Hide Option Label', 'formidable' ),
646 535 'class' => 'show_field_custom_html',
647 536 ),
648 - 'required_class' => array(
537 + 'required_class' => array(
649 538 'label' => __( 'Required Class', 'formidable' ),
650 539 'title' => __( 'Add class name if field is required', 'formidable' ),
651 540 'class' => 'show_field_custom_html',
652 541 ),
653 - 'error_class' => array(
542 + 'error_class' => array(
654 543 'label' => __( 'Error Class', 'formidable' ),
655 544 'title' => __( 'Add class name if field has an error on form submit', 'formidable' ),
656 545 'class' => 'show_field_custom_html',
657 546 ),
@@ -672,13 +561,13 @@
672 561 'label' => __( 'Delete Entry Link', 'formidable' ),
673 562 'class' => 'show_before_html show_after_html',
674 563 ),
675 564
676 - 'button_label' => array(
565 + 'button_label' => array(
677 566 'label' => __( 'Button Label', 'formidable' ),
678 567 'class' => 'show_submit_html',
679 568 ),
680 - 'button_action' => array(
569 + 'button_action' => array(
681 570 'label' => __( 'Button Hook', 'formidable' ),
682 571 'class' => 'show_submit_html',
683 572 ),
684 573 );
@@ -690,17 +579,14 @@
690 579 }
691 580
692 581 /**
693 582 * @since 4.0
694 - *
695 583 * @param array $args
696 - *
697 - * @return void
698 584 */
699 585 public static function insert_opt_html( $args ) {
700 - $class = $args['class'] ?? '';
701 - $fields = self::get_field_type_data_for_insert_opt_html();
702 - $field = $fields[ $args['type'] ] ?? array();
586 + $class = isset( $args['class'] ) ? $args['class'] : '';
587 + $fields = FrmField::all_field_selection();
588 + $field = isset( $fields[ $args['type'] ] ) ? $fields[ $args['type'] ] : array();
703 589
704 590 self::prepare_field_type( $field );
705 591
706 592 if ( ! isset( $field['icon'] ) ) {
@@ -707,9 +593,8 @@
707 593 $field['icon'] = 'frmfont frm_pencil_icon';
708 594 }
709 595
710 596 $possible_email_field = FrmFieldFactory::field_has_property( $args['type'], 'holds_email_values' );
711 -
712 597 if ( $possible_email_field ) {
713 598 $class .= ' show_frm_not_email_to';
714 599 }
715 600
@@ -715,37 +600,23 @@
715 600
716 601 if ( 'url' === $args['type'] ) {
717 602 $class .= ' frm_insert_url';
718 603 }
719 -
720 - $truncated_name = FrmAppHelper::truncate( $args['name'], 60 );
721 -
722 - if ( isset( $field['icon'] ) ) {
723 - $icon = FrmAppHelper::icon_by_class(
724 - $field['icon'],
725 - array(
726 - 'aria-hidden' => 'true',
727 - 'echo' => false,
728 - )
729 - );
730 - } else {
731 - $icon = '';
732 - }
733 604 ?>
734 605 <li class="<?php echo esc_attr( $class ); ?>">
735 - <a href="javascript:void(0)" class="frmids frm_insert_code" data-code="<?php echo esc_attr( $args['id'] ); ?>">
736 - <?php
737 - echo FrmAppHelper::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
738 - echo esc_html( $truncated_name );
739 - ?>
740 - <span>[<?php echo esc_attr( $args['id_label'] ?? $args['id'] ); ?>]</span>
606 + <a href="javascript:void(0)" class="frmids frm_insert_code"
607 + data-code="<?php echo esc_attr( $args['id'] ); ?>">
608 + <?php FrmAppHelper::icon_by_class( $field['icon'], array( 'aria-hidden' => 'true' ) ); ?>
609 + <?php echo esc_attr( FrmAppHelper::truncate( $args['name'], 60 ) ); ?>
610 + <span>[<?php echo esc_attr( isset( $args['id_label'] ) ? $args['id_label'] : $args['id'] ); ?>]</span>
741 611 </a>
742 - <a href="javascript:void(0)" class="frmkeys frm_insert_code frm_hidden" data-code="<?php echo esc_attr( $args['key'] ); ?>">
743 - <?php
744 - echo FrmAppHelper::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
745 - echo esc_html( $truncated_name );
746 - ?>
747 - <span>[<?php echo esc_attr( FrmAppHelper::truncate( $args['key_label'] ?? $args['key'], 7 ) ); ?>]</span>
612 + <a href="javascript:void(0)" class="frmkeys frm_insert_code frm_hidden"
613 + data-code="<?php echo esc_attr( $args['key'] ); ?>">
614 + <?php if ( isset( $field['icon'] ) ) { ?>
615 + <?php FrmAppHelper::icon_by_class( $field['icon'], array( 'aria-hidden' => 'true' ) ); ?>
616 + <?php } ?>
617 + <?php echo esc_attr( FrmAppHelper::truncate( $args['name'], 60 ) ); ?>
618 + <span>[<?php echo esc_attr( FrmAppHelper::truncate( isset( $args['key_label'] ) ? $args['key_label'] : $args['key'], 7 ) ); ?>]</span>
748 619 </a>
749 620 </li>
750 621 <?php
751 622 }
@@ -750,28 +621,10 @@
750 621 <?php
751 622 }
752 623
753 624 /**
754 - * Store and re-use field selection data for use when outputting shortcodes options in shortcode pop up.
755 - * This significantly improves performance by avoiding repeat calls to FrmField::all_field_selection.
756 - *
757 - * @since 6.10
758 - *
759 - * @return array
760 - */
761 - private static function get_field_type_data_for_insert_opt_html() {
762 - if ( ! isset( self::$field_type_data_for_insert_opt_html ) ) {
763 - self::$field_type_data_for_insert_opt_html = FrmField::all_field_selection();
764 - }
765 - return self::$field_type_data_for_insert_opt_html;
766 - }
767 -
768 - /**
769 625 * @since 4.0
770 - *
771 626 * @param array $args
772 - *
773 - * @return void
774 627 */
775 628 public static function insert_code_html( $args ) {
776 629 $defaults = array(
777 630 'class' => '',
@@ -801,12 +654,8 @@
801 654 * Some field types in add-ons may have been added with only
802 655 * a field type and name.
803 656 *
804 657 * @since 4.0
805 - *
806 - * @param array|string $field
807 - *
808 - * @return void
809 658 */
810 659 public static function prepare_field_type( &$field ) {
811 660 if ( ! is_array( $field ) ) {
812 661 $field = array(
@@ -820,13 +669,9 @@
820 669 * Automatically add end section fields if they don't exist (2.0 migration)
821 670 *
822 671 * @since 2.0
823 672 *
824 - * @param object $form
825 - * @param array $fields
826 - * @param bool $reset_fields
827 - *
828 - * @return void
673 + * @param boolean $reset_fields
829 674 */
830 675 public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
831 676 if ( empty( $fields ) ) {
832 677 return;
@@ -836,12 +681,11 @@
836 681 $open = false;
837 682 $prev_order = false;
838 683 $add_order = 0;
839 684 $last_field = false;
840 -
841 685 foreach ( $fields as $field ) {
842 686 if ( $prev_order === $field->field_order ) {
843 - ++$add_order;
687 + $add_order ++;
844 688 }
845 689
846 690 if ( $add_order ) {
847 691 $reset_fields = true;
@@ -868,14 +712,14 @@
868 712 }
869 713
870 714 // There is already an end section here, so there is no need to create one.
871 715 $open = false;
872 - }//end switch
716 + }
873 717 $prev_order = $field->field_order;
874 718
875 719 $last_field = $field;
876 720 unset( $field );
877 - }//end foreach
721 + }
878 722
879 723 self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
880 724 }
881 725
@@ -881,17 +725,8 @@
881 725
882 726 /**
883 727 * Create end section field if it doesn't exist. This is for migration from < 2.0
884 728 * 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 729 */
895 730 public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
896 731 if ( ! $open ) {
897 732 return;
@@ -900,27 +735,18 @@
900 735 $end_section_values['field_order'] = $field->field_order + 1;
901 736
902 737 FrmField::create( $end_section_values );
903 738
904 - if ( $move === 'move' ) {
739 + if ( $move == 'move' ) {
905 740 // bump the order of current field unless we're at the end of the form
906 741 FrmField::update( $field->id, array( 'field_order' => $field->field_order + 2 ) );
907 742 }
908 743
909 - $add_order += 2;
744 + $add_order += 2;
910 745 $open = false;
911 746 $reset_fields = true;
912 747 }
913 748
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 749 public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
924 750 $codes = array(
925 751 'form_name' => $title,
926 752 'form_description' => $description,
@@ -925,15 +751,14 @@
925 751 'form_name' => $title,
926 752 'form_description' => $description,
927 753 'entry_key' => true,
928 754 );
929 -
930 755 foreach ( $codes as $code => $show ) {
931 756 if ( $code === 'form_name' ) {
932 757 $replace_with = $form->name;
933 758 } elseif ( $code === 'form_description' ) {
934 759 $replace_with = FrmAppHelper::use_wpautop( $form->description );
935 - } elseif ( $code === 'entry_key' && ! empty( $_GET ) && isset( $_GET['entry'] ) ) {
760 + } elseif ( $code === 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) {
936 761 $replace_with = FrmAppHelper::simple_get( 'entry' );
937 762 } else {
938 763 $replace_with = '';
939 764 }
@@ -940,12 +765,12 @@
940 765
941 766 FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
942 767 }
943 768
944 - // Replace [form_key].
769 + //replace [form_key]
945 770 $html = str_replace( '[form_key]', $form->form_key, $html );
946 771
947 - // Replace [frmurl].
772 + //replace [frmurl]
948 773 $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html );
949 774
950 775 if ( strpos( $html, '[button_label]' ) ) {
951 776 add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
@@ -974,13 +799,8 @@
974 799
975 800 return $html;
976 801 }
977 802
978 - /**
979 - * @param string $submit
980 - *
981 - * @return string
982 - */
983 803 public static function submit_button_label( $submit ) {
984 804 if ( ! $submit ) {
985 805 $frm_settings = FrmAppHelper::get_settings();
986 806 $submit = $frm_settings->submit_value;
@@ -993,26 +813,18 @@
993 813 * If the Formidable styling isn't being loaded,
994 814 * use inline styling to hide the element
995 815 *
996 816 * @since 2.03.05
997 - *
998 - * @return void
999 817 */
1000 818 public static function maybe_hide_inline() {
1001 819 $frm_settings = FrmAppHelper::get_settings();
1002 -
1003 - if ( $frm_settings->load_style === 'none' ) {
820 + if ( $frm_settings->load_style == 'none' ) {
1004 821 echo ' style="display:none;"';
1005 - } elseif ( $frm_settings->load_style === 'dynamic' ) {
822 + } elseif ( $frm_settings->load_style == 'dynamic' ) {
1006 823 FrmStylesController::enqueue_style();
1007 824 }
1008 825 }
1009 826
1010 - /**
1011 - * @param array|bool|int|object|string $form
1012 - *
1013 - * @return string|null
1014 - */
1015 827 public static function get_form_style_class( $form = false ) {
1016 828 $style = self::get_form_style( $form );
1017 829 $class = ' with_frm_style';
1018 830
@@ -1018,10 +830,11 @@
1018 830
1019 831 if ( empty( $style ) ) {
1020 832 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
1021 833 return $class;
834 + } else {
835 + return;
1022 836 }
1023 - return;
1024 837 }
1025 838
1026 839 // If submit button needs to be inline or centered.
1027 840 if ( is_object( $form ) ) {
@@ -1053,9 +866,8 @@
1053 866 *
1054 867 * @since 5.0.12
1055 868 *
1056 869 * @param array $form
1057 - *
1058 870 * @return bool
1059 871 */
1060 872 private static function form_should_be_inline_and_missing_class( $form ) {
1061 873 if ( isset( $form['form_class'] ) && false !== strpos( ' ' . $form['form_class'] . ' ', ' frm_inline_form ' ) ) {
@@ -1067,9 +879,9 @@
1067 879
1068 880 /**
1069 881 * Returns appropriate class if form has top labels
1070 882 *
1071 - * @param array $form
883 + * @param $form
1072 884 *
1073 885 * @return string
1074 886 */
1075 887 private static function maybe_align_fields_top( $form ) {
@@ -1078,9 +890,9 @@
1078 890
1079 891 /**
1080 892 * Determine if a form has fields with top labels so submit button can be aligned properly
1081 893 *
1082 - * @param array $form
894 + * @param $form
1083 895 *
1084 896 * @return bool
1085 897 */
1086 898 private static function form_has_top_labels( $form ) {
@@ -1088,20 +900,16 @@
1088 900 return false;
1089 901 }
1090 902
1091 903 $fields = $form['fields'];
1092 -
1093 904 if ( count( $fields ) <= 0 ) {
1094 905 return false;
1095 906 }
1096 907
1097 - // Start from the fields closest to the submit button.
1098 - $fields = array_reverse( $fields );
1099 -
908 + $fields = array_reverse( $fields ); // start from the fields closest to the submit button
1100 909 foreach ( $fields as $field ) {
1101 - $type = $field['original_type'] ?? $field['type'];
910 + $type = isset( $field['original_type'] ) ? $field['original_type'] : $field['type'];
1102 911 $has_input = FrmFieldFactory::field_has_property( $type, 'has_input' );
1103 -
1104 912 if ( $has_input ) {
1105 913 return self::field_has_top_label( $field, $form );
1106 914 }
1107 915 }
@@ -1111,10 +919,10 @@
1111 919
1112 920 /**
1113 921 * Check if a field's label position is set to "top"
1114 922 *
1115 - * @param array $field
1116 - * @param bool|object|string $form
923 + * @param $field
924 + * @param $form
1117 925 *
1118 926 * @return bool
1119 927 */
1120 928 private static function field_has_top_label( $field, $form ) {
@@ -1123,33 +931,30 @@
1123 931 return in_array( $label_position, array( 'top', 'inside', 'hidden' ) );
1124 932 }
1125 933
1126 934 /**
1127 - * @param array|bool|int|object|string $form
935 + * @param object|string|boolean $form
1128 936 *
1129 937 * @return string
1130 938 */
1131 939 public static function get_form_style( $form ) {
1132 940 $style = 1;
1133 -
1134 941 if ( empty( $form ) || 'default' === $form ) {
1135 942 return $style;
1136 - }
1137 -
1138 - if ( is_object( $form ) && $form->parent_form_id ) {
943 + } elseif ( is_object( $form ) && $form->parent_form_id ) {
1139 944 // get the parent form if this is a child
1140 945 $form = $form->parent_form_id;
1141 - } elseif ( is_array( $form ) && ! empty( $form['parent_form_id'] ) ) {
946 + } elseif ( is_array( $form ) && isset( $form['parent_form_id'] ) && $form['parent_form_id'] ) {
1142 947 $form = $form['parent_form_id'];
1143 948 } elseif ( is_array( $form ) && isset( $form['custom_style'] ) ) {
1144 949 $style = $form['custom_style'];
1145 950 }
1146 951
1147 - if ( $form && ( is_string( $form ) || is_int( $form ) ) ) {
952 + if ( $form && is_string( $form ) ) {
1148 953 $form = FrmForm::getOne( $form );
1149 954 }
1150 955
1151 - $style = $form && is_object( $form ) && isset( $form->options['custom_style'] ) ? $form->options['custom_style'] : $style;
956 + $style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
1152 957
1153 958 return $style;
1154 959 }
1155 960
@@ -1155,13 +960,11 @@
1155 960
1156 961 /**
1157 962 * Display the validation error messages when an entry is submitted
1158 963 *
964 + * @param array $args - includes img, errors
965 + *
1159 966 * @since 2.0.6
1160 - *
1161 - * @param array $args Includes img, errors.
1162 - *
1163 - * @return void
1164 967 */
1165 968 public static function show_errors( $args ) {
1166 969 $invalid_msg = self::get_invalid_error_message( $args );
1167 970
@@ -1185,13 +988,11 @@
1185 988 * Display the error message in the front-end along with the image if set
1186 989 * The image was removed from the styling settings, but it may still be set with a hook
1187 990 * If the message in the global settings is empty, show every validation message in the error box
1188 991 *
992 + * @param array $args - includes img, errors, and show_img
993 + *
1189 994 * @since 2.0.6
1190 - *
1191 - * @param array $args Includes img, errors, and show_img.
1192 - *
1193 - * @return void
1194 995 */
1195 996 public static function show_error( $args ) {
1196 997 // remove any blank messages
1197 998 $args['errors'] = array_filter( (array) $args['errors'] );
@@ -1196,11 +997,10 @@
1196 997 // remove any blank messages
1197 998 $args['errors'] = array_filter( (array) $args['errors'] );
1198 999
1199 1000 $line_break_first = $args['show_img'];
1200 -
1201 1001 foreach ( $args['errors'] as $error_key => $error ) {
1202 - if ( $line_break_first && ! is_numeric( $error_key ) && ( $error_key === 'cptch_number' || strpos( $error_key, 'field' ) === 0 ) ) {
1002 + if ( $line_break_first && ! is_numeric( $error_key ) && ( $error_key == 'cptch_number' || strpos( $error_key, 'field' ) === 0 ) ) {
1203 1003 continue;
1204 1004 }
1205 1005
1206 1006 $id = str_replace( 'field', 'field_', $error_key );
@@ -1206,9 +1006,9 @@
1206 1006 $id = str_replace( 'field', 'field_', $error_key );
1207 1007 echo '<div id="' . esc_attr( $id ) . '_error">';
1208 1008
1209 1009 if ( $args['show_img'] && ! empty( $args['img'] ) ) {
1210 - echo '<img src="' . esc_url( $args['img'] ) . '" alt="" />';
1010 + echo '<img src="' . esc_attr( $args['img'] ) . '" alt="" />';
1211 1011 } else {
1212 1012 $args['show_img'] = true;
1213 1013 }
1214 1014
@@ -1217,37 +1017,34 @@
1217 1017 echo '</div>';
1218 1018 }
1219 1019 }
1220 1020
1221 - /**
1222 - * @param int|string $id
1223 - *
1224 - * @return void
1225 - */
1226 1021 public static function maybe_get_scroll_js( $id ) {
1227 1022 $offset = apply_filters( 'frm_scroll_offset', 4, array( 'form_id' => $id ) );
1228 -
1229 1023 if ( $offset != - 1 ) {
1230 1024 self::get_scroll_js( $id );
1231 1025 }
1232 1026 }
1233 1027
1028 + public static function get_scroll_js( $form_id ) {
1029 + echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
1030 + }
1031 +
1234 1032 /**
1235 - * @param int|string $form_id
1236 - *
1237 - * @return void
1033 + * @since 3.0
1238 1034 */
1239 - public static function get_scroll_js( $form_id ) {
1240 - echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
1035 + public static function actions_dropdown( $atts ) {
1036 + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
1037 + $status = $atts['status'];
1038 + $form_id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
1039 + $trash_link = self::delete_trash_info( $form_id, $status );
1040 + $links = self::get_action_links( $form_id, $status );
1041 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/actions-dropdown.php' );
1042 + }
1241 1043 }
1242 1044
1243 1045 /**
1244 1046 * @since 3.0
1245 - *
1246 - * @param int|object|string $form_id
1247 - * @param mixed $form
1248 - *
1249 - * @return array
1250 1047 */
1251 1048 public static function get_action_links( $form_id, $form ) {
1252 1049 if ( ! is_object( $form ) ) {
1253 1050 $form = FrmForm::getOne( $form_id );
@@ -1254,9 +1051,8 @@
1254 1051 }
1255 1052
1256 1053 $actions = array();
1257 1054 $trash_links = self::delete_trash_links( $form_id );
1258 -
1259 1055 if ( 'trash' == $form->status ) {
1260 1056 $actions['restore'] = $trash_links['restore'];
1261 1057
1262 1058 if ( current_user_can( 'frm_delete_forms' ) ) {
@@ -1263,9 +1059,8 @@
1263 1059 $actions['trash'] = $trash_links['delete'];
1264 1060 }
1265 1061 } elseif ( current_user_can( 'frm_edit_forms' ) ) {
1266 1062 $duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $form_id;
1267 -
1268 1063 if ( $form->is_template ) {
1269 1064 $actions['frm_duplicate'] = array(
1270 1065 'url' => wp_nonce_url( $duplicate_link ),
1271 1066 'label' => __( 'Create Form from Template', 'formidable' ),
@@ -1279,18 +1074,13 @@
1279 1074 );
1280 1075 }
1281 1076
1282 1077 $actions['trash'] = self::delete_trash_info( $form_id, $form->status );
1283 - }//end if
1078 + }
1284 1079
1285 1080 return $actions;
1286 1081 }
1287 1082
1288 - /**
1289 - * @param int|object|string $data
1290 - *
1291 - * @return string
1292 - */
1293 1083 public static function edit_form_link( $data ) {
1294 1084 $form_id = self::get_form_id_from_data( $data );
1295 1085
1296 1086 if ( ! $form_id ) {
@@ -1301,37 +1091,19 @@
1301 1091 $link = '<a href="' . esc_url( FrmForm::get_edit_link( $form_id ) ) . '">' . esc_html( $label ) . '</a>';
1302 1092 return $link;
1303 1093 }
1304 1094
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 1095 public static function edit_form_link_label( $data ) {
1322 1096 $name = self::get_form_name_from_data( $data );
1323 -
1324 1097 if ( ! $name ) {
1325 - return self::get_no_title_text();
1098 + return __( '(no title)', 'formidable' );
1326 1099 }
1327 1100 return FrmAppHelper::truncate( $name, 40 );
1328 1101 }
1329 1102
1330 1103 /**
1331 - * @param int|object|string $data
1332 - *
1333 - * @return int|string
1104 + * @param mixed data
1105 + * @return int
1334 1106 */
1335 1107 private static function get_form_id_from_data( $data ) {
1336 1108 if ( is_object( $data ) ) {
1337 1109 $form_id = $data->id;
@@ -1342,9 +1114,8 @@
1342 1114 }
1343 1115
1344 1116 /**
1345 1117 * @param mixed $data
1346 - *
1347 1118 * @return string
1348 1119 */
1349 1120 private static function get_form_name_from_data( $data ) {
1350 1121 if ( is_object( $data ) ) {
@@ -1355,15 +1126,8 @@
1355 1126 }
1356 1127 return $form_name;
1357 1128 }
1358 1129
1359 - /**
1360 - * @param int $id
1361 - * @param string $status
1362 - * @param string $length
1363 - *
1364 - * @return string
1365 - */
1366 1130 public static function delete_trash_link( $id, $status, $length = 'label' ) {
1367 1131 $link_details = self::delete_trash_info( $id, $status );
1368 1132
1369 1133 return self::format_link_html( $link_details, $length );
@@ -1370,20 +1134,13 @@
1370 1134 }
1371 1135
1372 1136 /**
1373 1137 * @since 3.0
1374 - *
1375 - * @param array $link_details
1376 - * @param string $length
1377 - *
1378 - * @return string
1379 1138 */
1380 1139 public static function format_link_html( $link_details, $length = 'label' ) {
1381 1140 $link = '';
1382 -
1383 1141 if ( ! empty( $link_details ) ) {
1384 1142 $link = '<a href="' . esc_url( $link_details['url'] ) . '" class="frm-trash-link"';
1385 -
1386 1143 if ( isset( $link_details['data'] ) ) {
1387 1144 foreach ( $link_details['data'] as $data => $value ) {
1388 1145 $link .= ' data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '"';
1389 1146 }
@@ -1390,13 +1147,12 @@
1390 1147 } elseif ( isset( $link_details['confirm'] ) ) {
1391 1148 $link .= ' onclick="return confirm(\'' . esc_attr( $link_details['confirm'] ) . '\')"';
1392 1149 }
1393 1150
1394 - $label = ( $link_details[ $length ] ?? $link_details['label'] );
1395 -
1396 - if ( $length === 'icon' && isset( $link_details[ $length ] ) ) {
1151 + $label = ( isset( $link_details[ $length ] ) ? $link_details[ $length ] : $link_details['label'] );
1152 + if ( $length == 'icon' && isset( $link_details[ $length ] ) ) {
1397 1153 $label = '<span class="' . $label . '" title="' . esc_attr( $link_details['label'] ) . '" aria-hidden="true"></span>';
1398 - $link .= ' aria-label="' . esc_attr( $link_details['label'] ) . '"';
1154 + $link .= ' aria-label="' . esc_attr( $link_details['label'] ) . '"';
1399 1155 }
1400 1156
1401 1157 $link .= '>' . $label . '</a>';
1402 1158 }
@@ -1405,18 +1161,13 @@
1405 1161 }
1406 1162
1407 1163 /**
1408 1164 * @since 3.0
1409 - *
1410 - * @param int $id
1411 - * @param string $status
1412 - *
1413 - * @return array
1414 1165 */
1415 1166 public static function delete_trash_info( $id, $status ) {
1416 1167 $labels = self::delete_trash_links( $id );
1417 1168
1418 - if ( 'trash' === $status ) {
1169 + if ( 'trash' == $status ) {
1419 1170 $info = $labels['restore'];
1420 1171 } elseif ( current_user_can( 'frm_delete_forms' ) ) {
1421 1172 if ( EMPTY_TRASH_DAYS ) {
1422 1173 $info = $labels['trash'];
@@ -1431,12 +1182,8 @@
1431 1182 }
1432 1183
1433 1184 /**
1434 1185 * @since 3.0
1435 - *
1436 - * @param int $id
1437 - *
1438 - * @return array
1439 1186 */
1440 1187 public static function delete_trash_links( $id ) {
1441 1188 $current_page = FrmAppHelper::get_simple_request( array( 'param' => 'form_type' ) );
1442 1189 $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
@@ -1472,38 +1219,36 @@
1472 1219 }
1473 1220
1474 1221 /**
1475 1222 * @since 3.0
1476 - *
1477 - * @return array
1478 1223 */
1479 1224 public static function css_classes() {
1480 1225 $classes = array(
1481 - 'frm_total' => array(
1226 + 'frm_total' => array(
1482 1227 'label' => __( 'Total', 'formidable' ),
1483 1228 'title' => __( 'Add this to a read-only field to display the text in bold without a border or background.', 'formidable' ),
1484 1229 ),
1485 - 'frm_total_big' => array(
1230 + 'frm_total_big' => array(
1486 1231 'label' => __( 'Big Total', 'formidable' ),
1487 1232 'title' => __( 'Add this to a read-only field to display the text in large, bold text without a border or background.', 'formidable' ),
1488 1233 ),
1489 - 'frm_scroll_box' => array(
1234 + 'frm_scroll_box' => array(
1490 1235 'label' => __( 'Scroll Box', 'formidable' ),
1491 1236 'title' => __( 'If you have many checkbox or radio button options, you may add this class to allow your user to easily scroll through the options. Or add a scrolling area around content in an HTML field.', 'formidable' ),
1492 1237 ),
1493 - 'frm_first' => array(
1238 + 'frm_first' => array(
1494 1239 'label' => __( 'First', 'formidable' ),
1495 1240 'title' => __( 'Add this to the first field in each row along with a width. ie frm_first frm4', 'formidable' ),
1496 1241 ),
1497 - 'frm_alignright' => __( 'Right', 'formidable' ),
1498 - 'frm_grid_first' => __( 'First Grid Row', 'formidable' ),
1499 - 'frm_grid' => __( 'Even Grid Row', 'formidable' ),
1500 - 'frm_grid_odd' => __( 'Odd Grid Row', 'formidable' ),
1242 + 'frm_alignright' => __( 'Right', 'formidable' ),
1243 + 'frm_grid_first' => __( 'First Grid Row', 'formidable' ),
1244 + 'frm_grid' => __( 'Even Grid Row', 'formidable' ),
1245 + 'frm_grid_odd' => __( 'Odd Grid Row', 'formidable' ),
1501 1246 'frm_color_block' => array(
1502 1247 'label' => __( 'Color Block', 'formidable' ),
1503 1248 'title' => __( 'Add a background color to the field or section.', 'formidable' ),
1504 1249 ),
1505 - 'frm_capitalize' => array(
1250 + 'frm_capitalize' => array(
1506 1251 'label' => __( 'Capitalize', 'formidable' ),
1507 1252 'title' => __( 'Automatically capitalize the first letter in each word.', 'formidable' ),
1508 1253 ),
1509 1254 );
@@ -1510,11 +1255,8 @@
1510 1255
1511 1256 return apply_filters( 'frm_layout_classes', $classes );
1512 1257 }
1513 1258
1514 - /**
1515 - * @return array
1516 - */
1517 1259 public static function grid_classes() {
1518 1260 return array(
1519 1261 'frm_half' => '1/2',
1520 1262 'frm_third' => '1/3',
@@ -1528,17 +1270,11 @@
1528 1270 }
1529 1271
1530 1272 /**
1531 1273 * @since 3.0
1532 - *
1533 - * @param mixed $style
1534 - * @param string $class
1535 - *
1536 - * @return string
1537 1274 */
1538 1275 public static function style_class_label( $style, $class ) {
1539 1276 $label = '';
1540 -
1541 1277 if ( empty( $style ) ) {
1542 1278 $label = $class;
1543 1279 } elseif ( ! is_array( $style ) ) {
1544 1280 $label = $style;
@@ -1548,13 +1284,8 @@
1548 1284
1549 1285 return $label;
1550 1286 }
1551 1287
1552 - /**
1553 - * @param string $status
1554 - *
1555 - * @return string
1556 - */
1557 1288 public static function status_nice_name( $status ) {
1558 1289 $nice_names = array(
1559 1290 'draft' => __( 'Draft', 'formidable' ),
1560 1291 'trash' => __( 'Trash', 'formidable' ),
@@ -1560,9 +1291,9 @@
1560 1291 'trash' => __( 'Trash', 'formidable' ),
1561 1292 'publish' => __( 'Published', 'formidable' ),
1562 1293 );
1563 1294
1564 - if ( ! in_array( $status, array_keys( $nice_names ), true ) ) {
1295 + if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
1565 1296 $status = 'publish';
1566 1297 }
1567 1298
1568 1299 $name = $nice_names[ $status ];
@@ -1575,11 +1306,10 @@
1575 1306 *
1576 1307 * @param array $categories The categories to render the icon for.
1577 1308 * @param array $atts {
1578 1309 * Optional. An array of attributes for rendering.
1579 - *
1580 1310 * @type string $html 'span' or 'div'. Default 'span'.
1581 - * @type bool $bg Whether to add a background color or not. Default false.
1311 + * @type boolean $bg Whether to add a background color or not. Default false.
1582 1312 * }
1583 1313 *
1584 1314 * @return void
1585 1315 */
@@ -1585,66 +1315,64 @@
1585 1315 */
1586 1316 public static function template_icon( $categories, $atts = array() ) {
1587 1317 // Define defaults.
1588 1318 $defaults = array(
1589 - 'bg' => true,
1319 + 'bg' => true,
1590 1320 );
1591 - $atts = array_merge( $defaults, $atts );
1321 + $atts = array_merge( $defaults, $atts );
1592 1322
1593 1323 // Filter out ignored categories.
1594 - $ignore = self::get_license_types();
1324 + $ignore = self::ignore_template_categories();
1595 1325 $categories = array_diff( $categories, $ignore );
1596 1326
1597 1327 // Define icons mapping.
1598 1328 $icons = array(
1599 - 'WooCommerce' => array( 'woocommerce', 'var(--purple)' ),
1600 - 'Post' => array( 'wordpress', 'rgb(0,160,210)' ),
1601 - 'User Registration' => array( 'register', 'var(--pink)' ),
1329 + 'WooCommerce' => array( 'woocommerce', 'var(--purple)' ),
1330 + 'Post' => array( 'wordpress', 'rgb(0,160,210)' ),
1331 + 'User Registration' => array( 'register', 'var(--pink)' ),
1602 1332 'Registration and Signup' => array( 'register', 'var(--pink)' ),
1603 - 'PayPal' => array( 'paypal' ),
1604 - 'Stripe' => array( 'credit_card', 'var(--green)' ),
1605 - 'Twilio' => array( 'sms' ),
1606 - 'Payment' => array( 'credit_card' ),
1607 - 'Order Form' => array( 'product' ),
1608 - 'Finance' => array( 'total' ),
1609 - 'Health and Wellness' => array( 'heart', 'var(--pink)' ),
1610 - 'Event Planning' => array( 'calendar', 'var(--orange)' ),
1611 - 'Real Estate' => array( 'house' ),
1612 - 'Nonprofit' => array( 'heart_solid' ),
1613 - 'Calculator' => array( 'calculator', 'var(--purple)' ),
1614 - 'Quiz' => array( 'percent' ),
1615 - 'Registrations' => array( 'address_card' ),
1616 - 'Customer Service' => array( 'users_solid' ),
1617 - 'Education' => array( 'pencil' ),
1618 - 'Marketing' => array( 'eye' ),
1619 - 'Feedback' => array( 'smile' ),
1620 - 'Business Operations' => array( 'case' ),
1621 - 'Contact Form' => array( 'email' ),
1622 - 'Conversational Forms' => array( 'chat_forms' ),
1623 - 'Survey' => array( 'chat_forms', 'var(--orange)' ),
1624 - 'Application' => array( 'align_right' ),
1625 - 'Signature' => array( 'signature' ),
1626 - '' => array( 'align_right' ),
1333 + 'PayPal' => array( 'paypal' ),
1334 + 'Stripe' => array( 'credit_card', 'var(--green)' ),
1335 + 'Twilio' => array( 'sms' ),
1336 + 'Payment' => array( 'credit_card' ),
1337 + 'Order Form' => array( 'product' ),
1338 + 'Finance' => array( 'total' ),
1339 + 'Health and Wellness' => array( 'heart', 'var(--pink)' ),
1340 + 'Event Planning' => array( 'calendar', 'var(--orange)' ),
1341 + 'Real Estate' => array( 'house' ),
1342 + 'Nonprofit' => array( 'heart_solid' ),
1343 + 'Calculator' => array( 'calculator', 'var(--purple)' ),
1344 + 'Quiz' => array( 'percent' ),
1345 + 'Registrations' => array( 'address_card' ),
1346 + 'Customer Service' => array( 'users_solid' ),
1347 + 'Education' => array( 'pencil' ),
1348 + 'Marketing' => array( 'eye' ),
1349 + 'Feedback' => array( 'smile' ),
1350 + 'Business Operations' => array( 'case' ),
1351 + 'Contact Form' => array( 'email' ),
1352 + 'Conversational Forms' => array( 'chat_forms' ),
1353 + 'Survey' => array( 'chat_forms', 'var(--orange)' ),
1354 + 'Application' => array( 'align_right' ),
1355 + 'Signature' => array( 'signature' ),
1356 + '' => array( 'align_right' ),
1627 1357 );
1628 1358
1629 1359 // Determine the icon to be used.
1630 1360 $icon = $icons[''];
1631 -
1632 1361 if ( count( $categories ) === 1 ) {
1633 1362 $category = reset( $categories );
1634 - $icon = $icons[ $category ] ?? $icon;
1363 + $icon = isset( $icons[ $category ] ) ? $icons[ $category ] : $icon;
1635 1364 } elseif ( ! empty( $categories ) ) {
1636 1365 $icons = array_intersect_key( $icons, array_flip( $categories ) );
1637 - $icon = reset( $icons );
1366 + $icon = reset( $icons );
1638 1367 }
1639 1368
1640 1369 // Prepare variables for output.
1641 1370 $icon_name = $icon[0];
1642 - $bg_color = $icon[1] ?? '';
1371 + $bg_color = isset( $icon[1] ) ? $icon[1] : '';
1643 1372
1644 1373 // Render the icon.
1645 1374 echo '<span class="frm-category-icon frm-icon-wrapper"';
1646 -
1647 1375 if ( $bg_color && $atts['bg'] ) {
1648 1376 echo ' style="background-color:' . esc_attr( $bg_color ) . '"';
1649 1377 }
1650 1378 echo '>';
@@ -1652,8 +1380,19 @@
1652 1380 echo '</span>';
1653 1381 }
1654 1382
1655 1383 /**
1384 + * Retrieves the list of template categories to ignore.
1385 + *
1386 + * @since 4.03.01
1387 + *
1388 + * @return string[] Array of categories to ignore.
1389 + */
1390 + public static function ignore_template_categories() {
1391 + return array( 'Business', 'Elite', 'Personal', 'Creator', 'Basic', 'free' );
1392 + }
1393 +
1394 + /**
1656 1395 * Get template install link.
1657 1396 *
1658 1397 * @since 4.02
1659 1398 *
@@ -1658,9 +1397,8 @@
1658 1397 * @since 4.02
1659 1398 *
1660 1399 * @param array $template Template details.
1661 1400 * @param array $args Additional arguments.
1662 - *
1663 1401 * @return array The link attributes.
1664 1402 */
1665 1403 public static function get_template_install_link( $template, $args ) {
1666 1404 $defaults = array(
@@ -1676,8 +1414,13 @@
1676 1414 'class' => 'frm-install-template',
1677 1415 'href' => 'rel',
1678 1416 'atts' => '',
1679 1417 );
1418 + } elseif ( self::plan_is_allowed( $args ) ) {
1419 + $link = array(
1420 + 'url' => FrmAppHelper::admin_upgrade_link( 'addons', 'account/downloads/' ) . '&utm_content=' . $template['slug'],
1421 + 'label' => __( 'Renew', 'formidable' ),
1422 + );
1680 1423 } else {
1681 1424 $link = array(
1682 1425 'url' => $args['pricing'],
1683 1426 'label' => __( 'Upgrade', 'formidable' ),
@@ -1692,9 +1435,8 @@
1692 1435 *
1693 1436 * @since 4.02.02
1694 1437 *
1695 1438 * @param array $args
1696 - *
1697 1439 * @return bool
1698 1440 */
1699 1441 public static function plan_is_allowed( $args ) {
1700 1442 if ( empty( $args['license_type'] ) ) {
@@ -1713,9 +1455,8 @@
1713 1455 foreach ( $plans as $plan ) {
1714 1456 if ( $included || $plan === $license_type ) {
1715 1457 break;
1716 1458 }
1717 -
1718 1459 $included = $plan === $plan_required;
1719 1460 }
1720 1461
1721 1462 return $included;
@@ -1725,13 +1466,8 @@
1725 1466 * If a template or add-on cannot be installed, show a message
1726 1467 * about which plan is required.
1727 1468 *
1728 1469 * @since 4.0
1729 - *
1730 - * @param string $requires
1731 - * @param string $link
1732 - *
1733 - * @return void
1734 1470 */
1735 1471 public static function show_plan_required( $requires, $link ) {
1736 1472 if ( empty( $requires ) ) {
1737 1473 return;
@@ -1738,9 +1474,9 @@
1738 1474 }
1739 1475
1740 1476 ?>
1741 1477 <p class="frm_plan_required">
1742 - <?php esc_html_e( 'Plan required:', 'formidable' ); ?>
1478 + <?php esc_html_e( 'License plan required:', 'formidable' ); ?>
1743 1479 <a href="<?php echo esc_url( $link ); ?>" target="_blank" rel="noopener">
1744 1480 <?php echo esc_html( $requires ); ?>
1745 1481 </a>
1746 1482 </p>
@@ -1750,10 +1486,9 @@
1750 1486 /**
1751 1487 * @since 4.0
1752 1488 *
1753 1489 * @param array $item
1754 - *
1755 - * @return false|string
1490 + * @return string|false
1756 1491 */
1757 1492 public static function get_plan_required( &$item ) {
1758 1493 if ( ! isset( $item['categories'] ) || ! is_array( $item['categories'] ) || ! empty( $item['url'] ) ) {
1759 1494 return false;
@@ -1758,15 +1493,18 @@
1758 1493 if ( ! isset( $item['categories'] ) || ! is_array( $item['categories'] ) || ! empty( $item['url'] ) ) {
1759 1494 return false;
1760 1495 }
1761 1496
1762 - $plans = self::get_license_types();
1497 + $plans = array( 'free', 'Basic', 'Personal', 'Plus', 'Creator', 'Business', 'Elite' );
1763 1498
1764 1499 foreach ( $item['categories'] as $k => $category ) {
1765 1500 if ( in_array( $category, $plans, true ) ) {
1766 1501 unset( $item['categories'][ $k ] );
1767 1502
1768 - $category = self::convert_legacy_package_names( $category );
1503 + if ( in_array( $category, array( 'Creator', 'Personal' ), true ) ) {
1504 + // Show the current package name.
1505 + $category = 'Plus';
1506 + }
1769 1507
1770 1508 return $category;
1771 1509 }
1772 1510 }
@@ -1774,54 +1512,8 @@
1774 1512 return false;
1775 1513 }
1776 1514
1777 1515 /**
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 1516 * Checks for warnings to be displayed after form settings are saved.
1825 1517 *
1826 1518 * @since 4.04
1827 1519 *
@@ -1857,9 +1549,9 @@
1857 1549
1858 1550 $options = $values['options'];
1859 1551 FrmAppHelper::sanitize_with_html( $options );
1860 1552
1861 - if ( ! isset( $options['success_action'] ) || $options['success_action'] !== 'redirect' || ! isset( $options['success_url'] ) ) {
1553 + if ( ( ! isset( $options['success_action'] ) ) || $options['success_action'] !== 'redirect' || ! isset( $options['success_url'] ) ) {
1862 1554 return false;
1863 1555 }
1864 1556
1865 1557 $unsafe_params_in_redirect = self::get_unsafe_params( $options['success_url'] );
@@ -1877,9 +1569,8 @@
1877 1569 * @return array An array of params whose names are reserved words or an empty array.
1878 1570 */
1879 1571 private static function get_unsafe_params( $url ) {
1880 1572 $redirect_components = parse_url( $url );
1881 -
1882 1573 if ( empty( $redirect_components['query'] ) ) {
1883 1574 return array();
1884 1575 }
1885 1576 parse_str( $redirect_components['query'], $redirect_params );
@@ -1984,9 +1675,8 @@
1984 1675 * @since 5.0.16
1985 1676 *
1986 1677 * @param string $url
1987 1678 * @param int $form_id
1988 - *
1989 1679 * @return string
1990 1680 */
1991 1681 public static function maybe_add_sanitize_url_attr( $url, $form_id ) {
1992 1682 if ( false === strpos( $url, '[' ) ) {
@@ -1994,9 +1684,8 @@
1994 1684 return $url;
1995 1685 }
1996 1686
1997 1687 $parsed = wp_parse_url( $url );
1998 -
1999 1688 if ( empty( $parsed['query'] ) ) {
2000 1689 // Do nothing if no query can be detected in the url string.
2001 1690 return $url;
2002 1691 }
@@ -2004,9 +1693,8 @@
2004 1693 $original_query = $parsed['query'];
2005 1694 $query = $parsed['query'];
2006 1695
2007 1696 $shortcodes = FrmFieldsHelper::get_shortcodes( $query, $form_id );
2008 -
2009 1697 if ( empty( $shortcodes[0] ) ) {
2010 1698 // No shortcodes found, do nothing.
2011 1699 return $url;
2012 1700 }
@@ -2024,17 +1712,15 @@
2024 1712 continue;
2025 1713 }
2026 1714
2027 1715 $new_shortcode = '[' . $shortcodes[2][ $key ];
2028 -
2029 1716 if ( $options ) {
2030 1717 $new_shortcode .= ' ' . $options;
2031 1718 }
2032 -
2033 1719 $new_shortcode .= ' sanitize_url=1]';
2034 1720
2035 1721 $query = str_replace( $shortcode, $new_shortcode, $query );
2036 - }//end foreach
1722 + }
2037 1723
2038 1724 if ( $query === $original_query ) {
2039 1725 return $url;
2040 1726 }
@@ -2042,8 +1728,20 @@
2042 1728 return str_replace( $original_query, $query, $url );
2043 1729 }
2044 1730
2045 1731 /**
1732 + * Check if Pro isn't up to date yet.
1733 + * 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).
1734 + *
1735 + * @since 6.2
1736 + *
1737 + * @return bool
1738 + */
1739 + public static function should_use_pro_for_ajax_submit() {
1740 + return is_callable( 'FrmProForm::is_ajax_on' ) && ! is_callable( 'FrmProFormsHelper::lite_supports_ajax_submit' );
1741 + }
1742 +
1743 + /**
2046 1744 * Outputs the appropriate button text in the publish box.
2047 1745 *
2048 1746 * @return void
2049 1747 */
@@ -2058,170 +1756,25 @@
2058 1756 }
2059 1757 }
2060 1758
2061 1759 /**
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
1760 + * @since 4.02
1761 + * @deprecated x.x
2070 1762 */
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;
1763 + public static function template_install_html( $link, $class = '' ) {
1764 + _deprecated_function( __METHOD__, 'x.x' );
2079 1765 }
2080 1766
2081 1767 /**
2082 - * Returns true if the preview should be blocked.
1768 + * Check an array of templates, determine how many the logged in user can use
2083 1769 *
2084 - * @since 6.20
1770 + * @deprecated x.x
2085 1771 *
2086 - * @param string $form_key
2087 - *
2088 - * @return bool
1772 + * @param array $templates
1773 + * @param array $args
1774 + * @return int
2089 1775 */
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 - * @since 3.0
2194 - * @deprecated 6.11
2195 - *
2196 - * @param array $atts
2197 - *
2198 - * @return void
2199 - */
2200 - public static function actions_dropdown( $atts ) {
2201 - _deprecated_function( __METHOD__, '6.11' );
2202 -
2203 - if ( ! FrmAppHelper::is_admin_page( 'formidable' ) ) {
2204 - return;
2205 - }
2206 -
2207 - $status = $atts['status'];
2208 - $form_id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
2209 - $trash_link = self::delete_trash_info( $form_id, $status );
2210 - $links = self::get_action_links( $form_id, $status );
2211 - 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;
1776 + public static function available_count( $templates, $args ) {
1777 + _deprecated_function( __METHOD__, 'x.x' );
1778 + return 0;
2226 1779 }
2227 1780 }