| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/Engineering/V1/iimec/wp-content/themes/annotum-base/functions/ |
Upload File : |
<?php
class Anno_Cacheer {
public $key;
public $timeout = 3600; // 1hr
public $enable_cache = true;
public function __construct($key = '', $timeout = false) {
if ($key) {
$this->key = $key;
}
if ($timeout) {
$this->timeout = $timeout;
}
}
public function render() {
$cache = get_transient($this->key);
if ($cache === false || $this->enable_cache === false) {
ob_start();
$this->cached();
$cache = ob_get_clean();
set_transient($this->key, $cache, $this->timeout);
}
echo $cache;
}
public function cached() {
// Do something...
}
}
class Anno_Featured_Articles extends Anno_Cacheer {
public $enable_cache = true;
public function cached() {
$q = new WP_Query(array(
'meta_query' => array(array(
'key' => '_anno_featured',
'value' => 'on'
)),
'post_type' => 'article',
'posts_per_page' => 5
));
if ($q->have_posts()) { ?>
<div id="home-featured" class="featured-posts carousel">
<ul>
<?php
while ($q->have_posts()) {
$q->the_post(); ?>
<li>
<div <?php post_class('carousel-item'); ?>>
<?php the_post_thumbnail('featured'); ?>
<h2 class="title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div class="content">
<?php the_excerpt(); ?>
</div>
</div>
</li>
<?php
}
?>
</ul>
</div>
<?php
wp_reset_postdata();
}
}
}
?>