Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

137 рядки
4.3 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_meta = sandbox_get_post_meta($post_id);
  8. if ( !isset($post_meta['_hide']) || !filter_var($post_meta['_hide'], FILTER_VALIDATE_BOOLEAN) ) {
  9. $post_taxonomies = sandbox_get_the_taxonomies_and_terms($post_id);
  10. $content = '';
  11. $post_class = 'no-download';
  12. $content_meta_args = array('date');
  13. // post style attribute
  14. $post_style = '';
  15. $color_hex_pattern = '/#([a-f0-9]{3}){1,2}\b/i';
  16. $has_background_color = isset($post_meta['_background-color']) && preg_match($color_hex_pattern, $post_meta['_background-color']);
  17. $has_post_style = $has_background_color;
  18. if ( $has_post_style ) {
  19. $post_style = ' style="';
  20. }
  21. // background-color
  22. if ( $has_background_color ) {
  23. $post_style .= 'background-color:' . $post_meta['_background-color'] . ';';
  24. $post_class .= ' has-background-color';
  25. }
  26. if ( $has_post_style ) {
  27. $post_style .= '"';
  28. }
  29. // Dark or light color scheme
  30. if ( isset($post_meta['_color-scheme']) ) {
  31. $post_class .= ' color-scheme-' . $post_meta['_color-scheme'];
  32. }
  33. // Show image before or after the content
  34. if ( isset($post_meta['_image-position']) ) {
  35. $post_class .= ' image-position-' . $post_meta['_image-position'];
  36. }
  37. // Post type "page" fields
  38. $subheadline = isset($post_meta['_subheadline']) ? apply_filters('the_content', $post_meta['_subheadline']) : '';
  39. // Post type "page"
  40. if ( $post_type === 'page' ) {
  41. $content_meta_args = false;
  42. }
  43. // Post type "service"
  44. if ( $post_type === 'service' ) {
  45. $content_meta_args = false;
  46. }
  47. // Post type "product" fields
  48. $produkt_pdf = isset($post_meta['_pdf-download']) ? $post_meta['_pdf-download'] : '';
  49. $produkt_url = isset($post_meta['_product-url']) ? $post_meta['_product-url'] : '';
  50. if ( !empty($produkt_pdf) ) {
  51. $produkt_url = wp_get_attachment_url($produkt_pdf);
  52. }
  53. if ( $post_type === 'produkt' ) {
  54. $content_meta_args = false;
  55. }
  56. // Download button
  57. $download_url = !empty($produkt_pdf) ? $produkt_pdf : '';
  58. $download_target = '';
  59. if ( !empty($download_url) ) {
  60. if ( parse_url($download_url, PHP_URL_HOST) !== $site_host ) {
  61. $download_target = ' target="_blank" rel="noopener"';
  62. }
  63. $post_class = 'has-download';
  64. }
  65. if ( empty($content) ) {
  66. $content = apply_filters('the_content', get_the_content());
  67. }
  68. ?>
  69. <article id="content" <?php post_class($post_class) ?><?php echo $post_style; ?>>
  70. <header class="content-header">
  71. <div class="inner">
  72. <h1 class="title"><?php the_title(); ?>
  73. <?php if ( !empty($download_url) ) { ?>
  74. <a class="download" href="<?php echo $download_url; ?>"<?php echo $download_target; ?>><?php echo __('Download', 'sandbox'); ?></a>
  75. <?php } ?></h1>
  76. <?php if ( !empty($subheadline) ) { ?>
  77. <div class="subheadline content">
  78. <?php echo $subheadline; ?>
  79. </div>
  80. <?php } ?>
  81. <?php if ( has_excerpt() ) { ?>
  82. <div class="intro">
  83. <?php the_excerpt(); ?>
  84. </div>
  85. <?php } ?>
  86. <?php if ( $meta = sandbox_get_meta_data($content_meta_args) ) { ?>
  87. <ul class="meta">
  88. <?php echo $meta; ?>
  89. </ul>
  90. <?php } ?>
  91. </div>
  92. </header>
  93. <?php
  94. /*
  95. * @Sidebar Content before
  96. */
  97. get_sidebar('content-before'); ?>
  98. <div class="content inner">
  99. <?php if ( has_post_thumbnail() ) { ?>
  100. <span class="post-thumbnail"><?php the_post_thumbnail('full'); ?></span>
  101. <?php } ?>
  102. <?php if ( !empty($content) ) { ?>
  103. <?php echo $content; ?>
  104. <?php } ?>
  105. </div>
  106. <?php
  107. /*
  108. * @Sidebar Content after
  109. */
  110. get_sidebar('content-after'); ?>
  111. <?php // If comments are open or we have at least one comment, load up the comment template. ?>
  112. <?php if ( comments_open() || get_comments_number() ) { ?>
  113. <?php comments_template('/comments.php'); ?>
  114. <?php } ?>
  115. </article><!-- .post -->
  116. <?php } ?>
  117. <?php get_footer() ?>