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