mirror of
https://github.com/woocommerce/storefront.git
synced 2025-08-21 04:11:59 +08:00
WooCommerce customizer class file
This commit is contained in:
parent
18a966db26
commit
ebc504730b
3 changed files with 365 additions and 243 deletions
|
@ -56,8 +56,6 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
'storefront_button_alt_background_color' => '#333333',
|
||||
'storefront_button_alt_text_color' => '#ffffff',
|
||||
'storefront_layout' => 'right',
|
||||
'storefront_sticky_add_to_cart' => true,
|
||||
'storefront_product_pagination' => true,
|
||||
'background_color' => 'ffffff',
|
||||
) );
|
||||
}
|
||||
|
@ -106,20 +104,6 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the WordPress core custom header feature.
|
||||
*
|
||||
* @deprecated 2.4.0
|
||||
* @return void
|
||||
*/
|
||||
public function custom_header_setup() {
|
||||
if ( function_exists( 'wc_deprecated_function' ) ) {
|
||||
wc_deprecated_function( __FUNCTION__, '2.4.0' );
|
||||
} else {
|
||||
_deprecated_function( __FUNCTION__, '2.4.0' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add postMessage support for site title and description for the Theme Customizer along with several other settings.
|
||||
*
|
||||
|
@ -470,40 +454,6 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
),
|
||||
) ) );
|
||||
|
||||
/**
|
||||
* Product Page
|
||||
*/
|
||||
$wp_customize->add_section( 'storefront_single_product_page' , array(
|
||||
'title' => __( 'Product Page', 'storefront' ),
|
||||
'priority' => 60,
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'storefront_product_pagination', array(
|
||||
'default' => apply_filters( 'storefront_default_product_pagination', true ),
|
||||
'sanitize_callback' => 'wp_validate_boolean',
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'storefront_sticky_add_to_cart', array(
|
||||
'default' => apply_filters( 'storefront_default_sticky_add_to_cart', true ),
|
||||
'sanitize_callback' => 'wp_validate_boolean',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'storefront_sticky_add_to_cart', array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'storefront_single_product_page',
|
||||
'label' => __( 'Sticky Add-To-Cart', 'storefront' ),
|
||||
'description' => __( 'A small content bar at the top of the browser window which includes relevant product information and an add-to-cart button. It slides into view once the standard add-to-cart button has scrolled out of view.', 'storefront' ),
|
||||
'priority' => 10,
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'storefront_product_pagination', array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'storefront_single_product_page',
|
||||
'label' => __( 'Product Pagination', 'storefront' ),
|
||||
'description' => __( 'Displays next and previous links on product pages. A product thumbnail is displayed with the title revealed on hover.', 'storefront' ),
|
||||
'priority' => 20,
|
||||
) );
|
||||
|
||||
/**
|
||||
* More
|
||||
*/
|
||||
|
@ -586,9 +536,6 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
.main-navigation ul li a:hover,
|
||||
.main-navigation ul li:hover > a,
|
||||
.site-title a:hover,
|
||||
a.cart-contents:hover,
|
||||
.site-header-cart .widget_shopping_cart a:hover,
|
||||
.site-header-cart:hover > li > a,
|
||||
.site-header ul.menu li.current-menu-item > a {
|
||||
color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['header_link_color'], 65 ) . ';
|
||||
}
|
||||
|
@ -625,21 +572,12 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
color: ' . $storefront_theme_mods['header_text_color'] . ';
|
||||
}
|
||||
|
||||
.storefront-handheld-footer-bar ul li.cart .count,
|
||||
button.menu-toggle:after,
|
||||
button.menu-toggle:before,
|
||||
button.menu-toggle span:before {
|
||||
background-color: ' . $storefront_theme_mods['header_link_color'] . ';
|
||||
}
|
||||
|
||||
.storefront-handheld-footer-bar ul li.cart .count {
|
||||
color: ' . $storefront_theme_mods['header_background_color'] . ';
|
||||
}
|
||||
|
||||
.storefront-handheld-footer-bar ul li.cart .count {
|
||||
border-color: ' . $storefront_theme_mods['header_background_color'] . ';
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: ' . $storefront_theme_mods['heading_color'] . ';
|
||||
}
|
||||
|
@ -649,9 +587,7 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
}
|
||||
|
||||
body,
|
||||
.secondary-navigation a,
|
||||
.onsale,
|
||||
.pagination .page-numbers li .page-numbers:not(.current), .woocommerce-pagination .page-numbers li .page-numbers:not(.current) {
|
||||
.secondary-navigation a {
|
||||
color: ' . $storefront_theme_mods['text_color'] . ';
|
||||
}
|
||||
|
||||
|
@ -668,8 +604,6 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
a:focus,
|
||||
.button:focus,
|
||||
.button.alt:focus,
|
||||
.button.added_to_cart:focus,
|
||||
.button.wc-forward:focus,
|
||||
button:focus,
|
||||
input[type="button"]:focus,
|
||||
input[type="reset"]:focus,
|
||||
|
@ -677,31 +611,31 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
outline-color: ' . $storefront_theme_mods['accent_color'] . ';
|
||||
}
|
||||
|
||||
button, input[type="button"], input[type="reset"], input[type="submit"], .button, .added_to_cart, .widget a.button, .site-header-cart .widget_shopping_cart a.button {
|
||||
button, input[type="button"], input[type="reset"], input[type="submit"], .button, .widget a.button {
|
||||
background-color: ' . $storefront_theme_mods['button_background_color'] . ';
|
||||
border-color: ' . $storefront_theme_mods['button_background_color'] . ';
|
||||
color: ' . $storefront_theme_mods['button_text_color'] . ';
|
||||
}
|
||||
|
||||
button:hover, input[type="button"]:hover, input[type="reset"]:hover, input[type="submit"]:hover, .button:hover, .added_to_cart:hover, .widget a.button:hover, .site-header-cart .widget_shopping_cart a.button:hover {
|
||||
button:hover, input[type="button"]:hover, input[type="reset"]:hover, input[type="submit"]:hover, .button:hover, .widget a.button:hover {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['button_background_color'], $darken_factor ) . ';
|
||||
border-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['button_background_color'], $darken_factor ) . ';
|
||||
color: ' . $storefront_theme_mods['button_text_color'] . ';
|
||||
}
|
||||
|
||||
button.alt, input[type="button"].alt, input[type="reset"].alt, input[type="submit"].alt, .button.alt, .added_to_cart.alt, .widget-area .widget a.button.alt, .added_to_cart, .widget a.button.checkout {
|
||||
button.alt, input[type="button"].alt, input[type="reset"].alt, input[type="submit"].alt, .button.alt, .widget-area .widget a.button.alt {
|
||||
background-color: ' . $storefront_theme_mods['button_alt_background_color'] . ';
|
||||
border-color: ' . $storefront_theme_mods['button_alt_background_color'] . ';
|
||||
color: ' . $storefront_theme_mods['button_alt_text_color'] . ';
|
||||
}
|
||||
|
||||
button.alt:hover, input[type="button"].alt:hover, input[type="reset"].alt:hover, input[type="submit"].alt:hover, .button.alt:hover, .added_to_cart.alt:hover, .widget-area .widget a.button.alt:hover, .added_to_cart:hover, .widget a.button.checkout:hover {
|
||||
button.alt:hover, input[type="button"].alt:hover, input[type="reset"].alt:hover, input[type="submit"].alt:hover, .button.alt:hover, .widget-area .widget a.button.alt:hover {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['button_alt_background_color'], $darken_factor ) . ';
|
||||
border-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['button_alt_background_color'], $darken_factor ) . ';
|
||||
color: ' . $storefront_theme_mods['button_alt_text_color'] . ';
|
||||
}
|
||||
|
||||
.pagination .page-numbers li .page-numbers.current, .woocommerce-pagination .page-numbers li .page-numbers.current {
|
||||
.pagination .page-numbers li .page-numbers.current {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['background_color'], $darken_factor ) . ';
|
||||
color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['text_color'], -10 ) . ';
|
||||
}
|
||||
|
@ -731,23 +665,6 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
color: ' . $storefront_theme_mods['hero_text_color'] . ';
|
||||
}
|
||||
|
||||
#order_review {
|
||||
background-color: ' . $storefront_theme_mods['background_color'] . ';
|
||||
}
|
||||
|
||||
#payment .payment_methods > li .payment_box,
|
||||
#payment .place-order {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['background_color'], -5 ) . ';
|
||||
}
|
||||
|
||||
#payment .payment_methods > li:not(.woocommerce-notice) {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['background_color'], -10 ) . ';
|
||||
}
|
||||
|
||||
#payment .payment_methods > li:not(.woocommerce-notice):hover {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['background_color'], -15 ) . ';
|
||||
}
|
||||
|
||||
@media screen and ( min-width: 768px ) {
|
||||
.secondary-navigation ul.menu a:hover {
|
||||
color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['header_text_color'], $brighten_factor ) . ';
|
||||
|
@ -757,171 +674,19 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
color: ' . $storefront_theme_mods['header_text_color'] . ';
|
||||
}
|
||||
|
||||
.site-header-cart .widget_shopping_cart,
|
||||
.main-navigation ul.menu ul.sub-menu,
|
||||
.main-navigation ul.nav-menu ul.children {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['header_background_color'], -15 ) . ';
|
||||
}
|
||||
|
||||
.site-header-cart .widget_shopping_cart .buttons,
|
||||
.site-header-cart .widget_shopping_cart .total {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['header_background_color'], -10 ) . ';
|
||||
}
|
||||
|
||||
.site-header {
|
||||
border-bottom-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['header_background_color'], -15 ) . ';
|
||||
}
|
||||
}';
|
||||
|
||||
if ( ! class_exists( 'Storefront_Product_Pagination' ) ) {
|
||||
$styles .= '.storefront-product-pagination a {
|
||||
color: ' . $storefront_theme_mods['text_color'] . ';
|
||||
background-color: ' . $storefront_theme_mods['background_color'] . ';
|
||||
}';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'Storefront_Sticky_Add_to_Cart' ) ) {
|
||||
$styles .= '
|
||||
.storefront-sticky-add-to-cart {
|
||||
color: ' . $storefront_theme_mods['text_color'] . ';
|
||||
background-color: ' . $storefront_theme_mods['background_color'] . ';
|
||||
}
|
||||
|
||||
.storefront-sticky-add-to-cart a:not(.button) {
|
||||
color: ' . $storefront_theme_mods['header_link_color'] . ';
|
||||
}';
|
||||
}
|
||||
|
||||
return apply_filters( 'storefront_customizer_css', $styles );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Customizer css associated with WooCommerce.
|
||||
*
|
||||
* @see get_storefront_theme_mods()
|
||||
* @return array $woocommerce_styles the WooCommerce css
|
||||
*/
|
||||
public function get_woocommerce_css() {
|
||||
$storefront_theme_mods = $this->get_storefront_theme_mods();
|
||||
$brighten_factor = apply_filters( 'storefront_brighten_factor', 25 );
|
||||
$darken_factor = apply_filters( 'storefront_darken_factor', -25 );
|
||||
|
||||
$woocommerce_styles = '
|
||||
a.cart-contents,
|
||||
.site-header-cart .widget_shopping_cart a {
|
||||
color: ' . $storefront_theme_mods['header_link_color'] . ';
|
||||
}
|
||||
|
||||
table.cart td.product-remove,
|
||||
table.cart td.actions {
|
||||
border-top-color: ' . $storefront_theme_mods['background_color'] . ';
|
||||
}
|
||||
|
||||
.woocommerce-tabs ul.tabs li.active a,
|
||||
ul.products li.product .price,
|
||||
.onsale,
|
||||
.widget_search form:before,
|
||||
.widget_product_search form:before {
|
||||
color: ' . $storefront_theme_mods['text_color'] . ';
|
||||
}
|
||||
|
||||
.woocommerce-breadcrumb a,
|
||||
a.woocommerce-review-link,
|
||||
.product_meta a {
|
||||
color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['text_color'], 5 ) . ';
|
||||
}
|
||||
|
||||
.onsale {
|
||||
border-color: ' . $storefront_theme_mods['text_color'] . ';
|
||||
}
|
||||
|
||||
.star-rating span:before,
|
||||
.quantity .plus, .quantity .minus,
|
||||
p.stars a:hover:after,
|
||||
p.stars a:after,
|
||||
.star-rating span:before,
|
||||
#payment .payment_methods li input[type=radio]:first-child:checked+label:before {
|
||||
color: ' . $storefront_theme_mods['accent_color'] . ';
|
||||
}
|
||||
|
||||
.widget_price_filter .ui-slider .ui-slider-range,
|
||||
.widget_price_filter .ui-slider .ui-slider-handle {
|
||||
background-color: ' . $storefront_theme_mods['accent_color'] . ';
|
||||
}
|
||||
|
||||
.order_details {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['background_color'], -7 ) . ';
|
||||
}
|
||||
|
||||
.order_details > li {
|
||||
border-bottom: 1px dotted ' . storefront_adjust_color_brightness( $storefront_theme_mods['background_color'], -28 ) . ';
|
||||
}
|
||||
|
||||
.order_details:before,
|
||||
.order_details:after {
|
||||
background: -webkit-linear-gradient(transparent 0,transparent 0),-webkit-linear-gradient(135deg,' . storefront_adjust_color_brightness( $storefront_theme_mods['background_color'], -7 ) . ' 33.33%,transparent 33.33%),-webkit-linear-gradient(45deg,' . storefront_adjust_color_brightness( $storefront_theme_mods['background_color'], -7 ) . ' 33.33%,transparent 33.33%)
|
||||
}
|
||||
|
||||
p.stars a:before,
|
||||
p.stars a:hover~a:before,
|
||||
p.stars.selected a.active~a:before {
|
||||
color: ' . $storefront_theme_mods['text_color'] . ';
|
||||
}
|
||||
|
||||
p.stars.selected a.active:before,
|
||||
p.stars:hover a:before,
|
||||
p.stars.selected a:not(.active):before,
|
||||
p.stars.selected a.active:before {
|
||||
color: ' . $storefront_theme_mods['accent_color'] . ';
|
||||
}
|
||||
|
||||
.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__trigger {
|
||||
background-color: ' . $storefront_theme_mods['button_background_color'] . ';
|
||||
color: ' . $storefront_theme_mods['button_text_color'] . ';
|
||||
}
|
||||
|
||||
.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__trigger:hover {
|
||||
background-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['button_background_color'], $darken_factor ) . ';
|
||||
border-color: ' . storefront_adjust_color_brightness( $storefront_theme_mods['button_background_color'], $darken_factor ) . ';
|
||||
color: ' . $storefront_theme_mods['button_text_color'] . ';
|
||||
}
|
||||
|
||||
.button.loading {
|
||||
color: ' . $storefront_theme_mods['button_background_color'] . ';
|
||||
}
|
||||
|
||||
.button.loading:hover {
|
||||
background-color: ' . $storefront_theme_mods['button_background_color'] . ';
|
||||
}
|
||||
|
||||
.button.loading:after {
|
||||
color: ' . $storefront_theme_mods['button_text_color'] . ';
|
||||
}
|
||||
|
||||
@media screen and ( min-width: 768px ) {
|
||||
.site-header-cart .widget_shopping_cart,
|
||||
.site-header .product_list_widget li .quantity {
|
||||
color: ' . $storefront_theme_mods['header_text_color'] . ';
|
||||
}
|
||||
}';
|
||||
|
||||
return apply_filters( 'storefront_customizer_woocommerce_css', $woocommerce_styles );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign Storefront styles to individual theme mods.
|
||||
*
|
||||
* @deprecated 2.3.1
|
||||
* @return void
|
||||
*/
|
||||
public function set_storefront_style_theme_mods() {
|
||||
if ( function_exists( 'wc_deprecated_function' ) ) {
|
||||
wc_deprecated_function( __FUNCTION__, '2.3.1' );
|
||||
} else {
|
||||
_deprecated_function( __FUNCTION__, '2.3.1' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CSS in <head> for styles handled by the theme customizer
|
||||
*
|
||||
|
@ -930,7 +695,6 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
*/
|
||||
public function add_customizer_css() {
|
||||
wp_add_inline_style( 'storefront-style', $this->get_css() );
|
||||
wp_add_inline_style( 'storefront-woocommerce-style', $this->get_woocommerce_css() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1036,6 +800,48 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the WordPress core custom header feature.
|
||||
*
|
||||
* @deprecated 2.4.0
|
||||
* @return void
|
||||
*/
|
||||
public function custom_header_setup() {
|
||||
if ( function_exists( 'wc_deprecated_function' ) ) {
|
||||
wc_deprecated_function( __FUNCTION__, '2.4.0' );
|
||||
} else {
|
||||
_deprecated_function( __FUNCTION__, '2.4.0' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Customizer css associated with WooCommerce.
|
||||
*
|
||||
* @deprecated 2.4.0
|
||||
* @return void
|
||||
*/
|
||||
public function get_woocommerce_css() {
|
||||
if ( function_exists( 'wc_deprecated_function' ) ) {
|
||||
wc_deprecated_function( __FUNCTION__, '2.3.1' );
|
||||
} else {
|
||||
_deprecated_function( __FUNCTION__, '2.3.1' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign Storefront styles to individual theme mods.
|
||||
*
|
||||
* @deprecated 2.3.1
|
||||
* @return void
|
||||
*/
|
||||
public function set_storefront_style_theme_mods() {
|
||||
if ( function_exists( 'wc_deprecated_function' ) ) {
|
||||
wc_deprecated_function( __FUNCTION__, '2.3.1' );
|
||||
} else {
|
||||
_deprecated_function( __FUNCTION__, '2.3.1' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue