custom-header.php 1.5 KB

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