functions.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. $query_args = array(
  82. 'family' => urlencode( implode( '|', $font_families ) ),
  83. 'subset' => urlencode( 'latin,latin-ext' ),
  84. );
  85. $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
  86. }
  87. return esc_url_raw( $fonts_url );
  88. }
  89. /**
  90. * Enqueue scripts and styles.
  91. */
  92. function sophisticated_business_scripts() {
  93. /**
  94. * Styles
  95. */
  96. wp_enqueue_style( 'sophisticated-business-fonts', sophisticated_business_fonts_url(), array(), null );
  97. wp_enqueue_script( 'sophisticated-business-script', get_stylesheet_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150302', true );
  98. }
  99. add_action( 'wp_enqueue_scripts', 'sophisticated_business_scripts' );
  100. /**
  101. * Enqueue supplemental block editor scripts.
  102. */
  103. function sophisticated_business_block_editor_scripts() {
  104. /**
  105. * Block Editor Scripts
  106. */
  107. //wp_enqueue_script( 'sophisticated-business-block-editor-filters', get_theme_file_uri( '/js/block-editor-filters.js' ), array(), '1.0', true );
  108. /**
  109. * Fonts
  110. */
  111. wp_enqueue_style( 'sophisticated-business-fonts', sophisticated_business_fonts_url(), array(), null );
  112. }
  113. add_action( 'enqueue_block_editor_assets', 'sophisticated_business_block_editor_scripts' );
  114. /**
  115. * Filter default color from Twenty Nineteen.
  116. */
  117. // Our filter callback function - HUE
  118. function sophisticated_business_primary_color_hue() {
  119. return 44;
  120. }
  121. add_filter( 'twentynineteen_default_hue', 'sophisticated_business_primary_color_hue' );
  122. // Our filter callback function - SATURATION
  123. function sophisticated_business_primary_color_saturation() {
  124. return 52;
  125. }
  126. add_filter( 'twentynineteen_default_saturation', 'sophisticated_business_primary_color_saturation' );
  127. // Our filter callback function - LIGHTNESS
  128. function sophisticated_business_primary_color_lightness() {
  129. return 57;
  130. }
  131. add_filter( 'twentynineteen_default_lightness', 'sophisticated_business_primary_color_lightness' );
  132. // Filter hover colour - lightness value
  133. function sophisticated_business_primary_color_lightness_hover() {
  134. return 47;
  135. }
  136. add_filter( 'twentynineteen_default_lightness_hover', 'sophisticated_business_primary_color_lightness_hover' );
  137. /**
  138. * Load Jetpack compatibility file.
  139. */
  140. require get_stylesheet_directory() . '/inc/jetpack.php';
  141. /**
  142. * Customizer additions.
  143. */
  144. require get_stylesheet_directory() . '/inc/customizer.php';