custom-header.php 1.5 KB

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