Merge pull request #28134 from woocommerce/add/2021-compat
Add support for Twenty Twenty-One theme
This commit is contained in:
commit
686872a237
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Admin
|
||||
*/
|
||||
.wp-admin.woocommerce-page {
|
||||
table.wp-list-table {
|
||||
tr.type-product {
|
||||
td.thumb {
|
||||
img {
|
||||
max-width: 40px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -530,6 +530,9 @@ final class WooCommerce {
|
|||
case 'twentytwenty':
|
||||
include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-twenty.php';
|
||||
break;
|
||||
case 'twentytwentyone':
|
||||
include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-twenty-one.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/**
|
||||
* Twenty Twenty One support.
|
||||
*
|
||||
* @since 4.7.0
|
||||
* @package WooCommerce\Classes
|
||||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Twenty_Twenty_One class.
|
||||
*/
|
||||
class WC_Twenty_Twenty_One {
|
||||
|
||||
/**
|
||||
* 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' ) );
|
||||
|
||||
// Enqueue wp-admin compatibility styles.
|
||||
add_action( 'admin_enqueue_scripts', array( __CLASS__ , 'enqueue_admin_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(
|
||||
'thumbnail_image_width' => 450,
|
||||
'single_image_width' => 600,
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the Twenty Twenty One 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 One wrapper.
|
||||
*/
|
||||
public static function output_content_wrapper_end() {
|
||||
echo '</main>';
|
||||
echo '</section>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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-one.css',
|
||||
'deps' => '',
|
||||
'version' => Constants::get_constant( 'WC_VERSION' ),
|
||||
'media' => 'all',
|
||||
'has_rtl' => true,
|
||||
);
|
||||
|
||||
return apply_filters( 'woocommerce_twenty_twenty_one_styles', $styles );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the wp-admin CSS overrides for this theme.
|
||||
*/
|
||||
public static function enqueue_admin_styles() {
|
||||
wp_enqueue_style(
|
||||
'woocommerce-twenty-twenty-one-admin',
|
||||
str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-twenty-one-admin.css',
|
||||
'',
|
||||
Constants::get_constant( 'WC_VERSION' ),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
WC_Twenty_Twenty_One::init();
|
|
@ -2336,6 +2336,7 @@ function wc_is_active_theme( $theme ) {
|
|||
function wc_is_wp_default_theme_active() {
|
||||
return wc_is_active_theme(
|
||||
array(
|
||||
'twentytwentyone',
|
||||
'twentytwenty',
|
||||
'twentynineteen',
|
||||
'twentyseventeen',
|
||||
|
|
Loading…
Reference in New Issue