PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmStyle.php +60 -122 6.276.13 View file →
@@ -3,19 +3,9 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmStyle {
7 -
8 7 /**
9 - * The meta name of default template style.
10 - *
11 - * @since 6.14
12 - *
13 - * @var string
14 - */
15 - private $default_template_style_meta_name = 'frm_style_default';
16 -
17 - /**
18 8 * Unique ID number of the current instance.
19 9 *
20 10 * @var int
21 11 */
@@ -28,9 +18,9 @@
28 18 */
29 19 public $id = 0;
30 20
31 21 /**
32 - * @param int|string $id The id of the stylesheet or 'default'.
22 + * @param int|string $id The id of the stylsheet or 'default'.
33 23 */
34 24 public function __construct( $id = 0 ) {
35 25 $this->id = $id;
36 26 }
@@ -43,9 +33,9 @@
43 33
44 34 $max_slug_value = 2147483647;
45 35 // We want to have at least 2 characters in the slug.
46 36 $min_slug_value = 37;
47 - $key = base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 );
37 + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
48 38
49 39 $style = array(
50 40 'post_type' => FrmStylesController::$post_type,
51 41 'ID' => '',
@@ -60,9 +50,8 @@
60 50 }
61 51
62 52 /**
63 53 * @param array $settings
64 - *
65 54 * @return int|WP_Error
66 55 */
67 56 public function save( $settings ) {
68 57 return FrmDb::save_settings( $settings, 'frm_styles' );
@@ -68,10 +57,8 @@
68 57 return FrmDb::save_settings( $settings, 'frm_styles' );
69 58 }
70 59
71 60 /**
72 - * @param int|string $id The id of the stylesheet or 'default'.
73 - *
74 61 * @return void
75 62 */
76 63 public function duplicate( $id ) {
77 64 // Duplicating is a pro feature. This is handled in FrmProStyle::duplicate instead.
@@ -80,14 +67,12 @@
80 67 /**
81 68 * Handle save actions in the visual styler edit page.
82 69 *
83 70 * @param mixed $id
84 - *
85 71 * @return array<int|WP_Error>
86 72 */
87 73 public function update( $id = 'default' ) {
88 - $all_instances = $this->get_all();
89 - $css_scope_helper = new FrmCssScopeHelper();
74 + $all_instances = $this->get_all();
90 75
91 76 if ( ! $id ) {
92 77 $new_style = (array) $this->get_new();
93 78 $all_instances[] = $new_style;
@@ -98,10 +83,9 @@
98 83 foreach ( $all_instances as $new_instance ) {
99 84 $new_instance = (array) $new_instance;
100 85 $this->id = $new_instance['ID'];
101 86
102 - // phpcs:ignore WordPress.Security.NonceVerification.Missing, Universal.Operators.StrictComparisons
103 - if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) {
87 + if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
104 88 // Don't continue if not saving this style.
105 89 continue;
106 90 }
107 91
@@ -106,9 +90,9 @@
106 90 }
107 91
108 92 // Custom CSS is no longer used from the default style, but it is still checked if the Global Setting is missing.
109 93 // Preserve the previous value in case Custom CSS has not been saved as a Global Setting yet.
110 - $custom_css = $new_instance['post_content']['custom_css'] ?? '';
94 + $custom_css = isset( $new_instance['post_content']['custom_css'] ) ? $new_instance['post_content']['custom_css'] : '';
111 95
112 96 // phpcs:ignore WordPress.Security.NonceVerification.Missing
113 97 if ( ! empty( $_POST['frm_style_setting']['post_title'] ) ) {
114 98 // The nonce check happens in FrmStylesController::save_style before this is called.
@@ -115,17 +99,12 @@
115 99 // phpcs:ignore WordPress.Security.NonceVerification.Missing
116 100 $new_instance['post_title'] = sanitize_text_field( wp_unslash( $_POST['frm_style_setting']['post_title'] ) );
117 101 }
118 102
119 - $new_instance['post_content'] = isset( $_POST['frm_style_setting']['post_content'] ) ? $this->sanitize_post_content( wp_unslash( $_POST['frm_style_setting']['post_content'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
103 + $new_instance['post_content'] = isset( $_POST['frm_style_setting']['post_content'] ) ? $this->sanitize_post_content( wp_unslash( $_POST['frm_style_setting']['post_content'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
120 104 $new_instance['post_content']['custom_css'] = $custom_css;
121 105 unset( $custom_css );
122 106
123 - if ( ! empty( $new_instance['post_content']['single_style_custom_css'] ) ) {
124 - $css_scope = 'frm_style_' . $new_instance['post_name'];
125 - $new_instance['post_content']['single_style_custom_css'] = $css_scope_helper->nest( $new_instance['post_content']['single_style_custom_css'], $css_scope );
126 - }
127 -
128 107 $new_instance['post_type'] = FrmStylesController::$post_type;
129 108 $new_instance['post_status'] = 'publish';
130 109
131 110 if ( ! $id ) {
@@ -140,10 +119,9 @@
140 119 }
141 120
142 121 if ( $this->is_color( $setting ) ) {
143 122 $color_val = $new_instance['post_content'][ $setting ];
144 -
145 - if ( $color_val !== '' && str_contains( $color_val, 'rgb' ) ) {
123 + if ( $color_val !== '' && false !== strpos( $color_val, 'rgb' ) ) {
146 124 // Maybe sanitize if invalid rgba value is entered.
147 125 $this->maybe_sanitize_rgba_value( $color_val );
148 126 }
149 127 $new_instance['post_content'][ $setting ] = str_replace( '#', '', $color_val );
@@ -153,10 +131,9 @@
153 131 $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
154 132 }
155 133 }
156 134
157 - $new_instance['post_content'] = FrmStylesHelper::update_base_font_size( $new_instance['post_content'], $this->get_defaults() );
158 - $action_ids[] = $this->save( $new_instance );
135 + $action_ids[] = $this->save( $new_instance );
159 136 }//end foreach
160 137
161 138 $this->save_settings();
162 139
@@ -168,12 +145,11 @@
168 145 *
169 146 * @since 5.3.2
170 147 *
171 148 * @param string $color_val The color value, by reference.
172 - *
173 149 * @return void
174 150 */
175 - private function maybe_sanitize_rgba_value( &$color_val ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
151 + private function maybe_sanitize_rgba_value( &$color_val ) {
176 152 if ( preg_match( '/(rgb|rgba)\(/', $color_val ) !== 1 ) {
177 153 return;
178 154 }
179 155
@@ -180,9 +156,8 @@
180 156 $color_val = trim( $color_val );
181 157 // Remove leading braces so (rgba(1,1,1,1) doesn't cause inconsistent braces.
182 158 $color_val = ltrim( $color_val, '(' );
183 159 $patterns = array( '/rgba\((\s*\d+\s*,){3}[[0-1]\.]+\)/', '/rgb\((\s*\d+\s*,){2}\s*[\d]+\)/' );
184 -
185 160 foreach ( $patterns as $pattern ) {
186 161 if ( preg_match( $pattern, $color_val ) === 1 ) {
187 162 return;
188 163 }
@@ -224,14 +199,13 @@
224 199 $new_value = floatval( $value );
225 200 }
226 201 }//end if
227 202
228 - $new_color_values[] = $new_value;
203 + $new_color_values[] = null === $new_value ? $value : $new_value;
229 204 }//end foreach
230 205
231 206 // add more 0s and 1 (if alpha position) if needed.
232 207 $missing_values = $length_of_color_codes - count( $new_color_values );
233 -
234 208 if ( $missing_values > 1 ) {
235 209 $insert_values = array_fill( 0, $missing_values - 1, 0 );
236 210 $last_value = 4 === $length_of_color_codes ? 1 : 0;
237 211 array_push( $insert_values, $last_value );
@@ -237,9 +211,8 @@
237 211 array_push( $insert_values, $last_value );
238 212 } elseif ( $missing_values === 1 ) {
239 213 $insert_values = 4 === $length_of_color_codes ? array( 1 ) : array( 0 );
240 214 }
241 -
242 215 if ( ! empty( $insert_values ) ) {
243 216 $new_color_values = array_merge( $new_color_values, $insert_values );
244 217 }
245 218
@@ -247,8 +220,9 @@
247 220 $prefix = substr( $color_val, 0, strpos( $color_val, '(' ) + 1 );
248 221 // Limit the number of opening braces after rgb/rgba. There should only be one.
249 222 $prefix = rtrim( $prefix, '(' ) . '(';
250 223 $new_color = $prefix . $new_color . ')';
224 +
251 225 $color_val = $new_color;
252 226 }
253 227
254 228 /**
@@ -254,9 +228,8 @@
254 228 /**
255 229 * @since 5.0.13
256 230 *
257 231 * @param array $settings
258 - *
259 232 * @return array
260 233 */
261 234 public function sanitize_post_content( $settings ) {
262 235 $defaults = $this->get_defaults();
@@ -261,17 +234,19 @@
261 234 public function sanitize_post_content( $settings ) {
262 235 $defaults = $this->get_defaults();
263 236 $valid_keys = array_keys( $defaults );
264 237 $sanitized_settings = array();
265 -
266 238 foreach ( $valid_keys as $key ) {
267 - $sanitized_settings[ $key ] = isset( $settings[ $key ] ) ? sanitize_textarea_field( $settings[ $key ] ) : $defaults[ $key ];
239 + if ( isset( $settings[ $key ] ) ) {
240 + $sanitized_settings[ $key ] = sanitize_textarea_field( $settings[ $key ] );
241 + } else {
242 + $sanitized_settings[ $key ] = $defaults[ $key ];
243 + }
268 244
269 - if ( 'custom_css' !== $key && 'single_style_custom_css' !== $key ) {
245 + if ( 'custom_css' !== $key ) {
270 246 $sanitized_settings[ $key ] = $this->strip_invalid_characters( $sanitized_settings[ $key ] );
271 247 }
272 248 }
273 -
274 249 return $sanitized_settings;
275 250 }
276 251
277 252 /**
@@ -279,9 +254,8 @@
279 254 *
280 255 * @since 6.2.3
281 256 *
282 257 * @param string $setting
283 - *
284 258 * @return string
285 259 */
286 260 private function strip_invalid_characters( $setting ) {
287 261 $characters_to_remove = array( '{', '}', ';', '[', ']' );
@@ -286,9 +260,9 @@
286 260 private function strip_invalid_characters( $setting ) {
287 261 $characters_to_remove = array( '{', '}', ';', '[', ']' );
288 262
289 263 // RGB is handled instead in self::maybe_sanitize_rgba_value.
290 - if ( ! str_starts_with( $setting, 'rgb' ) ) {
264 + if ( 0 !== strpos( $setting, 'rgb' ) ) {
291 265 $setting = $this->maybe_fix_braces( $setting, $characters_to_remove );
292 266 }
293 267
294 268 return str_replace( $characters_to_remove, '', $setting );
@@ -298,9 +272,8 @@
298 272 * @since 6.2.3
299 273 *
300 274 * @param string $setting
301 275 * @param array $characters_to_remove
302 - *
303 276 * @return string
304 277 */
305 278 private function maybe_fix_braces( $setting, &$characters_to_remove ) {
306 279 $number_of_opening_braces = substr_count( $setting, '(' );
@@ -322,28 +295,23 @@
322 295 /**
323 296 * @since 6.2.3
324 297 *
325 298 * @param string $input
326 - *
327 299 * @return string
328 300 */
329 301 private function trim_braces( $input ) {
330 302 $output = $input;
331 -
332 303 // Remove any ( from the start of the string as no CSS values expect at the first character.
333 304 if ( $output && in_array( $output[0], array( '(', ')' ), true ) ) {
334 305 $output = ltrim( $output, '()' );
335 306 }
336 -
337 307 // Remove extra braces from the end.
338 308 if ( in_array( substr( $output, -1 ), array( '(', ')' ), true ) ) {
339 309 $output = rtrim( $output, '()' );
340 -
341 - if ( str_contains( $output, '(' ) ) {
310 + if ( false !== strpos( $output, '(' ) ) {
342 311 $output .= ')';
343 312 }
344 313 }
345 -
346 314 return $output;
347 315 }
348 316
349 317 /**
@@ -349,13 +317,12 @@
349 317 /**
350 318 * @since 6.2.3
351 319 *
352 320 * @param string $setting
353 - *
354 321 * @return bool
355 322 */
356 323 private function should_remove_every_brace( $setting ) {
357 - if ( str_starts_with( trim( $setting, '()' ), 'calc' ) ) {
324 + if ( 0 === strpos( trim( $setting, '()' ), 'calc' ) ) {
358 325 // Support calc() sizes. We do not want to remove all braces when calc is used.
359 326 return false;
360 327 }
361 328
@@ -360,9 +327,8 @@
360 327 }
361 328
362 329 // Matches hex values but also checks for unexpected ( and ).
363 330 $looks_like_a_hex_value = preg_match( '/^(?:\()?(?!#?[a-fA-F0-9]*[^\(#\)\da-fA-F])[a-fA-F0-9\(\)]*(?:\))?$/', $setting );
364 -
365 331 if ( $looks_like_a_hex_value ) {
366 332 return true;
367 333 }
368 334
@@ -368,9 +334,13 @@
368 334
369 335 // Matches size values but also checks for unexpected ( and ).
370 336 // This is case insensitive so it will catch PX, PT, etc, as well.
371 337 $looks_like_a_size = preg_match( '/\(?[+-]?\d*\.?\d+(?:px|%|em|rem|ex|pt|pc|mm|cm|in)\)?/i', $setting );
372 - return (bool) $looks_like_a_size;
338 + if ( $looks_like_a_size ) {
339 + return true;
340 + }
341 +
342 + return false;
373 343 }
374 344
375 345 /**
376 346 * @since 3.01.01
@@ -375,14 +345,13 @@
375 345 /**
376 346 * @since 3.01.01
377 347 *
378 348 * @param string $setting
379 - *
380 349 * @return bool
381 350 */
382 351 private function is_color( $setting ) {
383 352 $extra_colors = array( 'error_bg', 'error_border', 'error_text' );
384 - return str_contains( $setting, 'color' ) || in_array( $setting, $extra_colors, true );
353 + return strpos( $setting, 'color' ) !== false || in_array( $setting, $extra_colors, true );
385 354 }
386 355
387 356 /**
388 357 * @since 3.01.01
@@ -425,19 +394,20 @@
425 394 }
426 395
427 396 /**
428 397 * @param string $filename
429 - *
430 398 * @return string
431 399 */
432 400 private function get_css_content( $filename ) {
433 - $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n";
401 + $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n";
402 +
434 403 $saving = true;
435 404 $frm_style = $this;
436 405
437 406 ob_start();
438 407 include $filename;
439 - $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_clean() ) );
408 + $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) );
409 + ob_end_clean();
440 410
441 411 return FrmStylesController::replace_relative_url( $css );
442 412 }
443 413
@@ -461,9 +431,8 @@
461 431 /**
462 432 * Delete a style by its post ID.
463 433 *
464 434 * @param int $id
465 - *
466 435 * @return false|WP_Post|null
467 436 */
468 437 public function destroy( $id ) {
469 438 if ( $id === $this->get_default_style()->ID ) {
@@ -477,11 +446,14 @@
477 446 */
478 447 public function get_one() {
479 448 if ( 'default' === $this->id ) {
480 449 $style = $this->get_default_style();
450 + if ( $style ) {
451 + $this->id = $style->ID;
452 + } else {
453 + $this->id = 0;
454 + }
481 455
482 - $this->id = $style ? $style->ID : 0;
483 -
484 456 return $style;
485 457 }
486 458
487 459 $style = get_post( $this->id );
@@ -504,9 +476,8 @@
504 476 /**
505 477 * @param string $orderby
506 478 * @param string $order
507 479 * @param int $limit
508 - *
509 480 * @return array
510 481 */
511 482 public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
512 483 $post_atts = array(
@@ -518,15 +489,15 @@
518 489 );
519 490
520 491 $temp_styles = FrmDb::check_cache( json_encode( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
521 492
522 - if ( ! $temp_styles ) {
493 + if ( empty( $temp_styles ) ) {
523 494 global $wpdb;
524 495 // make sure there wasn't a conflict with the query
525 - $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
496 + $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
526 497 $temp_styles = FrmDb::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );
527 498
528 - if ( ! $temp_styles ) {
499 + if ( empty( $temp_styles ) ) {
529 500 // create a new style if there are none
530 501 $new = $this->get_new();
531 502 $new->post_title = __( 'Formidable Style', 'formidable' );
532 503 $new->post_name = $new->post_title;
@@ -534,19 +505,19 @@
534 505 $new = $this->save( (array) $new );
535 506 $this->update( 'default' );
536 507
537 508 $post_atts['include'] = $new;
538 - $temp_styles = get_posts( $post_atts );
509 +
510 + $temp_styles = get_posts( $post_atts );
539 511 }
540 512 }
541 513
542 514 $default_values = $this->get_defaults();
543 515 $default_style = false;
544 - $styles = array();
545 516
517 + $styles = array();
546 518 foreach ( $temp_styles as $style ) {
547 519 $this->id = $style->ID;
548 -
549 520 if ( $style->menu_order ) {
550 521 if ( $default_style ) {
551 522 // only return one default
552 523 $style->menu_order = 0;
@@ -562,12 +533,13 @@
562 533 $style->post_content = $this->override_defaults( $style->post_content );
563 534 $style->post_content = wp_parse_args( $style->post_content, $default_values );
564 535
565 536 $styles[ $style->ID ] = $style;
566 - }//end foreach
537 + }
567 538
568 539 if ( ! $default_style ) {
569 - $default_style = reset( $styles );
540 + $default_style = reset( $styles );
541 +
570 542 $styles[ $default_style->ID ]->menu_order = 1;
571 543 }
572 544
573 545 return $styles;
@@ -574,10 +546,8 @@
574 546 }
575 547
576 548 /**
577 549 * @param array|null $styles
578 - *
579 - * @return object|null
580 550 */
581 551 public function get_default_style( $styles = null ) {
582 552 if ( ! isset( $styles ) ) {
583 553 $styles = $this->get_all( 'menu_order', 'DESC', 1 );
@@ -587,15 +557,12 @@
587 557 if ( $style->menu_order ) {
588 558 return $style;
589 559 }
590 560 }
591 -
592 - return null;
593 561 }
594 562
595 563 /**
596 564 * @param mixed $settings
597 - *
598 565 * @return mixed
599 566 */
600 567 public function override_defaults( $settings ) {
601 568 if ( ! is_array( $settings ) ) {
@@ -601,9 +568,9 @@
601 568 if ( ! is_array( $settings ) ) {
602 569 return $settings;
603 570 }
604 571
605 - $settings['line_height'] = ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] === 'auto' ? 'normal' : $settings['field_height']; // phpcs:ignore Universal.Operators.StrictComparisons, SlevomatCodingStandard.Files.LineLength.LineTooLong
572 + $settings['line_height'] = ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] === 'auto' ? 'normal' : $settings['field_height'];
606 573
607 574 if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
608 575 $settings['form_desc_size'] = $settings['description_font_size'];
609 576 $settings['form_desc_color'] = $settings['description_color'];
@@ -641,9 +608,9 @@
641 608 'form_align' => 'left',
642 609 'direction' => is_rtl() ? 'rtl' : 'ltr',
643 610 'fieldset' => '0px',
644 611 'fieldset_color' => '000000',
645 - 'fieldset_padding' => '0px 0px 15px 0px',
612 + 'fieldset_padding' => '0 0 15px 0',
646 613 'fieldset_bg_color' => '',
647 614
648 615 'title_size' => '40px',
649 616 'title_color' => '444444',
@@ -652,9 +619,9 @@
652 619 'form_desc_size' => '14px',
653 620 'form_desc_color' => '98A2B3',
654 621 'form_desc_margin_top' => '10px',
655 622 'form_desc_margin_bottom' => '25px',
656 - 'form_desc_padding' => '0px',
623 + 'form_desc_padding' => '0',
657 624
658 625 'font' => '',
659 626 'font_size' => '15px',
660 627 'label_color' => '344054',
@@ -663,9 +630,9 @@
663 630 'align' => 'left',
664 631 'width' => '150px',
665 632 'required_color' => 'F04438',
666 633 'required_weight' => 'bold',
667 - 'label_padding' => '0px 0px 5px 0px',
634 + 'label_padding' => '0 0 5px 0',
668 635
669 636 'description_font_size' => '12px',
670 637 'description_color' => '667085',
671 638 'description_weight' => 'normal',
@@ -670,9 +637,9 @@
670 637 'description_color' => '667085',
671 638 'description_weight' => 'normal',
672 639 'description_style' => 'normal',
673 640 'description_align' => 'left',
674 - 'description_margin' => '0px',
641 + 'description_margin' => '0',
675 642
676 643 'field_font_size' => '14px',
677 644 'field_height' => '36px',
678 645 'line_height' => 'normal',
@@ -710,9 +677,9 @@
710 677
711 678 'section_font_size' => '18px',
712 679 'section_color' => '344054',
713 680 'section_weight' => 'bold',
714 - 'section_pad' => '32px 0px 3px 0px',
681 + 'section_pad' => '32px 0 3px 0',
715 682 'section_mar_top' => '30px',
716 683 'section_mar_bottom' => '30px',
717 684 'section_bg_color' => '',
718 685 'section_border_color' => 'EAECF0',
@@ -765,14 +732,8 @@
765 732 'progress_border_color' => 'EAECF0',
766 733 'progress_border_size' => '1px',
767 734 'progress_size' => '30px',
768 735 'custom_css' => '',
769 - 'use_base_font_size' => false,
770 - 'base_font_size' => '15px',
771 - 'field_shape_type' => 'rounded-corner',
772 -
773 - 'enable_style_custom_css' => false,
774 - 'single_style_custom_css' => '',
775 736 );
776 737
777 738 return apply_filters( 'frm_default_style_settings', $defaults );
778 739 }
@@ -781,9 +742,8 @@
781 742 * Get a name attribute value for a style setting input.
782 743 *
783 744 * @param string $field_name
784 745 * @param string $post_field
785 - *
786 746 * @return string
787 747 */
788 748 public function get_field_name( $field_name, $post_field = 'post_content' ) {
789 749 return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']';
@@ -793,17 +753,17 @@
793 753 * @return array
794 754 */
795 755 public static function get_bold_options() {
796 756 return array(
797 - 100 => __( 'Thin', 'formidable' ),
798 - 200 => __( 'Extra Light', 'formidable' ),
799 - 300 => __( 'Light', 'formidable' ),
800 - 'normal' => __( 'Regular', 'formidable' ),
801 - 500 => __( 'Medium', 'formidable' ),
802 - 600 => __( 'Semi Bold', 'formidable' ),
803 - 'bold' => __( 'Bold', 'formidable' ),
804 - 800 => __( 'Extra Bold', 'formidable' ),
805 - 900 => __( 'Black', 'formidable' ),
757 + 100 => 100,
758 + 200 => 200,
759 + 300 => 300,
760 + 'normal' => __( 'normal', 'formidable' ),
761 + 500 => 500,
762 + 600 => 600,
763 + 'bold' => __( 'bold', 'formidable' ),
764 + 800 => 800,
765 + 900 => 900,
806 766 );
807 767 }
808 768
809 769 /**
@@ -809,17 +769,15 @@
809 769 /**
810 770 * Don't let imbalanced font families ruin the whole stylesheet.
811 771 *
812 772 * @param string $value
813 - *
814 773 * @return string
815 774 */
816 775 public function force_balanced_quotation( $value ) {
817 776 $balanced_characters = array( '"', "'" );
818 -
819 777 foreach ( $balanced_characters as $char ) {
820 778 $char_count = substr_count( $value, $char );
821 - $is_balanced = $char_count % 2 === 0;
779 + $is_balanced = $char_count % 2 == 0;
822 780
823 781 if ( $is_balanced ) {
824 782 continue;
825 783 }
@@ -829,27 +787,7 @@
829 787 } else {
830 788 $value .= $char;
831 789 }
832 790 }
833 -
834 791 return $value;
835 - }
836 -
837 - /**
838 - * Get the default template style
839 - *
840 - * @since 6.14
841 - *
842 - * @param int|string $style_id The post type "frm_styles" ID.
843 - *
844 - * @return string The json encoded template data
845 - */
846 - public function get_default_template_style( $style_id ) {
847 - $default_template = get_post_meta( (int) $style_id, $this->default_template_style_meta_name, true );
848 -
849 - if ( ! $default_template ) {
850 - return FrmAppHelper::prepare_and_encode( $this->get_defaults() );
851 - }
852 -
853 - return $default_template;
854 792 }
855 793 }