custom-header.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Sample implementation of the Custom Header feature
  4. * http://codex.wordpress.org/Custom_Headers
  5. *
  6. * @package Independent_Publisher_2
  7. */
  8. /**
  9. * Set up the WordPress core custom header feature.
  10. *
  11. * @uses independent_publisher_2_header_style()
  12. * @uses independent_publisher_2_admin_header_style()
  13. * @uses independent_publisher_2_admin_header_image()
  14. */
  15. function independent_publisher_2_custom_header_setup() {
  16. add_theme_support( 'custom-header', apply_filters( 'independent_publisher_2_custom_header_args', array(
  17. 'default-image' => '',
  18. 'default-text-color' => '333332',
  19. 'width' => 1440,
  20. 'height' => 600,
  21. 'flex-height' => true,
  22. 'wp-head-callback' => 'independent_publisher_2_header_style',
  23. ) ) );
  24. }
  25. add_action( 'after_setup_theme', 'independent_publisher_2_custom_header_setup' );
  26. if ( ! function_exists( 'independent_publisher_2_header_style' ) ) :
  27. /**
  28. * Styles the header image and text displayed on the blog
  29. *
  30. * @see independent_publisher_2_custom_header_setup().
  31. */
  32. function independent_publisher_2_header_style() {
  33. $header_text_color = get_header_textcolor();
  34. /*
  35. * If no custom options for text are set, let's bail.
  36. * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
  37. */
  38. if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
  39. return;
  40. }
  41. // If we get this far, we have custom styles. Let's do this.
  42. ?>
  43. <style id="independent-publisher-2-custom-header-css" type="text/css">
  44. <?php
  45. // Has the text been hidden?
  46. if ( ! display_header_text() ) :
  47. ?>
  48. .site-title,
  49. .site-description,
  50. #hero-header #hero-social-navigation {
  51. clip: rect(1px, 1px, 1px, 1px);
  52. position: absolute;
  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. .social-navigation li a,
  61. .site-header .menu-toggle {
  62. color: #<?php echo esc_attr( $header_text_color ); ?> !important;
  63. }
  64. .site-description {
  65. opacity: 0.8 !important;
  66. }
  67. .site-header .menu-toggle {
  68. border-color: #<?php echo esc_attr( $header_text_color ); ?> !important;
  69. }
  70. <?php endif; ?>
  71. </style>
  72. <?php
  73. }
  74. endif; // independent_publisher_2_header_style