functions.php 4.8 KB

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