Skip to content

Commit

Permalink
Merge pull request #672 from stellarwp/bugfix/KAD-4176
Browse files Browse the repository at this point in the history
Fixing issue with the row layout block where tablet column widths wer…
  • Loading branch information
mark-c-woodard authored Feb 24, 2025
2 parents 013323c + 6f484dd commit b68b08e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
40 changes: 39 additions & 1 deletion includes/blocks/class-kadence-blocks-row-layout-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
$column5_mobile = ( ! empty( $attributes['fifthColumnWidthMobile'] ) ? $attributes['fifthColumnWidthMobile'] : '' );
$column6_mobile = ( ! empty( $attributes['sixthColumnWidthMobile'] ) ? $attributes['sixthColumnWidthMobile'] : '' );
$collapse_layouts = array( 'row', 'two-grid', 'three-grid', 'last-row', 'first-row' );
$has_custom_widths = $this->has_custom_widths( $columns, $column1, $column2, $column3, $column4, $column5, $column6 );
$has_custom_widths_tablet = $this->has_custom_widths( $columns, $column1_tablet, $column2_tablet, $column3_tablet, $column4_tablet, $column5_tablet, $column6_tablet );
$has_custom_widths_mobile = $this->has_custom_widths( $columns, $column1_mobile, $column2_mobile, $column3_mobile, $column4_mobile, $column5_mobile, $column6_mobile );

//base desktop layout.
$grid_layout = $this->get_template_columns( $css, $columns, $layout, $inner_selector, $css->render_row_gap_property( $attributes, array( 'columnGutter', 'tabletGutter', 'mobileGutter' ), 'desktop', 'customGutter', 'gutterType' ), $column1, $column2, $column3, $column4, $column5, $column6 );
Expand Down Expand Up @@ -572,7 +575,13 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
//no tablet layout, but we have a tablet guttter width, so render the inherited column layout from desktop, potentially with custom widths.
$css->set_media_state( 'tablet' );
$css->set_selector( $inner_selector );
$grid_layout = $this->get_template_columns( $css, $columns, $layout, $inner_selector, $css->render_row_gap_property( $attributes, array( 'columnGutter', 'tabletGutter', 'mobileGutter' ), 'tablet', 'customGutter', 'gutterType' ), $column1_tablet, $column2_tablet, $column3_tablet, $column4_tablet, $column5_tablet, $column6_tablet );

//if no custom widths, need to use desktop widths
if ( $has_custom_widths_tablet ) {
$grid_layout = $this->get_template_columns( $css, $columns, $layout, $inner_selector, $css->render_row_gap_property( $attributes, array( 'columnGutter', 'tabletGutter', 'mobileGutter' ), 'tablet', 'customGutter', 'gutterType' ), $column1_tablet, $column2_tablet, $column3_tablet, $column4_tablet, $column5_tablet, $column6_tablet );
} else {
$grid_layout = $this->get_template_columns( $css, $columns, $layout, $inner_selector, $css->render_row_gap_property( $attributes, array( 'columnGutter', 'tabletGutter', 'mobileGutter' ), 'tablet', 'customGutter', 'gutterType' ), $column1, $column2, $column3, $column4, $column5, $column6 );
}
$css->add_property( 'grid-template-columns', $grid_layout );
}
if ( ! empty( $attributes['tabletLayout'] ) || $column1_tablet ) {
Expand Down Expand Up @@ -1591,6 +1600,35 @@ public function get_video_render( $attributes ) {
}
return $output;
}

/**
* Do we have any custom column width for the amount of rows in this block.
*
* @param mixed $columns The number of columns.
* @param mixed $column1 The first column width.
* @param mixed $column2 The second column width.
* @param mixed $column3 The third column width.
* @param mixed $column4 The fourth column width.
* @param mixed $column5 The fifth column width.
* @param mixed $column6 The sixth column width.
*/
public function has_custom_widths( $columns, $column1, $column2, $column3, $column4, $column5, $column6 ) {
switch( $columns ) {
case 1:
return !empty($column1);
case 2:
return !empty($column1) || !empty($column2);
case 3:
return !empty($column1) || !empty($column2) || !empty($column3);
case 4:
return !empty($column1) || !empty($column2) || !empty($column3) || !empty($column4);
case 5:
return !empty($column1) || !empty($column2) || !empty($column3) || !empty($column4) || !empty($column5);
case 6:
return !empty($column1) || !empty($column2) || !empty($column3) || !empty($column4) || !empty($column5) || !empty($column6);
}
}

/**
* Build HTML for dynamic blocks
*
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Release Date: TBD February 2025
* Update: FAQ Schema for accordions now processes dynamic content.
* Fix: Warning handled for CSS class.
* Fix: Gallery (Adv) arrow strings added to pot file.
* Fix: issue with row layout tablet column widths in certain setups.

= 3.4.9 =
Release Date: 11th February 2025
Expand Down

0 comments on commit b68b08e

Please sign in to comment.