'section', 'id' => self::SECTION_ID, 'title' => __( 'Content Settings', 'brandy' ), 'panel' => GeneralPanel::PANEL_ID, 'type' => 'brandy-section', 'description_hidden' => true, ); $configurations[] = array( 'configuration_type' => 'control', 'id' => self::SECTION_ID, 'label' => __( 'Content Settings', 'brandy' ), 'section' => self::SECTION_ID, 'type' => 'brandy_settings', 'input_attrs' => array( 'value' => '', 'style' => 'display:none;', ), 'partial' => false, 'default' => self::get_default_value(), 'transport' => 'postMessage', ); return $configurations; } public static function get_default_value() { return array( 'page' => array( 'container_width' => array( 'desktop' => array( 'unit' => '%', 'value' => 100, 'min' => 30, 'max' => 100, ), 'tablet' => null, 'mobile' => null, ), 'container_max_width' => array( 'desktop' => array( 'unit' => 'px', 'value' => 1500, 'min' => 300, 'max' => 2000, ), 'tablet' => null, 'mobile' => null, ), ), 'post' => array( 'container_width' => array( 'desktop' => array( 'unit' => '%', 'value' => 100, 'min' => 30, 'max' => 100, ), 'tablet' => null, 'mobile' => null, ), 'container_max_width' => array( 'desktop' => array( 'unit' => 'px', 'value' => 1500, 'min' => 300, 'max' => 2000, ), 'tablet' => null, 'mobile' => null, ), ), 'home' => array( 'container_width' => array( 'desktop' => array( 'unit' => '%', 'value' => 100, 'min' => 30, 'max' => 100, ), 'tablet' => null, 'mobile' => null, ), 'container_max_width' => array( 'desktop' => array( 'unit' => 'px', 'value' => 1500, 'min' => 300, 'max' => 2000, ), 'tablet' => null, 'mobile' => null, ), ), 'content_spacing' => 'normal', 'content_line_height' => array( 'desktop' => 2, 'tablet' => null, 'mobile' => null, ), ); } public static function print_global_css() { $settings = get_theme_mod( self::SECTION_ID ); $settings = empty( $settings ) ? self::get_default_value() : $settings; $css = ''; $css .= ':root{' . self::get_content_spacing_style( $settings['content_spacing'] ) . '}'; foreach ( array( 'home', 'post', 'page' ) as $page_type ) { if ( ! isset( $settings[ $page_type ] ) ) { continue; } $css .= implode( ' ', self::get_container_width_style( $settings[ $page_type ]['container_width'], $page_type ) ); $css .= implode( ' ', self::get_container_max_width_style( $settings[ $page_type ]['container_max_width'], $page_type ) ); } echo wp_kses_post( $css ); } public static function get_content_spacing_style( $value = 'normal' ) { if ( 'normal' === $value ) { return '--content-spacing:1.5em;'; } if ( 'loose' === $value ) { return '--content-spacing:3em;'; } return '--content-spacing:0.7em;'; } public static function get_container_width_style( $data, $page_type ) { $styles = array(); foreach ( array_keys( $data ) as $device ) { if ( ! in_array( $device, brandy_get_devices(), true ) ) { continue; } $css = 'body[page-type="' . $page_type . '"]{ --theme-container-width:' . StylesDataHelpers::get_dimension_css( Helpers::get_device_value( $data, $device ) ) . ';}'; if ( 'desktop' === $device ) { $styles[] = $css; } if ( 'tablet' === $device ) { $styles[] = DynamicCss::wrap_tablet_responsive( $css ); } if ( 'mobile' === $device ) { $styles[] = DynamicCss::wrap_mobile_responsive( $css ); } } return $styles; } public static function get_container_max_width_style( $data, $page_type ) { $styles = array(); foreach ( array_keys( $data ) as $device ) { if ( ! in_array( $device, brandy_get_devices(), true ) ) { continue; } $css = 'body[page-type="' . $page_type . '"]{ --theme-container-max-width:' . StylesDataHelpers::get_dimension_css( Helpers::get_device_value( $data, $device ) ) . ';}'; if ( 'desktop' === $device ) { $styles[] = $css; } if ( 'tablet' === $device ) { $styles[] = DynamicCss::wrap_tablet_responsive( $css ); } if ( 'mobile' === $device ) { $styles[] = DynamicCss::wrap_mobile_responsive( $css ); } } return $styles; } }