custom-header.php 1.8 KB

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