Пример #1
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     $list = array();
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             $object = get_post();
             /**
              * Respect post_as_object filter
              */
             $post_as_object = Stencil_Environment::filter('post_as_object', true);
             if ($post_as_object) {
                 /**
                  * Apply fancy Human Made Post object if loaded
                  */
                 if (class_exists('Post', false)) {
                     $item = Post::get($object->ID);
                 } else {
                     $item = $object;
                 }
             } else {
                 $item = (array) $object;
             }
             // Add item to the list.
             $list[] = $item;
             // Clean up.
             unset($item);
         }
     }
     wp_reset_postdata();
     $controller->set('posts', $list);
 }
Пример #2
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     $object = get_queried_object();
     if (class_exists('Taxonomy', false)) {
         $controller->set('taxonomy', Taxonomy::get($object->taxonomy));
     } else {
         $controller->set('taxonomy', $object);
     }
 }
Пример #3
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     $controller->set('author_display_name', get_the_author());
     $object = get_queried_object();
     if (class_exists('User', false)) {
         $controller->set('author', User::get($object->ID));
     } else {
         $controller->set('author', $object);
     }
 }
Пример #4
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     $url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $controller->set('self', $url);
     // Loading post(s) as object or array.
     $post_as_object = Stencil_Environment::filter('post_as_object', true);
     $object = get_queried_object();
     if ($object && is_a($object, 'WP_Post')) {
         /**
          * Filter to chose whether the 'post' variable is set as array or object
          */
         if ($post_as_object) {
             if (class_exists('Post', false)) {
                 $controller->set('post', Post::get($object->ID));
             } else {
                 $controller->set('post', $object);
             }
         } else {
             $controller->set('post', (array) $object);
         }
         // Additional handy variables.
         $controller->set('id', $object->ID);
         $controller->set('post_type', get_post_type($object));
     }
 }
Пример #5
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());
 }
Пример #6
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     $controller->set('search', get_search_query(true));
 }
Пример #7
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     $category = array('id' => get_query_var('cat'), 'name' => get_cat_name(get_query_var('cat')), 'title' => single_cat_title('', false), 'description' => term_description());
     $controller->set('category', $category);
 }
Пример #8
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     $controller->set('tag', single_tag_title('', false));
 }
Пример #9
0
 /**
  * Exection hook
  *
  * @param Stencil_Interface $controller Controller that initiated this class.
  */
 public function execute(Stencil_Interface $controller)
 {
     $controller->set('post_type', get_post_type());
 }