/wp-content/themes/Avada/faqs.php

https://gitlab.com/webkod3r/tripolis · PHP · 141 lines · 107 code · 19 blank · 15 comment · 13 complexity · 44dd7e2db3256733b6ed4c967c6687fb MD5 · raw file

  1. <?php
  2. // Template Name: FAQs
  3. get_header(); ?>
  4. <div id="content" class="fusion-faqs" <?php Avada()->layout->add_style( 'content_style' ); ?>>
  5. <?php
  6. // Get the content of the faq page itself
  7. while ( have_posts() ): the_post();
  8. ob_start();
  9. post_class();
  10. $post_classes = ob_get_clean();
  11. echo sprintf( '<div id="post-%s" %s>', get_the_ID(), $post_classes );
  12. // Get rich snippets of the faq page
  13. echo avada_render_rich_snippets_for_pages();
  14. // Get featured images of the faq page
  15. echo avada_featured_images_for_pages();
  16. // Render the content of the faq page
  17. echo '<div class="post-content">';
  18. the_content();
  19. avada_link_pages();
  20. echo '</div>';
  21. echo '</div>';
  22. endwhile;
  23. // Check if the post is password protected
  24. if ( ! post_password_required( $post->ID ) ) {
  25. // Get faq terms
  26. $faq_terms = get_terms( 'faq_category' );
  27. // Check if we should display filters
  28. if ( Avada()->settings->get( 'faq_filters' ) != 'no' &&
  29. $faq_terms
  30. ) {
  31. echo '<ul class="fusion-filters clearfix">';
  32. // Check if the "All" filter should be displayed
  33. if ( Avada()->settings->get( 'faq_filters' ) == 'yes' ) {
  34. echo sprintf( '<li class="fusion-filter fusion-filter-all fusion-active"><a data-filter="*" href="#">%s</a></li>', apply_filters( 'avada_faq_all_filter_name', __( 'All', 'Avada' ) ) );
  35. $first_filter = FALSE;
  36. } else {
  37. $first_filter = TRUE;
  38. }
  39. // Loop through the terms to setup all filters
  40. foreach ( $faq_terms as $faq_term ) {
  41. // If the "All" filter is disabled, set the first real filter as active
  42. if ( $first_filter ) {
  43. echo sprintf( '<li class="fusion-filter fusion-active"><a data-filter=".%s" href="#">%s</a></li>', urldecode( $faq_term->slug ), $faq_term->name );
  44. $first_filter = FALSE;
  45. } else {
  46. echo sprintf( '<li class="fusion-filter fusion-hidden"><a data-filter=".%s" href="#">%s</a></li>', urldecode( $faq_term->slug ), $faq_term->name );
  47. }
  48. }
  49. echo '</ul>';
  50. }
  51. ?>
  52. <div class="fusion-faqs-wrapper">
  53. <div class="accordian fusion-accordian">
  54. <div class="panel-group" id="accordian-one">
  55. <?php
  56. $args = array(
  57. 'post_type' => 'avada_faq',
  58. 'posts_per_page' => -1
  59. );
  60. $faq_items = new WP_Query( $args );
  61. $count = 0;
  62. while ( $faq_items->have_posts() ): $faq_items->the_post();
  63. $count++;
  64. //Get all terms of the post and it as classes; needed for filtering
  65. $post_classes = '';
  66. $post_terms = get_the_terms( $post->ID, 'faq_category' );
  67. if ( $post_terms ) {
  68. foreach ( $post_terms as $post_term ) {
  69. $post_classes .= urldecode( $post_term->slug ) . ' ';
  70. }
  71. }
  72. ?>
  73. <div class="fusion-panel panel-default fusion-faq-post <?php echo $post_classes; ?>">
  74. <?php // get the rich snippets for the post
  75. echo avada_render_rich_snippets_for_pages(); ?>
  76. <div class="panel-heading">
  77. <h4 class="panel-title toggle">
  78. <a data-toggle="collapse" class="collapsed" data-parent="#accordian-one" data-target="#collapse-<?php echo get_the_ID(); ?>" href="#collapse-<?php echo get_the_ID(); ?>">
  79. <div class="fusion-toggle-icon-wrapper">
  80. <i class="fa-fusion-box"></i>
  81. </div>
  82. <div class="fusion-toggle-heading"><?php echo get_the_title(); ?></div>
  83. </a>
  84. </h4>
  85. </div>
  86. <?php
  87. echo sprintf( '<div id="collapse-%s" class="panel-collapse collapse">', get_the_ID() );
  88. echo '<div class="panel-body toggle-content post-content">';
  89. // Render the featured image of the post
  90. if ( Avada()->settings->get( 'faq_featured_image' ) &&
  91. has_post_thumbnail()
  92. ) {
  93. $featured_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
  94. if ( $featured_image[0] ) {
  95. echo '<div class="flexslider post-slideshow">';
  96. echo '<ul class="slides">';
  97. echo '<li>';
  98. echo sprintf( '<a href="%s" data-rel="iLightbox[gallery]" data-title="%s" data-caption="%s">%s</a>',
  99. $featured_image[0], get_post_field( 'post_title', get_post_thumbnail_id() ), get_post_field( 'post_excerpt', get_post_thumbnail_id() ), get_the_post_thumbnail( get_the_ID(), 'blog-large' ) );
  100. echo '</li>';
  101. echo '</ul>';
  102. echo '</div>';
  103. }
  104. }
  105. // Render the post content
  106. the_content();
  107. ?>
  108. </div>
  109. </div>
  110. </div>
  111. <?php endwhile; // loop through faq_items ?>
  112. </div>
  113. </div>
  114. </div>
  115. <?php
  116. } // password check
  117. echo '</div>';
  118. wp_reset_query();
  119. do_action( 'fusion_after_content' );
  120. ?>
  121. <?php get_footer();
  122. // Omit closing PHP tag to avoid "Headers already sent" issues.