Components -> Layout * */ if ( ! defined( 'ABSPATH' ) ) exit; function tbkkt_layout_build_mapped_token_class_name( string $prefix, string $raw, array $allowed_slugs ): string { $slug = tbkkt_block_markup_sanitize_class_slug( str_replace( array( '_', ' ' ), '-', $raw ) ); return in_array( $slug, $allowed_slugs, true ) ? $prefix . $slug : ''; } function tbkkt_layout_build_class_names( array $attrs ): array { $classes = array( 'tbkkt-layout' ); $layout_mode = isset( $attrs['layoutMode'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['layoutMode'] ) : 'flex'; if ( ! in_array( $layout_mode, array( 'flex', 'grid' ), true ) ) : $layout_mode = 'flex'; endif; $classes[] = 'tbkkt-layout-' . $layout_mode; $classes[] = ( 'grid' === $layout_mode ) ? 'tbkkt-display-grid' : 'tbkkt-display-flex'; $dir = tbkkt_layout_build_mapped_token_class_name( 'tbkkt-flex-direction-', (string) ( $attrs['flexDirection'] ?? '' ), array( 'row', 'column', 'row-reverse', 'column-reverse' ) ); if ( $dir !== '' ) : $classes[] = $dir; endif; $dir_tablet = tbkkt_layout_build_mapped_token_class_name( 'tbkkt-flex-direction-', (string) ( $attrs['flexDirectionTablet'] ?? '' ), array( 'row', 'column', 'row-reverse', 'column-reverse' ) ); if ( $dir_tablet !== '' ) : $classes[] = $dir_tablet . '-tablet'; endif; $dir_mobile = tbkkt_layout_build_mapped_token_class_name( 'tbkkt-flex-direction-', (string) ( $attrs['flexDirectionMobile'] ?? '' ), array( 'row', 'column', 'row-reverse', 'column-reverse' ) ); if ( $dir_mobile !== '' ) : $classes[] = $dir_mobile . '-mobile'; endif; $wrap = tbkkt_layout_build_mapped_token_class_name( 'tbkkt-flex-wrap-', (string) ( $attrs['flexWrap'] ?? '' ), array( 'nowrap', 'wrap', 'wrap-reverse' ) ); if ( $wrap !== '' ) : $classes[] = $wrap; endif; $wrap_tablet = tbkkt_layout_build_mapped_token_class_name( 'tbkkt-flex-wrap-', (string) ( $attrs['flexWrapTablet'] ?? '' ), array( 'nowrap', 'wrap', 'wrap-reverse' ) ); if ( $wrap_tablet !== '' ) : $classes[] = $wrap_tablet . '-tablet'; endif; $wrap_mobile = tbkkt_layout_build_mapped_token_class_name( 'tbkkt-flex-wrap-', (string) ( $attrs['flexWrapMobile'] ?? '' ), array( 'nowrap', 'wrap', 'wrap-reverse' ) ); if ( $wrap_mobile !== '' ) : $classes[] = $wrap_mobile . '-mobile'; endif; $justify = tbkkt_block_markup_sanitize_class_slug( str_replace( array( '_', ' ' ), '-', (string) ( $attrs['flexJustify'] ?? '' ) ) ); $justify_allowed = array( 'flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'space-evenly' ); if ( in_array( $justify, $justify_allowed, true ) ) : $classes[] = 'tbkkt-justify-content-' . $justify; endif; $justify_tablet = tbkkt_block_markup_sanitize_class_slug( str_replace( array( '_', ' ' ), '-', (string) ( $attrs['flexJustifyTablet'] ?? '' ) ) ); if ( in_array( $justify_tablet, $justify_allowed, true ) ) : $classes[] = 'tbkkt-justify-content-' . $justify_tablet . '-tablet'; endif; $justify_mobile = tbkkt_block_markup_sanitize_class_slug( str_replace( array( '_', ' ' ), '-', (string) ( $attrs['flexJustifyMobile'] ?? '' ) ) ); if ( in_array( $justify_mobile, $justify_allowed, true ) ) : $classes[] = 'tbkkt-justify-content-' . $justify_mobile . '-mobile'; endif; $align = tbkkt_block_markup_sanitize_class_slug( str_replace( array( '_', ' ' ), '-', (string) ( $attrs['flexAlign'] ?? '' ) ) ); $align_allowed = array( 'flex-start', 'flex-end', 'center', 'stretch', 'baseline' ); if ( in_array( $align, $align_allowed, true ) ) : $classes[] = 'tbkkt-align-items-' . $align; endif; $align_tablet = tbkkt_block_markup_sanitize_class_slug( str_replace( array( '_', ' ' ), '-', (string) ( $attrs['flexAlignTablet'] ?? '' ) ) ); if ( in_array( $align_tablet, $align_allowed, true ) ) : $classes[] = 'tbkkt-align-items-' . $align_tablet . '-tablet'; endif; $align_mobile = tbkkt_block_markup_sanitize_class_slug( str_replace( array( '_', ' ' ), '-', (string) ( $attrs['flexAlignMobile'] ?? '' ) ) ); if ( in_array( $align_mobile, $align_allowed, true ) ) : $classes[] = 'tbkkt-align-items-' . $align_mobile . '-mobile'; endif; $children_width_mode = isset( $attrs['childrenWidthMode'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['childrenWidthMode'] ) : ''; if ( in_array( $children_width_mode, array( 'auto', 'equal' ), true ) ) : $classes[] = 'tbkkt-layout-children-' . $children_width_mode; endif; $children_width_mode_tablet = isset( $attrs['childrenWidthModeTablet'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['childrenWidthModeTablet'] ) : ''; if ( in_array( $children_width_mode_tablet, array( 'auto', 'equal' ), true ) ) : $classes[] = 'tbkkt-layout-children-' . $children_width_mode_tablet . '-tablet'; endif; $children_width_mode_mobile = isset( $attrs['childrenWidthModeMobile'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['childrenWidthModeMobile'] ) : ''; if ( in_array( $children_width_mode_mobile, array( 'auto', 'equal' ), true ) ) : $classes[] = 'tbkkt-layout-children-' . $children_width_mode_mobile . '-mobile'; endif; return $classes; }