functions.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php declare( strict_types = 1 ); ?>
  2. <?php
  3. /**
  4. * Modern Business functions and definitions
  5. *
  6. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  7. *
  8. * @package Modern_Business
  9. */
  10. if ( ! function_exists( 'modern_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 modern_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' => 128,
  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', 'modern-business' ),
  40. 'slug' => 'primary',
  41. 'color' => '#c43d80', // $color__link
  42. ),
  43. array(
  44. 'name' => __( 'Secondary', 'modern-business' ),
  45. 'slug' => 'secondary',
  46. 'color' => '#9e3067', // $color__border-link-hover
  47. ),
  48. array(
  49. 'name' => __( 'Dark Gray', 'modern-business' ),
  50. 'slug' => 'dark-gray',
  51. 'color' => '#181818', // $color__text-main
  52. ),
  53. array(
  54. 'name' => __( 'Light Gray', 'modern-business' ),
  55. 'slug' => 'light-gray',
  56. 'color' => '#686868', // $color__text-light
  57. ),
  58. array(
  59. 'name' => __( 'White', 'modern-business' ),
  60. 'slug' => 'white',
  61. 'color' => '#FFF',
  62. ),
  63. )
  64. );
  65. }
  66. endif; // modern_business_setup
  67. add_action( 'after_setup_theme', 'modern_business_setup', 30 );
  68. function modern_business_fonts_url() {
  69. $fonts_url = '';
  70. /* Translators: If there are characters in your language that are not
  71. * supported by IBM Plex Sans, translate this to 'off'. Do not translate
  72. * into your own language.
  73. */
  74. $font = esc_html_x( 'on', 'IBM Plex Sans font: on or off', 'modern-business' );
  75. if ( 'off' !== $font ) {
  76. $font_families = array();
  77. if ( 'off' !== $font ) {
  78. $font_families[] = 'IBM Plex Sans:300,300i,500,700';
  79. }
  80. /**
  81. * A filter to enable child themes to add/change/omit font families.
  82. *
  83. * @param array $font_families An array of font families to be imploded for the Google Font API
  84. */
  85. $font_families = apply_filters( 'included_google_font_families', $font_families );
  86. $query_args = array(
  87. 'family' => urlencode( implode( '|', $font_families ) ),
  88. 'subset' => urlencode( 'latin,latin-ext' ),
  89. );
  90. $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
  91. }
  92. return esc_url_raw( $fonts_url );
  93. }
  94. /**
  95. * Enqueue scripts and styles.
  96. */
  97. function modern_business_scripts() {
  98. /**
  99. * Styles
  100. */
  101. wp_enqueue_style( 'modern-business-fonts', modern_business_fonts_url(), array(), null );
  102. }
  103. add_action( 'wp_enqueue_scripts', 'modern_business_scripts' );
  104. add_action( 'enqueue_block_editor_assets', 'modern_business_scripts' );
  105. /**
  106. * Customizer additions
  107. */
  108. require get_stylesheet_directory() . '/inc/customizer.php';
  109. /**
  110. * Jetpack compatibility file.
  111. */
  112. require get_stylesheet_directory() . '/inc/jetpack.php';
  113. /**
  114. * WP.com compatibility file.
  115. */
  116. require get_stylesheet_directory() . '/inc/wpcom.php';