Skip to content

Commit

Permalink
KAD-3783 consolidated some unit variables
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbert-hernandez committed Jan 3, 2025
1 parent fb15166 commit 75f95d9
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions includes/blocks/class-kadence-blocks-infobox-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) ) {
Expand Down Expand Up @@ -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' );
}
}
Expand Down Expand Up @@ -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' );
}
}
Expand Down

0 comments on commit 75f95d9

Please sign in to comment.