コード例 #1
0
ファイル: archived.php プロジェクト: moorscode/stencil
 /**
  * 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
ファイル: taxonomy.php プロジェクト: moorscode/stencil
 /**
  * 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
ファイル: author.php プロジェクト: moorscode/stencil
 /**
  * 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
ファイル: always.php プロジェクト: moorscode/stencil
 /**
  * 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
ファイル: singular.php プロジェクト: moorscode/stencil
 /**
  * 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
ファイル: search.php プロジェクト: moorscode/stencil
 /**
  * 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
ファイル: category.php プロジェクト: moorscode/stencil
 /**
  * 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
ファイル: tag.php プロジェクト: moorscode/stencil
 /**
  * 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());
 }