Esempio n. 1
0
 /**
  * Sets defaults like cache, compile and template directory paths.
  *
  * @throws Exception When cache path cannot be used.
  */
 public function __construct()
 {
     $upload_dir = wp_upload_dir();
     $current_theme = wp_get_theme();
     $theme_slug = $current_theme->get_stylesheet();
     /**
      * Make the upload folder the root for changing files, this is the place
      * that is most likely writable.
      *
      * Keeping the theme name as container prevents accidental problems with
      * caching or compiling files when switching themes.
      */
     $root = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . $theme_slug;
     $this->cache_path = implode(DIRECTORY_SEPARATOR, array($root, 'cache', ''));
     $this->compile_path = implode(DIRECTORY_SEPARATOR, array($root, 'compiled', ''));
     /**
      * Filter: views directory
      */
     $views_path = Stencil_Environment::filter('path-views', 'views');
     /**
      * Get all directories (root + optional child theme)
      */
     $this->template_path = Stencil_File_System::get_potential_directories($views_path);
     /**
      * Attempt to make the directories
      */
     if (!wp_mkdir_p($this->cache_path)) {
         throw new Exception('Cache path could not be created.');
     }
     if (!wp_mkdir_p($this->compile_path)) {
         throw new Exception('Compile path could not be created.');
     }
 }
Esempio n. 2
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     $post_type = get_post_type();
     Stencil_Environment::trigger('single', $controller);
     Stencil_Environment::trigger($post_type, $controller);
     Stencil_Environment::trigger(get_the_ID(), $controller);
     $page_template = get_page_template();
     if ($page_template) {
         // Always include template file.
         include $page_template;
         $page_template_base = basename($page_template);
         Stencil_File_System::load($page_template_base);
         Stencil_Environment::trigger(rtrim($page_template_base, '.php'), $controller);
         Stencil_Environment::trigger($page_template_base, $controller);
     }
 }
Esempio n. 3
0
/**
 * Get the right controller and include it
 *
 * This is generally used inside a router.php Stencil hook
 *
 * @param string $file Control file to include.
 *
 * @return bool
 */
function include_stencil_controller($file)
{
    return Stencil_File_System::load($file);
}