[ Index ]

MailPress 544

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

title

Body

[close]

/mp-includes/class/ -> MP_newsletter_scheduler_post_.class.php (source)

   1  <?php
   2  abstract class MP_newsletter_scheduler_post_ extends MP_newsletter_scheduler_
   3  {
   4  	function __construct($description)
   5      {
   6          parent::__construct($description);
   7  
   8          add_action("publish_{$this->post_type}",    array($this, 'publish'), 8, 1);
   9      }
  10  
  11  	function publish($post_id)
  12      {
  13          if (get_post_meta($post_id, '_MailPress_prior_to_install')) return true;
  14  
  15          $newsletters = MP_Newsletter::get_active_by_scheduler($this->id);
  16          if (empty($newsletters)) return true;
  17  
  18          $post = get_post($post_id);
  19          $the_title = apply_filters('the_title', $post->post_title );
  20  
  21          $y = $this->year;
  22          $m = $this->month;
  23          $d = $this->day;
  24  
  25          $results = array();
  26  
  27          $trace = MP_Newsletter_schedulers::header_report("publish_{$this->post_type} : {$post_id}    {$this->id}");
  28          foreach($newsletters as $newsletter)
  29          {
  30              $this->newsletter = $newsletter;
  31  
  32              $this->newsletter['mail']['the_title'] = $the_title;
  33  
  34              $this->newsletter['processor']['query_posts']['p'] = $post_id;
  35              if ($this->post_type != 'post') $this->newsletter['processor']['query_posts']['post_type'] = $this->post_type;
  36  
  37              $this->newsletter['params']['post_id']  = $post_id;
  38              $this->newsletter['params']['meta_key'] = $this->get_meta_key();
  39              if ($this->post_type != 'post') $this->newsletter['params']['post_type']= $this->post_type;
  40          
  41              $h = $this->hour  + $this->get_hour();
  42              $i = $this->minute+ $this->get_minute();
  43  
  44              $results[] = $this->schedule_single_event( $this->mktime( $h, $i, 0, $m, $d, $y ), 'mp_process_post_newsletter' );
  45          }
  46  
  47          if (!empty($results))
  48          {
  49              MP_Newsletter_schedulers::sep_report($trace);
  50              $results = array_reverse($results);
  51              uasort($results, create_function('$a, $b', 'return strcmp($a["timestamp"], $b["timestamp"]);'));
  52              foreach($results as $result) $trace->log($result['log']);
  53          }
  54          MP_Newsletter_schedulers::footer_report($trace);
  55      }
  56  
  57  	function get_meta_key()
  58      {
  59          $trailer = '';
  60  
  61          if ('post' != $this->post_type) $trailer .= "_{$this->post_type}";
  62          if (isset($this->taxonomy))
  63          {
  64              $trailer .= "_{$this->taxonomy}";
  65              if (isset($this->newsletter['params']['term_id']))     $trailer .= "_{$this->newsletter['params']['term_id']}";
  66              elseif (isset($this->newsletter['params']['cat_id']))    $trailer .= "_{$this->newsletter['params']['cat_id']}";  // backward compatibility
  67          }
  68  
  69          return "_MailPress_published{$trailer}";
  70      }
  71  }


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