示例#1
0
 /**
  * Get the classname of the required Implementation
  */
 public static function boot()
 {
     $implementation = Stencil_Environment::filter('implementation', false);
     $required = Stencil_Environment::filter('require', false);
     if ($implementation !== $required) {
         $message = __('<em>Theme - Implementation conflict</em>. The active theme requires the Stencil Implementation: <em>%s</em> to be active.', 'stencil');
         $message = sprintf($message, $required);
         Stencil_Feedback::notification('error', $message);
         return null;
     }
     // Tell the implementation to active itself.
     Stencil_Environment::trigger('activate-' . $required);
 }
 /**
  * StencilDwoo2 constructor.
  */
 public function __construct()
 {
     parent::__construct();
     /**
      * PHP version check!
      *
      * This implementation uses namespaces, which are not available before PHP 5.3.0
      */
     if (version_compare(PHP_VERSION, '5.3.0', '<')) {
         Stencil_Feedback::notification('error', 'Dwoo requires PHP 5.3 or higher. This server is running ' . PHP_VERSION);
         return;
     }
     require_once 'lib/Dwoo/Autoloader.php';
     // Register Dwoo namespace and register autoloader.
     $autoloader = new Dwoo\Autoloader();
     $autoloader->add('Dwoo', dirname(__FILE__) . '/lib/Dwoo');
     $autoloader->register(true);
     $this->engine = new Dwoo\Core($this->compile_path, $this->cache_path);
     $this->engine->setTemplateDir($this->template_path);
     // Add custom plugins to smarty (per template).
     $plugin_dir = apply_filters('Dwoo:2-template-plugin-dir', 'dwoo-plugins');
     /**
      * Add theme plugins & child-theme plugins
      */
     if (!empty($plugin_dir)) {
         $template_root = get_template_directory();
         $plugin_bases = array($template_root);
         $child_root = get_stylesheet_directory();
         if ($child_root !== $template_root) {
             $plugin_bases[] = $child_root;
         }
         foreach ($plugin_bases as $plugin_base) {
             $plugin_dir = implode(DIRECTORY_SEPARATOR, array($plugin_base, $plugin_dir, ''));
             if (is_dir($plugin_dir)) {
                 $this->engine->getLoader()->addDirectory($plugin_dir);
             }
         }
     }
     /*
      * require_once( 'plugins/function.wp.php' );
      * $this->engine->addPlugin('wp', 'dwoo_wp');
      */
     $this->ready();
 }