示例#1
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->settings = new \SimpleSubscribe\Settings(SUBSCRIBE_KEY);
     $this->settingsAll = $this->settings->getSettings();
     $this->htmlEmail = isset($this->settingsAll['emailType']['source']) ? $this->settingsAll['emailType']['source'] == 0 ? TRUE : FALSE : TRUE;
     $this->subscribers = \SimpleSubscribe\RepositorySubscribers::getInstance();
     $this->log = \SimpleSubscribe\RepositoryLog::getInstance();
     $this->mailer = new \Nette\Mail\SendmailMailer();
     $this->senderName = isset($this->settingsAll['misc']['senderName']) ? $this->settingsAll['misc']['senderName'] : html_entity_decode(get_option('blogname'), ENT_QUOTES);
     $this->senderEmail = isset($this->settingsAll['misc']['senderEmail']) ? $this->settingsAll['misc']['senderEmail'] : get_option('admin_email');
 }
示例#2
0
 /**
  * On post publish
  *
  * @param $post
  * @return mixed
  */
 public function onPublish($post)
 {
     if ($post) {
         $subcribers = $this->subscribers->getAllActiveEmails();
         $postDigest = $this->getPostDigestBody($post);
         try {
             $this->sendEmail($subcribers, $postDigest->subject, $postDigest->data);
             // log success message
             $this->log->add(1, 'Digest successfully sent to ' . count($subcribers) . ' subscribers. Post ID: ' . $post->ID);
         } catch (EmailException $e) {
             // log error
             $this->log->add(0, $e->getMessage());
         }
     } else {
         // log error
         $this->log->add(0, 'Digest not sent - no post included. Removed maybe?');
     }
 }
示例#3
0
文件: TableLogs.php 项目: jekv/devia
 /**
  * Claring log messages
  */
 public function process_bulk_action()
 {
     try {
         switch ($this->current_action()) {
             case 'emptyLog':
                 $this->log->truncate();
                 $this->addNotice('updated', 'All log messages cleared!');
                 break;
             case 'delete':
                 if (is_numeric($_GET['id'])) {
                     $this->log->delete(array('id' => $_GET['id']));
                     $this->addNotice('updated', 'Log message deleted!');
                 }
                 break;
         }
     } catch (RepositaryLogException $e) {
         $this->addNotice('error', $e->getMessage());
     }
 }
示例#4
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // admin actions
     add_action('admin_init', array($this, 'adminInit'));
     add_action('admin_menu', array($this, 'adminMenu'));
     add_action('admin_notices', array($this, 'adminNotices'));
     add_action('admin_enqueue_scripts', function () {
         wp_enqueue_style('core', SUBSCRIBE_ASSETS . 'styleAdmin.css', null, '2.0');
         wp_enqueue_script('netteForms', SUBSCRIBE_ASSETS . 'netteForms.js', array(), '1.0.0');
     });
     // settings & forms
     $this->settings = new \SimpleSubscribe\Settings(SUBSCRIBE_KEY);
     $this->subscribers = \SimpleSubscribe\RepositorySubscribers::getInstance();
     $this->log = \SimpleSubscribe\RepositoryLog::getInstance();
     $this->email = \SimpleSubscribe\Email::getInstance();
     $this->formSettings = \SimpleSubscribe\Forms::settings($this->settings->getSettings());
     $this->formEmailTemplate = \SimpleSubscribe\Forms::emailTemplate($this->settings->getSettings());
     $this->formEmail = \SimpleSubscribe\Forms::email($_GET);
     $this->formSubscriber = \SimpleSubscribe\Forms::subscribeAdmin($this->settings->getTableColumns());
     $this->formSubscriberWp = \SimpleSubscribe\Forms::subscribeAdminWp($this->subscribers->getAllRegisteredInactive());
     $this->formEmailPreview = \SimpleSubscribe\Forms::emailPreview();
 }
示例#5
0
 /**
  * What shall we do, what shall we do? :D
  *
  * @param $post
  */
 public function onPublish($post)
 {
     // settings
     $timing = $this->settings->getTiming();
     $inCategory = $this->settings->inCategory($post);
     if ($post->post_type == 'post' && $inCategory) {
         switch ($timing) {
             case 1:
                 \SimpleSubscribe\Cron::scheduleCron(Utils::NINE_AM, $post->ID);
                 $this->log->add(1, 'Cron scheduled, 9AM for Post ID: ' . $post->ID);
                 break;
             case 2:
                 \SimpleSubscribe\Cron::scheduleCron(Utils::NINE_PM, $post->ID);
                 $this->log->add(1, 'Cron scheduled, 9PM for Post ID: ' . $post->ID);
                 break;
             case 0:
             default:
                 $this->email->onPublish($post);
                 break;
         }
     }
 }