post.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * The common code for the single and looped post template
  4. *
  5. * @package vamtam/consulting
  6. */
  7. global $post, $wp_query;
  8. if ( ! isset( $blog_query ) ) {
  9. $blog_query = $wp_query;
  10. }
  11. extract( VamtamPostFormats::post_layout_info() );
  12. $format = get_post_format();
  13. $format = empty( $format ) ? 'standard' : $format;
  14. $post_data = array_merge( array(
  15. 'p' => $post,
  16. 'format' => $format,
  17. ), VamtamPostFormats::post_layout_info() );
  18. if ( has_post_format( 'quote' ) && ! $blog_query->is_single( $post ) && ($news || ! $show_content) ) {
  19. $post_data['content'] = '';
  20. } else {
  21. if ( $blog_query->is_single( $post ) ) {
  22. VamtamPostFormats::block_gallery_beaver();
  23. $post_data['content'] = apply_filters( 'the_content', get_the_content() );
  24. VamtamPostFormats::enable_gallery_beaver();
  25. } elseif ( $show_content && ! $news ) {
  26. VamtamPostFormats::block_gallery_beaver();
  27. $post_data['content'] = apply_filters( 'the_content', get_the_content( esc_html__( 'Read more', 'vamtam-consulting' ), false ) );
  28. VamtamPostFormats::enable_gallery_beaver();
  29. } else {
  30. $post_data['content'] = get_the_excerpt();
  31. }
  32. }
  33. $post_data = VamtamPostFormats::process( $post_data );
  34. $has_media = isset( $post_data['media'] ) ? 'has-image' : 'no-image';
  35. $article_class = array( 'post-article', $has_media . '-wrapper' );
  36. if ( $blog_query->is_single( $post ) ) {
  37. $article_class[] = 'single';
  38. }
  39. $inner_class = array( $format . '-post-format', 'clearfix' );
  40. $inner_class[] = isset( $post_data['act_as_image'] ) ? 'as-image' : 'as-normal';
  41. $inner_class[] = isset( $post_data['act_as_standard'] ) ? 'as-standard-post-format' : ''
  42. ?>
  43. <div class="<?php echo esc_attr( implode( ' ', $article_class ) ); ?>" itemscope itemtype="<?php class_exists( 'VamtamBlogModule' ) && VamtamBlogModule::schema_itemtype(); ?>" itemid="<?php the_permalink() ?>">
  44. <?php class_exists( 'VamtamBlogModule' ) && VamtamBlogModule::schema_meta(); ?>
  45. <div class="<?php echo esc_attr( implode( ' ', $inner_class ) ); ?>">
  46. <?php
  47. if ( $blog_query->is_single( $post ) ) {
  48. include locate_template( 'templates/post/main/single.php' );
  49. } elseif ( $news ) {
  50. include locate_template( 'templates/post/main/news.php' );
  51. } else {
  52. include locate_template( 'templates/post/main/loop.php' );
  53. }
  54. ?>
  55. </div>
  56. </div>