Skip to content

Commit e45cc4a

Browse files
authored
Merge pull request #532 from stellarwp/bugfix/KAD-3245
bugfix/KAD-3245
2 parents 10a5c11 + 00e9162 commit e45cc4a

File tree

1 file changed

+57
-44
lines changed

1 file changed

+57
-44
lines changed

includes/blocks/class-kadence-blocks-column-block.php

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -446,52 +446,17 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
446446
}
447447
}
448448
// inside of Row.
449-
if ( ! empty( $desktop_vertical_align ) ) {
450-
// Restart $align variable to avoid inherit from above value assignment
451-
$align = 'center';
452-
$justify_content = '';
453-
switch ( $desktop_vertical_align ) {
454-
case 'top':
455-
$align = 'flex-start';
456-
$justify_content = 'flex-start';
457-
break;
458-
case 'bottom':
459-
$align = 'flex-end';
460-
$justify_content = 'flex-end';
461-
break;
462-
case 'space-between':
463-
$justify_content = 'space-between';
464-
break;
465-
case 'space-around':
466-
$justify_content = 'space-around';
467-
break;
468-
case 'space-evenly':
469-
$justify_content = 'space-evenly';
470-
break;
471-
case 'stretch':
472-
$justify_content = 'stretch';
473-
break;
474-
default:
475-
$justify_content = 'center';
476-
break;
477-
}
478-
if ( 'horizontal' === $desktop_direction || 'horizontal-reverse' === $desktop_direction ) {
479-
$css->set_selector( '.kt-row-column-wrap > .kadence-column' . $unique_id );
480-
$css->add_property( 'align-self', $align );
481-
$css->set_selector( '.kt-inner-column-height-full:not(.kt-has-1-columns) > .wp-block-kadence-column.kadence-column' . $unique_id );
482-
$css->add_property( 'align-self', 'auto' );
483-
$css->set_selector( '.kt-inner-column-height-full:not(.kt-has-1-columns) > .wp-block-kadence-column.kadence-column' . $unique_id . ' > .kt-inside-inner-col' );
484-
$css->add_property( 'align-items', $align );
485-
} else {
486-
$css->set_selector( '.kt-row-column-wrap > .kadence-column' . $unique_id );
487-
$css->add_property( 'align-self', $align );
488-
$css->set_selector( '.kt-inner-column-height-full:not(.kt-has-1-columns) > .wp-block-kadence-column.kadence-column' . $unique_id );
489-
$css->add_property( 'align-self', 'auto' );
490-
$css->set_selector( '.kt-inner-column-height-full:not(.kt-has-1-columns) > .wp-block-kadence-column.kadence-column' . $unique_id . ' > .kt-inside-inner-col' );
491-
$css->add_property( 'flex-direction', 'column' );
492-
$css->add_property( 'justify-content', $justify_content );
449+
$alignments = [
450+
'desktop' => ['vertical_align' => $desktop_vertical_align, 'direction' => $desktop_direction],
451+
'tablet' => ['vertical_align' => $tablet_vertical_align, 'direction' => $tablet_direction],
452+
'mobile' => ['vertical_align' => $mobile_vertical_align, 'direction' => $mobile_direction],
453+
];
454+
foreach ($alignments as $media_state => $align) {
455+
if ( ! empty($align['vertical_align']) ) {
456+
$this->set_vertical_align($media_state, $align['vertical_align'], $align['direction'], $css, $unique_id);
493457
}
494458
}
459+
$css->set_media_state('desktop');
495460
// Background.
496461
$background_type = ! empty( $attributes['backgroundType'] ) ? $attributes['backgroundType'] : 'normal';
497462
$css->set_selector( '.kadence-column' . $unique_id . ' > .kt-inside-inner-col' );
@@ -892,5 +857,53 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
892857
}
893858
return $css->css_output();
894859
}
860+
861+
private function set_vertical_align($media_state, $media_vertical_align, $media_direction, $css, $unique_id) {
862+
// Restart $align variable to avoid inherit from above value assignment
863+
$align = 'center';
864+
$justify_content = '';
865+
switch ( $media_vertical_align ) {
866+
case 'top':
867+
$align = 'flex-start';
868+
$justify_content = 'flex-start';
869+
break;
870+
case 'bottom':
871+
$align = 'flex-end';
872+
$justify_content = 'flex-end';
873+
break;
874+
case 'space-between':
875+
$justify_content = 'space-between';
876+
break;
877+
case 'space-around':
878+
$justify_content = 'space-around';
879+
break;
880+
case 'space-evenly':
881+
$justify_content = 'space-evenly';
882+
break;
883+
case 'stretch':
884+
$justify_content = 'stretch';
885+
break;
886+
default:
887+
$justify_content = 'center';
888+
break;
889+
}
890+
$css->set_media_state($media_state);
891+
if ( 'horizontal' === $media_direction || 'horizontal-reverse' === $media_direction ) {
892+
$css->set_selector( '.kt-row-column-wrap > .kadence-column' . $unique_id );
893+
$css->add_property( 'align-self', $align );
894+
$css->set_selector( '.kt-inner-column-height-full:not(.kt-has-1-columns) > .wp-block-kadence-column.kadence-column' . $unique_id );
895+
$css->add_property( 'align-self', 'auto' );
896+
$css->set_selector( '.kt-inner-column-height-full:not(.kt-has-1-columns) > .wp-block-kadence-column.kadence-column' . $unique_id . ' > .kt-inside-inner-col' );
897+
$css->add_property( 'align-items', $align );
898+
} else {
899+
$css->set_selector( '.kt-row-column-wrap > .kadence-column' . $unique_id );
900+
$css->add_property( 'align-self', $align );
901+
$css->set_selector( '.kt-inner-column-height-full:not(.kt-has-1-columns) > .wp-block-kadence-column.kadence-column' . $unique_id );
902+
$css->add_property( 'align-self', 'auto' );
903+
$css->set_selector( '.kt-inner-column-height-full:not(.kt-has-1-columns) > .wp-block-kadence-column.kadence-column' . $unique_id . ' > .kt-inside-inner-col' );
904+
$css->add_property( 'flex-direction', 'column' );
905+
$css->add_property( 'justify-content', $justify_content );
906+
}
907+
}
895908
}
896909
Kadence_Blocks_Column_Block::get_instance();

0 commit comments

Comments
 (0)