Ejemplo 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();
 }
Ejemplo n.º 2
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();
 }