PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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/FrmStylesHelper.php +131 -668 6.255.0 View file →
@@ -14,8 +14,57 @@
14 14 return $uploads;
15 15 }
16 16
17 17 /**
18 + * @since 4.0
19 + */
20 + public static function get_style_menu( $active = '' ) {
21 + ob_start();
22 + self::style_menu( $active );
23 + $menu = ob_get_contents();
24 + ob_end_clean();
25 +
26 + return $menu;
27 + }
28 +
29 + public static function style_menu( $active = '' ) {
30 + ?>
31 + <ul class="frm_form_nav">
32 + <li>
33 + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ); ?>"
34 + class="<?php echo ( '' == $active ) ? 'current_page' : ''; ?>">
35 + <?php esc_html_e( 'Edit Styles', 'formidable' ); ?>
36 + </a>
37 + </li>
38 + <li>
39 + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ); ?>"
40 + class="<?php echo ( 'manage' == $active ) ? 'current_page' : ''; ?>">
41 + <?php esc_html_e( 'Manage Styles', 'formidable' ); ?>
42 + </a>
43 + </li>
44 + <li>
45 + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ); ?>"
46 + class="<?php echo ( 'custom_css' == $active ) ? 'current_page' : ''; ?>">
47 + <?php esc_html_e( 'Custom CSS', 'formidable' ); ?>
48 + </a>
49 + </li>
50 + </ul>
51 + <?php
52 + }
53 +
54 + /**
55 + * @since 4.0
56 + */
57 + public static function styler_save_button( $atts ) {
58 + $style = $atts['style'];
59 + if ( ! empty( $style->ID ) && empty( $style->menu_order ) ) {
60 + $delete_link = admin_url( 'admin.php?page=formidable-styles&frm_action=destroy&id=' . $style->ID );
61 + }
62 +
63 + include( FrmAppHelper::plugin_path() . '/classes/views/styles/header-buttons.php' );
64 + }
65 +
66 + /**
18 67 * Called from the admin header.
19 68 *
20 69 * @since 4.0
21 70 */
@@ -25,8 +74,27 @@
25 74 <?php
26 75 }
27 76
28 77 /**
78 + * Either get the heading or the style switcher.
79 + *
80 + * @since 4.0
81 + */
82 + public static function styler_switcher( $atts ) {
83 + if ( has_action( 'frm_style_switcher_heading' ) ) {
84 + do_action( 'frm_style_switcher_heading', $atts );
85 + } else {
86 + ?>
87 + <div class="frm_top_left">
88 + <h1>
89 + <?php echo esc_html( $atts['style']->post_title ); ?>
90 + </h1>
91 + </div>
92 + <?php
93 + }
94 + }
95 +
96 + /**
29 97 * @since 2.05
30 98 */
31 99 public static function get_css_label_positions() {
32 100 return array(
@@ -37,17 +105,10 @@
37 105 'inside' => __( 'inside', 'formidable' ),
38 106 );
39 107 }
40 108
41 - /**
42 - * @since 6.11 Added $field param.
43 - *
44 - * @param array|object $field
45 - *
46 - * @return array
47 - */
48 - public static function get_single_label_positions( $field = array() ) {
49 - $label_positions = array(
109 + public static function get_single_label_positions() {
110 + return array(
50 111 'top' => __( 'Top', 'formidable' ),
51 112 'left' => __( 'Left', 'formidable' ),
52 113 'right' => __( 'Right', 'formidable' ),
53 114 'inline' => __( 'Inline (left without a set width)', 'formidable' ),
@@ -54,18 +115,8 @@
54 115 'none' => __( 'None', 'formidable' ),
55 116 'hidden' => __( 'Hidden (but leave the space)', 'formidable' ),
56 117 'inside' => __( 'Placeholder inside the field', 'formidable' ),
57 118 );
58 -
59 - /**
60 - * Allows updating label positions in field settings.
61 - *
62 - * @since 6.11
63 - *
64 - * @param array $label_positions
65 - * @param array|object $field
66 - */
67 - return apply_filters( 'frm_single_label_positions', $label_positions, $field );
68 119 }
69 120
70 121 public static function minus_icons() {
71 122 return array(
@@ -133,13 +184,13 @@
133 184 }
134 185
135 186 /**
136 187 * @since 2.0
137 - * @return string The class for this icon.
188 + * @return The class for this icon
138 189 */
139 190 public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
140 - if ( 'arrow' === $type && is_numeric( $key ) ) {
141 - // frm_arrowup6_icon.
191 + if ( 'arrow' == $type && is_numeric( $key ) ) {
192 + //frm_arrowup6_icon
142 193 $arrow = array(
143 194 '-' => 'down',
144 195 '+' => 'up',
145 196 );
@@ -144,9 +195,9 @@
144 195 '+' => 'up',
145 196 );
146 197 $class = 'frm_arrow' . $arrow[ $icon ];
147 198 } else {
148 - // frm_minus1_icon.
199 + //frm_minus1_icon
149 200 $key = str_replace( 'p', '', $key );
150 201 $plus = array(
151 202 '-' => 'minus',
152 203 '+' => 'plus',
@@ -161,20 +212,14 @@
161 212
162 213 return $class;
163 214 }
164 215
165 - /**
166 - * @param WP_Post $style
167 - * @param FrmStyle $frm_style
168 - * @param string $type
169 - * @return void
170 - */
171 216 public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
172 217 $function_name = $type . '_icons';
173 218 $icons = self::$function_name();
174 219 unset( $function_name );
175 220
176 - $name = 'arrow' === $type ? 'collapse_icon' : 'repeat_icon';
221 + $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
177 222 ?>
178 223 <div class="btn-group" id="frm_<?php echo esc_attr( $name ); ?>_select">
179 224 <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
180 225 <?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ); ?>
@@ -182,17 +227,15 @@
182 227 <b class="caret"></b>
183 228 </button>
184 229 <ul class="multiselect-container frm-dropdown-menu">
185 230 <?php foreach ( $icons as $key => $icon ) { ?>
186 - <li <?php echo $style->post_content['collapse_icon'] == $key ? 'class="active"' : ''; ?>>
231 + <li <?php echo ( $style->post_content['collapse_icon'] == $key ) ? 'class="active"' : ''; ?>>
187 232 <a href="javascript:void(0);">
188 233 <label>
189 - <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 ); ?> />
234 + <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 ); ?>/>
190 235 <span>
191 - <?php
192 - FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $key, '+', $type ) );
193 - FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $key, '-', $type ) );
194 - ?>
236 + <?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $key, '+', $type ) ); ?>
237 + <?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $key, '-', $type ) ); ?>
195 238 </span>
196 239 </label>
197 240 </a>
198 241 </li>
@@ -201,55 +244,16 @@
201 244 </div>
202 245 <?php
203 246 }
204 247
205 - /**
206 - * Convert a color setting to a RGB CSV (without the rgb()/rgba() wrapper).
207 - *
208 - * @since 2.0
209 - *
210 - * @param string $color Color setting value. This could be hex or rgb.
211 - * @return string RGB value without the rgb() wrapper.
212 - */
213 - public static function hex2rgb( $color ) {
214 - if ( 0 === strpos( $color, 'rgb' ) ) {
215 - $rgb = self::get_rgb_array_from_rgb( $color );
216 - } else {
217 - $rgb = self::get_rgb_array_from_hex( $color );
218 - }
219 - return implode( ',', $rgb );
220 - }
248 + public static function hex2rgb( $hex ) {
249 + $hex = str_replace( '#', '', $hex );
221 250
222 - /**
223 - * Remove the rgb()/rgba() wrapper from a RGB color and return its R, G and B values as an array.
224 - *
225 - * @since 6.8.3
226 - *
227 - * @param string $rgb RGB value including the rgb() or rgba() wrapper.
228 - * @return array<string> including three numeric values for R, G, and B.
229 - */
230 - private static function get_rgb_array_from_rgb( $rgb ) {
231 - $rgb = str_replace( array( 'rgb(', 'rgba(', ')' ), '', $rgb );
232 - $rgb = explode( ',', $rgb );
233 - if ( 4 === count( $rgb ) ) {
234 - // Drop the alpha. The function is expected to only return r,g,b with no alpha.
235 - array_pop( $rgb );
236 - }
237 - return $rgb;
238 - }
251 + list( $r, $g, $b ) = sscanf( $hex, '%02x%02x%02x' );
239 252
240 - /**
241 - * Get the R, G, and B array values from a Hex color code.
242 - *
243 - * @since 6.8.3
244 - *
245 - * @param string $hex A hex color string.
246 - * @return array<string> Including three numeric values for R, G, and B.
247 - */
248 - private static function get_rgb_array_from_hex( $hex ) {
249 - $hex = str_replace( '#', '', $hex );
250 - list( $r, $g, $b ) = sscanf( $hex, '%02x%02x%02x' );
251 - return array( $r, $g, $b );
253 + $rgb = array( $r, $g, $b );
254 +
255 + return implode( ',', $rgb );
252 256 }
253 257
254 258 /**
255 259 * @since 4.0
@@ -260,104 +264,23 @@
260 264 return 'rgba(' . $rgb . ',' . $a . ')';
261 265 }
262 266
263 267 /**
264 - * @since 6.0
268 + * @param $hex string - The original color in hex format #ffffff
269 + * @param $steps integer - should be between -255 and 255. Negative = darker, positive = lighter
265 270 *
266 - * @param string $rgba Color setting value. This could be hex or rgb.
267 - * @return string Hex color value.
268 - */
269 - private static function rgb_to_hex( $rgba ) {
270 - if ( strpos( $rgba, '#' ) === 0 ) {
271 - // Color is already hex.
272 - return $rgba;
273 - }
274 - preg_match( '/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i', $rgba, $by_color );
275 - return sprintf( '%02x%02x%02x', $by_color[1], $by_color[2], $by_color[3] );
276 - }
277 -
278 - /**
279 - * @since 6.8
280 - *
281 - * @param string $hsl
282 - * @return string|null Null if it fails to parse the HSL string.
283 - */
284 - private static function hsl_to_hex( $hsl ) {
285 - // Convert hsla to hsl.
286 - $hsl = preg_replace( '/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/', 'hsl($1, $2%, $3%)', $hsl );
287 -
288 - // Extract HSL components from the color string.
289 - preg_match( '/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/', $hsl, $matches );
290 -
291 - if ( count( $matches ) !== 4 ) {
292 - // Invalid HSL string format.
293 - return null;
294 - }
295 -
296 - // Extract HSL values.
297 - $h = (int) $matches[1];
298 - $s = (int) $matches[2] / 100;
299 - $l = (int) $matches[3] / 100;
300 -
301 - // Calculate RGB values.
302 - $c = ( 1 - abs( 2 * $l - 1 ) ) * $s;
303 - $x = $c * ( 1 - abs( ( (int) ( $h / 60 ) % 2 ) - 1 ) );
304 - $m = $l - $c / 2;
305 - $r = 0;
306 - $g = 0;
307 - $b = 0;
308 -
309 - if ( $h >= 0 && $h < 60 ) {
310 - $r = $c;
311 - $g = $x;
312 - } elseif ( $h >= 60 && $h < 120 ) {
313 - $r = $x;
314 - $g = $c;
315 - } elseif ( $h >= 120 && $h < 180 ) {
316 - $g = $c;
317 - $b = $x;
318 - } elseif ( $h >= 180 && $h < 240 ) {
319 - $g = $x;
320 - $b = $c;
321 - } elseif ( $h >= 240 && $h < 300 ) {
322 - $r = $x;
323 - $b = $c;
324 - } elseif ( $h >= 300 && $h < 360 ) {
325 - $r = $c;
326 - $b = $x;
327 - }//end if
328 -
329 - // Convert RGB to 8-bit values
330 - $r = round( ( $r + $m ) * 255 );
331 - $g = round( ( $g + $m ) * 255 );
332 - $b = round( ( $b + $m ) * 255 );
333 -
334 - // Convert RGB to hex
335 - $hex = sprintf( '%02x%02x%02x', $r, $g, $b );
336 -
337 - return $hex;
338 - }
339 -
340 - /**
341 271 * @since 2.3
342 - * @param string $hex string The original color in hex format #ffffff.
343 - * @param int $steps integer Should be between -255 and 255. Negative = darker, positive = lighter.
344 272 */
345 273 public static function adjust_brightness( $hex, $steps ) {
346 274 $steps = max( - 255, min( 255, $steps ) );
347 275
348 - if ( 0 === strpos( $hex, 'rgba(' ) ) {
349 - $rgba = str_replace( ')', '', str_replace( 'rgba(', '', $hex ) );
350 - list ( $r, $g, $b, $a ) = array_map( 'trim', explode( ',', $rgba ) );
351 - $r = max( 0, min( 255, $r + $steps ) );
352 - $g = max( 0, min( 255, $g + $steps ) );
353 - $b = max( 0, min( 255, $b + $steps ) );
354 - return 'rgba(' . $r . ',' . $g . ',' . $b . ',' . $a . ')';
355 - }
356 -
357 276 // Normalize into a six character long hex string
358 277 $hex = str_replace( '#', '', $hex );
359 - self::fill_hex( $hex );
278 + if ( strlen( $hex ) == 3 ) {
279 + $hex = str_repeat( substr( $hex, 0, 1 ), 2 );
280 + $hex .= str_repeat( substr( $hex, 1, 1 ), 2 );
281 + $hex .= str_repeat( substr( $hex, 2, 1 ), 2 );
282 + }
360 283
361 284 // Split into three parts: R, G and B
362 285 $color_parts = str_split( $hex, 2 );
363 286 $return = '#';
@@ -362,15 +285,11 @@
362 285 $color_parts = str_split( $hex, 2 );
363 286 $return = '#';
364 287
365 288 foreach ( $color_parts as $color ) {
366 - // Convert to decimal.
367 - $color = hexdec( $color );
368 - // Adjust color.
369 - $color = max( 0, min( 255, $color + $steps ) );
370 -
371 - // Make two char hex code.
372 - $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT );
289 + $color = hexdec( $color ); // Convert to decimal
290 + $color = max( 0, min( 255, $color + $steps ) ); // Adjust color
291 + $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code
373 292 }
374 293
375 294 return $return;
376 295 }
@@ -375,51 +294,8 @@
375 294 return $return;
376 295 }
377 296
378 297 /**
379 - * @since 6.0
380 - *
381 - * @param string $color
382 - * @return int
383 - */
384 - public static function get_color_brightness( $color ) {
385 - if ( 0 === strpos( $color, 'rgb' ) ) {
386 - $color = self::rgb_to_hex( $color );
387 - }
388 -
389 - if ( 0 === strpos( $color, 'hsl' ) ) {
390 - $hsl_to_hex = self::hsl_to_hex( $color );
391 - if ( is_null( $hsl_to_hex ) ) {
392 - // Fallback if we cannot convert the HSL value.
393 - return 0;
394 - }
395 - $color = $hsl_to_hex;
396 - }
397 -
398 - self::fill_hex( $color );
399 -
400 - $c_r = hexdec( substr( $color, 0, 2 ) );
401 - $c_g = hexdec( substr( $color, 2, 2 ) );
402 - $c_b = hexdec( substr( $color, 4, 2 ) );
403 - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
404 -
405 - return $brightness;
406 - }
407 -
408 - /**
409 - * Change a 3 character hex color to a 6 character one.
410 - *
411 - * @since 6.0
412 - *
413 - * @return void
414 - */
415 - private static function fill_hex( &$color ) {
416 - if ( 3 === strlen( $color ) ) {
417 - $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
418 - }
419 - }
420 -
421 - /**
422 298 * @since 4.05.02
423 299 */
424 300 public static function get_css_vars( $vars = array() ) {
425 301 $vars = apply_filters( 'frm_css_vars', $vars );
@@ -432,188 +308,49 @@
432 308 public static function output_vars( $settings, $defaults = array(), $vars = array() ) {
433 309 if ( empty( $vars ) ) {
434 310 $vars = self::get_css_vars( array_keys( $settings ) );
435 311 }
436 - $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', 'use_base_font_size', 'field_shape_type' );
312 + $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' );
437 313 $vars = array_diff( $vars, $remove );
438 314
439 315 foreach ( $vars as $var ) {
440 - if ( ! isset( $settings[ $var ] ) || ! self::css_key_is_valid( $var ) ) {
316 + if ( ! isset( $settings[ $var ] ) ) {
441 317 continue;
442 318 }
443 319 if ( ! isset( $defaults[ $var ] ) ) {
444 320 $defaults[ $var ] = '';
445 321 }
446 -
447 - $prepared_value = '';
448 - if ( self::should_add_css_var( $settings, $defaults, $var, $prepared_value ) ) {
449 - echo '--' . esc_html( self::clean_var_name( str_replace( '_', '-', $var ) ) ) . ':' . $prepared_value . ';'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
322 + $show = empty( $defaults ) || ( $settings[ $var ] !== '' && $settings[ $var ] !== $defaults[ $var ] );
323 + if ( $show ) {
324 + echo '--' . esc_html( str_replace( '_', '-', $var ) ) . ':' . ( $var === 'font' ? FrmAppHelper::kses( $settings[ $var ] ) : esc_html( $settings[ $var ] ) ) . ';'; // WPCS: XSS ok.
450 325 }
451 326 }
452 327 }
453 328
454 329 /**
455 - * Check if a CSS variable setting is not blank, doesn't match the default, and doesn't include invalid substrings.
456 - *
457 - * @since 6.24
458 - *
459 - * @param array $settings Array of setting values.
460 - * @param array $defaults Array of default values.
461 - * @param string $var The setting key name.
462 - * @param string $prepared_value The value from calling css_var_prepare_value. This is set by reference so it can be used after this function is called.
463 - * @return bool True if the CSS value should be printed.
464 - */
465 - private static function should_add_css_var( $settings, $defaults, $var, &$prepared_value ) {
466 - $prepared_value = self::css_var_prepare_value( $settings, $var );
467 - if ( $prepared_value === '' ) {
468 - return false;
469 - }
470 -
471 - if ( $defaults && $defaults[ $var ] === $prepared_value ) {
472 - return false;
473 - }
474 -
475 - return self::css_value_is_valid( $prepared_value );
476 - }
477 -
478 - /**
479 - * Prevent invalid CSS keys from getting added to the generated CSS.
480 - *
481 - * @since 6.20
482 - *
483 - * @param string $key
484 - * @return bool
485 - */
486 - private static function css_key_is_valid( $key ) {
487 - // Any key that is abnormally large is not valid.
488 - // Any key that contains a '{' is not valid.
489 - return strlen( $key ) < 100 && false === strpos( $key, '{' );
490 - }
491 -
492 - /**
493 - * Confirm a CSS value is valid.
494 - * If it appears to contain JavaScript, it will not be added.
495 - *
496 - * @since 6.20
497 - *
498 - * @param string $var
499 - * @return bool
500 - */
501 - private static function css_value_is_valid( $var ) {
502 - if ( is_numeric( $var ) ) {
503 - return true;
504 - }
505 -
506 - // None of these substrings should be present in any CSS value.
507 - $invalid_substrings = array(
508 - 'function(',
509 - ';userAgent',
510 - ';stopPropagation',
511 - '{const',
512 - 'window[',
513 - 'navigator[',
514 - 'Array;',
515 - );
516 -
517 - foreach ( $invalid_substrings as $substring ) {
518 - if ( strpos( $var, $substring ) !== false ) {
519 - return false;
520 - }
521 - }
522 -
523 - return true;
524 - }
525 -
526 -
527 - /**
528 - * Remove anything that isn't used as a CSS variable name.
529 - *
530 - * @param string $var_name
531 - * @return string
532 - */
533 - private static function clean_var_name( $var_name ) {
534 - return preg_replace( '/[^a-zA-Z0-9_-]/', '', $var_name );
535 - }
536 -
537 - /**
538 - * Prepare the value for a CSS variable.
539 - *
540 - * @since 6.14
541 - *
542 - * @param array $settings An array of css style.
543 - * @param string $key
544 - *
545 - * @return string
546 - */
547 - private static function css_var_prepare_value( $settings, $key ) {
548 - $value = $settings[ $key ];
549 -
550 - if ( ! is_string( $value ) && ! is_numeric( $value ) ) {
551 - return '';
552 - }
553 -
554 - switch ( $key ) {
555 - case 'font':
556 - return safecss_filter_attr( $value );
557 -
558 - case 'border_width_error':
559 - case 'field_border_width':
560 - if ( ! empty( $settings['field_shape_type'] ) && 'underline' === $settings['field_shape_type'] ) {
561 - return safecss_filter_attr( '0px 0px ' . $value . ' 0px' );
562 - }
563 - break;
564 -
565 - case 'box_shadow':
566 - if ( ! empty( $settings['field_shape_type'] ) && 'underline' === $settings['field_shape_type'] ) {
567 - return safecss_filter_attr( 'none' );
568 - }
569 - break;
570 -
571 - case 'border_radius':
572 - if ( ! empty( $settings['field_shape_type'] ) ) {
573 - switch ( $settings['field_shape_type'] ) {
574 - case 'underline':
575 - case 'regular':
576 - return safecss_filter_attr( '0px' );
577 - case 'circle':
578 - return safecss_filter_attr( '30px' );
579 - }
580 - }
581 - break;
582 - }//end switch
583 -
584 - return esc_html( $value );
585 - }
586 -
587 - /**
588 330 * @since 2.3
589 - *
590 - * @param WP_Post $style
591 - * @return array
592 331 */
593 332 public static function get_settings_for_output( $style ) {
594 333 if ( self::previewing_style() ) {
595 - $frm_style = new FrmStyle();
596 - if ( isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
597 334
335 + if ( isset( $_POST['frm_style_setting'] ) ) {
598 336 // Sanitizing is done later.
599 - $posted = wp_unslash( $_POST['frm_style_setting'] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
337 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
338 + $posted = wp_unslash( $_POST['frm_style_setting'] );
600 339 if ( ! is_array( $posted ) ) {
601 340 $posted = json_decode( $posted, true );
602 341 FrmAppHelper::format_form_data( $posted );
603 - $settings = $frm_style->sanitize_post_content( $posted['frm_style_setting']['post_content'] );
342 + $settings = $posted['frm_style_setting']['post_content'];
604 343 $style_name = sanitize_title( $posted['style_name'] );
605 344 } else {
606 - $settings = $frm_style->sanitize_post_content( $posted['post_content'] );
345 + $settings = $posted['post_content'];
607 346 $style_name = FrmAppHelper::get_post_param( 'style_name', '', 'sanitize_title' );
608 347 }
609 348 } else {
610 - $settings = $frm_style->sanitize_post_content( wp_unslash( $_GET ) );
349 + $settings = $_GET;
611 350 $style_name = FrmAppHelper::get_param( 'style_name', '', 'get', 'sanitize_title' );
612 351 }
613 352
614 - $settings = self::update_base_font_size( $settings, $frm_style->get_defaults() );
615 -
616 353 FrmAppHelper::sanitize_value( 'sanitize_text_field', $settings );
617 354
618 355 $settings['style_class'] = '';
619 356 if ( ! empty( $style_name ) ) {
@@ -621,11 +358,11 @@
621 358 }
622 359 } else {
623 360 $settings = $style->post_content;
624 361 $settings['style_class'] = 'frm_style_' . $style->post_name . '.';
625 - }//end if
362 + }
626 363
627 - $settings['style_class'] .= 'with_frm_style';
364 + $settings['style_class'] .= 'with_frm_style';
628 365 $settings['font'] = stripslashes( $settings['font'] );
629 366 $settings['change_margin'] = self::description_margin_for_screensize( $settings['width'] );
630 367
631 368 $checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' );
@@ -639,9 +376,9 @@
639 376
640 377 $settings['field_height'] = $settings['field_height'] === '' ? 'auto' : $settings['field_height'];
641 378 $settings['field_width'] = $settings['field_width'] === '' ? 'auto' : $settings['field_width'];
642 379 $settings['auto_width'] = $settings['auto_width'] ? 'auto' : $settings['field_width'];
643 - $settings['box_shadow'] = ! empty( $settings['remove_box_shadow'] ) ? 'none' : '0 1px 2px 0 rgba(18, 18, 23, 0.05)';
380 + $settings['box_shadow'] = ( isset( $settings['remove_box_shadow'] ) && $settings['remove_box_shadow'] ) ? 'none' : '0 1px 1px rgba(0, 0, 0, 0.075) inset';
644 381
645 382 if ( ! isset( $settings['repeat_icon'] ) ) {
646 383 $settings['repeat_icon'] = 1;
647 384 }
@@ -649,64 +386,8 @@
649 386 return $settings;
650 387 }
651 388
652 389 /**
653 - * Update the "Base Font Size" value from "Quick Settings across multiple settings values".
654 - *
655 - * @since 6.14
656 - *
657 - * @param array $settings An array of css style.
658 - *
659 - * @return array
660 - */
661 - public static function update_base_font_size( $settings, $defaults ) {
662 - if ( empty( $settings['base_font_size'] ) || empty( $settings['use_base_font_size'] ) || 'false' === $settings['use_base_font_size'] ) {
663 - return $settings;
664 - }
665 - $base_font_size = (int) $settings['base_font_size'];
666 - $font_size = $defaults['font_size'];
667 - $font_sizes_to_update = array(
668 - 'font_size',
669 - 'field_font_size',
670 - 'check_font_size',
671 - 'title_size',
672 - 'form_desc_size',
673 - 'description_font_size',
674 - 'section_font_size',
675 - 'submit_font_size',
676 - 'success_font_size',
677 - 'error_font_size',
678 - 'progress_size',
679 - );
680 -
681 - array_map(
682 - function ( $key ) use ( $defaults, $font_size, $base_font_size, &$settings ) {
683 - if ( isset( $settings[ $key ] ) ) {
684 - $settings[ $key ] = round( self::get_base_font_size_scale( $key, $font_size, $defaults ) * $base_font_size ) . 'px';
685 - }
686 - },
687 - $font_sizes_to_update
688 - );
689 -
690 - return $settings;
691 - }
692 -
693 - /**
694 - * Get style font size scale value.
695 - *
696 - * @since 6.14
697 - *
698 - * @return float
699 - */
700 - private static function get_base_font_size_scale( $key, $value, $defaults ) {
701 - if ( empty( $defaults[ $key ] ) || ! is_numeric( (int) $defaults[ $key ] ) || ! is_numeric( (int) $value ) || 0 === (int) $value ) {
702 - return 1;
703 - }
704 -
705 - return round( (int) $defaults[ $key ] / (int) $value, 2 );
706 - }
707 -
708 - /**
709 390 * @since 2.3
710 391 */
711 392 public static function prepare_color_output( &$settings, $allow_transparent = true ) {
712 393 $colors = self::allow_color_override();
@@ -721,10 +402,8 @@
721 402 }
722 403
723 404 /**
724 405 * @since 2.3
725 - *
726 - * @return array
727 406 */
728 407 private static function allow_color_override() {
729 408 $frm_style = new FrmStyle();
730 409 $colors = $frm_style->get_color_settings();
@@ -732,20 +411,13 @@
732 411 $transparent = array(
733 412 'fieldset_color',
734 413 'fieldset_bg_color',
735 414 'bg_color',
736 - 'bg_color_active',
737 - 'bg_color_disabled',
738 415 'section_bg_color',
739 416 'error_bg',
740 417 'success_bg_color',
741 418 'progress_bg_color',
742 419 'progress_active_bg_color',
743 - 'submit_border_color',
744 - 'submit_hover_border_color',
745 - 'submit_active_border_color',
746 - 'submit_hover_bg_color',
747 - 'submit_active_bg_color',
748 420 );
749 421
750 422 return array(
751 423 'transparent' => $transparent,
@@ -759,43 +431,14 @@
759 431 private static function get_color_output( $default, &$color ) {
760 432 $color = trim( $color );
761 433 if ( empty( $color ) ) {
762 434 $color = $default;
763 - } elseif ( false !== strpos( $color, 'rgb(' ) ) {
764 - $color = str_replace( 'rgb(', 'rgba(', $color );
765 - $color = str_replace( ')', ',1)', $color );
766 - } elseif ( strpos( $color, '#' ) === false && self::is_hex( $color ) ) {
435 + } elseif ( strpos( $color, '#' ) === false ) {
767 436 $color = '#' . $color;
768 437 }
769 438 }
770 439
771 440 /**
772 - * If a color looks like a hex code without the #, prepend the #.
773 - * A color looks like a hex code if it does not contain the substrings "rgb", "rgba", "hsl", "hsla", or "hwb".
774 - *
775 - * @since 6.8
776 - *
777 - * @param string $color
778 - * @return bool
779 - */
780 - private static function is_hex( $color ) {
781 - $non_hex_substrings = array(
782 - 'rgba(',
783 - 'hsl(',
784 - 'hsla(',
785 - 'hwb(',
786 - );
787 -
788 - foreach ( $non_hex_substrings as $substring ) {
789 - if ( false !== strpos( $color, $substring ) ) {
790 - return false;
791 - }
792 - }
793 -
794 - return true;
795 - }
796 -
797 - /**
798 441 * If left/right label is over a certain size,
799 442 * adjust the field description margin at a different screen size
800 443 *
801 444 * @since 2.3
@@ -815,231 +458,51 @@
815 458 }
816 459
817 460 /**
818 461 * @since 2.3
819 - *
820 - * @return bool
821 462 */
822 463 public static function previewing_style() {
823 - $ajax_change = isset( $_POST['action'] ) && $_POST['action'] === 'frm_change_styling' && isset( $_POST['frm_style_setting'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
464 + $ajax_change = isset( $_POST['action'] ) && $_POST['action'] === 'frm_change_styling' && isset( $_POST['frm_style_setting'] );
824 465
825 466 return $ajax_change || isset( $_GET['flat'] );
826 467 }
827 468
828 469 /**
829 - * 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.
830 - *
831 - * @since 6.0
832 - *
833 - * @param int|string $form_id
834 - * @return string
470 + * @deprecated 3.01
471 + * @codeCoverageIgnore
835 472 */
836 - public static function get_list_url( $form_id ) {
837 - return admin_url( 'admin.php?page=formidable-styles&form=' . absint( $form_id ) );
473 + public static function get_sigle_label_postitions() {
474 + return FrmDeprecated::get_sigle_label_postitions();
838 475 }
839 476
840 477 /**
841 - * Get the back button args from Style settings.
842 - *
843 - * @since 6.14
844 - *
845 - * @param stdClass|WP_Post $style
846 - * @param int $form_id
847 - * @return array
478 + * @deprecated 3.02.03
479 + * @codeCoverageIgnore
848 480 */
849 - public static function get_style_options_back_button_args( $style, $form_id ) {
850 - if ( self::is_advanced_settings() ) {
851 - return array(
852 - 'title' => __( 'Quick Settings', 'formidable' ),
853 - 'id' => 'frm_style_back_to_quick_settings',
854 - );
855 - }
856 - return array(
857 - 'href' => self::get_list_url( $form_id ),
858 - 'title' => $style->post_title,
859 - );
481 + public static function jquery_themes() {
482 + return FrmDeprecated::jquery_themes();
860 483 }
861 484
862 485 /**
863 - * Get a link to edit a target style post object in the visual styler.
864 - *
865 - * @param stdClass|WP_Post $style
866 - * @param int|string $form_id Used for the back button and preview form target.
867 - * @param string $section The url param section.
868 - *
869 - * @return string
486 + * @deprecated 3.02.03
487 + * @codeCoverageIgnore
870 488 */
871 - public static function get_edit_url( $style, $form_id = 0, $section = '' ) {
872 - $query_args = array(
873 - 'page' => 'formidable-styles',
874 - 'frm_action' => 'edit',
875 - 'id' => $style->ID,
876 - 'section' => $section,
877 - );
878 -
879 - if ( $form_id ) {
880 - // We include &form_id for the back button to know where to point to.
881 - $query_args['form'] = $form_id;
882 - }
883 -
884 - return add_query_arg( $query_args, admin_url( 'admin.php' ) );
489 + public static function jquery_css_url( $theme_css ) {
490 + return FrmDeprecated::jquery_css_url( $theme_css );
885 491 }
886 492
887 493 /**
888 - * Get a count of the number of forms assigned to a target style ID.
889 - * All unassigned forms are included in the count for the default style.
890 - *
891 - * @since 6.0
892 - *
893 - * @param int|string $style_id
894 - * @param bool $is_default
895 - * @return int
494 + * @deprecated 3.02.03
495 + * @codeCoverageIgnore
896 496 */
897 - public static function get_form_count_for_style( $style_id, $is_default ) {
898 - $serialized = serialize( array( 'custom_style' => (string) $style_id ) );
899 - // Chop off the "a:1:{" from the front and the "}" from the back.
900 - $substring = substr( $serialized, 5, -1 );
901 - $number_of_forms = FrmDb::get_count(
902 - 'frm_forms',
903 - array(
904 - 'status' => 'published',
905 - 'options LIKE' => $substring,
906 - )
907 - );
908 -
909 - if ( ! $is_default ) {
910 - // Exit early as the rest of the code is about including the default count.
911 - return $number_of_forms;
912 - }
913 -
914 - $conversational_style_id = FrmDb::get_var( 'posts', array( 'post_name' => 'lines-no-boxes' ), 'ID' );
915 - $number_of_forms += self::get_default_style_count( $style_id, $conversational_style_id );
916 -
917 - return $number_of_forms;
497 + public static function enqueue_jquery_css() {
498 + FrmDeprecated::enqueue_jquery_css();
918 499 }
919 500
920 501 /**
921 - * Get the number of forms that use the default style.
922 - *
923 - * @since 6.0
924 - *
925 - * @param int|string $style_id
926 - * @param mixed $conversational_style_id
927 - * @return int
502 + * @deprecated 3.02.03
503 + * @codeCoverageIgnore
928 504 */
929 - private static function get_default_style_count( $style_id, $conversational_style_id ) {
930 - $substrings = array_map(
931 - function ( $value ) {
932 - $substring = serialize( array( 'custom_style' => $value ) );
933 - return substr( $substring, 5, -1 );
934 - },
935 - array( '1', 1 )
936 - );
937 - $where = array(
938 - 'status' => 'published',
939 - 0 => array(
940 - 'options NOT LIKE' => 'custom_style',
941 - 'or' => 1,
942 - 'options LIKE' => $substrings,
943 - ),
944 - );
945 -
946 - if ( $conversational_style_id ) {
947 - // When a conversational style is set, check for it in the query by wrapping the where and adding a conversational option check.
948 - $is_conversational_style = (int) $style_id === (int) $conversational_style_id;
949 - $where[0] = array(
950 - // The chat option doesn't exist if it isn't on.
951 - ( $is_conversational_style ? 'options LIKE' : 'options NOT LIKE' ) => ';s:4:"chat";',
952 - $where[0],
953 - );
954 - }
955 -
956 - return FrmDb::get_count( 'frm_forms', $where );
957 - }
958 -
959 - /**
960 - * Check if the current page is the advanced settings page.
961 - *
962 - * @since 6.14
963 - *
964 - * @return bool True if is advanced settings, false otherwise.
965 - */
966 - public static function is_advanced_settings() {
967 - return FrmAppHelper::get_param( 'section' ) === 'advanced-settings' && FrmAppHelper::get_param( 'page' ) === 'formidable-styles';
968 - }
969 -
970 - /**
971 - * Get wrapper classname for style editor sections.
972 - *
973 - * @since 6.16
974 - *
975 - * @param string $section_type
976 - *
977 - * @return string The style editor wrapper classname.
978 - */
979 - public static function style_editor_get_wrapper_classname( $section_type ) {
980 - $is_quick_settings = ( 'quick-settings' === $section_type );
981 - $classname = 'frm-style-editor-form';
982 - $classname .= ( ! self::is_advanced_settings() xor $is_quick_settings ) ? ' frm_hidden' : '';
983 - $classname .= FrmAppHelper::pro_is_installed() ? ' frm-pro' : '';
984 -
985 - return $classname;
986 - }
987 -
988 - /**
989 - * Retrieve the background image URL of the submit button.
990 - * It may be either a full URL string (used in versions prior to 6.14) or a numeric attachment ID (introduced in version 6.14).
991 - *
992 - * @since 6.14
993 - *
994 - * @param array $settings
995 - * @return false|string Return image url or false.
996 - */
997 - public static function get_submit_image_bg_url( $settings ) {
998 - $background_image = $settings['submit_bg_img'];
999 - if ( empty( $background_image ) ) {
1000 - return false;
1001 - }
1002 - // Handle the case where the submit_bg_img is a full URL string. If the settings were saved with the older styler version prior to 6.14, the submit_bg_img will be a full URL string.
1003 - if ( ! is_numeric( $background_image ) ) {
1004 - return $background_image;
1005 - }
1006 -
1007 - return wp_get_attachment_url( (int) $background_image );
1008 - }
1009 -
1010 - /**
1011 - * Determines if the chosen JavaScript library should be used.
1012 - *
1013 - * @since 6.13
1014 - *
1015 - * @return bool
1016 - */
1017 - public static function use_chosen_js() {
1018 - if ( ! FrmAppHelper::pro_is_installed() ) {
1019 - return false;
1020 - }
1021 -
1022 - return is_callable( 'FrmProAppHelper::use_chosen_js' )
1023 - ? FrmProAppHelper::use_chosen_js()
1024 - : true;
1025 - }
1026 -
1027 - /**
1028 - * Returns the bottom part from a margin/padding value.
1029 - *
1030 - * @since 6.17
1031 - *
1032 - * @param string $value The margin/padding value.
1033 - * @return string
1034 - */
1035 - public static function get_bottom_value( $value ) {
1036 - if ( ! $value ) {
1037 - return $value;
1038 - }
1039 - $parts = explode( ' ', $value );
1040 - if ( count( $parts ) < 3 ) {
1041 - return $parts[0];
1042 - }
1043 - return $parts[2];
505 + public static function get_form_for_page() {
506 + return FrmDeprecated::get_form_for_page();
1044 507 }
1045 508 }