'section', 'id' => self::SECTION_ID, 'title' => __( 'Sale Badge', 'brandy' ), 'panel' => WooCommercePanel::PANEL_ID, 'type' => 'brandy-section', 'description_hidden' => true, ); $configurations[] = array( 'configuration_type' => 'control', 'id' => self::SECTION_ID, 'label' => __( 'Sale Badge', '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( 'text_color' => '#ffffff', 'font_size' => array( 'unit' => 'px', 'value' => 14, 'min' => 10, 'max' => 30, ), 'text' => __( 'Sale!', 'brandy' ), //phpcs:ignore 'background_color' => 'rgb(255 172 112)', 'border' => array( 'width' => array( 'unit' => 'px', 'value' => 0, 'min' => 0, 'max' => 50, ), 'radius' => array( 'unit' => 'px', 'value' => 7, 'min' => 0, 'max' => 50, ), 'color' => '#000000', ), 'padding' => array( 'unit' => 'px', 'top' => 1, 'bottom' => 1, 'left' => 8, 'right' => 8, ), ); } public static function print_dynamic_css() { $settings = get_theme_mod( self::SECTION_ID ); $settings = empty( $settings ) ? self::get_default_value() : $settings; $css = ''; $variables = array(); $variables[] = '--wc-sale-badge-font-size:' . StylesDataHelpers::get_dimension_css( $settings['font_size'] ); $variables[] = '--wc-sale-badge-text-color:' . $settings['text_color']; $variables[] = '--wc-sale-badge-background-color:' . $settings['background_color']; $variables[] = '--wc-sale-badge-border-width:' . StylesDataHelpers::get_dimension_css( $settings['border']['width'] ); $variables[] = '--wc-sale-badge-border-radius:' . StylesDataHelpers::get_dimension_css( $settings['border']['radius'] ); $variables[] = '--wc-sale-badge-border-color:' . $settings['border']['color']; $variables[] = '--wc-sale-badge-padding:' . StylesDataHelpers::get_spacing_css( $settings['padding'] ); $css .= 'body{' . implode( ';', $variables ) . '}'; echo wp_kses_post( $css ); } }