Exemplo n.º 1
0
 /**
  * Constructor, does all this beautiful magic, loads all libs
  * registers all sorts of funky hooks, checks stuff and so on.
  */
 public function __construct()
 {
     // nette, nope, we're not going without you brother
     if (!defined('NETTE')) {
         require_once 'libs/Nette/Nette.min.php';
     }
     // If debugging is the process of removing bugs, then programming must be the process of putting them in. - Edsger W. Dijkstra
     //\Nette\Diagnostics\Debugger::$productionMode = FALSE;
     //\Nette\Diagnostics\Debugger::enable();
     // required libs
     $robotLoader = new \Nette\Loaders\RobotLoader();
     $robotLoader->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libs' . DIRECTORY_SEPARATOR);
     $robotLoader->setCacheStorage(new \Nette\Caching\Storages\MemoryStorage());
     $robotLoader->register();
     // cosntants define
     define('SUBSCRIBE_KEY', 'simpleSubscribe');
     define('SUBSCRIBE_CRON', 'simple_subscribe_cron');
     define('SUBSCRIBE_HOME_URL', get_option('siteurl'));
     define('SUBSCRIBE_FOLDER', plugins_url(NULL, __FILE__));
     define('SUBSCRIBE_ASSETS', SUBSCRIBE_FOLDER . '/assets/');
     define('SUBSCRIBE_TEMPLATES', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR);
     define('SUBSCRIBE_API_URL', SUBSCRIBE_HOME_URL . '/' . '?' . SUBSCRIBE_KEY);
     // init
     add_action('init', array($this, 'init'));
     //add_action('admin_init', array($this, 'on_plugin_activated_redirect') );
     // widgets + shortcodes
     \SimpleSubscribe\Widgets::register();
     \SimpleSubscribe\Shortcodes::register();
     // settings
     $this->settings = new \SimpleSubscribe\Settings(SUBSCRIBE_KEY);
     $this->settingsAll = $this->settings->getSettings();
 }
Exemplo n.º 2
0
 /**
  * Display the whole thang
  *
  * @param array $data
  */
 public function display($data = array())
 {
     $template = new \SimpleSubscribe\Template('adminApi.latte');
     $templateGuts = $this->hasMessages() ? $this->getMessages() : \SimpleSubscribe\FrontEnd::unsubscriptionForm();
     $templateAction = $this->hasMessages() ? 'Confirm Subscription' : 'Unsubscribe';
     $templateBackUrl = $this->settings->getBackLinkUrl();
     $defaults = array('action' => $templateAction, 'stylesheetUrl' => SUBSCRIBE_ASSETS . 'styleApi.css', 'guts' => $templateGuts, 'backLink' => '<a href="' . $templateBackUrl . '">Back to homepage &raquo;</a>');
     $template->prepareTemplate($defaults, $data);
     echo $template->getTemplate();
 }
Exemplo n.º 3
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // get wordpress database object (no injection sorry!
     global $wpdb;
     // variables
     $this->database = $wpdb;
     $this->settings = new \SimpleSubscribe\Settings(SUBSCRIBE_KEY);
     $this->settingsAll = $this->settings->getSettings();
     // we get the table name from class name
     preg_match('#Repository(\\w+)$#', get_class($this), $class);
     $tablePreName = \Nette\Utils\Strings::contains($class[1], 'Subscribers') ? $class[1] : 'Subscribers' . $class[1];
     $this->tableName = $this->database->prefix . Utils::camelCaseToUnderscore($tablePreName);
     $this->tableSingleName = \Nette\Utils\Strings::firstUpper($class[1]);
     $this->count = $this->count();
 }
Exemplo n.º 4
0
 /**
  * Email template settings in adin
  *
  * @param null $defaults
  * @return Nette\Forms\Form
  */
 public static function emailTemplate($defaults = NULL)
 {
     $form = new Form('adminEmailTemplate');
     // Email template
     $form->addGroup('E-mail template');
     $formEmail = $form->addContainer('emailType');
     $formEmail->addSelect('source', 'E-mail type', array('HTML', 'Plain Text'));
     $formEmail->addSelect('type', 'E-mail digest type', array('Short Excerpt.', 'Short Excerpt with Featured Image', 'Whole Post (not recommended)'));
     // Design of e-mail
     $form->addGroup('E-mail design');
     $formDesign = $form->addContainer('emailDesign');
     $formDesign->addText('colourBodyBg', 'E-mail background colour')->setType('color')->setOption('description', 'Default: #ececec')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Background colour must be a valid hex code.', '^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$');
     $formDesign->addText('colourBg', 'Header background colour')->setType('color')->setOption('description', 'Default: #f5f5f5')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Background colour must be a valid hex code.', '^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$');
     $formDesign->addText('colourTitle', 'Header title colour')->setType('color')->setOption('description', 'Default: #000000')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Title colour must be a valid hex code.', '^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$');
     $formDesign->addText('colourLinks', 'Links colour')->setType('color')->setOption('description', 'Default: #000000')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Link colour must be a valid hex code.', '^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$');
     // Social links
     $form->addGroup('Social Media Links');
     $formSocial = $form->addContainer('social');
     foreach (Settings::getSocialServices() as $key => $value) {
         $formSocial->addText($key, $value . ' profile URL')->addCondition(Form::FILLED)->addRule(Form::URL, $value . ' profile URL, must be a valid URL.');
     }
     // Submit
     $form->addSubmit('submit', 'Save')->setAttribute('class', 'button-primary');
     // set dafaults
     if ($defaults) {
         $form->setDefaults($defaults);
     }
     return $form;
 }
Exemplo n.º 5
0
 /**
  * Basic setup, returns table columns.
  *
  * @return array
  */
 function get_columns()
 {
     return array_merge(array('cb' => '<input type="checkbox" />', 'email' => 'E-mail', 'active' => 'Active?'), $this->settings->getTableColumns(), array('date' => 'Registered', 'ip' => 'IP'));
 }