Guest User

Untitled

a guest
Oct 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <?php
  2. if ( is_front_page() )
  3. {
  4. if ( get_header_image() )
  5. {
  6. // So, so good!
  7. $custom_header_attachment_id = get_custom_header()->attachment_id;
  8. $custom_header_image_alt = trim( strip_tags( get_post_meta(
  9. $custom_header_attachment_id,
  10. '_wp_attachment_image_alt',
  11. true
  12. ) ) );
  13. ?>
  14. <div class="header__featured-image-container">
  15. <?php
  16. $args = [
  17. // 'class' => 'header__featured-image',
  18. // 'alt' => $custom_header_image_alt
  19. ];
  20.  
  21. echo get_header_image_tag( $args );
  22. ?>
  23. </div>
  24. <?php
  25. }
  26. }
  27. ?>
  28.  
  29. <?php
  30. function ivana_custom_header_setup()
  31. {
  32. add_theme_support( 'custom-header', apply_filters( 'ivana_custom_header_args', [
  33. 'default-image' => '',
  34. 'default-text-color' => '000',
  35. 'width' => '1000',
  36. 'height' => '250',
  37. 'flex-width' => true,
  38. 'flex-height' => true,
  39. 'wp-head-callback' => 'ivana_header_style'
  40. ] ) );
  41. }
  42. add_action( 'after_setup_theme', 'ivana_custom_header_setup' );
  43.  
  44. function ivana_header_style()
  45. {
  46. $header_text_color = get_header_textcolor();
  47.  
  48. if ( get_theme_support( 'custom-header', 'default-text-color' ) )
  49. {
  50. ?>
  51. <style type="text/css">
  52. <?php
  53. if ( ! display_header_text() )
  54. {
  55. ?>
  56. .site-title,
  57. .site-description {
  58. position: absolute;
  59. /* This is a nice approach, haven't thought about it! */
  60. clip: rect(1px, 1px, 1px, 1px);
  61. }
  62. <?php
  63. }
  64. else
  65. {
  66. ?>
  67. .site-title a,
  68. .site-description {
  69. color: <?php echo esc_attr( $header_text_color ); ?>;
  70. }
  71. <?php } ?>
  72. </style>
  73. <?php
  74. }
  75. }
Add Comment
Please, Sign In to add comment