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

734 lines 20.0 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 /**
189 * Convert a color setting to a RGB CSV (without the rgb()/rgba() wrapper).
190 *
191 * @since 2.0
192 *
193 * @param string $color Color setting value. This could be hex or rgb.
194 * @return string RGB value without the rgb() wrapper.
195 */
196 public static function hex2rgb( $color ) {
197 if ( 0 === strpos( $color, 'rgb' ) ) {
198 $rgb = self::get_rgb_array_from_rgb( $color );
199 } else {
200 $rgb = self::get_rgb_array_from_hex( $color );
201 }
202 return implode( ',', $rgb );
203 }
204
205 /**
206 * Remove the rgb()/rgba() wrapper from a RGB color and return its R, G and B values as an array.
207 *
208 * @since 6.8.3
209 *
210 * @param string $rgb RGB value including the rgb() or rgba() wrapper.
211 * @return array<string> including three numeric values for R, G, and B.
212 */
213 private static function get_rgb_array_from_rgb( $rgb ) {
214 $rgb = str_replace( array( 'rgb(', 'rgba(', ')' ), '', $rgb );
215 $rgb = explode( ',', $rgb );
216 if ( 4 === count( $rgb ) ) {
217 // Drop the alpha. The function is expected to only return r,g,b with no alpha.
218 array_pop( $rgb );
219 }
220 return $rgb;
221 }
222
223 /**
224 * Get the R, G, and B array values from a Hex color code.
225 *
226 * @since 6.8.3
227 *
228 * @param string $hex A hex color string.
229 * @return array<string> Including three numeric values for R, G, and B.
230 */
231 private static function get_rgb_array_from_hex( $hex ) {
232 $hex = str_replace( '#', '', $hex );
233 list( $r, $g, $b ) = sscanf( $hex, '%02x%02x%02x' );
234 return array( $r, $g, $b );
235 }
236
237 /**
238 * @since 4.0
239 */
240 public static function hex2rgba( $hex, $a ) {
241 $rgb = self::hex2rgb( $hex );
242
243 return 'rgba(' . $rgb . ',' . $a . ')';
244 }
245
246 /**
247 * @since 6.0
248 *
249 * @param string $rgba Color setting value. This could be hex or rgb.
250 * @return string Hex color value.
251 */
252 private static function rgb_to_hex( $rgba ) {
253 if ( strpos( $rgba, '#' ) === 0 ) {
254 // Color is already hex.
255 return $rgba;
256 }
257 preg_match( '/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i', $rgba, $by_color );
258 return sprintf( '%02x%02x%02x', $by_color[1], $by_color[2], $by_color[3] );
259 }
260
261 /**
262 * @since 6.8
263 *
264 * @param string $hsl
265 * @return string|null Null if it fails to parse the HSL string.
266 */
267 private static function hsl_to_hex( $hsl ) {
268 // Convert hsla to hsl.
269 $hsl = preg_replace( '/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/', 'hsl($1, $2%, $3%)', $hsl );
270
271 // Extract HSL components from the color string.
272 preg_match( '/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/', $hsl, $matches );
273
274 if ( count( $matches ) !== 4 ) {
275 // Invalid HSL string format.
276 return null;
277 }
278
279 // Extract HSL values.
280 $h = (int) $matches[1];
281 $s = (int) $matches[2] / 100;
282 $l = (int) $matches[3] / 100;
283
284 // Calculate RGB values.
285 $c = ( 1 - abs( 2 * $l - 1 ) ) * $s;
286 $x = $c * ( 1 - abs( ( (int) ( $h / 60 ) % 2 ) - 1 ) );
287 $m = $l - $c / 2;
288 $r = 0;
289 $g = 0;
290 $b = 0;
291
292 if ( $h >= 0 && $h < 60 ) {
293 $r = $c;
294 $g = $x;
295 } elseif ( $h >= 60 && $h < 120 ) {
296 $r = $x;
297 $g = $c;
298 } elseif ( $h >= 120 && $h < 180 ) {
299 $g = $c;
300 $b = $x;
301 } elseif ( $h >= 180 && $h < 240 ) {
302 $g = $x;
303 $b = $c;
304 } elseif ( $h >= 240 && $h < 300 ) {
305 $r = $x;
306 $b = $c;
307 } elseif ( $h >= 300 && $h < 360 ) {
308 $r = $c;
309 $b = $x;
310 }//end if
311
312 // Convert RGB to 8-bit values
313 $r = round( ( $r + $m ) * 255 );
314 $g = round( ( $g + $m ) * 255 );
315 $b = round( ( $b + $m ) * 255 );
316
317 // Convert RGB to hex
318 $hex = sprintf( '%02x%02x%02x', $r, $g, $b );
319
320 return $hex;
321 }
322
323 /**
324 * @since 2.3
325 * @param string $hex string The original color in hex format #ffffff.
326 * @param int $steps integer Should be between -255 and 255. Negative = darker, positive = lighter.
327 */
328 public static function adjust_brightness( $hex, $steps ) {
329 $steps = max( - 255, min( 255, $steps ) );
330
331 if ( 0 === strpos( $hex, 'rgba(' ) ) {
332 $rgba = str_replace( ')', '', str_replace( 'rgba(', '', $hex ) );
333 list ( $r, $g, $b, $a ) = array_map( 'trim', explode( ',', $rgba ) );
334 $r = max( 0, min( 255, $r + $steps ) );
335 $g = max( 0, min( 255, $g + $steps ) );
336 $b = max( 0, min( 255, $b + $steps ) );
337 return 'rgba(' . $r . ',' . $g . ',' . $b . ',' . $a . ')';
338 }
339
340 // Normalize into a six character long hex string
341 $hex = str_replace( '#', '', $hex );
342 self::fill_hex( $hex );
343
344 // Split into three parts: R, G and B
345 $color_parts = str_split( $hex, 2 );
346 $return = '#';
347
348 foreach ( $color_parts as $color ) {
349 // Convert to decimal.
350 $color = hexdec( $color );
351 // Adjust color.
352 $color = max( 0, min( 255, $color + $steps ) );
353
354 // Make two char hex code.
355 $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT );
356 }
357
358 return $return;
359 }
360
361 /**
362 * @since 6.0
363 *
364 * @param string $color
365 * @return int
366 */
367 public static function get_color_brightness( $color ) {
368 if ( 0 === strpos( $color, 'rgb' ) ) {
369 $color = self::rgb_to_hex( $color );
370 }
371
372 if ( 0 === strpos( $color, 'hsl' ) ) {
373 $hsl_to_hex = self::hsl_to_hex( $color );
374 if ( is_null( $hsl_to_hex ) ) {
375 // Fallback if we cannot convert the HSL value.
376 return 0;
377 }
378 $color = $hsl_to_hex;
379 }
380
381 self::fill_hex( $color );
382
383 $c_r = hexdec( substr( $color, 0, 2 ) );
384 $c_g = hexdec( substr( $color, 2, 2 ) );
385 $c_b = hexdec( substr( $color, 4, 2 ) );
386 $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
387
388 return $brightness;
389 }
390
391 /**
392 * Change a 3 character hex color to a 6 character one.
393 *
394 * @since 6.0
395 *
396 * @return void
397 */
398 private static function fill_hex( &$color ) {
399 if ( 3 === strlen( $color ) ) {
400 $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
401 }
402 }
403
404 /**
405 * @since 4.05.02
406 */
407 public static function get_css_vars( $vars = array() ) {
408 $vars = apply_filters( 'frm_css_vars', $vars );
409 return array_unique( $vars );
410 }
411
412 /**
413 * @since 4.05.02
414 */
415 public static function output_vars( $settings, $defaults = array(), $vars = array() ) {
416 if ( empty( $vars ) ) {
417 $vars = self::get_css_vars( array_keys( $settings ) );
418 }
419 $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' );
420 $vars = array_diff( $vars, $remove );
421
422 foreach ( $vars as $var ) {
423 if ( ! isset( $settings[ $var ] ) ) {
424 continue;
425 }
426 if ( ! isset( $defaults[ $var ] ) ) {
427 $defaults[ $var ] = '';
428 }
429 $show = empty( $defaults ) || ( $settings[ $var ] !== '' && $settings[ $var ] !== $defaults[ $var ] );
430 if ( $show ) {
431 echo '--' . esc_html( str_replace( '_', '-', $var ) ) . ':' . ( $var === 'font' ? FrmAppHelper::kses( $settings[ $var ] ) : esc_html( $settings[ $var ] ) ) . ';'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
432 }
433 }
434 }
435
436 /**
437 * @since 2.3
438 *
439 * @param WP_Post $style
440 * @return array
441 */
442 public static function get_settings_for_output( $style ) {
443 if ( self::previewing_style() ) {
444 $frm_style = new FrmStyle();
445 if ( isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
446
447 // Sanitizing is done later.
448 $posted = wp_unslash( $_POST['frm_style_setting'] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
449 if ( ! is_array( $posted ) ) {
450 $posted = json_decode( $posted, true );
451 FrmAppHelper::format_form_data( $posted );
452 $settings = $frm_style->sanitize_post_content( $posted['frm_style_setting']['post_content'] );
453 $style_name = sanitize_title( $posted['style_name'] );
454 } else {
455 $settings = $frm_style->sanitize_post_content( $posted['post_content'] );
456 $style_name = FrmAppHelper::get_post_param( 'style_name', '', 'sanitize_title' );
457 }
458 } else {
459 $settings = $frm_style->sanitize_post_content( wp_unslash( $_GET ) );
460 $style_name = FrmAppHelper::get_param( 'style_name', '', 'get', 'sanitize_title' );
461 }
462
463 FrmAppHelper::sanitize_value( 'sanitize_text_field', $settings );
464
465 $settings['style_class'] = '';
466 if ( ! empty( $style_name ) ) {
467 $settings['style_class'] = $style_name . '.';
468 }
469 } else {
470 $settings = $style->post_content;
471 $settings['style_class'] = 'frm_style_' . $style->post_name . '.';
472 }//end if
473
474 $settings['style_class'] .= 'with_frm_style';
475 $settings['font'] = stripslashes( $settings['font'] );
476 $settings['change_margin'] = self::description_margin_for_screensize( $settings['width'] );
477
478 $checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' );
479 foreach ( $checkbox_opts as $opt ) {
480 if ( ! isset( $settings[ $opt ] ) ) {
481 $settings[ $opt ] = 0;
482 }
483 }
484
485 self::prepare_color_output( $settings );
486
487 $settings['field_height'] = $settings['field_height'] === '' ? 'auto' : $settings['field_height'];
488 $settings['field_width'] = $settings['field_width'] === '' ? 'auto' : $settings['field_width'];
489 $settings['auto_width'] = $settings['auto_width'] ? 'auto' : $settings['field_width'];
490 $settings['box_shadow'] = ! empty( $settings['remove_box_shadow'] ) ? 'none' : '0 1px 1px rgba(0, 0, 0, 0.075) inset';
491
492 if ( ! isset( $settings['repeat_icon'] ) ) {
493 $settings['repeat_icon'] = 1;
494 }
495
496 return $settings;
497 }
498
499 /**
500 * @since 2.3
501 */
502 public static function prepare_color_output( &$settings, $allow_transparent = true ) {
503 $colors = self::allow_color_override();
504 foreach ( $colors as $css => $opts ) {
505 if ( $css === 'transparent' && ! $allow_transparent ) {
506 $css = '';
507 }
508 foreach ( $opts as $opt ) {
509 self::get_color_output( $css, $settings[ $opt ] );
510 }
511 }
512 }
513
514 /**
515 * @since 2.3
516 *
517 * @return array
518 */
519 private static function allow_color_override() {
520 $frm_style = new FrmStyle();
521 $colors = $frm_style->get_color_settings();
522
523 $transparent = array(
524 'fieldset_color',
525 'fieldset_bg_color',
526 'bg_color',
527 'bg_color_active',
528 'bg_color_disabled',
529 'section_bg_color',
530 'error_bg',
531 'success_bg_color',
532 'progress_bg_color',
533 'progress_active_bg_color',
534 'submit_border_color',
535 'submit_hover_border_color',
536 'submit_active_border_color',
537 'submit_hover_bg_color',
538 'submit_active_bg_color',
539 );
540
541 return array(
542 'transparent' => $transparent,
543 '' => array_diff( $colors, $transparent ),
544 );
545 }
546
547 /**
548 * @since 2.3
549 */
550 private static function get_color_output( $default, &$color ) {
551 $color = trim( $color );
552 if ( empty( $color ) ) {
553 $color = $default;
554 } elseif ( false !== strpos( $color, 'rgb(' ) ) {
555 $color = str_replace( 'rgb(', 'rgba(', $color );
556 $color = str_replace( ')', ',1)', $color );
557 } elseif ( strpos( $color, '#' ) === false && self::is_hex( $color ) ) {
558 $color = '#' . $color;
559 }
560 }
561
562 /**
563 * If a color looks like a hex code without the #, prepend the #.
564 * A color looks like a hex code if it does not contain the substrings "rgb", "rgba", "hsl", "hsla", or "hwb".
565 *
566 * @since 6.8
567 *
568 * @param string $color
569 * @return bool
570 */
571 private static function is_hex( $color ) {
572 $non_hex_substrings = array(
573 'rgba(',
574 'hsl(',
575 'hsla(',
576 'hwb(',
577 );
578
579 foreach ( $non_hex_substrings as $substring ) {
580 if ( false !== strpos( $color, $substring ) ) {
581 return false;
582 }
583 }
584
585 return true;
586 }
587
588 /**
589 * If left/right label is over a certain size,
590 * adjust the field description margin at a different screen size
591 *
592 * @since 2.3
593 */
594 private static function description_margin_for_screensize( $width ) {
595 $temp_label_width = str_replace( 'px', '', $width );
596 $change_margin = false;
597 if ( $temp_label_width >= 230 ) {
598 $change_margin = '800px';
599 } elseif ( $width >= 215 ) {
600 $change_margin = '700px';
601 } elseif ( $width >= 180 ) {
602 $change_margin = '650px';
603 }
604
605 return $change_margin;
606 }
607
608 /**
609 * @since 2.3
610 *
611 * @return bool
612 */
613 public static function previewing_style() {
614 $ajax_change = isset( $_POST['action'] ) && $_POST['action'] === 'frm_change_styling' && isset( $_POST['frm_style_setting'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
615
616 return $ajax_change || isset( $_GET['flat'] );
617 }
618
619 /**
620 * 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.
621 *
622 * @since 6.0
623 *
624 * @param int|string $form_id
625 * @return string
626 */
627 public static function get_list_url( $form_id ) {
628 return admin_url( 'admin.php?page=formidable-styles&form=' . absint( $form_id ) );
629 }
630
631 /**
632 * Get a link to edit a target style post object in the visual styler.
633 *
634 * @param stdClass|WP_Post $style
635 * @param int|string $form_id Used for the back button and preview form target.
636 * @return string
637 */
638 public static function get_edit_url( $style, $form_id = 0 ) {
639 $query_args = array(
640 'page' => 'formidable-styles',
641 'frm_action' => 'edit',
642 'id' => $style->ID,
643 );
644
645 if ( $form_id ) {
646 // We include &form_id for the back button to know where to point to.
647 $query_args['form'] = $form_id;
648 }
649
650 return add_query_arg( $query_args, admin_url( 'admin.php' ) );
651 }
652
653 /**
654 * Get a count of the number of forms assigned to a target style ID.
655 * All unassigned forms are included in the count for the default style.
656 *
657 * @since 6.0
658 *
659 * @param int|string $style_id
660 * @param bool $is_default
661 * @return int
662 */
663 public static function get_form_count_for_style( $style_id, $is_default ) {
664 $serialized = serialize( array( 'custom_style' => (string) $style_id ) );
665 // Chop off the "a:1:{" from the front and the "}" from the back.
666 $substring = substr( $serialized, 5, -1 );
667 $number_of_forms = FrmDb::get_count(
668 'frm_forms',
669 array(
670 'status' => 'published',
671 'options LIKE' => $substring,
672 )
673 );
674
675 if ( ! $is_default ) {
676 // Exit early as the rest of the code is about including the default count.
677 return $number_of_forms;
678 }
679
680 $conversational_style_id = FrmDb::get_var( 'posts', array( 'post_name' => 'lines-no-boxes' ), 'ID' );
681 $number_of_forms += self::get_default_style_count( $style_id, $conversational_style_id );
682
683 return $number_of_forms;
684 }
685
686 /**
687 * Get the number of forms that use the default style.
688 *
689 * @since 6.0
690 *
691 * @param int|string $style_id
692 * @param mixed $conversational_style_id
693 * @return int
694 */
695 private static function get_default_style_count( $style_id, $conversational_style_id ) {
696 $substrings = array_map(
697 function ( $value ) {
698 $substring = serialize( array( 'custom_style' => $value ) );
699 return substr( $substring, 5, -1 );
700 },
701 array( '1', 1 )
702 );
703 $where = array(
704 'status' => 'published',
705 0 => array(
706 'options NOT LIKE' => 'custom_style',
707 'or' => 1,
708 'options LIKE' => $substrings,
709 ),
710 );
711
712 if ( $conversational_style_id ) {
713 // When a conversational style is set, check for it in the query by wrapping the where and adding a conversational option check.
714 $is_conversational_style = (int) $style_id === (int) $conversational_style_id;
715 $where[0] = array(
716 // The chat option doesn't exist if it isn't on.
717 ( $is_conversational_style ? 'options LIKE' : 'options NOT LIKE' ) => ';s:4:"chat";',
718 $where[0],
719 );
720 }
721
722 return FrmDb::get_count( 'frm_forms', $where );
723 }
724
725 /**
726 * @since 5.5.1
727 * @deprecated 6.10
728 * @return void
729 */
730 public static function maybe_include_font_icon_css() {
731 _deprecated_function( __METHOD__, '6.10' );
732 }
733 }
734