[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/newsletter/processors/ -> week-1.php (source)

   1  <?php
   2  class MP_Newsletter_processor_week_1 extends MP_newsletter_processor_
   3  {
   4      const day_in_sec  = 86400;  // 24*60*60
   5      const week_in_sec = 604800; // 7*24*60*60
   6  
   7      public $id = 'week-1';
   8  
   9  	function get_bounds() 
  10      {
  11          $d = $this->time;
  12          $wd= $this->get_wday();
  13          $h = $this->get_hour();
  14          $i = $this->get_minute();
  15  
  16          $format = 'Y-m-d ' . zeroise($h, 2) . ':' . zeroise($i, 2) . ':00';
  17  
  18          while (date('w', $d) != $wd) $d -= self::day_in_sec;
  19  
  20          $this->upper_bound = date($format, $d);
  21  
  22          if ($this->upper_bound > $this->date)
  23          {
  24              $d -= self::week_in_sec;
  25              $this->upper_bound = date($format, $d);
  26          }
  27  
  28          $this->lower_bound = date($format, $d - self::week_in_sec);
  29  
  30          switch (true)
  31          {
  32              case (isset($this->options['threshold'])) :            // old old format
  33                  $y = substr($this->options['threshold'], 0, 4);
  34                  $w = substr($this->options['threshold'], 4, 2);
  35                  $this->old_lower_bound = date('Y-m-d 00:00:00', strtotime("{$y}W{$w}1"));
  36              break;
  37              case (isset($this->options['end_of_week'])) :             // old format
  38                  $this->old_lower_bound = date('Y-m-d 00:00:00', $this->options['end_of_week'] + self::day_in_sec);
  39              break;
  40              default :
  41                  $this->get_old_lower_bound();
  42              break;
  43          }
  44      }
  45  
  46  	function query_posts($query_posts = array()) 
  47      { 
  48          if (substr($this->lower_bound, 11, 8) == '00:00:00' && date('w', strtotime($this->lower_bound)) == 1 &&
  49              substr($this->upper_bound, 11, 8) == '00:00:00' && date('w', strtotime($this->upper_bound)) == 1 )
  50          {
  51              $query_posts['year'] = date('o', strtotime($this->lower_bound));
  52              $query_posts['w']    = date('W', strtotime($this->lower_bound));
  53              return $query_posts;
  54          }
  55  
  56          $this->add_filter();
  57          return $query_posts;
  58      }
  59  }
  60  new MP_Newsletter_processor_week_1(__('Previous week', MP_TXTDOM));


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1