Пример #1
0
 /**
  * Run plugin
  */
 public function run()
 {
     $this->loader->add('BarsMaster', dirname(dirname(__FILE__)));
     $this->loader->add('Twig', dirname(dirname(__FILE__)));
     if ($this->config->has('plugin_prefix') && $this->config->has('plugin_source')) {
         $prefix = $this->config->get('plugin_prefix');
         $path = $this->config->get('plugin_source');
         $this->loader->add($prefix, $path);
     }
     $this->loader = apply_filters(sprintf('%s_before_loader_register', $this->pluginName), $this->loader, $this);
     $this->loader->register();
     /* Twig */
     try {
         $templatesPath = $this->getPluginPath() . '/app/templates';
         $this->twig = new Twig_Environment(new Twig_Loader_Filesystem($templatesPath), array('cache' => $this->config->get('plugin_cache_twig', false), 'debug' => $this->isDev()));
         if ($this->isDev()) {
             $this->twig->addExtension(new Twig_Extension_Debug());
         }
     } catch (Twig_Error_Loader $e) {
         wp_die(sprintf('Invalid plugin path specified: "%s"', $e->getMessage()));
     }
     $this->getLang()->loadTextDomain();
     /** @TODO THROW TRY CATCH */
     if ($this->config->has('plugin_menu')) {
         $this->menu = new Rsc_Menu_Page($this->resolver);
         foreach ($parameters = $this->config->get('plugin_menu') as $key => $value) {
             if (method_exists($this->menu, $method = sprintf('set%s', str_replace('_', '', $key)))) {
                 call_user_func_array(array($this->menu, $method), array($value));
             }
         }
         $this->menu = apply_filters(sprintf('%s_before_menu_register', $this->pluginName), $this->menu);
         $this->menu->register();
     }
     $this->twig->addGlobal('environment', $this);
     $this->twig->addGlobal('request', new Rsc_Http_Request());
     $this->resolver = apply_filters(sprintf('%s_before_resolver_register', $this->pluginName), $this->resolver);
     $this->registerActivation();
     /* Do not edit this code in any case */
     //        $this->fc320fde997f9bea5c39d56e094bfb99();
     add_action('plugins_loaded', array($this, 'extend'));
 }