2019-11-19 16:58:16 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Twenty Twenty support.
|
|
|
|
*
|
|
|
|
* @since 3.8.1
|
|
|
|
* @package WooCommerce/Classes
|
|
|
|
*/
|
|
|
|
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WC_Twenty_Twenty class.
|
|
|
|
*/
|
|
|
|
class WC_Twenty_Twenty {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Theme init.
|
|
|
|
*/
|
|
|
|
public static function init() {
|
|
|
|
|
|
|
|
// Change WooCommerce wrappers.
|
|
|
|
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
|
|
|
|
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
|
|
|
|
|
|
|
|
add_action( 'woocommerce_before_main_content', array( __CLASS__, 'output_content_wrapper' ), 10 );
|
|
|
|
add_action( 'woocommerce_after_main_content', array( __CLASS__, 'output_content_wrapper_end' ), 10 );
|
|
|
|
|
|
|
|
// This theme doesn't have a traditional sidebar.
|
|
|
|
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
|
|
|
|
|
|
|
|
// Enqueue theme compatibility styles.
|
|
|
|
add_filter( 'woocommerce_enqueue_styles', array( __CLASS__, 'enqueue_styles' ) );
|
|
|
|
|
|
|
|
// Register theme features.
|
|
|
|
add_theme_support( 'wc-product-gallery-zoom' );
|
|
|
|
add_theme_support( 'wc-product-gallery-lightbox' );
|
|
|
|
add_theme_support( 'wc-product-gallery-slider' );
|
|
|
|
add_theme_support(
|
|
|
|
'woocommerce',
|
|
|
|
array(
|
2019-11-24 08:51:15 +00:00
|
|
|
'thumbnail_image_width' => 450,
|
2019-11-19 18:36:10 +00:00
|
|
|
'single_image_width' => 600,
|
2019-11-19 16:58:16 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2019-11-22 14:37:54 +00:00
|
|
|
// Background color change.
|
|
|
|
add_action( 'after_setup_theme', array( __CLASS__, 'set_white_background' ), 10 );
|
|
|
|
|
2019-11-19 16:58:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open the Twenty Twenty wrapper.
|
|
|
|
*/
|
|
|
|
public static function output_content_wrapper() {
|
|
|
|
echo '<section id="primary" class="content-area">';
|
|
|
|
echo '<main id="main" class="site-main">';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Close the Twenty Twenty wrapper.
|
|
|
|
*/
|
|
|
|
public static function output_content_wrapper_end() {
|
|
|
|
echo '</main>';
|
|
|
|
echo '</section>';
|
|
|
|
}
|
|
|
|
|
2019-11-26 19:54:04 +00:00
|
|
|
/**
|
|
|
|
* Set background color to white if it's default, otherwise don't touch it.
|
|
|
|
*/
|
2019-11-22 14:37:54 +00:00
|
|
|
public static function set_white_background() {
|
2019-12-20 17:21:08 +00:00
|
|
|
$background = sanitize_hex_color_no_hash( get_theme_mod( 'background_color' ) );
|
2019-11-22 14:37:54 +00:00
|
|
|
$background_default = 'f5efe0';
|
|
|
|
|
|
|
|
// Don't change user's choice of background color.
|
2019-11-26 19:54:04 +00:00
|
|
|
if ( ! empty( $background ) && $background !== $background_default ) {
|
2019-11-22 14:37:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In case default background is found, change it to white.
|
|
|
|
set_theme_mod( 'background_color', 'fff' );
|
|
|
|
}
|
|
|
|
|
2019-11-19 16:58:16 +00:00
|
|
|
/**
|
|
|
|
* Enqueue CSS for this theme.
|
|
|
|
*
|
|
|
|
* @param array $styles Array of registered styles.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function enqueue_styles( $styles ) {
|
|
|
|
unset( $styles['woocommerce-general'] );
|
|
|
|
|
|
|
|
$styles['woocommerce-general'] = array(
|
|
|
|
'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-twenty.css',
|
|
|
|
'deps' => '',
|
|
|
|
'version' => WC_VERSION,
|
|
|
|
'media' => 'all',
|
|
|
|
'has_rtl' => true,
|
|
|
|
);
|
|
|
|
|
|
|
|
return apply_filters( 'woocommerce_twenty_twenty_styles', $styles );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
WC_Twenty_Twenty::init();
|