functions.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /**
  3. * Child Theme Functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package WordPress
  8. * @since 1.0.0
  9. */
  10. if ( ! function_exists( 'redhill_theme_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 redhill_theme_setup() {
  19. // Add child theme editor styles, compiled from `style-child-theme-editor.scss`.
  20. add_editor_style( 'style-editor.css' );
  21. // Remove parent theme font sizes
  22. remove_theme_support( 'editor-font-sizes' );
  23. // Add child theme editor font sizes to match Sass-map variables in `_config-child-theme-deep.scss`.
  24. add_theme_support(
  25. 'editor-font-sizes',
  26. array(
  27. array(
  28. 'name' => __( 'Small', 'redhill' ),
  29. 'shortName' => __( 'S', 'redhill' ),
  30. 'size' => 16.66,
  31. 'slug' => 'small',
  32. ),
  33. array(
  34. 'name' => __( 'Normal', 'redhill' ),
  35. 'shortName' => __( 'N', 'redhill' ),
  36. 'size' => 20,
  37. 'slug' => 'normal',
  38. ),
  39. array(
  40. 'name' => __( 'Medium', 'redhill' ),
  41. 'shortName' => __( 'M', 'redhill' ),
  42. 'size' => 24,
  43. 'slug' => 'medium',
  44. ),
  45. array(
  46. 'name' => __( 'Large', 'redhill' ),
  47. 'shortName' => __( 'L', 'redhill' ),
  48. 'size' => 28.8,
  49. 'slug' => 'large',
  50. ),
  51. array(
  52. 'name' => __( 'Huge', 'redhill' ),
  53. 'shortName' => __( 'XL', 'redhill' ),
  54. 'size' => 34.56,
  55. 'slug' => 'huge',
  56. ),
  57. )
  58. );
  59. // Add child theme editor color pallete to match Sass-map variables in `_config-child-theme-deep.scss`.
  60. add_theme_support(
  61. 'editor-color-palette',
  62. array(
  63. array(
  64. 'name' => __( 'Primary', 'redhill' ),
  65. 'slug' => 'primary',
  66. 'color' => '#CA2017',
  67. ),
  68. array(
  69. 'name' => __( 'Secondary', 'redhill' ),
  70. 'slug' => 'secondary',
  71. 'color' => '#007FDB',
  72. ),
  73. array(
  74. 'name' => __( 'Dark Gray', 'redhill' ),
  75. 'slug' => 'foreground-dark',
  76. 'color' => '#111111',
  77. ),
  78. array(
  79. 'name' => __( 'Gray', 'redhill' ),
  80. 'slug' => 'foreground',
  81. 'color' => '#444444',
  82. ),
  83. array(
  84. 'name' => __( 'Light Gray', 'redhill' ),
  85. 'slug' => 'foreground-light',
  86. 'color' => '#666666',
  87. ),
  88. array(
  89. 'name' => __( 'Lighter Gray', 'varia' ),
  90. 'slug' => 'background-dark',
  91. 'color' => '#DDDDDD',
  92. ),
  93. array(
  94. 'name' => __( 'Subtle Gray', 'varia' ),
  95. 'slug' => 'background-light',
  96. 'color' => '#FAFAFA',
  97. ),
  98. array(
  99. 'name' => __( 'White', 'redhill' ),
  100. 'slug' => 'background',
  101. 'color' => '#FFFFFF',
  102. ),
  103. )
  104. );
  105. // Add child theme support for core custom logo.
  106. add_theme_support(
  107. 'custom-logo',
  108. array(
  109. 'height' => 120,
  110. 'width' => 100,
  111. 'flex-width' => true,
  112. 'flex-height' => false,
  113. 'header-text' => array( 'site-title', 'site-description' ),
  114. )
  115. );
  116. }
  117. endif;
  118. add_action( 'after_setup_theme', 'redhill_theme_setup', 12 );
  119. /**
  120. * Set the content width in pixels, based on the child-theme's design and stylesheet.
  121. *
  122. * Priority 0 to make it available to lower priority callbacks.
  123. *
  124. * @global int $content_width Content width.
  125. */
  126. function redhill_theme_content_width() {
  127. // This variable is intended to be overruled from themes.
  128. // Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
  129. // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
  130. $GLOBALS['content_width'] = apply_filters( 'redhill_theme_content_width', 740 );
  131. }
  132. add_action( 'after_setup_theme', 'redhill_theme_content_width', 0 );
  133. /**
  134. * Enqueue scripts and styles.
  135. */
  136. function redhill_theme_scripts() {
  137. // dequeue parent styles
  138. wp_dequeue_style( 'varia-style' );
  139. // enqueue child styles
  140. wp_enqueue_style( 'redhill-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ));
  141. // enqueue child RTL styles
  142. wp_style_add_data( 'redhill-style', 'rtl', 'replace' );
  143. }
  144. add_action( 'wp_enqueue_scripts', 'redhill_theme_scripts', 99 );