functions.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /**
  3. * Sophisticated Business (Twenty Nineteen) functions and definitions.
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Sophisticated_Business
  8. */
  9. if ( ! function_exists( 'sophisticated_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 sophisticated_business_setup() {
  18. // Switches Gutenberg controls to work against a dark background.
  19. add_theme_support( 'dark-editor-style' );
  20. /**
  21. * Add support for core custom logo.
  22. *
  23. * @link https://codex.wordpress.org/Theme_Logo
  24. */
  25. add_theme_support(
  26. 'custom-logo',
  27. array(
  28. 'height' => 120,
  29. 'width' => 190,
  30. 'flex-width' => true,
  31. 'flex-height' => false,
  32. 'header-text' => array( 'site-title' ),
  33. )
  34. );
  35. // Editor color palette.
  36. add_theme_support(
  37. 'editor-color-palette',
  38. array(
  39. array(
  40. 'name' => __( 'Primary', 'sophisticated-business' ),
  41. 'slug' => 'primary',
  42. 'color' => '#caab57', // $color__link
  43. ),
  44. array(
  45. 'name' => __( 'Secondary', 'sophisticated-business' ),
  46. 'slug' => 'secondary',
  47. 'color' => '#b59439', // $color__border-link-hover
  48. ),
  49. array(
  50. 'name' => __( 'Dark Gray', 'sophisticated-business' ),
  51. 'slug' => 'dark-gray',
  52. 'color' => '#1c1c1c', // $color__text-screen
  53. ),
  54. array(
  55. 'name' => __( 'Light Gray', 'sophisticated-business' ),
  56. 'slug' => 'light-gray',
  57. 'color' => '#cccccc', // $color__text-light
  58. ),
  59. array(
  60. 'name' => __( 'White', 'sophisticated-business' ),
  61. 'slug' => 'white',
  62. 'color' => '#ffffff',
  63. ),
  64. )
  65. );
  66. }
  67. endif; // sophisticated_business_setup
  68. add_action( 'after_setup_theme', 'sophisticated_business_setup', 30 );
  69. function sophisticated_business_fonts_url() {
  70. $fonts_url = '';
  71. /* Translators: If there are characters in your language that are not
  72. * supported by Open Sans, translate this to 'off'. Do not translate
  73. * into your own language.
  74. */
  75. $poppins = esc_html_x( 'on', 'Poppins font: on or off', 'sophisticated-business' );
  76. if ( 'off' !== $poppins ) {
  77. $font_families = array();
  78. if ( 'off' !== $poppins ) {
  79. $font_families[] = 'Poppins:400,600,700,400italic,600italic';
  80. }
  81. /**
  82. * A filter to enable child themes to add/change/omit font families.
  83. *
  84. * @param array $font_families An array of font families to be imploded for the Google Font API
  85. */
  86. $font_families = apply_filters( 'included_google_font_families', $font_families );
  87. $query_args = array(
  88. 'family' => urlencode( implode( '|', $font_families ) ),
  89. 'subset' => urlencode( 'latin,latin-ext' ),
  90. );
  91. $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
  92. }
  93. return esc_url_raw( $fonts_url );
  94. }
  95. /**
  96. * Enqueue scripts and styles.
  97. */
  98. function sophisticated_business_scripts() {
  99. /**
  100. * Styles
  101. */
  102. wp_enqueue_style( 'sophisticated-business-fonts', sophisticated_business_fonts_url(), array(), null );
  103. wp_enqueue_script( 'sophisticated-business-script', get_stylesheet_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150302', true );
  104. }
  105. add_action( 'wp_enqueue_scripts', 'sophisticated_business_scripts' );
  106. /**
  107. * Enqueue supplemental block editor scripts.
  108. */
  109. function sophisticated_business_block_editor_scripts() {
  110. /**
  111. * Block Editor Scripts
  112. */
  113. //wp_enqueue_script( 'sophisticated-business-block-editor-filters', get_theme_file_uri( '/js/block-editor-filters.js' ), array(), '1.0', true );
  114. /**
  115. * Fonts
  116. */
  117. wp_enqueue_style( 'sophisticated-business-fonts', sophisticated_business_fonts_url(), array(), null );
  118. }
  119. add_action( 'enqueue_block_editor_assets', 'sophisticated_business_block_editor_scripts' );
  120. /**
  121. * Filter default color from Twenty Nineteen.
  122. */
  123. // Our filter callback function - HUE
  124. function sophisticated_business_primary_color_hue() {
  125. return 44;
  126. }
  127. add_filter( 'twentynineteen_default_hue', 'sophisticated_business_primary_color_hue' );
  128. // Our filter callback function - SATURATION
  129. function sophisticated_business_primary_color_saturation() {
  130. return 52;
  131. }
  132. add_filter( 'twentynineteen_default_saturation', 'sophisticated_business_primary_color_saturation' );
  133. // Our filter callback function - LIGHTNESS
  134. function sophisticated_business_primary_color_lightness() {
  135. return 57;
  136. }
  137. add_filter( 'twentynineteen_default_lightness', 'sophisticated_business_primary_color_lightness' );
  138. // Filter hover colour - lightness value
  139. function sophisticated_business_primary_color_lightness_hover() {
  140. return 47;
  141. }
  142. add_filter( 'twentynineteen_default_lightness_hover', 'sophisticated_business_primary_color_lightness_hover' );
  143. /**
  144. * Load Jetpack compatibility file.
  145. */
  146. require get_stylesheet_directory() . '/inc/jetpack.php';
  147. /**
  148. * Customizer additions.
  149. */
  150. require get_stylesheet_directory() . '/inc/customizer.php';