Advertisement
Guest User

display-featured.php

a guest
Mar 12th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. <?php
  2. /**
  3. * The template for displaying featured content
  4. *
  5. * @package Solid_Construction
  6. */
  7. ?>
  8.  
  9. <?php
  10. $enable_content = get_theme_mod( 'solid_construction_featured_content_option', 'homepage' );
  11.  
  12. if ( ! solid_construction_check_section( $enable_content ) ) {
  13. // Bail if featured content is disabled.
  14. return;
  15. }
  16.  
  17. $type = get_theme_mod( 'solid_construction_featured_content_type', 'demo' );
  18.  
  19. if ( 'image' !== $type && 'demo' !== $type ) {
  20. $featured_posts = solid_construction_get_posts( 'featured_content' );
  21.  
  22. if ( empty( $featured_posts ) ) {
  23. return;
  24. }
  25. }
  26.  
  27. if ( 'featured-content' === $type ) {
  28. $title = get_option( 'featured_content_title', esc_html__( 'Contents', 'solid-construction-pro' ) );
  29. $sub_title = get_option( 'featured_content_content' );
  30. } else {
  31. $title = get_theme_mod( 'solid_construction_featured_content_archive_title', esc_html__( 'Featured', 'solid-construction-pro' ) );
  32. if( class_exists( 'Polylang' ) ) {
  33. $title = pll__( $title );
  34. }
  35. $sub_title = get_theme_mod( 'solid_construction_featured_content_sub_title', esc_html__( 'Here you can showcase the x number of featured contents', 'solid-construction-pro' ) );
  36. if( class_exists( 'Polylang' ) ) {
  37. $sub_title = pll__( $sub_title );
  38. }
  39. }
  40.  
  41. $layout = get_theme_mod( 'solid_construction_featured_content_layout', 'layout-three' );
  42. ?>
  43.  
  44. <div class="featured-content-section section">
  45. <div class="wrapper">
  46. <?php if ( '' !== $title || '' !== $sub_title ) : ?>
  47. <div class="section-heading-wrapper">
  48. <?php if ( '' !== $title ) : ?>
  49. <div class="section-title-wrapper">
  50. <h2 class="section-title"><?php echo wp_kses_post( $title ); ?></h2>
  51. </div><!-- .page-title-wrapper -->
  52. <?php endif; ?>
  53.  
  54. <?php if ( '' !== $sub_title ) : ?>
  55. <div class="section-description">
  56. <?php echo wp_kses_post( $sub_title ); ?>
  57. </div><!-- .section-description -->
  58. <?php endif; ?>
  59. </div><!-- .section-heading-wrapper -->
  60. <?php endif; ?>
  61.  
  62. <div class="section-content-wrapper <?php echo esc_attr( $layout ); ?>">
  63.  
  64. <?php
  65. if ( 'demo' === $type ) {
  66. get_template_part( 'template-parts/featured-content/demo', 'featured' );
  67. }
  68. elseif ( 'image' === $type ) {
  69. get_template_part( 'template-parts/featured-content/content', 'image' );
  70. } else {
  71. foreach ( $featured_posts as $post ) {
  72. setup_postdata( $post );
  73.  
  74. // Include the featured content template.
  75. get_template_part( 'template-parts/featured-content/content', 'featured' );
  76. }
  77.  
  78. wp_reset_postdata();
  79. }
  80. ?>
  81.  
  82. <?php
  83. $target = get_theme_mod( 'solid_construction_featured_content_target' ) ? '_blank': '_self';
  84. $link = get_theme_mod( 'solid_construction_featured_content_link', '#' );
  85. $text = get_theme_mod( 'solid_construction_featured_content_text', esc_html__( 'View All', 'solid-construction-pro' ) );
  86.  
  87. if ( $text ) :
  88. ?>
  89. <p class="view-all-button">
  90. <span class="more-button"><a class="more-link" target="<?php echo $target; ?>" href="<?php echo esc_url( $link ); ?>"><?php echo esc_html( $text ); ?></a></span>
  91. </p>
  92. <?php endif; ?>
  93.  
  94. </div><!-- .featured-content-wrapper -->
  95. </div><!-- .wrapper -->
  96. </div><!-- #featured-content-section -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement