[ Index ]

MailPress 544

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

title

Body

[close]

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

   1  <?php
   2  abstract class MP_newsletter_post_type_
   3  {
   4      var $register_priority = 10;
   5  
   6  	function __construct() 
   7      {
   8          add_action('MailPress_register_newsletter',    array($this, 'register'), $this->register_priority);
   9  
  10          if (method_exists($this,'init')) add_action('init', array($this, 'init'), 1);
  11  
  12          if (is_admin())
  13          {
  14          // settings
  15              add_filter('MailPress_subscriptions_newsletter_th',        array($this, 'subscriptions_newsletter_th'), 10, 2 );
  16          // install
  17              register_activation_hook(  plugin_basename($this->file),    array($this, 'install'));
  18              register_deactivation_hook(plugin_basename($this->file),    array($this, 'uninstall'));
  19          // for link on plugin page
  20              add_filter('plugin_action_links',                    array($this, 'plugin_action_links'), 10, 2 );
  21          }
  22  
  23          $this->args = array(    'root'         => MP_CONTENT_DIR . "advanced/newsletters/{$this->post_type}",
  24                          'root_filter'     => "MailPress_advanced_newsletters_{$this->post_type}_root",
  25                          'files'        => array("post_type", "daily", "weekly", "monthly"),
  26  
  27                          'Template'        => $this->post_type,
  28  
  29                          'post_type'    => $this->post_type,
  30  
  31  
  32          );
  33      }
  34  
  35  	function register() 
  36      {
  37          MP_Newsletter::register_files($this->args);
  38      }
  39  
  40  	function subscriptions_newsletter_th($th, $newsletter)
  41      {
  42          if (    isset($newsletter['params']['post_type'])     && $this->post_type == $newsletter['params']['post_type'] && !isset($newsletter['params']['taxonomy']) )
  43              return '** ' . $newsletter['mail']['the_post_type'] . ' **';
  44          return $th;
  45      }
  46  
  47  	function install() 
  48      {
  49          $event = "Install newsletter_{$this->post_type}";
  50          if (isset($this->taxonomy)) $event .=  "_{$this->taxonomy}";
  51  
  52          $now4cron = current_time('timestamp', 'gmt');
  53          wp_schedule_single_event($now4cron - 1, 'mp_schedule_newsletters', array('args' => array('event' => $event )));
  54      }
  55  
  56  	function uninstall() 
  57      {
  58          MailPress_newsletter::unschedule_hook('mp_process_newsletter');
  59  
  60          $event = "Uninstall newsletter_{$this->post_type}";
  61          if (isset($this->taxonomy)) $event .=  "_{$this->taxonomy}";
  62  
  63          $now4cron = current_time('timestamp', 'gmt');
  64          wp_schedule_single_event($now4cron + 1, 'mp_schedule_newsletters', array('args' => array('event' => $event )));
  65      }
  66  
  67  	function plugin_action_links($links, $file)
  68      {
  69          return MailPress::plugin_links($links, $file, plugin_basename($this->file), 'subscriptions');
  70      }
  71  }


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