), '.site-description' ); //Typography $typography_defaults = json_encode( array( 'font' => 'System default', 'regularweight' => 'regular', 'category' => 'sans-serif' ) ); $body_font = get_theme_mod( 'sydney_body_font', $typography_defaults ); $headings_font = get_theme_mod( 'sydney_headings_font', $typography_defaults ); $body_font = json_decode( $body_font, true ); $headings_font = json_decode( $headings_font, true ); if ( 'System default' !== $body_font['font'] ) { $custom .= 'body { font-family:' . esc_attr( $body_font['font'] ) . ',' . esc_attr( $body_font['category'] ) . '; font-weight: ' . esc_attr( $body_font['regularweight'] ) . ';}' . "\n"; } if ( 'System default' !== $headings_font['font'] ) { $custom .= 'h1,h2,h3,h4,h5,h6,.site-title { font-family:' . esc_attr( $headings_font['font'] ) . ',' . esc_attr( $headings_font['category'] ) . '; font-weight: ' . esc_attr( $headings_font['regularweight'] ) . ';}' . "\n"; } $enable_top_menu_typography = get_theme_mod( 'enable_top_menu_typography', 0 ); if ( $enable_top_menu_typography ) { $menu_font = get_theme_mod( 'sydney_menu_font', $typography_defaults ); $menu_font = json_decode( $menu_font, true ); $menu_text_transform = get_theme_mod( 'menu_items_text_transform' ); if ( 'System default' !== $menu_font['font'] ) { $custom .= '#mainnav > div > ul > li > a { font-family:' . esc_attr( $menu_font['font'] ) . ',' . esc_attr( $menu_font['category'] ) . '; font-weight: ' . esc_attr( $menu_font['regularweight'] ) . ';}' . "\n"; } $custom .= "#mainnav > div > ul > li > a { text-transform:" . esc_attr( $menu_text_transform ) . ";}" . "\n"; $custom .= $this->get_font_sizes_css( 'sydney_menu_font_size', $defaults = array( 'desktop' => 14, 'tablet' => 14, 'mobile' => 14 ), '#mainnav > div > ul > li' ); $custom .= $this->get_font_sizes_css( 'sydney_menu_font_size', $defaults = array( 'desktop' => 14, 'tablet' => 14, 'mobile' => 14 ), '.header-item' ); } $headings_font_style = get_theme_mod( 'headings_font_style' ); $headings_line_height = get_theme_mod( 'headings_line_height', 1.2 ); $headings_letter_spacing = get_theme_mod( 'headings_letter_spacing' ); $headings_text_transform = get_theme_mod( 'headings_text_transform' ); $headings_text_decoration = get_theme_mod( 'headings_text_decoration' ); $custom .= "h1,h2,h3,h4,h5,h6,.site-title { text-decoration:" . esc_attr( $headings_text_decoration ) . ";text-transform:" . esc_attr( $headings_text_transform ) . ";font-style:" . esc_attr( $headings_font_style ) . ";line-height:" . esc_attr( $headings_line_height ) . ";letter-spacing:" . esc_attr( $headings_letter_spacing ) . "px;}" . "\n"; $custom .= $this->get_font_sizes_css( 'h1_font_size', $defaults = array( 'desktop' => 48, 'tablet' => 42, 'mobile' => 32 ), 'h1:not(.site-title)' ); $custom .= $this->get_font_sizes_css( 'h2_font_size', $defaults = array( 'desktop' => 38, 'tablet' => 32, 'mobile' => 24 ), 'h2' ); $custom .= $this->get_font_sizes_css( 'h3_font_size', $defaults = array( 'desktop' => 32, 'tablet' => 24, 'mobile' => 20 ), 'h3' ); $custom .= $this->get_font_sizes_css( 'h4_font_size', $defaults = array( 'desktop' => 24, 'tablet' => 18, 'mobile' => 16 ), 'h4' ); $custom .= $this->get_font_sizes_css( 'h5_font_size', $defaults = array( 'desktop' => 20, 'tablet' => 16, 'mobile' => 16 ), 'h5' ); $custom .= $this->get_font_sizes_css( 'h6_font_size', $defaults = array( 'desktop' => 16, 'tablet' => 16, 'mobile' => 16 ), 'h6' ); $body_font_style = get_theme_mod( 'body_font_style' ); $body_line_height = get_theme_mod( 'body_line_height', 1.68 ); $body_letter_spacing = get_theme_mod( 'body_letter_spacing' ); $body_text_transform = get_theme_mod( 'body_text_transform' ); $body_text_decoration = get_theme_mod( 'body_text_decoration' ); $custom .= "p, .posts-layout .entry-post { text-decoration:" . esc_attr( $body_text_decoration ) . "}" . "\n"; $custom .= "body, .posts-layout .entry-post { text-transform:" . esc_attr( $body_text_transform ) . ";font-style:" . esc_attr( $body_font_style ) . ";line-height:" . esc_attr( $body_line_height ) . ";letter-spacing:" . esc_attr( $body_letter_spacing ) . "px;}" . "\n"; $custom .= $this->get_font_sizes_css( 'body_font_size', $defaults = array( 'desktop' => 16, 'tablet' => 16, 'mobile' => 16 ), 'body' ); //Woocommerce single $single_sku = get_theme_mod( 'single_product_sku', 1 ); $single_categories = get_theme_mod( 'single_product_categories', 1 ); $single_tags = get_theme_mod( 'single_product_tags', 1 ); $single_sticky_add_to_cart_elements_spacing = get_theme_mod( 'single_sticky_add_to_cart_elements_spacing', 35 ); if( !$single_sku ) { $custom .= ".single-product .product_meta .sku_wrapper { display: none }"; } if( !$single_categories ) { $custom .= ".single-product .product_meta .posted_in { display: none }"; } if( !$single_tags ) { $custom .= ".single-product .product_meta .tagged_as { display: none }"; } if( !$single_sku && !$single_categories && !$single_tags ) { $custom .= ".single-product .product_meta { border-top: 0; }"; } $custom .= $this->get_font_sizes_css( 'single_product_title_size', $defaults = array( 'desktop' => 32, 'tablet' => 32, 'mobile' => 32 ), '.woocommerce div.product .product-gallery-summary .entry-title' ); $custom .= $this->get_font_sizes_css( 'single_product_price_size', $defaults = array( 'desktop' => 24, 'tablet' => 24, 'mobile' => 24 ), '.woocommerce div.product .product-gallery-summary .price .amount' ); //Woocommerce loop $shop_product_element_spacing = get_theme_mod( 'shop_product_element_spacing', 12 ); $custom .= ".woocommerce ul.products li.product .col-md-7 > *,.woocommerce ul.products li.product .col-md-8 > *,.woocommerce ul.products li.product > * { margin-bottom:" . esc_attr( $shop_product_element_spacing ) . "px;}" . "\n"; $shop_product_sale_tag_layout = get_theme_mod( 'shop_product_sale_tag_layout', 'layout2' ); $shop_sale_tag_spacing = get_theme_mod( 'shop_sale_tag_spacing', 20 ); $shop_sale_tag_radius = get_theme_mod( 'shop_sale_tag_radius', 0 ); $custom .= ".wc-block-grid__product-onsale, span.onsale {border-radius:" . esc_attr( $shop_sale_tag_radius ) . "px;top:" . esc_attr( $shop_sale_tag_spacing ) . "px!important;left:" . esc_attr( $shop_sale_tag_spacing ) . "px!important;}" . "\n"; if ( 'layout2' === $shop_product_sale_tag_layout ) { $custom .= ".wc-block-grid__product-onsale, .products span.onsale {left:auto!important;right:" . esc_attr( $shop_sale_tag_spacing ) . "px;}" . "\n"; } $custom .= $this->get_color_css( 'single_product_sale_color', '', '.wc-block-grid__product-onsale, span.onsale' ); $custom .= $this->get_background_color_css( 'single_product_sale_background_color', '', '.wc-block-grid__product-onsale, span.onsale' ); $custom .= $this->get_color_css( 'shop_product_product_title', '', 'ul.wc-block-grid__products li.wc-block-grid__product .wc-block-grid__product-title, ul.wc-block-grid__products li.wc-block-grid__product .woocommerce-loop-product__title, ul.wc-block-grid__products li.product .wc-block-grid__product-title, ul.wc-block-grid__products li.product .woocommerce-loop-product__title, ul.products li.wc-block-grid__product .wc-block-grid__product-title, ul.products li.wc-block-grid__product .woocommerce-loop-product__title, ul.products li.product .wc-block-grid__product-title, ul.products li.product .woocommerce-loop-product__title, ul.products li.product .woocommerce-loop-category__title, .woocommerce-loop-product__title .botiga-wc-loop-product__title' ); $custom .= $this->get_color_css( 'color_body_text', '', 'a.wc-forward:not(.checkout-button)' ); $custom .= $this->get_color_css( 'color_link_hover', '', 'a.wc-forward:not(.checkout-button):hover' ); $custom .= $this->get_color_css( 'button_color_hover', '', '.woocommerce-pagination li .page-numbers:hover' ); $custom .= $this->get_border_color_rgba_css( 'color_body_text', '#212121', '.woocommerce-sorting-wrapper', '0.1' ); $shop_categories_alignment = get_theme_mod( 'shop_categories_alignment', 'center' ); $custom .= "ul.products li.product-category .woocommerce-loop-category__title { text-align:" . esc_attr( $shop_categories_alignment ) . ";}" . "\n"; $shop_categories_layout = get_theme_mod( 'shop_categories_layout', 'layout1' ); $shop_categories_radius = get_theme_mod( 'shop_categories_radius', 0 ); $custom .= "ul.products li.product-category > a, ul.products li.product-category > a > img { border-radius:" . esc_attr( $shop_categories_radius ) . "px;}" . "\n"; if( 'layout4' === $shop_categories_layout ) { $custom .= ".product-category-item-layout4 ul.products li.product-category > a h2 { border-radius: 0 0 " . esc_attr( $shop_categories_radius ) . "px " . esc_attr( $shop_categories_radius ) . "px;}" . "\n"; } //Cart display coupon form $shop_cart_show_coupon_form = get_theme_mod( 'shop_cart_show_coupon_form', 1 ); if( !$shop_cart_show_coupon_form ) { $custom .= '.woocommerce-cart .coupon { display: none; }'; } //Cart display coupon form $shop_checkout_show_coupon_form = get_theme_mod( 'shop_checkout_show_coupon_form', 1 ); if( !$shop_checkout_show_coupon_form ) { $custom .= '.woocommerce-checkout .woocommerce-form-coupon-toggle { display: none; }'; } $shop_product_card_style = get_theme_mod( 'shop_product_card_style', 'layout1' ); $shop_product_card_border_color = get_theme_mod( 'shop_product_card_border_color', '#eee' ); $shop_product_card_border_size = get_theme_mod( 'shop_product_card_border_size', 1 ); $shop_product_card_background = get_theme_mod( 'shop_product_card_background' ); $shop_product_card_radius = get_theme_mod( 'shop_product_card_radius' ); $shop_product_card_thumb_radius = get_theme_mod( 'shop_product_card_thumb_radius' ); if ( 'layout2' === $shop_product_card_style || 'layout3' === $shop_product_card_style ) { $custom .= ".woocommerce-page ul.products li.product { background-color: " . esc_attr( $shop_product_card_background ) . ";border-radius: " . intval( $shop_product_card_radius ) . "px; border: " . intval( $shop_product_card_border_size ) . "px solid " . esc_attr( $shop_product_card_border_color ) . ";padding:30px;}" . "\n"; $custom .= "ul.products li.wc-block-grid__product .loop-image-wrap, ul.products li.product .loop-image-wrap { overflow:hidden;border-radius:" . esc_attr( $shop_product_card_thumb_radius ) . "px;}" . "\n"; } if ( 'layout3' === $shop_product_card_style ) { $custom .= "ul.wc-block-grid__products li.wc-block-grid__product .loop-image-wrap, ul.wc-block-grid__products li.product .loop-image-wrap, ul.products li.wc-block-grid__product .loop-image-wrap, ul.products li.product .loop-image-wrap { margin:-30px -30px 12px;}" . "\n"; } //Global colors $custom .= $this->get_color_css( 'color_link_default', '', '.entry-content a:not(.button):not(.elementor-button-link)' ); $custom .= $this->get_color_css( 'color_link_hover', '', '.entry-content a:not(.button):not(.elementor-button-link):hover' ); $custom .= $this->get_color_css( 'color_heading_1', '', 'h1' ); $custom .= $this->get_color_css( 'color_heading_2', '', 'h2' ); $custom .= $this->get_color_css( 'color_heading_3', '', 'h3' ); $custom .= $this->get_color_css( 'color_heading_4', '', 'h4' ); $custom .= $this->get_color_css( 'color_heading_5', '', 'h5' ); $custom .= $this->get_color_css( 'color_heading_6', '', 'h6' ); $custom .= $this->get_color_css( 'color_forms_text', '', 'div.wpforms-container-full .wpforms-form input[type=date], div.wpforms-container-full .wpforms-form input[type=datetime], div.wpforms-container-full .wpforms-form input[type=datetime-local], div.wpforms-container-full .wpforms-form input[type=email], div.wpforms-container-full .wpforms-form input[type=month], div.wpforms-container-full .wpforms-form input[type=number], div.wpforms-container-full .wpforms-form input[type=password], div.wpforms-container-full .wpforms-form input[type=range], div.wpforms-container-full .wpforms-form input[type=search], div.wpforms-container-full .wpforms-form input[type=tel], div.wpforms-container-full .wpforms-form input[type=text], div.wpforms-container-full .wpforms-form input[type=time], div.wpforms-container-full .wpforms-form input[type=url], div.wpforms-container-full .wpforms-form input[type=week], div.wpforms-container-full .wpforms-form select, div.wpforms-container-full .wpforms-form textarea,input[type="text"],input[type="email"],input[type="url"],input[type="password"],input[type="search"],input[type="number"],input[type="tel"],input[type="range"],input[type="date"],input[type="month"],input[type="week"],input[type="time"],input[type="datetime"],input[type="datetime-local"],input[type="color"],textarea,select,.woocommerce .select2-container .select2-selection--single,.woocommerce-page .select2-container .select2-selection--single,input[type="text"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="password"]:focus, input[type="search"]:focus, input[type="number"]:focus, input[type="tel"]:focus, input[type="range"]:focus, input[type="date"]:focus, input[type="month"]:focus, input[type="week"]:focus, input[type="time"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="color"]:focus, textarea:focus, select:focus, .woocommerce .select2-container .select2-selection--single:focus, .woocommerce-page .select2-container .select2-selection--single:focus,.select2-container--default .select2-selection--single .select2-selection__rendered,.wp-block-search .wp-block-search__input,.wp-block-search .wp-block-search__input:focus' ); $custom .= $this->get_background_color_css( 'color_forms_background', '', 'div.wpforms-container-full .wpforms-form input[type=date], div.wpforms-container-full .wpforms-form input[type=datetime], div.wpforms-container-full .wpforms-form input[type=datetime-local], div.wpforms-container-full .wpforms-form input[type=email], div.wpforms-container-full .wpforms-form input[type=month], div.wpforms-container-full .wpforms-form input[type=number], div.wpforms-container-full .wpforms-form input[type=password], div.wpforms-container-full .wpforms-form input[type=range], div.wpforms-container-full .wpforms-form input[type=search], div.wpforms-container-full .wpforms-form input[type=tel], div.wpforms-container-full .wpforms-form input[type=text], div.wpforms-container-full .wpforms-form input[type=time], div.wpforms-container-full .wpforms-form input[type=url], div.wpforms-container-full .wpforms-form input[type=week], div.wpforms-container-full .wpforms-form select, div.wpforms-container-full .wpforms-form textarea,input[type="text"],input[type="email"],input[type="url"],input[type="password"],input[type="search"],input[type="number"],input[type="tel"],input[type="range"],input[type="date"],input[type="month"],input[type="week"],input[type="time"],input[type="datetime"],input[type="datetime-local"],input[type="color"],textarea,select,.woocommerce .select2-container .select2-selection--single,.woocommerce-page .select2-container .select2-selection--single,.woocommerce-cart .woocommerce-cart-form .actions .coupon input[type="text"]' ); $color_forms_borders = get_theme_mod( 'color_forms_borders' ); $custom .= "div.wpforms-container-full .wpforms-form input[type=date], div.wpforms-container-full .wpforms-form input[type=datetime], div.wpforms-container-full .wpforms-form input[type=datetime-local], div.wpforms-container-full .wpforms-form input[type=email], div.wpforms-container-full .wpforms-form input[type=month], div.wpforms-container-full .wpforms-form input[type=number], div.wpforms-container-full .wpforms-form input[type=password], div.wpforms-container-full .wpforms-form input[type=range], div.wpforms-container-full .wpforms-form input[type=search], div.wpforms-container-full .wpforms-form input[type=tel], div.wpforms-container-full .wpforms-form input[type=text], div.wpforms-container-full .wpforms-form input[type=time], div.wpforms-container-full .wpforms-form input[type=url], div.wpforms-container-full .wpforms-form input[type=week], div.wpforms-container-full .wpforms-form select, div.wpforms-container-full .wpforms-form textarea,input[type=\"text\"],input[type=\"email\"],input[type=\"url\"],input[type=\"password\"],input[type=\"search\"],input[type=\"number\"],input[type=\"tel\"],input[type=\"range\"],input[type=\"date\"],input[type=\"month\"],input[type=\"week\"],input[type=\"time\"],input[type=\"datetime\"],input[type=\"datetime-local\"],input[type=\"color\"],textarea,select,.woocommerce .select2-container .select2-selection--single,.woocommerce-page .select2-container .select2-selection--single,.woocommerce-account fieldset,.woocommerce-account .woocommerce-form-login, .woocommerce-account .woocommerce-form-register,.woocommerce-cart .woocommerce-cart-form .actions .coupon input[type=\"text\"],.wp-block-search .wp-block-search__input { border-color:" . esc_attr( $color_forms_borders ) . ";}" . "\n"; $color_forms_placeholder = get_theme_mod( 'color_forms_placeholder' ); $custom .= "input::placeholder { color:" . esc_attr( $color_forms_placeholder ) . ";opacity:1;}" . "\n"; $custom .= "input:-ms-input-placeholder { color:" . esc_attr( $color_forms_placeholder ) . ";}" . "\n"; $custom .= "input::-ms-input-placeholder { color:" . esc_attr( $color_forms_placeholder ) . ";}" . "\n"; /* End porting */ //Container widths $container_width = get_theme_mod( 'container_width', 1170 ); if ( 1170 !== $container_width ) { $custom .= '@media (min-width: 1200px) { .container { width:100%;max-width: ' . intval( $container_width ) . 'px; } }'; } $narrow_container_width = get_theme_mod( 'narrow_container_width', 860 ); if ( 860 !== $narrow_container_width ) { $custom .= '@media (min-width: 1200px) { .container-narrow { width:100%;max-width: ' . intval( $narrow_container_width ) . 'px; } }'; } $custom = apply_filters( 'sydney_custom_css', $custom ); $custom = $this->minify( $custom ); return $custom; } /** * Print styles */ public function print_styles() { $custom = $this->output_css(); wp_add_inline_style( 'sydney-style-min', $custom ); wp_localize_script( 'sydney_customizer', 'sydney_theme_options', $this->customizer_js ); } /** * CSS code minification. */ private function minify( $css ) { $css = preg_replace( '/\s+/', ' ', $css ); $css = preg_replace( '/\/\*[^\!](.*?)\*\//', '', $css ); $css = preg_replace( '/(,|:|;|\{|}) /', '$1', $css ); $css = preg_replace( '/ (,|;|\{|})/', '$1', $css ); $css = preg_replace( '/(:| )0\.([0-9]+)(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}.${2}${3}', $css ); $css = preg_replace( '/(:| )(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/i', '${1}0', $css ); return trim( $css ); } /** * Get color CSS */ public static function get_background_color_css( $setting, $default, $selector, $important = false ) { $mod = get_theme_mod( $setting, $default ); Sydney_Custom_CSS::get_instance()->mount_customizer_js_options( $selector, $setting, 'background-color', '', $important ); return $selector . '{ background-color:' . esc_attr( $mod ) . ';}' . "\n"; } /** * Get color CSS */ public static function get_color_css( $setting, $default, $selector, $important = false ) { $mod = get_theme_mod( $setting, $default ); Sydney_Custom_CSS::get_instance()->mount_customizer_js_options( $selector, $setting, 'color', '', $important ); return $selector . '{ color:' . esc_attr( $mod ) . ';}' . "\n"; } /** * Get border color CSS */ public static function get_border_color_css( $setting, $default, $selector ) { $mod = get_theme_mod( $setting, $default ); return $selector . '{ border-color:' . esc_attr( $mod ) . ';}' . "\n"; } /** * Get fill CSS */ public static function get_fill_css( $setting, $default, $selector, $important = false ) { $mod = get_theme_mod( $setting, $default ); Sydney_Custom_CSS::get_instance()->mount_customizer_js_options( $selector, $setting, 'fill', '', $important ); return $selector . '{ fill:' . esc_attr( $mod ) . ';}' . "\n"; } /** * Get stroke CSS */ public static function get_stroke_css( $setting, $default, $selector ) { $mod = get_theme_mod( $setting, $default ); return $selector . '{ stroke:' . esc_attr( $mod ) . ';}' . "\n"; } //Font sizes public static function get_font_sizes_css( $setting, $defaults, $selector ) { $devices = array( 'desktop' => '@media (min-width: 992px)', 'tablet' => '@media (min-width: 576px) and (max-width: 991px)', 'mobile' => '@media (max-width: 575px)' ); $css = ''; foreach ( $devices as $device => $media ) { $mod = get_theme_mod( $setting . '_' . $device, $defaults[$device] ); $css .= $media . ' { ' . $selector . ' { font-size:' . intval( $mod ) . 'px;} }' . "\n"; } return $css; } public static function mount_customizer_js_options( $selector = '', $setting = '', $prop = '', $opacity = '', $important = false ) { $options = array( 'option' => $setting, 'selector' => $selector, 'prop' => $prop ); if( $opacity ) { $options[ 'rgba' ] = $opacity; } // if( strpos( $selector, ':after' ) !== FALSE || strpos( $selector, ':before' ) !== FALSE || strpos( $selector, ':hover' ) !== FALSE || $important ) { $options[ 'pseudo' ] = true; // } Sydney_Custom_CSS::get_instance()->customizer_js[] = $options; } //Max width public static function get_max_width_css( $setting, $defaults, $selector ) { $devices = array( 'desktop' => '@media (min-width: 992px)', 'tablet' => '@media (min-width: 576px) and (max-width: 991px)', 'mobile' => '@media (max-width: 575px)' ); $css = ''; foreach ( $devices as $device => $media ) { $mod = get_theme_mod( $setting . '_' . $device, $defaults[$device] ); $css .= $media . ' { ' . $selector . ' { max-width:' . intval( $mod ) . 'px;} }' . "\n"; } return $css; } //Max height public static function get_max_height_css( $setting, $defaults, $selector ) { $devices = array( 'desktop' => '@media (min-width: 992px)', 'tablet' => '@media (min-width: 576px) and (max-width: 991px)', 'mobile' => '@media (max-width: 575px)' ); $css = ''; foreach ( $devices as $device => $media ) { $mod = get_theme_mod( $setting . '_' . $device, $defaults[$device] ); $css .= $media . ' { ' . $selector . ' { max-height:' . intval( $mod ) . 'px;} }' . "\n"; } return $css; } //Top bottom padding public static function get_top_bottom_padding_css( $setting, $defaults, $selector ) { $devices = array( 'desktop' => '@media (min-width: 992px)', 'tablet' => '@media (min-width: 576px) and (max-width: 991px)', 'mobile' => '@media (max-width: 575px)' ); $css = ''; foreach ( $devices as $device => $media ) { $mod = get_theme_mod( $setting . '_' . $device, $defaults[$device] ); $css .= $media . ' { ' . $selector . ' { padding-top:' . intval( $mod ) . 'px;padding-bottom:' . intval( $mod ) . 'px;} }' . "\n"; } return $css; } //Left right padding public static function get_left_right_padding_css( $setting, $defaults, $selector ) { $devices = array( 'desktop' => '@media (min-width: 992px)', 'tablet' => '@media (min-width: 576px) and (max-width: 991px)', 'mobile' => '@media (max-width: 575px)' ); $css = ''; foreach ( $devices as $device => $media ) { $mod = get_theme_mod( $setting . '_' . $device, $defaults[$device] ); $css .= $media . ' { ' . $selector . ' { padding-left:' . intval( $mod ) . 'px;padding-right:' . intval( $mod ) . 'px;} }' . "\n"; } return $css; } public function hex2rgba($color, $opacity = false) { if ($color[0] == '#' ) { $color = substr( $color, 1 ); } $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); $rgb = array_map('hexdec', $hex); $opacity = 0.9; $output = 'rgba('.implode(",",$rgb).','.$opacity.')'; return $output; } /** * Get background color rgba CSS */ public static function get_background_color_rgba_css( $setting, $default, $selector, $opacity ) { $mod = get_theme_mod( $setting, $default ); return $selector . '{ background-color:' . esc_attr( Sydney_Custom_CSS::get_instance()->hex2rgba( $mod, $opacity ) ) . ';}' . "\n"; } /** * Get border color rgba CSS */ public static function get_border_color_rgba_css( $setting, $default, $selector, $opacity, $important = false ) { $mod = get_theme_mod( $setting, $default ); return $selector . '{ border-color:' . esc_attr( Sydney_Custom_CSS::get_instance()->hex2rgba( $mod, $opacity ) ) . ( $important ? '!important' : '' ) .';}' . "\n"; } } /** * Initialize class */ Sydney_Custom_CSS::get_instance(); endif;