PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8.2
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
formidable / classes / helpers / FrmStylesHelper.php

FrmStylesHelper.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.8.2, at classes/helpers/FrmStylesHelper.php

804 lines 21.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 class FrmStylesHelper {
7
8 public static function get_upload_base() {
9 $uploads = wp_upload_dir();
10 if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
11 $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
12 }
13
14 return $uploads;
15 }
16
17 /**
18 * Called from the admin header.
19 *
20 * @since 4.0
21 */
22 public static function save_button() {
23 ?>
24 <input type="submit" name="submit" class="button button-primary frm-button-primary" value="<?php esc_attr_e( 'Update', 'formidable' ); ?>" />
25 <?php
26 }
27
28 /**
29 * @since 2.05
30 */
31 public static function get_css_label_positions() {
32 return array(
33 'none' => __( 'top', 'formidable' ),
34 'left' => __( 'left', 'formidable' ),
35 'right' => __( 'right', 'formidable' ),
36 'no_label' => __( 'none', 'formidable' ),
37 'inside' => __( 'inside', 'formidable' ),
38 );
39 }
40
41 public static function get_single_label_positions() {
42 return array(
43 'top' => __( 'Top', 'formidable' ),
44 'left' => __( 'Left', 'formidable' ),
45 'right' => __( 'Right', 'formidable' ),
46 'inline' => __( 'Inline (left without a set width)', 'formidable' ),
47 'none' => __( 'None', 'formidable' ),
48 'hidden' => __( 'Hidden (but leave the space)', 'formidable' ),
49 'inside' => __( 'Placeholder inside the field', 'formidable' ),
50 );
51 }
52
53 public static function minus_icons() {
54 return array(
55 0 => array(
56 '-' => '62e',
57 '+' => '62f',
58 ),
59 1 => array(
60 '-' => '600',
61 '+' => '602',
62 ),
63 2 => array(
64 '-' => '604',
65 '+' => '603',
66 ),
67 3 => array(
68 '-' => '633',
69 '+' => '632',
70 ),
71 4 => array(
72 '-' => '613',
73 '+' => '60f',
74 ),
75 );
76 }
77
78 public static function arrow_icons() {
79 $minus_icons = self::minus_icons();
80
81 return array(
82 6 => array(
83 '-' => '62d',
84 '+' => '62a',
85 ),
86 0 => array(
87 '-' => '60d',
88 '+' => '609',
89 ),
90 1 => array(
91 '-' => '60e',
92 '+' => '60c',
93 ),
94 2 => array(
95 '-' => '630',
96 '+' => '631',
97 ),
98 3 => array(
99 '-' => '62b',
100 '+' => '628',
101 ),
102 4 => array(
103 '-' => '62c',
104 '+' => '629',
105 ),
106 5 => array(
107 '-' => '635',
108 '+' => '634',
109 ),
110 'p0' => $minus_icons[0],
111 'p1' => $minus_icons[1],
112 'p2' => $minus_icons[2],
113 'p3' => $minus_icons[3],
114 'p4' => $minus_icons[4],
115 );
116 }
117
118 /**
119 * @since 2.0
120 * @return string The class for this icon.
121 */
122 public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
123 if ( 'arrow' === $type && is_numeric( $key ) ) {
124 // frm_arrowup6_icon.
125 $arrow = array(
126 '-' => 'down',
127 '+' => 'up',
128 );
129 $class = 'frm_arrow' . $arrow[ $icon ];
130 } else {
131 // frm_minus1_icon.
132 $key = str_replace( 'p', '', $key );
133 $plus = array(
134 '-' => 'minus',
135 '+' => 'plus',
136 );
137 $class = 'frm_' . $plus[ $icon ];
138 }
139
140 if ( $key ) {
141 $class .= $key;
142 }
143 $class .= '_icon';
144
145 return $class;
146 }
147
148 /**
149 * @param WP_Post $style
150 * @param FrmStyle $frm_style
151 * @param string $type
152 * @return void
153 */
154 public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
155 $function_name = $type . '_icons';
156 $icons = self::$function_name();
157 unset( $function_name );
158
159 $name = 'arrow' === $type ? 'collapse_icon' : 'repeat_icon';
160 ?>
161 <div class="btn-group" id="frm_<?php echo esc_attr( $name ); ?>_select">
162 <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
163 <?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ); ?>
164 <?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ); ?>
165 <b class="caret"></b>
166 </button>
167 <ul class="multiselect-container frm-dropdown-menu">
168 <?php foreach ( $icons as $key => $icon ) { ?>
169 <li <?php echo ( $style->post_content['collapse_icon'] == $key ) ? 'class="active"' : ''; ?>>
170 <a href="javascript:void(0);">
171 <label>
172 <input type="radio" value="<?php echo esc_attr( $key ); ?>" name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ); ?>" <?php checked( $style->post_content[ $name ], $key ); ?> />
173 <span>
174 <?php
175 FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $key, '+', $type ) );
176 FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $key, '-', $type ) );
177 ?>
178 </span>
179 </label>
180 </a>
181 </li>
182 <?php } ?>
183 </ul>
184 </div>
185 <?php
186 }
187
188 public static function hex2rgb( $hex ) {
189 $hex = str_replace( '#', '', $hex );
190
191 list( $r, $g, $b ) = sscanf( $hex, '%02x%02x%02x' );
192
193 $rgb = array( $r, $g, $b );
194
195 return implode( ',', $rgb );
196 }
197
198 /**
199 * @since 4.0
200 */
201 public static function hex2rgba( $hex, $a ) {
202 $rgb = self::hex2rgb( $hex );
203
204 return 'rgba(' . $rgb . ',' . $a . ')';
205 }
206
207 /**
208 * @since 6.0
209 *
210 * @param string $rgba
211 * @return string
212 */
213 private static function rgb_to_hex( $rgba ) {
214 if ( strpos( $rgba, '#' ) === 0 ) {
215 return $rgba;
216 }
217 preg_match( '/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i', $rgba, $by_color );
218 return sprintf( '%02x%02x%02x', $by_color[1], $by_color[2], $by_color[3] );
219 }
220
221 /**
222 * @since 6.8
223 *
224 * @param string $hsl
225 * @return string|null Null if it fails to parse the HSL string.
226 */
227 private static function hsl_to_hex( $hsl ) {
228 // Convert hsla to hsl.
229 $hsl = preg_replace( '/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/', 'hsl($1, $2%, $3%)', $hsl );
230
231 // Extract HSL components from the color string.
232 preg_match( '/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/', $hsl, $matches );
233
234 if ( count( $matches ) !== 4 ) {
235 // Invalid HSL string format.
236 return null;
237 }
238
239 // Extract HSL values.
240 $h = (int) $matches[1];
241 $s = (int) $matches[2] / 100;
242 $l = (int) $matches[3] / 100;
243
244 // Calculate RGB values.
245 $c = ( 1 - abs( 2 * $l - 1 ) ) * $s;
246 $x = $c * ( 1 - abs( ( (int) ( $h / 60 ) % 2 ) - 1 ) );
247 $m = $l - $c / 2;
248 $r = 0;
249 $g = 0;
250 $b = 0;
251
252 if ( $h >= 0 && $h < 60 ) {
253 $r = $c;
254 $g = $x;
255 } elseif ( $h >= 60 && $h < 120 ) {
256 $r = $x;
257 $g = $c;
258 } elseif ( $h >= 120 && $h < 180 ) {
259 $g = $c;
260 $b = $x;
261 } elseif ( $h >= 180 && $h < 240 ) {
262 $g = $x;
263 $b = $c;
264 } elseif ( $h >= 240 && $h < 300 ) {
265 $r = $x;
266 $b = $c;
267 } elseif ( $h >= 300 && $h < 360 ) {
268 $r = $c;
269 $b = $x;
270 }//end if
271
272 // Convert RGB to 8-bit values
273 $r = round( ( $r + $m ) * 255 );
274 $g = round( ( $g + $m ) * 255 );
275 $b = round( ( $b + $m ) * 255 );
276
277 // Convert RGB to hex
278 $hex = sprintf( '%02x%02x%02x', $r, $g, $b );
279
280 return $hex;
281 }
282
283 /**
284 * @param string $hex string The original color in hex format #ffffff.
285 * @param int $steps integer Should be between -255 and 255. Negative = darker, positive = lighter.
286 *
287 * @since 2.3
288 */
289 public static function adjust_brightness( $hex, $steps ) {
290 $steps = max( - 255, min( 255, $steps ) );
291
292 if ( 0 === strpos( $hex, 'rgba(' ) ) {
293 $rgba = str_replace( ')', '', str_replace( 'rgba(', '', $hex ) );
294 list ( $r, $g, $b, $a ) = array_map( 'trim', explode( ',', $rgba ) );
295 $r = max( 0, min( 255, $r + $steps ) );
296 $g = max( 0, min( 255, $g + $steps ) );
297 $b = max( 0, min( 255, $b + $steps ) );
298 return 'rgba(' . $r . ',' . $g . ',' . $b . ',' . $a . ')';
299 }
300
301 // Normalize into a six character long hex string
302 $hex = str_replace( '#', '', $hex );
303 self::fill_hex( $hex );
304
305 // Split into three parts: R, G and B
306 $color_parts = str_split( $hex, 2 );
307 $return = '#';
308
309 foreach ( $color_parts as $color ) {
310 // Convert to decimal.
311 $color = hexdec( $color );
312 // Adjust color.
313 $color = max( 0, min( 255, $color + $steps ) );
314
315 // Make two char hex code.
316 $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT );
317 }
318
319 return $return;
320 }
321
322 /**
323 * @since 6.0
324 *
325 * @param string $color
326 * @return int
327 */
328 public static function get_color_brightness( $color ) {
329 if ( 0 === strpos( $color, 'rgb' ) ) {
330 $color = self::rgb_to_hex( $color );
331 }
332
333 if ( 0 === strpos( $color, 'hsl' ) ) {
334 $hsl_to_hex = self::hsl_to_hex( $color );
335 if ( is_null( $hsl_to_hex ) ) {
336 // Fallback if we cannot convert the HSL value.
337 return 0;
338 }
339 $color = $hsl_to_hex;
340 }
341
342 self::fill_hex( $color );
343
344 $c_r = hexdec( substr( $color, 0, 2 ) );
345 $c_g = hexdec( substr( $color, 2, 2 ) );
346 $c_b = hexdec( substr( $color, 4, 2 ) );
347 $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
348
349 return $brightness;
350 }
351
352 /**
353 * Change a 3 character hex color to a 6 character one.
354 *
355 * @since 6.0
356 *
357 * @return void
358 */
359 private static function fill_hex( &$color ) {
360 if ( 3 === strlen( $color ) ) {
361 $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
362 }
363 }
364
365 /**
366 * @since 4.05.02
367 */
368 public static function get_css_vars( $vars = array() ) {
369 $vars = apply_filters( 'frm_css_vars', $vars );
370 return array_unique( $vars );
371 }
372
373 /**
374 * @since 4.05.02
375 */
376 public static function output_vars( $settings, $defaults = array(), $vars = array() ) {
377 if ( empty( $vars ) ) {
378 $vars = self::get_css_vars( array_keys( $settings ) );
379 }
380 $remove = array( 'remove_box_shadow', 'remove_box_shadow_active', 'theme_css', 'theme_name', 'theme_selector', 'important_style', 'submit_style', 'collapse_icon', 'center_form', 'custom_css', 'style_class', 'submit_bg_img', 'change_margin', 'repeat_icon' );
381 $vars = array_diff( $vars, $remove );
382
383 foreach ( $vars as $var ) {
384 if ( ! isset( $settings[ $var ] ) ) {
385 continue;
386 }
387 if ( ! isset( $defaults[ $var ] ) ) {
388 $defaults[ $var ] = '';
389 }
390 $show = empty( $defaults ) || ( $settings[ $var ] !== '' && $settings[ $var ] !== $defaults[ $var ] );
391 if ( $show ) {
392 echo '--' . esc_html( str_replace( '_', '-', $var ) ) . ':' . ( $var === 'font' ? FrmAppHelper::kses( $settings[ $var ] ) : esc_html( $settings[ $var ] ) ) . ';'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
393 }
394 }
395 }
396
397 /**
398 * @since 2.3
399 *
400 * @param WP_Post $style
401 * @return array
402 */
403 public static function get_settings_for_output( $style ) {
404 if ( self::previewing_style() ) {
405 $frm_style = new FrmStyle();
406 if ( isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
407
408 // Sanitizing is done later.
409 $posted = wp_unslash( $_POST['frm_style_setting'] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
410 if ( ! is_array( $posted ) ) {
411 $posted = json_decode( $posted, true );
412 FrmAppHelper::format_form_data( $posted );
413 $settings = $frm_style->sanitize_post_content( $posted['frm_style_setting']['post_content'] );
414 $style_name = sanitize_title( $posted['style_name'] );
415 } else {
416 $settings = $frm_style->sanitize_post_content( $posted['post_content'] );
417 $style_name = FrmAppHelper::get_post_param( 'style_name', '', 'sanitize_title' );
418 }
419 } else {
420 $settings = $frm_style->sanitize_post_content( wp_unslash( $_GET ) );
421 $style_name = FrmAppHelper::get_param( 'style_name', '', 'get', 'sanitize_title' );
422 }
423
424 FrmAppHelper::sanitize_value( 'sanitize_text_field', $settings );
425
426 $settings['style_class'] = '';
427 if ( ! empty( $style_name ) ) {
428 $settings['style_class'] = $style_name . '.';
429 }
430 } else {
431 $settings = $style->post_content;
432 $settings['style_class'] = 'frm_style_' . $style->post_name . '.';
433 }//end if
434
435 $settings['style_class'] .= 'with_frm_style';
436 $settings['font'] = stripslashes( $settings['font'] );
437 $settings['change_margin'] = self::description_margin_for_screensize( $settings['width'] );
438
439 $checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' );
440 foreach ( $checkbox_opts as $opt ) {
441 if ( ! isset( $settings[ $opt ] ) ) {
442 $settings[ $opt ] = 0;
443 }
444 }
445
446 self::prepare_color_output( $settings );
447
448 $settings['field_height'] = $settings['field_height'] === '' ? 'auto' : $settings['field_height'];
449 $settings['field_width'] = $settings['field_width'] === '' ? 'auto' : $settings['field_width'];
450 $settings['auto_width'] = $settings['auto_width'] ? 'auto' : $settings['field_width'];
451 $settings['box_shadow'] = ! empty( $settings['remove_box_shadow'] ) ? 'none' : '0 1px 1px rgba(0, 0, 0, 0.075) inset';
452
453 if ( ! isset( $settings['repeat_icon'] ) ) {
454 $settings['repeat_icon'] = 1;
455 }
456
457 return $settings;
458 }
459
460 /**
461 * @since 2.3
462 */
463 public static function prepare_color_output( &$settings, $allow_transparent = true ) {
464 $colors = self::allow_color_override();
465 foreach ( $colors as $css => $opts ) {
466 if ( $css === 'transparent' && ! $allow_transparent ) {
467 $css = '';
468 }
469 foreach ( $opts as $opt ) {
470 self::get_color_output( $css, $settings[ $opt ] );
471 }
472 }
473 }
474
475 /**
476 * @since 2.3
477 *
478 * @return array
479 */
480 private static function allow_color_override() {
481 $frm_style = new FrmStyle();
482 $colors = $frm_style->get_color_settings();
483
484 $transparent = array(
485 'fieldset_color',
486 'fieldset_bg_color',
487 'bg_color',
488 'bg_color_active',
489 'bg_color_disabled',
490 'section_bg_color',
491 'error_bg',
492 'success_bg_color',
493 'progress_bg_color',
494 'progress_active_bg_color',
495 'submit_border_color',
496 'submit_hover_border_color',
497 'submit_active_border_color',
498 'submit_hover_bg_color',
499 'submit_active_bg_color',
500 );
501
502 return array(
503 'transparent' => $transparent,
504 '' => array_diff( $colors, $transparent ),
505 );
506 }
507
508 /**
509 * @since 2.3
510 */
511 private static function get_color_output( $default, &$color ) {
512 $color = trim( $color );
513 if ( empty( $color ) ) {
514 $color = $default;
515 } elseif ( false !== strpos( $color, 'rgb(' ) ) {
516 $color = str_replace( 'rgb(', 'rgba(', $color );
517 $color = str_replace( ')', ',1)', $color );
518 } elseif ( strpos( $color, '#' ) === false && self::is_hex( $color ) ) {
519 $color = '#' . $color;
520 }
521 }
522
523 /**
524 * If a color looks like a hex code without the #, prepend the #.
525 * A color looks like a hex code if it does not contain the substrings "rgb", "rgba", "hsl", "hsla", or "hwb".
526 *
527 * @since 6.8
528 *
529 * @param string $color
530 * @return bool
531 */
532 private static function is_hex( $color ) {
533 $non_hex_substrings = array(
534 'rgba(',
535 'hsl(',
536 'hsla(',
537 'hwb(',
538 );
539
540 foreach ( $non_hex_substrings as $substring ) {
541 if ( false !== strpos( $color, $substring ) ) {
542 return false;
543 }
544 }
545
546 return true;
547 }
548
549 /**
550 * If left/right label is over a certain size,
551 * adjust the field description margin at a different screen size
552 *
553 * @since 2.3
554 */
555 private static function description_margin_for_screensize( $width ) {
556 $temp_label_width = str_replace( 'px', '', $width );
557 $change_margin = false;
558 if ( $temp_label_width >= 230 ) {
559 $change_margin = '800px';
560 } elseif ( $width >= 215 ) {
561 $change_margin = '700px';
562 } elseif ( $width >= 180 ) {
563 $change_margin = '650px';
564 }
565
566 return $change_margin;
567 }
568
569 /**
570 * @since 2.3
571 *
572 * @return bool
573 */
574 public static function previewing_style() {
575 $ajax_change = isset( $_POST['action'] ) && $_POST['action'] === 'frm_change_styling' && isset( $_POST['frm_style_setting'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
576
577 return $ajax_change || isset( $_GET['flat'] );
578 }
579
580 /**
581 * @since 5.5.1
582 * @return void
583 */
584 public static function maybe_include_font_icon_css() {
585 $signature_add_on_is_active = class_exists( 'FrmSigAppHelper', false );
586
587 if ( ! FrmAppHelper::pro_is_installed() && ! $signature_add_on_is_active ) {
588 // If Pro and Signatures are both not active, there is no need to include the font icon CSS in lite.
589 return;
590 }
591
592 $pro_version_will_handle_loading = false;
593
594 if ( class_exists( 'FrmProDb', false ) ) {
595 $pro_version_that_includes_font_icons_css = '5.5.1';
596
597 // Include font icons in Lite for backward compatibility with older version of Pro.
598 $pro_version_will_handle_loading = version_compare( FrmProDb::$plug_version, $pro_version_that_includes_font_icons_css, '>=' );
599 }
600
601 $load_it_here = false;
602 if ( ! $pro_version_will_handle_loading ) {
603 // If Pro is not handling it, we still need to include it for the Signature add on.
604 $load_it_here = $signature_add_on_is_active;
605 }
606
607 if ( $load_it_here ) {
608 readfile( FrmAppHelper::plugin_path() . '/css/font_icons.css' );
609 }
610 }
611
612 /**
613 * Get the URL for the Styler page list view (where you can assign styles to a form and view style templates) for a target form.
614 *
615 * @since 6.0
616 *
617 * @param string|int $form_id
618 * @return string
619 */
620 public static function get_list_url( $form_id ) {
621 return admin_url( 'admin.php?page=formidable-styles&form=' . absint( $form_id ) );
622 }
623
624 /**
625 * Get a link to edit a target style post object in the visual styler.
626 *
627 * @param WP_Post|stdClass $style
628 * @param string|int $form_id Used for the back button and preview form target.
629 * @return string
630 */
631 public static function get_edit_url( $style, $form_id = 0 ) {
632 $query_args = array(
633 'page' => 'formidable-styles',
634 'frm_action' => 'edit',
635 'id' => $style->ID,
636 );
637
638 if ( $form_id ) {
639 // We include &form_id for the back button to know where to point to.
640 $query_args['form'] = $form_id;
641 }
642
643 return add_query_arg( $query_args, admin_url( 'admin.php' ) );
644 }
645
646 /**
647 * Get a count of the number of forms assigned to a target style ID.
648 * All unassigned forms are included in the count for the default style.
649 *
650 * @since 6.0
651 *
652 * @param string|int $style_id
653 * @param bool $is_default
654 * @return int
655 */
656 public static function get_form_count_for_style( $style_id, $is_default ) {
657 $serialized = serialize( array( 'custom_style' => (string) $style_id ) );
658 // Chop off the "a:1:{" from the front and the "}" from the back.
659 $substring = substr( $serialized, 5, -1 );
660 $number_of_forms = FrmDb::get_count(
661 'frm_forms',
662 array(
663 'status' => 'published',
664 'options LIKE' => $substring,
665 )
666 );
667
668 if ( ! $is_default ) {
669 // Exit early as the rest of the code is about including the default count.
670 return $number_of_forms;
671 }
672
673 $conversational_style_id = FrmDb::get_var( 'posts', array( 'post_name' => 'lines-no-boxes' ), 'ID' );
674 $number_of_forms += self::get_default_style_count( $style_id, $conversational_style_id );
675
676 return $number_of_forms;
677 }
678
679 /**
680 * Get the number of forms that use the default style.
681 *
682 * @since 6.0
683 *
684 * @param string|int $style_id
685 * @param mixed $conversational_style_id
686 * @return int
687 */
688 private static function get_default_style_count( $style_id, $conversational_style_id ) {
689 $substrings = array_map(
690 function( $value ) {
691 $substring = serialize( array( 'custom_style' => $value ) );
692 return substr( $substring, 5, -1 );
693 },
694 array( '1', 1 )
695 );
696 $where = array(
697 'status' => 'published',
698 0 => array(
699 'options NOT LIKE' => 'custom_style',
700 'or' => 1,
701 'options LIKE' => $substrings,
702 ),
703 );
704
705 if ( $conversational_style_id ) {
706 // When a conversational style is set, check for it in the query by wrapping the where and adding a conversational option check.
707 $is_conversational_style = (int) $style_id === (int) $conversational_style_id;
708 $where[0] = array(
709 // The chat option doesn't exist if it isn't on.
710 ( $is_conversational_style ? 'options LIKE' : 'options NOT LIKE' ) => ';s:4:"chat";',
711 $where[0],
712 );
713 }
714
715 return FrmDb::get_count( 'frm_forms', $where );
716 }
717
718 /**
719 * @deprecated 3.01
720 * @codeCoverageIgnore
721 */
722 public static function get_sigle_label_postitions() {
723 return FrmDeprecated::get_sigle_label_postitions();
724 }
725
726 /**
727 * @deprecated 3.02.03
728 * @codeCoverageIgnore
729 */
730 public static function jquery_themes() {
731 return FrmDeprecated::jquery_themes();
732 }
733
734 /**
735 * @deprecated 3.02.03
736 * @codeCoverageIgnore
737 */
738 public static function jquery_css_url( $theme_css ) {
739 return FrmDeprecated::jquery_css_url( $theme_css );
740 }
741
742 /**
743 * @deprecated 3.02.03
744 * @codeCoverageIgnore
745 */
746 public static function enqueue_jquery_css() {
747 FrmDeprecated::enqueue_jquery_css();
748 }
749
750 /**
751 * @deprecated 3.02.03
752 * @codeCoverageIgnore
753 */
754 public static function get_form_for_page() {
755 return FrmDeprecated::get_form_for_page();
756 }
757
758 /**
759 * @since 4.0
760 * @deprecated 6.0 The style menu is no longer used in the styler.
761 *
762 * @param string $active
763 * @return string
764 */
765 public static function get_style_menu( $active = '' ) {
766 _deprecated_function( __METHOD__, '6.0' );
767 return '';
768 }
769
770 /**
771 * @deprecated 6.0 The style menu is no longer used in the styler.
772 *
773 * @param string $active
774 * @return void
775 */
776 public static function style_menu( $active = '' ) {
777 _deprecated_function( __METHOD__, '6.0' );
778 }
779
780 /**
781 * Either get the heading or the style switcher.
782 *
783 * @since 4.0
784 * @deprecated 6.0 The style switcher was replaced with a form switcher and is no longer used.
785 *
786 * @param array $atts
787 * @return void
788 */
789 public static function styler_switcher( $atts ) {
790 _deprecated_function( __METHOD__, '6.0' );
791 }
792
793 /**
794 * @since 4.0
795 * @deprecated 6.0 The styler now uses the Embed/Preview/Update header. It uses the same save button as other pages with Form tabs.
796 *
797 * @param array $atts
798 * @return void
799 */
800 public static function styler_save_button( $atts ) {
801 _deprecated_function( __METHOD__, '6.0' );
802 }
803 }
804