class-wc-twenty-seventeen.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Twenty Seventeen support.
  4. *
  5. * @since 2.6.9
  6. * @package WooCommerce/Classes
  7. */
  8. defined( 'ABSPATH' ) || exit;
  9. /**
  10. * WC_Twenty_Seventeen class.
  11. */
  12. class WC_Twenty_Seventeen {
  13. /**
  14. * Theme init.
  15. */
  16. public static function init() {
  17. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
  18. remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
  19. add_action( 'woocommerce_before_main_content', array( __CLASS__, 'output_content_wrapper' ), 10 );
  20. add_action( 'woocommerce_after_main_content', array( __CLASS__, 'output_content_wrapper_end' ), 10 );
  21. add_filter( 'woocommerce_enqueue_styles', array( __CLASS__, 'enqueue_styles' ) );
  22. add_filter( 'twentyseventeen_custom_colors_css', array( __CLASS__, 'custom_colors_css' ), 10, 3 );
  23. add_theme_support( 'wc-product-gallery-zoom' );
  24. add_theme_support( 'wc-product-gallery-lightbox' );
  25. add_theme_support( 'wc-product-gallery-slider' );
  26. add_theme_support( 'woocommerce', array(
  27. 'thumbnail_image_width' => 250,
  28. 'single_image_width' => 350,
  29. ) );
  30. }
  31. /**
  32. * Enqueue CSS for this theme.
  33. *
  34. * @param array $styles Array of registered styles.
  35. * @return array
  36. */
  37. public static function enqueue_styles( $styles ) {
  38. unset( $styles['woocommerce-general'] );
  39. $styles['woocommerce-general'] = array(
  40. 'src' => str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/twenty-seventeen.css',
  41. 'deps' => '',
  42. 'version' => WC_VERSION,
  43. 'media' => 'all',
  44. 'has_rtl' => true,
  45. );
  46. return apply_filters( 'woocommerce_twenty_seventeen_styles', $styles );
  47. }
  48. /**
  49. * Open the Twenty Seventeen wrapper.
  50. */
  51. public static function output_content_wrapper() {
  52. echo '<div class="wrap">';
  53. echo '<div id="primary" class="content-area twentyseventeen">';
  54. echo '<main id="main" class="site-main" role="main">';
  55. }
  56. /**
  57. * Close the Twenty Seventeen wrapper.
  58. */
  59. public static function output_content_wrapper_end() {
  60. echo '</main>';
  61. echo '</div>';
  62. get_sidebar();
  63. echo '</div>';
  64. }
  65. /**
  66. * Custom colors.
  67. *
  68. * @param string $css Styles.
  69. * @param string $hue Color.
  70. * @param string $saturation Saturation.
  71. * @return string
  72. */
  73. public static function custom_colors_css( $css, $hue, $saturation ) {
  74. $css .= '
  75. .colors-custom .select2-container--default .select2-selection--single {
  76. border-color: hsl( ' . $hue . ', ' . $saturation . ', 73% );
  77. }
  78. .colors-custom .select2-container--default .select2-selection__rendered {
  79. color: hsl( ' . $hue . ', ' . $saturation . ', 40% );
  80. }
  81. .colors-custom .select2-container--default .select2-selection--single .select2-selection__arrow b {
  82. border-color: hsl( ' . $hue . ', ' . $saturation . ', 40% ) transparent transparent transparent;
  83. }
  84. .colors-custom .select2-container--focus .select2-selection {
  85. border-color: #000;
  86. }
  87. .colors-custom .select2-container--focus .select2-selection--single .select2-selection__arrow b {
  88. border-color: #000 transparent transparent transparent;
  89. }
  90. .colors-custom .select2-container--focus .select2-selection .select2-selection__rendered {
  91. color: #000;
  92. }
  93. ';
  94. return $css;
  95. }
  96. }
  97. WC_Twenty_Seventeen::init();