You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

318 lines
13 KiB

  1. <?php get_header() ?>
  2. <?php the_post() ?>
  3. <?php
  4. $site_host = parse_url(get_site_url(), PHP_URL_HOST);
  5. $post_id = get_the_ID();
  6. $post_type = get_post_type($post_id);
  7. $post_type_object = get_post_type_object($post_type);
  8. $post_meta = sandbox_get_post_meta($post_id);
  9. if ( !isset($post_meta['_hide']) || !filter_var($post_meta['_hide'], FILTER_VALIDATE_BOOLEAN) ) {
  10. $post_taxonomies = sandbox_get_the_taxonomies_and_terms($post_id);
  11. $content = '';
  12. $post_class = 'no-download';
  13. $content_meta_args = array('rtime', 'author', 'date');
  14. // Post type "page" fields
  15. $subheadline = isset($post_meta['_subheadline']) ? apply_filters('the_content', $post_meta['_subheadline']) : '';
  16. // Post type "page"
  17. if ( $post_type === 'page' ) {
  18. $content_meta_args = false;
  19. }
  20. // Post type "service"
  21. if ( $post_type === 'service' ) {
  22. $content_meta_args = false;
  23. }
  24. // Post type "aktivitaet"
  25. if ( $post_type === 'aktivitaet' ) {
  26. $content_meta_args = array('period');
  27. // echo var_dump($post_meta);
  28. $can_book = isset($post_meta['_can-book']) ? filter_var($post_meta['_can-book'], FILTER_VALIDATE_BOOLEAN) : false;
  29. $booking_form_slug = isset($post_meta['_booking-form']) ? $post_meta['_booking-form'] : '';
  30. $conditions_table = isset($post_meta['_conditions-table']) ? $post_meta['_conditions-table'] : '';
  31. $terms = isset($post_meta['_terms']) ? $post_meta['_terms'] : '';
  32. $links_internal = isset($post_meta['_links-internal']) ? $post_meta['_links-internal'] : '';
  33. $links_external = isset($post_meta['_links-external']) ? $post_meta['_links-external'] : '';
  34. $pdf_download = isset($post_meta['_pdf-download']) ? $post_meta['_pdf-download'] : '';
  35. }
  36. // Post type "news"
  37. if ( $post_type === 'news' ) {
  38. $content_meta_args = false;
  39. }
  40. // Post type "product" fields
  41. $produkt_pdf = isset($post_meta['_pdf-download']) ? $post_meta['_pdf-download'] : '';
  42. $produkt_url = isset($post_meta['_product-url']) ? $post_meta['_product-url'] : '';
  43. if ( !empty($produkt_pdf) ) {
  44. $produkt_url = wp_get_attachment_url($produkt_pdf);
  45. }
  46. if ( $post_type === 'produkt' ) {
  47. $content_meta_args = false;
  48. }
  49. // Download button
  50. $download_url = !empty($produkt_pdf) ? $produkt_pdf : '';
  51. $download_target = '';
  52. if ( !empty($download_url) ) {
  53. if ( parse_url($download_url, PHP_URL_HOST) !== $site_host ) {
  54. $download_target = ' target="_blank" rel="noopener"';
  55. }
  56. $post_class = 'has-download';
  57. }
  58. if ( empty($content) ) {
  59. $content = apply_filters('the_content', get_the_content());
  60. }
  61. $related_options = array(
  62. 'orderby' => 'menu_order',
  63. 'order' => 'DESC',
  64. 'posts_per_page' => 3,
  65. );
  66. $has_related = false;
  67. $post_tag_ids = array();
  68. if ( !empty($post_taxonomies) ) {
  69. foreach( $post_taxonomies['post_tag']['terms'] as $post_tag ) {
  70. $post_tag_ids[] = $post_tag['term_id'];
  71. }
  72. }
  73. if ( !empty($post_tag_ids) ) {
  74. $related_options = array_merge($related_options, array(
  75. 'post_type' => $post_type,
  76. 'tax_query' => array(array(
  77. 'taxonomy' => 'post_tag',
  78. 'terms' => $post_tag_ids,
  79. )),
  80. 'post__not_in' => array($post_id),
  81. ));
  82. $has_related = true;
  83. }
  84. ?>
  85. <article id="content" <?php post_class($post_class) ?>>
  86. <?php
  87. /*
  88. * @Sidebar Content before
  89. */
  90. get_sidebar('content-before'); ?>
  91. <div class="content inner">
  92. <header class="content-header">
  93. <div class="inner">
  94. <h1 class="title"><?php the_title(); ?></h1>
  95. <?php if ( !empty($subheadline) ) { ?>
  96. <div class="subheadline">
  97. <?php echo $subheadline; ?>
  98. </div>
  99. <?php } ?>
  100. <?php if ( $meta = sandbox_get_meta_data($content_meta_args) ) { ?>
  101. <ul class="meta">
  102. <?php echo $meta; ?>
  103. </ul>
  104. <?php } ?>
  105. <?php if ( has_excerpt() ) { ?>
  106. <div class="intro">
  107. <?php the_excerpt(); ?>
  108. </div>
  109. <?php } ?>
  110. </div>
  111. </header>
  112. <?php if ( $post_type === 'aktivitaet' ) { ?>
  113. <nav class="<?php echo $post_type; ?>-tabs">
  114. <ul class="menu tabs">
  115. <?php if ( !empty($content) ) { ?>
  116. <li class="<?php echo $post_type; ?>-description"><a href="#<?php echo $post_type; ?>-beschreibung"><?php echo __('Beschreibung', 'sandbox'); ?></a></li>
  117. <?php } ?>
  118. <?php if ( !empty($conditions) ) { ?>
  119. <li class="<?php echo $post_type; ?>-conditions"><a href="#<?php echo $post_type; ?>-konditionen"><?php echo __('Konditionen', 'sandbox'); ?></a></li>
  120. <?php } ?>
  121. <?php if ( !empty($terms) ) { ?>
  122. <li class="<?php echo $post_type; ?>-terms"><a href="#<?php echo $post_type; ?>-bedingungen"><?php echo __('Bedingungen', 'sandbox'); ?></a></li>
  123. <?php } ?>
  124. <?php if ( $can_book && !empty($booking_form_slug) ) { ?>
  125. <li class="<?php echo $post_type; ?>-booking"><a href="#<?php echo $post_type; ?>-anmeldung"><?php echo __('Anmeldung', 'sandbox'); ?></a></li>
  126. <?php } ?>
  127. <li class="<?php echo $post_type; ?>-downloads"><a href="#<?php echo $post_type; ?>-downloads"><?php echo __('Links & Downloads', 'sandbox'); ?></a></li>
  128. </ul>
  129. </nav>
  130. <?php } ?>
  131. <?php if ( has_post_thumbnail() ) { ?>
  132. <span class="post-thumbnail"><?php the_post_thumbnail('blog-hero'); ?></span>
  133. <?php } ?>
  134. <?php if ( !empty($content) ) { ?>
  135. <section id="<?php echo $post_type; ?>-beschreibung">
  136. <?php echo $content; ?>
  137. </section>
  138. <?php } ?>
  139. <?php if ( $post_type === 'aktivitaet' ) { ?>
  140. <?php if ( !empty($conditions_table) ) { ?>
  141. <?php
  142. $table_content = '';
  143. foreach ( $conditions_table as $condition_row ) {
  144. if ( !empty($condition_row) ) {
  145. $table_content .= '<tr>';
  146. foreach ( $condition_row as $condition_cell ) {
  147. $table_content .= '<td>';
  148. $table_content .= empty($condition_cell) ? '&nbsp;' : $condition_cell;
  149. $table_content .= '</td>';
  150. }
  151. $table_content .= '</tr>';
  152. }
  153. }
  154. ?>
  155. <section id="<?php echo $post_type; ?>-konditionen" class="conditions">
  156. <h3><?php echo __('Konditionen', 'sandbox'); ?></h3>
  157. <table>
  158. <colgroup>
  159. <col width="auto">
  160. <col width="80px">
  161. <col width="80px">
  162. </colgroup>
  163. <tbody>
  164. <?php echo $table_content; ?>
  165. </tbody>
  166. </table>
  167. </section>
  168. <?php } ?>
  169. <?php if ( !empty($terms) ) { ?>
  170. <section id="<?php echo $post_type; ?>-bedingungen" class="terms">
  171. <h3><?php echo __('Teilnahmebedingungen ', 'sandbox'); ?></h3>
  172. <?php echo apply_filters('the_content', $terms); ?>
  173. </section>
  174. <?php } ?>
  175. <?php if ( $can_book && !empty($booking_form_slug) ) { ?>
  176. <section id="<?php echo $post_type; ?>-anmeldung" class="booking">
  177. <h3><?php echo __('Anmeldung', 'sandbox'); ?> <?php the_title(); ?></h3>
  178. <?php echo do_shortcode('[cf7form cf7key="' . $booking_form_slug . '"]'); ?>
  179. </section>
  180. <?php } ?>
  181. <?php if ( !empty($links_internal) || !empty($links_external) || !empty($pdf_download) ) { ?>
  182. <section id="<?php echo $post_type; ?>-downloads" class="downloads">
  183. <h3><?php echo __('Links & Downloads', 'sandbox'); ?></h3>
  184. <ul class="links-downloads">
  185. <?php if ( !empty($links_internal) ) { ?>
  186. <?php foreach ( $links_internal as $link_id ) { ?>
  187. <li class="internal"><a href="<?php echo get_permalink(intval($link_id)); ?>"><?php echo get_the_title(intval($link_id)); ?></a></li>
  188. <?php } ?>
  189. <?php } ?>
  190. <?php if ( !empty($links_external) ) { ?>
  191. <?php foreach ( $links_external as $link ) { ?>
  192. <li class="external"><a href="<?php echo $link['url']; ?>" target="_blank" rel="nofollow,noopener"><?php echo $link['text']; ?></a></li>
  193. <?php } ?>
  194. <?php } ?>
  195. <?php if ( !empty($pdf_download) ) { ?>
  196. <li class="download"><a href="<?php echo wp_get_attachment_url($pdf_download); ?>" target="_blank"><?php echo __('Infos im PDF herunterladen', 'sandbox'); ?></a></li>
  197. <?php } ?>
  198. </ul>
  199. </section>
  200. <?php } ?>
  201. <?php } ?>
  202. </div>
  203. <?php
  204. /*
  205. * @Sidebar Content after
  206. */
  207. get_sidebar('content-after'); ?>
  208. <?php // If comments are open or we have at least one comment, load up the comment template. ?>
  209. <?php if ( comments_open() || get_comments_number() ) { ?>
  210. <?php comments_template('/comments-alpha_download.php'); ?>
  211. <?php } ?>
  212. </article><!-- .post -->
  213. <?php } ?>
  214. <?php if ( $post_type === 'post' ) { ?>
  215. <h2 class="title author-title"><?php echo __('About the author', 'sandbox'); ?></h2>
  216. <div class="author-information">
  217. <?php
  218. $author_name = get_the_author();
  219. $author_position = get_the_author_meta('_position');
  220. $author_description = get_the_author_meta('description');
  221. $author_image = get_wp_user_avatar(get_the_author_ID(), 'thumbnail-semi-large');
  222. $author_linkedin_name = get_the_author_meta('_linkedin');
  223. $author_linkedin_url = 'https://www.linkedin.com/in/' . $author_linkedin_name;
  224. ?>
  225. <?php if ( $author_image ) { ?>
  226. <span class="author-image"><?php echo $author_image; ?></span>
  227. <?php } ?>
  228. <div class="content">
  229. <h3><?php echo $author_name; ?></h3>
  230. <?php if ( $author_position ) { ?>
  231. <p class="position"><?php echo $author_position; ?></p>
  232. <?php } ?>
  233. <?php if ( $author_description ) { ?>
  234. <p><?php echo $author_description; ?></p>
  235. <?php } ?>
  236. <ul class="contacts">
  237. <li class="linkedin"><a href="<?php echo $author_linkedin_url; ?>" target="_blank" rel="noopener, noreferrer"><?php echo $author_name; ?></a></li>
  238. </ul>
  239. </div>
  240. </div>
  241. <?php } ?>
  242. <div class="blog-navigation">
  243. <?php if ( $post_type === 'post' ) { ?>
  244. <?php
  245. $blog_posts_page_id = intval(get_option('page_for_posts'));
  246. ?>
  247. <a class="button back-to-blog" href="<?php echo get_permalink($blog_posts_page_id); ?>"><?php echo __('Back to blog', 'sandbox'); ?></a>
  248. <?php } ?>
  249. <nav class="navigation post-navigation" aria-label="<?php echo __('Posts', 'sandbox'); ?>">
  250. <h2 class="screen-reader-text"><?php echo __('Post navigation', 'sandbox'); ?></h2>
  251. <div class="nav-links">
  252. <div class="nav-previous">
  253. <?php previous_post_link('%link', '<span class="meta-nav" aria-hidden="true">' . __('Vorige ' . $post_type_object->labels->singular_name, 'sandbox') . '</span> ' . '<span class="screen-reader-text">' . __('Previous post:', 'sandbox') . '</span> ' . '<span class="post-title">%title</span>'); ?>
  254. </div>
  255. <div class="nav-next">
  256. <?php next_post_link('%link', '<span class="meta-nav" aria-hidden="true">' . __('Nächste ' . $post_type_object->labels->singular_name, 'sandbox') . '</span> ' . '<span class="screen-reader-text">' . __('Next post:', 'sandbox') . '</span> ' . '<span class="post-title">%title</span>'); ?>
  257. </div>
  258. </div>
  259. </nav>
  260. </div>
  261. <?php
  262. if ( $has_related ) {
  263. $related = new WP_Query($related_options);
  264. }
  265. ?>
  266. <?php if ( $has_related && $related->have_posts() ) { ?>
  267. <h2 class="title related-title"><?php echo __('Related posts', 'sandbox'); ?></h2>
  268. <div class="related-posts">
  269. <div class="inner">
  270. <?php while ( $related->have_posts() ) {
  271. $related->the_post(); ?>
  272. <?php
  273. $post_type = get_post_type();
  274. $post_meta = get_post_custom();
  275. $more_text = sandbox_get_more_text($post_type, $post_meta);
  276. $excerpt = has_excerpt() ? get_the_excerpt() : wp_trim_words(get_the_content(), 40);
  277. $excerpt .= ' <span class="more">' . $more_text . '</span>';
  278. ?>
  279. <a <?php post_class('related-post') ?> href="<?php the_permalink(); ?>">
  280. <figure class="related-thumbnail"><?php the_post_thumbnail('sandbox-default'); ?></figure>
  281. <div class="inner content">
  282. <h3><?php the_title(); ?></h3>
  283. <?php echo apply_filters('the_content', $excerpt); ?>
  284. <?php if ( $meta = sandbox_get_meta_data(array('rtime', 'author', 'date')) ) { ?>
  285. <ul class="meta">
  286. <?php echo $meta; ?>
  287. </ul>
  288. <?php } ?>
  289. </div>
  290. </a>
  291. <?php } ?>
  292. </div>
  293. </div>
  294. <?php } ?>
  295. <?php wp_reset_postdata(); ?>
  296. <?php get_footer() ?>