[ Index ]

MailPress 7.1

[ 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          $advanced_path = 'advanced/' . get_current_blog_id() . "/newsletters/{$this->post_type}";
  24  
  25          $this->args = array(     'root'         => MP_UPL_ABSPATH . $advanced_path,
  26                          'root_filter'     => "MailPress_advanced_newsletters_{$this->post_type}_root",
  27                          'files'        => array( "post_type", "daily", "weekly", "monthly" ),
  28  
  29                          'Template'        => $this->post_type,
  30  
  31                          'post_type'    => $this->post_type,
  32  
  33  
  34           );
  35      }
  36  
  37  	function register() 
  38      {
  39          MP_Newsletter::register_files( $this->args );
  40      }
  41  
  42  	function subscriptions_newsletter_th( $th, $newsletter )
  43      {
  44          if (     isset( $newsletter['params']['post_type'] )     && $this->post_type == $newsletter['params']['post_type'] && !isset( $newsletter['params']['taxonomy'] ) )
  45              return '** ' . $newsletter['mail']['the_post_type'] . ' **';
  46          return $th;
  47      }
  48  
  49  	function install() 
  50      {
  51          $event = "Install newsletter_{$this->post_type}";
  52          if ( isset( $this->taxonomy ) ) $event .=  "_{$this->taxonomy}";
  53  
  54          $now4cron = current_time( 'timestamp', 'gmt' );
  55          wp_schedule_single_event( $now4cron - 1, 'mp_schedule_newsletters', array( 'args' => array( 'event' => $event ) ) );
  56      }
  57  
  58  	function uninstall() 
  59      {
  60          wp_unschedule_hook( 'mp_process_newsletter' );
  61  
  62          $event = "Uninstall newsletter_{$this->post_type}";
  63          if ( isset( $this->taxonomy ) ) $event .=  "_{$this->taxonomy}";
  64  
  65          $now4cron = current_time( 'timestamp', 'gmt' );
  66          wp_schedule_single_event( $now4cron + 1, 'mp_schedule_newsletters', array( 'args' => array( 'event' => $event ) ) );
  67      }
  68  
  69  	function plugin_action_links( $links, $file )
  70      {
  71          return MailPress::plugin_links( $links, $file, plugin_basename( $this->file ), 'subscriptions' );
  72      }
  73  }


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1