custom-header.php 1.5 KB

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