示例#1
0
文件: index.php 项目: phabos/leo-knit
 public static function sniff_requests()
 {
     global $wp;
     if (isset($wp->query_vars['__api'])) {
         $articles = array();
         sleep(1);
         $offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
         $posts = PostCollection::getPosts($offset);
         if (count($posts) > 0) {
             $i = 0;
             foreach ($posts as $post) {
                 $articles[$i]['articleId'] = $i;
                 $articles[$i]['pos'] = $offset * PostCollection::$nbPostPerPage + $i + 1;
                 $articles[$i]['title'] = $post->post_title;
                 $articles[$i]['postId'] = $post->ID;
                 $articles[$i]['description'] = Post::getDescription($post->ID);
                 $articles[$i]['smallthumb'] = Post::getThumbnail($post->ID, 'medium')[0];
                 $articles[$i]['date'] = Helper::dateToDatetime($post->post_date)->format('d-m-y');
                 $articles[$i]['tags'] = Post::getTags($post->ID);
                 $articles[$i]['bigthumb'] = Post::getThumbnail($post->ID, 'full')[0];
                 $articles[$i]['content'] = $post->post_content;
                 $articles[$i]['uniqId'] = 'article-id-' . $articles[$i]['pos'];
                 $articles[$i]['gallery'] = plugins\ImgGal\ImgGalFront::PH_build_array_gallery($post->ID);
                 $articles[$i]['pattern'] = get_post_meta($post->ID, '_ph_pattern', true);
                 $i++;
             }
         }
         wp_send_json($articles);
         die;
     }
 }
示例#2
0
 /**
  * Returns a prefilled CategoryCollection
  *
  * @return  \BFewo\Iterator\CategoryCollection
  */
 protected function prepareCategoryCollection()
 {
     $categoryCollection = new CategoryCollection();
     for ($c = 0; $c < 5; $c++) {
         $postCollection = new PostCollection();
         $category = new Category($postCollection);
         $categoryCollection->append($category);
         for ($p = 0; $p < 5; $p++) {
             $tagCollection = new TagCollection();
             $post = new Post($tagCollection);
             $postCollection->append($post);
             for ($t = 0; $t < 5; $t++) {
                 $tag = new Tag();
                 $tagCollection->append($tag);
             }
         }
     }
     return $categoryCollection;
 }