An updated theme (based on Atticus Finch) for ClassicPress
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.6 KiB

3 years ago
  1. <?php
  2. /**
  3. * Sample implementation of the Custom Header feature
  4. * http://codex.wordpress.org/Custom_Headers
  5. *
  6. * You can add an optional custom header image to header.php like so ...
  7. *
  8. <?php if ( get_header_image() ) : ?>
  9. <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
  10. <img src="<?php header_image(); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="">
  11. </a>
  12. <?php endif; // End header image check. ?>
  13. *
  14. * @package Atticus Finch
  15. */
  16. /**
  17. * Set up the WordPress core custom header feature.
  18. *
  19. * @uses atticus_finch_header_style()
  20. * @uses atticus_finch_admin_header_style()
  21. * @uses atticus_finch_admin_header_image()
  22. */
  23. function atticus_finch_custom_header_setup() {
  24. add_theme_support( 'custom-header', apply_filters( 'atticus_finch_custom_header_args', array(
  25. 'default-image' => '',
  26. 'default-text-color' => '000000',
  27. 'width' => 1000,
  28. 'height' => 250,
  29. 'flex-height' => true,
  30. 'wp-head-callback' => 'atticus_finch_header_style',
  31. 'admin-head-callback' => 'atticus_finch_admin_header_style',
  32. 'admin-preview-callback' => 'atticus_finch_admin_header_image',
  33. ) ) );
  34. }
  35. add_action( 'after_setup_theme', 'atticus_finch_custom_header_setup' );
  36. if ( ! function_exists( 'atticus_finch_header_style' ) ) :
  37. /**
  38. * Styles the header image and text displayed on the blog
  39. *
  40. * @see atticus_finch_custom_header_setup().
  41. */
  42. function atticus_finch_header_style() {
  43. $header_text_color = get_header_textcolor();
  44. // If no custom options for text are set, let's bail
  45. // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value.
  46. if ( HEADER_TEXTCOLOR == $header_text_color ) {
  47. return;
  48. }
  49. // If we get this far, we have custom styles. Let's do this.
  50. ?>
  51. <style type="text/css">
  52. <?php
  53. // Has the text been hidden?
  54. if ( 'blank' == $header_text_color ) :
  55. ?>
  56. .site-title,
  57. .site-description {
  58. position: absolute;
  59. clip: rect(1px, 1px, 1px, 1px);
  60. }
  61. <?php
  62. // If the user has set a custom color for the text use that.
  63. else :
  64. ?>
  65. .site-title a,
  66. .site-description {
  67. color: #<?php echo esc_attr( $header_text_color ); ?>;
  68. }
  69. <?php endif; ?>
  70. </style>
  71. <?php
  72. }
  73. endif; // atticus_finch_header_style
  74. if ( ! function_exists( 'atticus_finch_admin_header_style' ) ) :
  75. /**
  76. * Styles the header image displayed on the Appearance > Header admin panel.
  77. *
  78. * @see atticus_finch_custom_header_setup().
  79. */
  80. function atticus_finch_admin_header_style() {
  81. ?>
  82. <style type="text/css">
  83. .appearance_page_custom-header #headimg {
  84. border: none;
  85. }
  86. #headimg h1,
  87. #desc {
  88. }
  89. #headimg h1 {
  90. }
  91. #headimg h1 a {
  92. }
  93. #desc {
  94. }
  95. #headimg img {
  96. }
  97. </style>
  98. <?php
  99. }
  100. endif; // atticus_finch_admin_header_style
  101. if ( ! function_exists( 'atticus_finch_admin_header_image' ) ) :
  102. /**
  103. * Custom header image markup displayed on the Appearance > Header admin panel.
  104. *
  105. * @see atticus_finch_custom_header_setup().
  106. */
  107. function atticus_finch_admin_header_image() {
  108. ?>
  109. <div id="headimg">
  110. <h1 class="displaying-header-text">
  111. <a id="name" style="<?php echo esc_attr( 'color: #' . get_header_textcolor() ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a>
  112. </h1>
  113. <div class="displaying-header-text" id="desc" style="<?php echo esc_attr( 'color: #' . get_header_textcolor() ); ?>"><?php bloginfo( 'description' ); ?></div>
  114. <?php if ( get_header_image() ) : ?>
  115. <img src="<?php header_image(); ?>" alt="">
  116. <?php endif; ?>
  117. </div>
  118. <?php
  119. }
  120. endif; // atticus_finch_admin_header_image