content-cover.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /**
  3. * Displays the content when the cover template is used.
  4. *
  5. * @package WordPress
  6. * @subpackage Twenty_Twenty
  7. * @since Twenty Twenty 1.0
  8. */
  9. ?>
  10. <article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
  11. <?php
  12. // On the cover page template, output the cover header.
  13. $cover_header_style = '';
  14. $cover_header_classes = '';
  15. $color_overlay_style = '';
  16. $color_overlay_classes = '';
  17. $image_url = ! post_password_required() ? get_the_post_thumbnail_url( get_the_ID(), 'twentytwenty-fullscreen' ) : '';
  18. if ( $image_url ) {
  19. $cover_header_style = ' style="background-image: url( ' . esc_url( $image_url ) . ' );"';
  20. $cover_header_classes = ' bg-image';
  21. }
  22. // Get the color used for the color overlay.
  23. $color_overlay_color = get_theme_mod( 'cover_template_overlay_background_color' );
  24. if ( $color_overlay_color ) {
  25. $color_overlay_style = ' style="color: ' . esc_attr( $color_overlay_color ) . ';"';
  26. } else {
  27. $color_overlay_style = '';
  28. }
  29. // Get the fixed background attachment option.
  30. if ( get_theme_mod( 'cover_template_fixed_background', true ) ) {
  31. $cover_header_classes .= ' bg-attachment-fixed';
  32. }
  33. // Get the opacity of the color overlay.
  34. $color_overlay_opacity = get_theme_mod( 'cover_template_overlay_opacity' );
  35. $color_overlay_opacity = ( false === $color_overlay_opacity ) ? 80 : $color_overlay_opacity;
  36. $color_overlay_classes .= ' opacity-' . $color_overlay_opacity;
  37. ?>
  38. <div class="cover-header <?php echo $cover_header_classes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>"<?php echo $cover_header_style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We need to double check this, but for now, we want to pass PHPCS ;) ?>>
  39. <div class="cover-header-inner-wrapper screen-height">
  40. <div class="cover-header-inner">
  41. <div class="cover-color-overlay color-accent<?php echo esc_attr( $color_overlay_classes ); ?>"<?php echo $color_overlay_style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We need to double check this, but for now, we want to pass PHPCS ;) ?>></div>
  42. <header class="entry-header has-text-align-center">
  43. <div class="entry-header-inner section-inner medium">
  44. <?php
  45. /**
  46. * Allow child themes and plugins to filter the display of the categories in the article header.
  47. *
  48. * @since Twenty Twenty 1.0
  49. *
  50. * @param bool Whether to show the categories in article header, Default true.
  51. */
  52. $show_categories = apply_filters( 'twentytwenty_show_categories_in_entry_header', true );
  53. if ( true === $show_categories && has_category() ) {
  54. ?>
  55. <div class="entry-categories">
  56. <span class="screen-reader-text"><?php _e( 'Categories', 'twentytwenty' ); ?></span>
  57. <div class="entry-categories-inner">
  58. <?php the_category( ' ' ); ?>
  59. </div><!-- .entry-categories-inner -->
  60. </div><!-- .entry-categories -->
  61. <?php
  62. }
  63. the_title( '<h1 class="entry-title">', '</h1>' );
  64. if ( is_page() ) {
  65. ?>
  66. <div class="to-the-content-wrapper">
  67. <a href="#post-inner" class="to-the-content fill-children-current-color">
  68. <?php twentytwenty_the_theme_svg( 'arrow-down' ); ?>
  69. <div class="screen-reader-text"><?php _e( 'Scroll Down', 'twentytwenty' ); ?></div>
  70. </a><!-- .to-the-content -->
  71. </div><!-- .to-the-content-wrapper -->
  72. <?php
  73. } else {
  74. $intro_text_width = '';
  75. if ( is_singular() ) {
  76. $intro_text_width = ' small';
  77. } else {
  78. $intro_text_width = ' thin';
  79. }
  80. if ( has_excerpt() ) {
  81. ?>
  82. <div class="intro-text section-inner max-percentage<?php echo esc_attr( $intro_text_width ); ?>">
  83. <?php the_excerpt(); ?>
  84. </div>
  85. <?php
  86. }
  87. twentytwenty_the_post_meta( get_the_ID(), 'single-top' );
  88. }
  89. ?>
  90. </div><!-- .entry-header-inner -->
  91. </header><!-- .entry-header -->
  92. </div><!-- .cover-header-inner -->
  93. </div><!-- .cover-header-inner-wrapper -->
  94. </div><!-- .cover-header -->
  95. <div class="post-inner" id="post-inner">
  96. <div class="entry-content">
  97. <?php
  98. the_content();
  99. ?>
  100. </div><!-- .entry-content -->
  101. <?php
  102. wp_link_pages(
  103. array(
  104. 'before' => '<nav class="post-nav-links bg-light-background" aria-label="' . esc_attr__( 'Page', 'twentytwenty' ) . '"><span class="label">' . __( 'Pages:', 'twentytwenty' ) . '</span>',
  105. 'after' => '</nav>',
  106. 'link_before' => '<span class="page-number">',
  107. 'link_after' => '</span>',
  108. )
  109. );
  110. edit_post_link();
  111. // Single bottom post meta.
  112. twentytwenty_the_post_meta( get_the_ID(), 'single-bottom' );
  113. if ( is_single() ) {
  114. get_template_part( 'template-parts/entry-author-bio' );
  115. }
  116. ?>
  117. </div><!-- .post-inner -->
  118. <?php
  119. if ( is_single() ) {
  120. get_template_part( 'template-parts/navigation' );
  121. }
  122. /**
  123. * Output comments wrapper if it's a post, or if comments are open,
  124. * or if there's a comment number – and check for password.
  125. * */
  126. if ( ( is_single() || is_page() ) && ( comments_open() || get_comments_number() ) && ! post_password_required() ) {
  127. ?>
  128. <div class="comments-wrapper section-inner">
  129. <?php comments_template(); ?>
  130. </div><!-- .comments-wrapper -->
  131. <?php
  132. }
  133. ?>
  134. </article><!-- .post -->