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 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. // 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. if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
  36. return;
  37. }
  38. // If we get this far, we have custom styles. Let's do this.
  39. ?>
  40. <style type="text/css">
  41. <?php
  42. // Has the text been hidden?
  43. if ( 'blank' == $header_text_color ) :
  44. ?>
  45. .site-title,
  46. .site-description {
  47. position: absolute;
  48. clip: rect(1px, 1px, 1px, 1px);
  49. }
  50. <?php
  51. // If the user has set a custom color for the text use that
  52. else :
  53. ?>
  54. .site-title,
  55. .site-description {
  56. color: #<?php echo esc_attr( $header_text_color ); ?>;
  57. }
  58. <?php endif; ?>
  59. </style>
  60. <?php
  61. }
  62. endif; // canard_header_style