custom-header.php 1.7 KB

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