Fixed transient behavior when the cache plugin is enabled.
[WebKit-https.git] / Websites / webkit.org / wp-content / themes / webkit / includes.php
1 <?php
2 /**
3  * Template Name: Included Page
4  **/
5 ?>
6 <?php get_header(); ?>
7
8     <?php if (have_posts()) : while (have_posts()) : the_post(); 
9             
10         $path = dirname(ABSPATH);
11         $file = get_post_meta(get_the_ID(), 'include-markdown', true);
12
13         $cachekey = "cached_include_" . $file;
14         if ( is_super_cache_enabled() || false === ( $content = get_transient($cachekey) ) ) {
15             ob_start();
16             include $path . '/' . $file;
17             $content = ob_get_clean();
18
19             // Handle sub-section anchors
20             $content = preg_replace('/\[]\(\#([^\)]+)\)\s+?/', '<a href="#$1" name="$1"></a>', $content);
21             
22             // Transform Markdown
23             $Markdown = WPCom_Markdown::get_instance();
24             $content = wp_unslash( $Markdown->transform($content) );
25             
26             // Index table of contents
27             $content = table_of_contents_index($content, get_the_ID());
28             
29             set_transient($cachekey, $content, DAY_IN_SECONDS);
30         }
31         
32     ?>
33
34         <article class="page<?php if ( has_table_of_contents() ) echo ' with-toc';?>" id="post-<?php the_ID(); ?>">
35                 
36             <h1><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>
37             
38             <div class="bodycopy">
39             <?php table_of_contents(); ?>
40             <?php
41                 echo apply_filters('the_content', $content);
42             ?>
43             </div>
44         </article>
45
46     <?php //comments_template(); ?>
47
48     <?php endwhile; else:
49         include('444.php');
50     endif; ?>
51
52 <?php get_footer(); ?>