custom-header.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Custom Header feature
  4. * http://codex.wordpress.org/Custom_Headers
  5. *
  6. * @package Lodestar
  7. */
  8. /**
  9. * Set up the WordPress core custom header feature.
  10. *
  11. * @uses lodestar_header_style()
  12. */
  13. function lodestar_custom_header_setup() {
  14. add_theme_support( 'custom-header', apply_filters( 'lodestar_custom_header_args', array(
  15. 'default-image' => get_template_directory_uri() . '/assets/images/header.jpg',
  16. 'default-text-color' => 'ffffff',
  17. 'width' => 2000,
  18. 'height' => 1200,
  19. 'flex-height' => true,
  20. 'wp-head-callback' => 'lodestar_header_style',
  21. ) ) );
  22. }
  23. add_action( 'after_setup_theme', 'lodestar_custom_header_setup' );
  24. if ( ! function_exists( 'lodestar_header_style' ) ) :
  25. /**
  26. * Styles the header image and text displayed on the blog
  27. *
  28. * @see lodestar_custom_header_setup().
  29. */
  30. function lodestar_header_style() {
  31. $header_text_color = get_header_textcolor();
  32. // If no custom options for text are set, let's bail
  33. // get_header_textcolor() options: add_theme_support( 'custom-header' ) is default, hide text (returns 'blank') or any hex value.
  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 ( 'blank' === $header_text_color ) :
  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. .site-description {
  55. color: #<?php echo esc_attr( $header_text_color ); ?>;
  56. }
  57. <?php endif; ?>
  58. </style>
  59. <?php
  60. }
  61. endif; // lodestar_header_style