custom-header.php 1.7 KB

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