Advertisement
Guest User

page-home.php

a guest
Sep 18th, 2013
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.56 KB | None | 0 0
  1. <?php
  2. /* Template name: Home page */
  3.  
  4. get_header(); ?>
  5.  
  6. <?php if ( have_posts() ) while ( have_posts() ) : the_post();
  7. ?>
  8. <div class="row white">
  9.  
  10. <?php
  11.     // Load intranet homepage settings
  12.     $hc = "homepage_control_campaign_message";
  13.     $hcitem = get_option($hc);
  14.     $campaign_message = $hcitem;
  15.  
  16.     $hc = new Pod ('homepage_control');
  17.     $top_pages =  $hc->get_field('top_pages');
  18.    
  19.  
  20.     $hc = "homepage_control_emergency_message";
  21.     $hcitem = get_option($hc);
  22.     $homecontent =  $hcitem;
  23.  
  24.     if ($homecontent ): //Display emergency message
  25.     ?>
  26.     <div class="twelvecol last">
  27.         <div class="content-wrapper">
  28.             <div id='intranet-announcement' class="bbp-template-notice">
  29.                 <?php   echo wpautop($homecontent); ?>
  30.             </div>
  31.         </div>
  32.     </div> 
  33.     <?php endif; ?>
  34.  
  35.     <div class="content-wrapper">
  36.         <div class="sixcol">
  37.             <?php   dynamic_sidebar('home-widget-area0'); ?>   
  38.         </div>
  39.         <div class="threecol">
  40.             <?php   dynamic_sidebar('home-widget-area1'); ?>
  41.             <?php   dynamic_sidebar('home-widget-area2'); ?>
  42.         </div>
  43.         <div class="threecol last">
  44.             <?php   dynamic_sidebar('home-widget-area3'); ?>   
  45.             <?php   dynamic_sidebar('home-widget-area4'); ?>   
  46.         </div>
  47.         <div class="twelvecol white last">
  48.             <?php   if ($campaign_message) { //Display campaign message
  49.             echo "<div class='content-wrapper'>".wpautop($campaign_message)."</div>";
  50.             }
  51.             ?>
  52.             <br>
  53.         </div>
  54.     </div>
  55. </div>
  56.  
  57. <?php endwhile; ?>
  58. <?php
  59.  
  60. $removenews = get_transient('cached_removenews');
  61. if (!$removenews || !is_array($removenews)){
  62.  
  63. //process expired news
  64.  
  65. $gis = "general_intranet_time_zone";
  66. $tzone = get_option($gis);
  67. date_default_timezone_set($tzone);
  68. $tdate= getdate();
  69. $tdate = $tdate['year']."-".$tdate['mon']."-".$tdate['mday'];
  70. $tday = date( 'd' , strtotime($tdate) );
  71. $tmonth = date( 'm' , strtotime($tdate) );
  72. $tyear= date( 'Y' , strtotime($tdate) );
  73. $sdate=$tyear."-".$tmonth."-".$tday;
  74. $stime=date('H:i');
  75.  
  76. $oldnews = query_posts(array(
  77. 'post_type'=>'news',
  78. 'meta_query'=>array(array(
  79. 'relation'=>'AND',
  80. 'key'=>'expiry_date',
  81. 'value'=>$sdate,
  82. 'compare'=>'<='
  83. ),
  84. array(
  85. 'key'=>'expiry_time',
  86. 'value'=>$stime,
  87. 'compare'=>'<='
  88. ))));
  89.  
  90. if ( count($oldnews) > 0 ){
  91.     foreach ($oldnews as $old) {
  92.         $expiryaction = get_post_meta($old->ID,'expiry_action',true);
  93.         if ($expiryaction=='Revert to draft status'){
  94.               $my_post = array();
  95.               $my_post['ID'] = $old->ID;
  96.               $my_post['post_status'] = 'draft';
  97.               wp_update_post( $my_post );
  98.               delete_post_meta($old->ID, 'expiry_date');
  99.               delete_post_meta($old->ID, 'expiry_time');
  100.               delete_post_meta($old->ID, 'expiry_action');
  101.         }  
  102.         if ($expiryaction=='Change to regular news'){
  103.             update_post_meta($old->ID, 'news_listing_type', 'Regular', 'Need to know');
  104.               delete_post_meta($old->ID, 'expiry_date');
  105.               delete_post_meta($old->ID, 'expiry_time');
  106.               delete_post_meta($old->ID, 'expiry_action');
  107.         }  
  108.         if ($expiryaction=='Move to trash'){
  109.               $my_post = array();
  110.               $my_post['ID'] = $old->ID;
  111.               $my_post['post_status'] = 'trash';
  112.               delete_post_meta($old->ID, 'expiry_date');
  113.               delete_post_meta($old->ID, 'expiry_time');
  114.               delete_post_meta($old->ID, 'expiry_action');
  115.               wp_update_post( $my_post );
  116.         }  
  117.     }
  118. }
  119. $timer=array();
  120. $timer[]='last_removed';
  121. $gi = "general_intranet_expired_news_cache";
  122. $expirednewscache = get_option($gi);
  123. if ($expirednewscache <= 0 ) {
  124.     $expirednewscache = 8;//default to 8 hours for checking expired news
  125. }
  126.  
  127. set_transient('cached_removenews',$timer,60*$expirednewscache); // customised cache period
  128. wp_reset_query();
  129. }
  130.  
  131.  
  132. //
  133. ?>
  134. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement