Esempio n. 1
0
 public function __construct($plugin_path)
 {
     if (!is_string($plugin_path) && empty(CommonHelpers::strim($plugin_path))) {
         throw new ArgException(ArgException::INVALID_PARAMETER_TYPE, [__('Inproper type of parameter', PluginDataSet::load()->plugin_name)]);
     }
     $this->_plugin_path = $plugin_path;
 }
Esempio n. 2
0
 /**
  * MGPLN costructor
  * @access   public
  * @param    string    $name    The string used to uniquely identify this plugin.
  * @param    string    $version To identify the version of the plugin
  */
 public function __construct($name = 'megaforms', $version = 'beta')
 {
     PluginDataSet::load()->version = CommonHelpers::strim($version);
     PluginDataSet::load()->plugin_name = CommonHelpers::strim($name);
     PluginDataSet::load()->plugin_path = plugin_dir_path(__DIR__);
     PluginDataSet::load()->plugin_url = plugin_dir_url(__DIR__);
     PluginDataSet::load()->vendor_path = PluginDataSet::load()->plugin_path . 'Vendor/';
     PluginDataSet::load()->libs_path = PluginDataSet::load()->vendor_path . 'Libs/';
     PluginDataSet::load()->views_path = PluginDataSet::load()->vendor_path . 'Views/';
     PluginDataSet::load()->uploads_path = PluginDataSet::load()->vendor_path . 'data/.uploads/';
     /** object PluginDataSet */
     PluginDataSet::load()->checkDependencies();
     I18n::load()->setUp();
 }
Esempio n. 3
0
 /**
  * Load files from external sources
  * @param $path
  * @return string
  * @throws FileException
  */
 public static function loadFile($path, $fileName)
 {
     $libContent = file_get_contents($path);
     if (is_writable(PluginDataSet::load()->uploads_path)) {
         $localPath = PluginDataSet::load()->uploads_path . $fileName;
         if (file_put_contents($localPath, $libContent)) {
             return $localPath;
         } else {
             throw new FileException(FileException::WRITTING_ERROR, [$localPath]);
         }
     } else {
         throw new FileException(FileException::INACCESSIBLE_PATH, [$path]);
     }
 }
Esempio n. 4
0
 public function setLocale()
 {
     load_plugin_textdomain($this->_domain, false, plugin_dir_path(PluginDataSet::load()->plugin_path));
 }
Esempio n. 5
0
 protected function __construct()
 {
     $this->_view = Templater::load();
     $this->_view->init(PluginDataSet::load()->views_path);
 }
Esempio n. 6
0
 public function start()
 {
     PluginDataSet::load()->is_ajax = Http::load()->isAjax();
     if (is_admin() && !PluginDataSet::load()->is_ajax) {
         $this->init_admin_settings();
     }
     $this->parseRequest();
     if (!$this->isPluginRoute()) {
         return;
     }
     $currentPage = $this->formPath();
     if (($error = $this->followRoute($currentPage)) === false) {
         throw new CoreException($error, [$currentPage]);
     } else {
         include_once $currentPage;
     }
     if (($error = $this->isPathCorrect()) !== true) {
         throw new CoreException($error, [$this->_page, $this->_controller, $this->_action]);
     }
     $classname = $this->formFullPath($this->_controller);
     $currentController = new $classname();
     call_user_func_array([$currentController, $this->_action], $this->_param);
 }
Esempio n. 7
0
 /**
  *
  */
 public function register_admin_settings_pages()
 {
     foreach ($this->_settings as $menu_slug => $pageParams) {
         if (!strcmp($menu_slug, $pageParams['menu_slug'])) {
             add_menu_page(__($pageParams['page_title'], PluginDataSet::load()->plugin_name), __($pageParams['menu_title'], PluginDataSet::load()->plugin_name), $pageParams['capabilities'], $pageParams['menu_slug'], $pageParams['function'], $pageParams['icon_url'], $pageParams['position']);
             $this->_used_settings[$menu_slug] = $pageParams;
         } else {
             add_submenu_page($pageParams['parent_slug'], __($pageParams['page_title'], PluginDataSet::load()->plugin_name), __($pageParams['sub_menu_title'], PluginDataSet::load()->plugin_name), $pageParams['capabilities'], $pageParams['menu_slug'], $pageParams['function']);
             $this->_used_settings[$menu_slug]['subpages'] = $pageParams;
         }
     }
     $this->_settings = [];
 }