functions.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /**
  3. * Friendly Business functions and definitions.
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Friendly_Business
  8. */
  9. if ( ! function_exists( 'friendly_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 friendly_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' => 180,
  27. 'width' => 180,
  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', 'friendly-business' ),
  39. 'slug' => 'primary',
  40. 'color' => '#20603c', // $color__link
  41. ),
  42. array(
  43. 'name' => __( 'Secondary', 'friendly-business' ),
  44. 'slug' => 'secondary',
  45. 'color' => '#133a24', // $color__border-link-hover
  46. ),
  47. array(
  48. 'name' => __( 'Dark Gray', 'friendly-business' ),
  49. 'slug' => 'dark-gray',
  50. 'color' => '#3c2323', // $color__text-main
  51. ),
  52. array(
  53. 'name' => __( 'Light Gray', 'friendly-business' ),
  54. 'slug' => 'light-gray',
  55. 'color' => '#0d1b24', // $color__text-dark
  56. ),
  57. array(
  58. 'name' => __( 'White', 'friendly-business' ),
  59. 'slug' => 'white',
  60. 'color' => '#ffffff',
  61. ),
  62. )
  63. );
  64. }
  65. endif; // friendly_business_setup
  66. add_action( 'after_setup_theme', 'friendly_business_setup', 30 );
  67. function friendly_business_fonts_url() {
  68. $fonts_url = '';
  69. /* Translators: If there are characters in your language that are not
  70. * supported by Rubik, translate this to 'off'. Do not translate
  71. * into your own language.
  72. */
  73. $rubik = esc_html_x( 'on', 'Rubik font: on or off', 'friendly-business' );
  74. if ( 'off' !== $rubik ) {
  75. $font_families = array();
  76. if ( 'off' !== $rubik ) {
  77. $font_families[] = 'Rubik:400,700,400italic,700italic';
  78. }
  79. /**
  80. * A filter to enable child themes to add/change/omit font families.
  81. *
  82. * @param array $font_families An array of font families to be imploded for the Google Font API
  83. */
  84. $font_families = apply_filters( 'included_google_font_families', $font_families );
  85. $query_args = array(
  86. 'family' => urlencode( implode( '|', $font_families ) ),
  87. 'subset' => urlencode( 'latin,latin-ext' ),
  88. );
  89. $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
  90. }
  91. return esc_url_raw( $fonts_url );
  92. }
  93. /**
  94. * Enqueue scripts and styles.
  95. */
  96. function friendly_business_scripts() {
  97. /**
  98. * Styles
  99. */
  100. wp_enqueue_style( 'friendly-business-fonts', friendly_business_fonts_url(), array(), null );
  101. }
  102. add_action( 'wp_enqueue_scripts', 'friendly_business_scripts' );
  103. /**
  104. * Enqueue supplemental block editor scripts.
  105. */
  106. function friendly_business_block_editor_scripts() {
  107. /**
  108. * Block Editor Scripts
  109. */
  110. wp_enqueue_style( 'friendly-business-fonts', friendly_business_fonts_url(), array(), null );
  111. wp_enqueue_script( 'friendly-business-block-editor-filters', get_theme_file_uri( '/js/block-editor-filters.js' ), array(), '1.0', true );
  112. }
  113. add_action( 'enqueue_block_editor_assets', 'friendly_business_block_editor_scripts' );
  114. /**
  115. * Filter default color from Twenty Nineteen.
  116. */
  117. function friendly_business_primary_color_hue() {
  118. return 146;
  119. }
  120. add_filter( 'twentynineteen_default_hue', 'friendly_business_primary_color_hue' );
  121. function friendly_business_primary_color_saturation() {
  122. return 50;
  123. }
  124. add_filter( 'twentynineteen_default_saturation', 'friendly_business_primary_color_saturation' );
  125. function friendly_business_primary_color_lightness() {
  126. return 25;
  127. }
  128. add_filter( 'twentynineteen_default_lightness', 'friendly_business_primary_color_lightness' );
  129. /**
  130. * Load Jetpack compatibility file.
  131. */
  132. require get_stylesheet_directory() . '/inc/jetpack.php';
  133. /**
  134. * Customizer additions.
  135. */
  136. require get_stylesheet_directory() . '/inc/customizer.php';