| @@ -94,10 +94,9 @@ | ||
| 94 | 94 | if ( ! empty( $style->post_content['position'] ) ) { |
| 95 | 95 | $label_position = $style->post_content['position']; |
| 96 | 96 | } else { |
| 97 | 97 | $frm_style = new FrmStyle(); |
| 98 | - $defaults = $frm_style->get_defaults(); | |
| 99 | - $label_position = $defaults['position']; | |
| 98 | + $label_position = $frm_style->get_defaults()['position']; | |
| 100 | 99 | } |
| 101 | 100 | |
| 102 | 101 | $class_name = 'frm_style_' . $style->post_name; |
| 103 | 102 | $params = array( |
| @@ -150,9 +149,9 @@ | ||
| 150 | 149 | } |
| 151 | 150 | |
| 152 | 151 | $color = $style->post_content[ $key ]; |
| 153 | 152 | |
| 154 | - if ( 0 === strpos( $color, 'rgba' ) ) { | |
| 153 | + if ( str_starts_with( $color, 'rgba' ) ) { | |
| 155 | 154 | preg_match_all( '/([\\d.]+)/', $color, $matches ); |
| 156 | 155 | |
| 157 | 156 | if ( isset( $matches[1][3] ) && is_numeric( $matches[1][3] ) ) { |
| 158 | 157 | // Consider a faded out rgba value as light even when the color is dark. |
| @@ -270,10 +269,11 @@ | ||
| 270 | 269 | // Add the background color setting for fieldsets to the card. |
| 271 | 270 | if ( empty( $style->post_content['fieldset_bg_color'] ) ) { |
| 272 | 271 | $background_color = '#fff'; |
| 273 | 272 | } else { |
| 274 | - $background_color = ( 0 === strpos( $style->post_content['fieldset_bg_color'], 'rgb' ) ? $style->post_content['fieldset_bg_color'] : '#' . $style->post_content['fieldset_bg_color'] ); | |
| 273 | + $background_color = str_starts_with( $style->post_content['fieldset_bg_color'], 'rgb' ) ? $style->post_content['fieldset_bg_color'] : '#' . $style->post_content['fieldset_bg_color']; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 275 | 274 | } |
| 275 | + | |
| 276 | 276 | $styles[] = '--preview-background-color: ' . $background_color; |
| 277 | 277 | |
| 278 | 278 | if ( empty( $style->post_content['submit_border_color'] ) ) { |
| 279 | 279 | $style->post_content['submit_border_color'] = 'transparent'; |
| @@ -280,9 +280,8 @@ | ||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // Apply additional styles from the style. |
| 283 | 283 | $rules_to_apply = self::get_style_keys_for_card(); |
| 284 | - | |
| 285 | 284 | $frm_style = new FrmStyle(); |
| 286 | 285 | $color_settings = $frm_style->get_color_settings(); |
| 287 | 286 | |
| 288 | 287 | foreach ( $rules_to_apply as $key ) { |
| @@ -290,12 +289,11 @@ | ||
| 290 | 289 | // A template from the API may not include every style key. If something is missing, skip it. |
| 291 | 290 | continue; |
| 292 | 291 | } |
| 293 | 292 | |
| 294 | - $value = $style->post_content[ $key ]; | |
| 293 | + $value = $style->post_content[ $key ]; | |
| 294 | + $is_hex = in_array( $key, $color_settings, true ) && $value && '#' !== $value[0] && ! str_contains( $value, 'rgb' ) && $value !== 'transparent'; | |
| 295 | 295 | |
| 296 | - $is_hex = in_array( $key, $color_settings, true ) && $value && '#' !== $value[0] && false === strpos( $value, 'rgb' ) && $value !== 'transparent'; | |
| 297 | - | |
| 298 | 296 | if ( $is_hex ) { |
| 299 | 297 | $value = '#' . $value; |
| 300 | 298 | } |
| 301 | 299 | |
| @@ -356,8 +354,9 @@ | ||
| 356 | 354 | } |
| 357 | 355 | |
| 358 | 356 | $first_style = reset( $styles ); |
| 359 | 357 | $is_template_wrapper = is_array( $first_style ); |
| 358 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 360 | 359 | ?> |
| 361 | 360 | <div <?php FrmAppHelper::array_to_html_params( $card_wrapper_params, true ); ?>> |
| 362 | 361 | <?php |
| 363 | 362 | if ( $is_template_wrapper ) { |
| @@ -367,8 +366,9 @@ | ||
| 367 | 366 | } |
| 368 | 367 | ?> |
| 369 | 368 | </div> |
| 370 | 369 | <?php |
| 370 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * Overwrite some styles. We want to make sure the sizes are normalized for the cards. |
| @@ -464,8 +464,9 @@ | ||
| 464 | 464 | if ( $count <= self::PAGE_SIZE ) { |
| 465 | 465 | // Not enough cards to require pagination. |
| 466 | 466 | return; |
| 467 | 467 | } |
| 468 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 468 | 469 | ?> |
| 469 | 470 | <div class="frm-style-card-pagination frm_wrap"> |
| 470 | 471 | <a href="#" class="frm-show-all-styles"> |
| 471 | 472 | <?php |
| @@ -477,8 +478,9 @@ | ||
| 477 | 478 | ?> |
| 478 | 479 | </a> |
| 479 | 480 | </div> |
| 480 | 481 | <?php |
| 482 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 481 | 483 | } |
| 482 | 484 | |
| 483 | 485 | /** |
| 484 | 486 | * @since 6.0 |