/** * Run Cron */ public static function cron() { $data = func_get_args(); if (is_numeric($data[0])) { // let's assume this is post ID right $post = get_post($data[0]); if (!empty($post)) { \SimpleSubscribe\Email::getInstance()->onPublish($post); } } }
/** * 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(); }
/** * I thought it was clear from the name, yup, it adds user. * * @param $data */ public function add($data) { if ($this->userByEmailExists($data->email)) { throw new RepositarySubscribersException('We are really sorry, but user with this e-mail address already exists.', 0); } else { $data->active = 0; $data->ip = \SimpleSubscribe\Utils::getRealIp(); if ($this->insert($data)) { try { $email = \SimpleSubscribe\Email::getInstance(); $email->sendConfiramtionEmail($data->email, $this->database->insert_id); } catch (EmailException $e) { throw new RepositarySubscribersException($e->getMessage()); } } return TRUE; } }