Пример #1
0
 /**
  * Boot up the main Stencil flow
  *
  * Triggered by the {FILTER_PREFIX}engine_ready hook
  * @see Environment::format_hook
  *
  * @param Stencil_Implementation $engine Boot Stencil with the supplied engine.
  */
 public static function boot(Stencil_Implementation $engine)
 {
     remove_action(Stencil_Environment::format_hook('engine_ready'), array(__CLASS__, __FUNCTION__));
     if (!isset(self::$instance)) {
         self::$instance = new Stencil($engine);
         /**
          * This cannot be inside the constructor:
          */
         Stencil_Environment::trigger('initialize', self::$instance);
     }
 }
Пример #2
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);
 }
Пример #3
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);
     }
 }
Пример #4
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     /**
      * Filter: force the page to have the permalink presentation
      */
     $force_permalink = Stencil_Environment::filter('force_permalink', false);
     if ($force_permalink) {
         $url = $controller->get('self');
         $permalink = get_permalink();
         if ($url && $permalink) {
             if ($permalink !== $url) {
                 wp_redirect($permalink);
                 die;
             }
         }
     }
     Stencil_Environment::trigger('singular', $controller, get_queried_object());
 }
Пример #5
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     Stencil_Environment::trigger('archive', $controller);
     Stencil_Environment::trigger('archive_' . get_post_type(), $controller);
 }
Пример #6
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     Stencil_Environment::trigger('home', $this);
 }
Пример #7
0
 /**
  * Unified function for fetching and displaying a template
  *
  * @param string $template Template file to load.
  * @param string $from Source of this request.
  *
  * @return mixed|WP_Error
  *
  * @throws LogicException When we are still recording a variable.
  */
 protected function internal_fetch($template, $from)
 {
     if (!is_null($this->recording_for)) {
         throw new LogicException(sprintf('Stencil: trying to fetch view %s but still recording for "%s".', $template, $this->recording_for));
     }
     $implementation = $this->get_implementation();
     // Hook pre_fetch / pre_display.
     Stencil_Environment::trigger('pre_' . $from, $template);
     // Make sure undefined index errors are not caught; template engines don't check for these.
     $error_reporting = error_reporting();
     error_reporting(error_reporting() & ~E_NOTICE);
     // Fetch.
     $fetched = $implementation->fetch($template . '.' . $implementation->get_template_extension());
     // Restore error_reporting.
     error_reporting($error_reporting);
     /**
      * Apply filtering
      */
     $fetched = Stencil_Environment::filter('content', $fetched);
     /**
      * Echo if we are displaying
      */
     if ('display' === $from) {
         echo $fetched;
     }
     // Hook post_fetch / post_display.
     Stencil_Environment::trigger('post_' . $from, $template);
     if ('fetch' === $from) {
         return $fetched;
     }
     return '';
 }
Пример #8
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     Stencil_Environment::trigger('error', $controller);
     Stencil_Environment::trigger('404', $controller);
 }
Пример #9
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     Stencil_Environment::trigger('search', $controller);
 }
Пример #10
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     Stencil_Environment::trigger('category', $controller);
     Stencil_Environment::trigger('category.' . get_query_var('cat'), $controller);
 }
Пример #11
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     Stencil_Environment::trigger('comments_popup', $controller);
 }
Пример #12
0
 /**
  * Called when the implementation is ready
  */
 protected function ready()
 {
     Stencil_Environment::trigger('engine_ready', $this);
 }
Пример #13
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     Stencil_Environment::trigger('author', $controller);
     Stencil_Environment::trigger('author.' . get_the_ID(), $controller);
 }