custom-header.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Implementation of the Custom Header feature.
  4. *
  5. * @link https://developer.wordpress.org/themes/functionality/custom-headers/
  6. *
  7. * @package Shoreditch
  8. */
  9. /**
  10. * Set up the WordPress core custom header feature.
  11. *
  12. * @uses shoreditch_header_style()
  13. */
  14. function shoreditch_custom_header_setup() {
  15. add_theme_support( 'custom-header', apply_filters( 'shoreditch_custom_header_args', array(
  16. 'default-image' => '',
  17. 'default-text-color' => '3e69dc',
  18. 'width' => 2000,
  19. 'height' => 250,
  20. 'flex-height' => true,
  21. 'flex-width' => true,
  22. 'wp-head-callback' => 'shoreditch_header_style',
  23. ) ) );
  24. }
  25. add_action( 'after_setup_theme', 'shoreditch_custom_header_setup' );
  26. if ( ! function_exists( 'shoreditch_header_style' ) ) :
  27. /**
  28. * Styles the header image and text displayed on the blog.
  29. *
  30. * @see shoreditch_custom_header_setup().
  31. */
  32. function shoreditch_header_style() {
  33. $header_text_color = get_header_textcolor();
  34. /*
  35. * If no custom options for text are set, let's bail.
  36. * get_header_textcolor() options: add_theme_support( 'custom-header' ) is default, hide text (returns 'blank') or any hex value.
  37. */
  38. if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
  39. return;
  40. }
  41. // If we get this far, we have custom styles. Let's do this.
  42. ?>
  43. <style type="text/css">
  44. <?php
  45. // Has the text been hidden?
  46. if ( 'blank' === $header_text_color ) :
  47. ?>
  48. .site-title,
  49. .site-description {
  50. position: absolute;
  51. clip: rect(1px, 1px, 1px, 1px);
  52. }
  53. <?php
  54. // If the user has set a custom color for the text use that.
  55. else :
  56. ?>
  57. .site-title a,
  58. .site-description {
  59. color: #<?php echo esc_attr( $header_text_color ); ?>;
  60. }
  61. <?php endif; ?>
  62. </style>
  63. <?php
  64. }
  65. endif;