content-audio.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * Template part for displaying audio posts
  4. *
  5. * @link https://codex.wordpress.org/Template_Hierarchy
  6. *
  7. * @package WordPress
  8. * @subpackage Twenty_Seventeen
  9. * @since 1.0
  10. * @version 1.2
  11. */
  12. ?>
  13. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  14. <?php
  15. if ( is_sticky() && is_home() ) {
  16. echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
  17. }
  18. ?>
  19. <header class="entry-header">
  20. <?php
  21. if ( 'post' === get_post_type() ) {
  22. echo '<div class="entry-meta">';
  23. if ( is_single() ) {
  24. twentyseventeen_posted_on();
  25. } else {
  26. echo twentyseventeen_time_link();
  27. twentyseventeen_edit_link();
  28. };
  29. echo '</div><!-- .entry-meta -->';
  30. };
  31. if ( is_single() ) {
  32. the_title( '<h1 class="entry-title">', '</h1>' );
  33. } elseif ( is_front_page() && is_home() ) {
  34. the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
  35. } else {
  36. the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
  37. }
  38. ?>
  39. </header><!-- .entry-header -->
  40. <?php
  41. $content = apply_filters( 'the_content', get_the_content() );
  42. $audio = false;
  43. // Only get audio from the content if a playlist isn't present.
  44. if ( false === strpos( $content, 'wp-playlist-script' ) ) {
  45. $audio = get_media_embedded_in_content( $content, array( 'audio' ) );
  46. }
  47. ?>
  48. <?php if ( '' !== get_the_post_thumbnail() && ! is_single() ) : ?>
  49. <div class="post-thumbnail">
  50. <a href="<?php the_permalink(); ?>">
  51. <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
  52. </a>
  53. </div><!-- .post-thumbnail -->
  54. <?php endif; ?>
  55. <div class="entry-content">
  56. <?php
  57. if ( ! is_single() ) {
  58. // If not a single post, highlight the audio file.
  59. if ( ! empty( $audio ) ) {
  60. foreach ( $audio as $audio_html ) {
  61. echo '<div class="entry-audio">';
  62. echo $audio_html;
  63. echo '</div><!-- .entry-audio -->';
  64. }
  65. };
  66. };
  67. if ( is_single() || empty( $audio ) ) {
  68. /* translators: %s: Name of current post */
  69. the_content( sprintf(
  70. __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
  71. get_the_title()
  72. ) );
  73. wp_link_pages( array(
  74. 'before' => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
  75. 'after' => '</div>',
  76. 'link_before' => '<span class="page-number">',
  77. 'link_after' => '</span>',
  78. ) );
  79. };
  80. ?>
  81. </div><!-- .entry-content -->
  82. <?php
  83. if ( is_single() ) {
  84. twentyseventeen_entry_footer();
  85. }
  86. ?>
  87. </article><!-- #post-## -->