Нема описа

class-wc-twenty-seventeen.php 3.3KB

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