Ei kuvausta

class-wc-twenty-twenty-one.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Twenty Twenty One support.
  4. *
  5. * @since 4.7.0
  6. * @package WooCommerce\Classes
  7. */
  8. use Automattic\Jetpack\Constants;
  9. defined( 'ABSPATH' ) || exit;
  10. /**
  11. * WC_Twenty_Twenty_One class.
  12. */
  13. class WC_Twenty_Twenty_One {
  14. /**
  15. * Theme init.
  16. */
  17. public static function init() {
  18. // Change WooCommerce wrappers.
  19. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
  20. remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
  21. // This theme doesn't have a traditional sidebar.
  22. remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
  23. // Enqueue theme compatibility styles.
  24. add_filter( 'woocommerce_enqueue_styles', array( __CLASS__, 'enqueue_styles' ) );
  25. // Enqueue wp-admin compatibility styles.
  26. add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_admin_styles' ) );
  27. // Register theme features.
  28. add_theme_support( 'wc-product-gallery-zoom' );
  29. add_theme_support( 'wc-product-gallery-lightbox' );
  30. add_theme_support( 'wc-product-gallery-slider' );
  31. add_theme_support(
  32. 'woocommerce',
  33. array(
  34. 'thumbnail_image_width' => 450,
  35. 'single_image_width' => 600,
  36. )
  37. );
  38. }
  39. /**
  40. * Enqueue CSS for this theme.
  41. *
  42. * @param array $styles Array of registered styles.
  43. * @return array
  44. */
  45. public static function enqueue_styles( $styles ) {
  46. unset( $styles['woocommerce-general'] );
  47. $styles['woocommerce-general'] = array(
  48. 'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-twenty-one.css',
  49. 'deps' => '',
  50. 'version' => Constants::get_constant( 'WC_VERSION' ),
  51. 'media' => 'all',
  52. 'has_rtl' => true,
  53. );
  54. return apply_filters( 'woocommerce_twenty_twenty_one_styles', $styles );
  55. }
  56. /**
  57. * Enqueue the wp-admin CSS overrides for this theme.
  58. */
  59. public static function enqueue_admin_styles() {
  60. wp_enqueue_style(
  61. 'woocommerce-twenty-twenty-one-admin',
  62. str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-twenty-one-admin.css',
  63. '',
  64. Constants::get_constant( 'WC_VERSION' ),
  65. 'all'
  66. );
  67. }
  68. }
  69. WC_Twenty_Twenty_One::init();