Components -> Container * */ if ( ! defined( 'ABSPATH' ) ) exit; function tbkkt_container_get_allowed_tag_names(): array { return array( 'div', 'section', 'article', 'header', 'footer', 'aside', 'nav', 'main' ); } function tbkkt_container_sanitize_tag_name( string $tag ): string { $tag = strtolower( trim( $tag ) ); return in_array( $tag, tbkkt_container_get_allowed_tag_names(), true ) ? $tag : 'div'; } function tbkkt_container_append_custom_width_style( array &$parts, array $attrs, string $mode_key, string $width_key, string $css_var ): void { if ( ! isset( $attrs[ $mode_key ] ) || (string) $attrs[ $mode_key ] !== 'custom' ) return; $width = tbkkt_style_value_sanitize_length( (string) ( $attrs[ $width_key ] ?? '' ) ); if ( $width === '' ) return; $parts[] = $css_var . ':' . $width . ';'; } function tbkkt_container_build_outer_class_names( array $attrs ): array { $classes = array( 'tbkkt-container' ); $allowed_modes = array( 'none', 'wide', 'full', 'custom' ); $block_mode = isset( $attrs['blockWidthMode'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['blockWidthMode'] ) : 'none'; if ( ! in_array( $block_mode, $allowed_modes, true ) ) $block_mode = 'none'; $classes[] = 'tbkkt-container-width-' . $block_mode; $block_mode_tablet = isset( $attrs['blockWidthModeTablet'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['blockWidthModeTablet'] ) : ''; if ( in_array( $block_mode_tablet, $allowed_modes, true ) ) : $classes[] = 'tbkkt-container-width-' . $block_mode_tablet . '-tablet'; endif; $block_mode_mobile = isset( $attrs['blockWidthModeMobile'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['blockWidthModeMobile'] ) : ''; if ( in_array( $block_mode_mobile, $allowed_modes, true ) ) : $classes[] = 'tbkkt-container-width-' . $block_mode_mobile . '-mobile'; endif; return $classes; } function tbkkt_container_build_outer_style_declarations( array $attrs ): string { $parts = array(); tbkkt_container_append_custom_width_style( $parts, $attrs, 'blockWidthMode', 'blockCustomMaxWidth', '--tbkkt--container--width' ); tbkkt_container_append_custom_width_style( $parts, $attrs, 'blockWidthModeTablet', 'blockCustomMaxWidthTablet', '--tbkkt--container--width--tablet' ); tbkkt_container_append_custom_width_style( $parts, $attrs, 'blockWidthModeMobile', 'blockCustomMaxWidthMobile', '--tbkkt--container--width--mobile' ); return implode( '', $parts ); } function tbkkt_container_build_inner_class_names( array $attrs ): array { $allowed_modes = array( 'none', 'wide', 'full', 'custom' ); $classes = array( 'tbkkt-container-inner' ); $content_mode = isset( $attrs['contentWidthMode'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['contentWidthMode'] ) : 'none'; if ( ! in_array( $content_mode, $allowed_modes, true ) ) : $content_mode = 'none'; endif; $classes[] = 'tbkkt-content-width-' . $content_mode; $content_mode_tablet = isset( $attrs['contentWidthModeTablet'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['contentWidthModeTablet'] ) : ''; if ( in_array( $content_mode_tablet, $allowed_modes, true ) ) : $classes[] = 'tbkkt-content-width-' . $content_mode_tablet . '-tablet'; endif; $content_mode_mobile = isset( $attrs['contentWidthModeMobile'] ) ? tbkkt_block_markup_sanitize_class_slug( (string) $attrs['contentWidthModeMobile'] ) : ''; if ( in_array( $content_mode_mobile, $allowed_modes, true ) ) : $classes[] = 'tbkkt-content-width-' . $content_mode_mobile . '-mobile'; endif; return $classes; } function tbkkt_container_build_inner_style_declarations( array $attrs ): string { $parts = array(); tbkkt_container_append_custom_width_style( $parts, $attrs, 'contentWidthMode', 'contentCustomMaxWidth', '--tbkkt--content--width' ); tbkkt_container_append_custom_width_style( $parts, $attrs, 'contentWidthModeTablet', 'contentCustomMaxWidthTablet', '--tbkkt--content--width--tablet' ); tbkkt_container_append_custom_width_style( $parts, $attrs, 'contentWidthModeMobile', 'contentCustomMaxWidthMobile', '--tbkkt--content--width--mobile' ); return implode( '', $parts ); }