functions.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php declare( strict_types = 1 ); ?>
  2. <?php
  3. /**
  4. * Elegant Business functions and definitions.
  5. *
  6. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  7. *
  8. * @package Elegant_Business
  9. */
  10. if ( ! function_exists( 'elegant_business_setup' ) ) :
  11. /**
  12. * Sets up theme defaults and registers support for various WordPress features.
  13. *
  14. * Note that this function is hooked into the after_setup_theme hook, which
  15. * runs before the init hook. The init hook is too late for some features, such
  16. * as indicating support for post thumbnails.
  17. */
  18. function elegant_business_setup() {
  19. /**
  20. * Add support for core custom logo.
  21. *
  22. * @link https://codex.wordpress.org/Theme_Logo
  23. */
  24. add_theme_support(
  25. 'custom-logo',
  26. array(
  27. 'height' => 128,
  28. 'width' => 190,
  29. 'flex-width' => true,
  30. 'flex-height' => false,
  31. 'header-text' => array( 'site-title' ),
  32. )
  33. );
  34. // Editor color palette.
  35. add_theme_support(
  36. 'editor-color-palette',
  37. array(
  38. array(
  39. 'name' => __( 'Primary', 'elegant-business' ),
  40. 'slug' => 'primary',
  41. 'color' => '#c43d80', // $color__link
  42. ),
  43. array(
  44. 'name' => __( 'Secondary', 'elegant-business' ),
  45. 'slug' => 'secondary',
  46. 'color' => '#9e3067', // $color__border-link-hover
  47. ),
  48. array(
  49. 'name' => __( 'Dark Gray', 'elegant-business' ),
  50. 'slug' => 'dark-gray',
  51. 'color' => '#111111', // $color__text-main
  52. ),
  53. array(
  54. 'name' => __( 'Light Gray', 'elegant-business' ),
  55. 'slug' => 'light-gray',
  56. 'color' => '#767676', // $color__text-light
  57. ),
  58. array(
  59. 'name' => __( 'White', 'elegant-business' ),
  60. 'slug' => 'white',
  61. 'color' => '#ffffff',
  62. ),
  63. )
  64. );
  65. }
  66. endif; // elegant_business_setup
  67. add_action( 'after_setup_theme', 'elegant_business_setup', 30 );
  68. // Our filter callback function
  69. function elegant_business_primary_color_hue() {
  70. // Hue
  71. return 330;
  72. }
  73. add_filter( 'twentynineteen_default_hue', 'elegant_business_primary_color_hue' );
  74. // Our filter callback function
  75. function elegant_business_primary_color_saturation() {
  76. // Saturation
  77. return 53;
  78. }
  79. add_filter( 'twentynineteen_default_saturation', 'elegant_business_primary_color_saturation' );
  80. // Our filter callback function
  81. function elegant_business_primary_color_lightness() {
  82. // Lightness
  83. return 50;
  84. }
  85. add_filter( 'twentynineteen_default_lightness', 'elegant_business_primary_color_lightness' );
  86. // Our filter callback function
  87. function elegant_business_primary_color_lightness_hover() {
  88. // Lightness
  89. return 40;
  90. }
  91. add_filter( 'twentynineteen_default_lightness_hover', 'elegant_business_primary_color_lightness_hover' );
  92. /**
  93. * Google font URLs.
  94. */
  95. function elegant_business_fonts_url() {
  96. $fonts_url = '';
  97. /* Translators: If there are characters in your language that are not
  98. * supported by Open Sans, translate this to 'off'. Do not translate
  99. * into your own language.
  100. */
  101. $source_serif_pro = esc_html_x( 'on', 'Source Serif Pro font: on or off', 'elegant-business' );
  102. if ( 'off' !== $source_serif_pro ) {
  103. $font_families = array();
  104. if ( 'off' !== $source_serif_pro ) {
  105. $font_families[] = 'Source Serif Pro:400,700,400italic';
  106. }
  107. /**
  108. * A filter to enable child themes to add/change/omit font families.
  109. *
  110. * @param array $font_families An array of font families to be imploded for the Google Font API
  111. */
  112. $font_families = apply_filters( 'included_google_font_families', $font_families );
  113. $query_args = array(
  114. 'family' => urlencode( implode( '|', $font_families ) ),
  115. 'subset' => urlencode( 'latin,latin-ext' ),
  116. );
  117. $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
  118. }
  119. return esc_url_raw( $fonts_url );
  120. }
  121. /**
  122. * Enqueue scripts and styles.
  123. */
  124. function elegant_business_scripts() {
  125. /**
  126. * Styles
  127. */
  128. wp_enqueue_style( 'elegant-business-fonts', elegant_business_fonts_url(), array(), null );
  129. // Replace print styles
  130. wp_dequeue_style( 'twentynineteen-print-style' );
  131. wp_enqueue_style( 'elegant-business-print-style', get_stylesheet_directory_uri() . '/print.css', array(), wp_get_theme()->get( 'Version' ), 'print' );
  132. }
  133. add_action( 'wp_enqueue_scripts', 'elegant_business_scripts', 99 );
  134. /**
  135. * Enqueue supplemental block editor scripts.
  136. */
  137. function elegant_business_block_editor_scripts() {
  138. /**
  139. * Styles
  140. */
  141. wp_enqueue_style( 'elegant-business-fonts', elegant_business_fonts_url(), array(), null );
  142. }
  143. add_action( 'enqueue_block_editor_assets', 'elegant_business_block_editor_scripts' );
  144. /**
  145. * Load extras.php file (if necessary).
  146. */
  147. require get_stylesheet_directory() . '/inc/extras.php';
  148. /**
  149. * Load wpcom compatibility file (if necessary).
  150. */
  151. require get_stylesheet_directory() . '/inc/wpcom.php';
  152. /**
  153. * Load Jetpack compatibility file.
  154. */
  155. require get_stylesheet_directory() . '/inc/jetpack.php';
  156. /**
  157. * Customizer additions.
  158. */
  159. require get_stylesheet_directory() . '/inc/customizer.php';