From 75f95d908a03382c2a6ab1d0b6b312f81fbb4d0f Mon Sep 17 00:00:00 2001 From: gilbert-hernandez Date: Fri, 3 Jan 2025 12:14:50 -0700 Subject: [PATCH] KAD-3783 consolidated some unit variables --- .../class-kadence-blocks-infobox-block.php | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/includes/blocks/class-kadence-blocks-infobox-block.php b/includes/blocks/class-kadence-blocks-infobox-block.php index e7a762d19..db4661434 100644 --- a/includes/blocks/class-kadence-blocks-infobox-block.php +++ b/includes/blocks/class-kadence-blocks-infobox-block.php @@ -360,47 +360,49 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) { $css->add_property( 'border-left-width', $media_style['borderWidth'][3] . 'px' ); } } + $padding_unit = isset( $media_style['paddingUnit'] ) ? $media_style['paddingUnit'] : 'px'; if ( isset( $media_style['padding'] ) && is_array( $media_style['padding'] ) ) { if ( isset( $media_style['padding'][0] ) && is_numeric( $media_style['padding'][0] ) ) { - $css->add_property( 'padding-top', $media_style['padding'][0] . (isset($media_style['paddingUnit']) ? $media_style['paddingUnit'] : 'px') ); + $css->add_property( 'padding-top', $media_style['padding'][0] . $padding_unit ); } if ( isset( $media_style['padding'][1] ) && is_numeric( $media_style['padding'][1] ) ) { - $css->add_property( 'padding-right', $media_style['padding'][1] . (isset($media_style['paddingUnit']) ? $media_style['paddingUnit'] : 'px') ); + $css->add_property( 'padding-right', $media_style['padding'][1] . $padding_unit ); } if ( isset( $media_style['padding'][2] ) && is_numeric( $media_style['padding'][2] ) ) { - $css->add_property( 'padding-bottom', $media_style['padding'][2] . (isset($media_style['paddingUnit']) ? $media_style['paddingUnit'] : 'px') ); + $css->add_property( 'padding-bottom', $media_style['padding'][2] . $padding_unit ); } if ( isset( $media_style['padding'][3] ) && is_numeric( $media_style['padding'][3] ) ) { - $css->add_property( 'padding-left', $media_style['padding'][3] . (isset($media_style['paddingUnit']) ? $media_style['paddingUnit'] : 'px') ); + $css->add_property( 'padding-left', $media_style['padding'][3] . $padding_unit ); } } + $margin_unit = isset( $media_style['marginUnit'] ) ? $media_style['marginUnit'] : 'px'; if ( isset( $media_style['margin'] ) && is_array( $media_style['margin'] ) && isset( $attributes['mediaAlign'] ) && 'top' !== $attributes['mediaAlign'] ) { if ( isset( $media_style['margin'][0] ) && is_numeric( $media_style['margin'][0] ) ) { - $css->add_property( 'margin-top', $media_style['margin'][0] . (isset($media_style['marginUnit']) ? $media_style['marginUnit'] : 'px') ); + $css->add_property( 'margin-top', $media_style['margin'][0] . $margin_unit ); } if ( isset( $media_style['margin'][1] ) && is_numeric( $media_style['margin'][1] ) ) { - $css->add_property( 'margin-right', $media_style['margin'][1] . (isset($media_style['marginUnit']) ? $media_style['marginUnit'] : 'px') ); + $css->add_property( 'margin-right', $media_style['margin'][1] . $margin_unit ); } if ( isset( $media_style['margin'][2] ) && is_numeric( $media_style['margin'][2] ) ) { - $css->add_property( 'margin-bottom', $media_style['margin'][2] . (isset($media_style['marginUnit']) ? $media_style['marginUnit'] : 'px') ); + $css->add_property( 'margin-bottom', $media_style['margin'][2] . $margin_unit ); } if ( isset( $media_style['margin'][3] ) && is_numeric( $media_style['margin'][3] ) ) { - $css->add_property( 'margin-left', $media_style['margin'][3] . (isset($media_style['marginUnit']) ? $media_style['marginUnit'] : 'px') ); + $css->add_property( 'margin-left', $media_style['margin'][3] . $margin_unit ); } } if ( isset( $media_style['margin'] ) && is_array( $media_style['margin'] ) && ( ! isset( $attributes['mediaAlign'] ) || 'top' === $attributes['mediaAlign'] ) ) { $css->set_selector( $base_selector . ' .kt-blocks-info-box-media-container' ); if ( isset( $media_style['margin'][0] ) && is_numeric( $media_style['margin'][0] ) ) { - $css->add_property( 'margin-top', $media_style['margin'][0] . (isset($media_style['marginUnit']) ? $media_style['marginUnit'] : 'px') ); + $css->add_property( 'margin-top', $media_style['margin'][0] . $margin_unit ); } if ( isset( $media_style['margin'][1] ) && is_numeric( $media_style['margin'][1] ) ) { - $css->add_property( 'margin-right', $media_style['margin'][1] . (isset($media_style['marginUnit']) ? $media_style['marginUnit'] : 'px') ); + $css->add_property( 'margin-right', $media_style['margin'][1] . $margin_unit ); } if ( isset( $media_style['margin'][2] ) && is_numeric( $media_style['margin'][2] ) ) { - $css->add_property( 'margin-bottom', $media_style['margin'][2] . (isset($media_style['marginUnit']) ? $media_style['marginUnit'] : 'px') ); + $css->add_property( 'margin-bottom', $media_style['margin'][2] . $margin_unit ); } if ( isset( $media_style['margin'][3] ) && is_numeric( $media_style['margin'][3] ) ) { - $css->add_property( 'margin-left', $media_style['margin'][3] . (isset($media_style['marginUnit']) ? $media_style['marginUnit'] : 'px') ); + $css->add_property( 'margin-left', $media_style['margin'][3] . $margin_unit ); } } if ( isset( $media_style['borderRadius'] ) && ! empty( $media_style['borderRadius'] ) && isset( $media_style['padding'] ) && is_array( $media_style['padding'] ) && ! empty( array_filter( $media_style['padding'], fn($value) => $value > 0 ) ) ) { @@ -536,21 +538,22 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) { } $css->set_media_state( 'desktop' ); } + $title_min_height_unit = isset( $attributes['titleMinHeightUnit'] ) ? $attributes['titleMinHeightUnit'] : 'px'; if ( isset( $attributes['titleMinHeight'] ) && is_array( $attributes['titleMinHeight'] ) && isset( $attributes['titleMinHeight'][0] ) ) { if ( is_numeric( $attributes['titleMinHeight'][0] ) ) { $css->set_selector( $base_selector . ' ' . $titleTag . '.kt-blocks-info-box-title' ); - $css->add_property( 'min-height', $attributes['titleMinHeight'][0] . (isset($attributes['titleMinHeightUnit']) ? $attributes['titleMinHeightUnit'] : 'px') ); + $css->add_property( 'min-height', $attributes['titleMinHeight'][0] . $title_min_height_unit ); } if ( isset( $attributes['titleMinHeight'][1] ) && is_numeric( $attributes['titleMinHeight'][1] ) ) { $css->set_media_state( 'tablet' ); $css->set_selector( $base_selector . ' ' . $titleTag . '.kt-blocks-info-box-title' ); - $css->add_property( 'min-height', $attributes['titleMinHeight'][1] . (isset($attributes['titleMinHeightUnit']) ? $attributes['titleMinHeightUnit'] : 'px') ); + $css->add_property( 'min-height', $attributes['titleMinHeight'][1] . $title_min_height_unit ); $css->set_media_state( 'desktop' ); } if ( isset( $attributes['titleMinHeight'][2] ) && is_numeric( $attributes['titleMinHeight'][2] ) ) { $css->set_media_state( 'mobile' ); $css->set_selector( $base_selector . ' ' . $titleTag . '.kt-blocks-info-box-title' ); - $css->add_property( 'min-height', $attributes['titleMinHeight'][2] . (isset($attributes['titleMinHeightUnit']) ? $attributes['titleMinHeightUnit'] : 'px') ); + $css->add_property( 'min-height', $attributes['titleMinHeight'][2] . $title_min_height_unit ); $css->set_media_state( 'desktop' ); } } @@ -710,21 +713,22 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) { } $css->set_media_state( 'desktop' ); } + $text_min_height_unit = isset( $attributes['textMinHeightUnit'] ) ? $attributes['textMinHeightUnit'] : 'px'; if ( isset( $attributes['textMinHeight'] ) && is_array( $attributes['textMinHeight'] ) && isset( $attributes['textMinHeight'][0] ) ) { if ( is_numeric( $attributes['textMinHeight'][0] ) ) { $css->set_selector( $base_selector . ' .kt-blocks-info-box-text' ); - $css->add_property( 'min-height', $attributes['textMinHeight'][0] . (isset($attributes['textMinHeightUnit']) ? $attributes['textMinHeightUnit'] : 'px') ); + $css->add_property( 'min-height', $attributes['textMinHeight'][0] . $text_min_height_unit ); } if ( isset( $attributes['textMinHeight'][1] ) && is_numeric( $attributes['textMinHeight'][1] ) ) { $css->set_media_state( 'tablet' ); $css->set_selector( $base_selector . ' .kt-blocks-info-box-text' ); - $css->add_property( 'min-height', $attributes['textMinHeight'][1] . (isset($attributes['textMinHeightUnit']) ? $attributes['textMinHeightUnit'] : 'px') ); + $css->add_property( 'min-height', $attributes['textMinHeight'][1] . $text_min_height_unit ); $css->set_media_state( 'desktop' ); } if ( isset( $attributes['textMinHeight'][2] ) && is_numeric( $attributes['textMinHeight'][2] ) ) { $css->set_media_state( 'mobile' ); $css->set_selector( $base_selector . ' .kt-blocks-info-box-text' ); - $css->add_property( 'min-height', $attributes['textMinHeight'][2] . (isset($attributes['textMinHeightUnit']) ? $attributes['textMinHeightUnit'] : 'px') ); + $css->add_property( 'min-height', $attributes['textMinHeight'][2] . $text_min_height_unit ); $css->set_media_state( 'desktop' ); } }