/** * get slides from posts */ public function getSlidesFromPosts($publishedOnly = false, $gal_ids = array()) { $slideTemplates = $this->getSlidesFromGallery($publishedOnly); $slideTemplates = RevSliderFunctions::assocToArray($slideTemplates); if (count($slideTemplates) == 0) { return array(); } $sourceType = $this->getParam("source_type", "gallery"); if (!empty($gal_ids)) { $sourceType = 'specific_posts'; } //change to specific posts, give the gal_ids to the list switch ($sourceType) { case "posts": //check where to get posts from $sourceType = $this->getParam("fetch_type", "cat_tag"); switch ($sourceType) { case 'cat_tag': default: $arrPosts = $this->getPostsFromCategories($publishedOnly); break; case 'related': $arrPosts = $this->getPostsFromRelated(); break; case 'popular': $arrPosts = $this->getPostsFromPopular(); break; case 'recent': $arrPosts = $this->getPostsFromRecent(); break; case 'next_prev': $arrPosts = $this->getPostsNextPrevious(); break; } break; case "specific_posts": $arrPosts = $this->getPostsFromSpecificList($gal_ids); break; case 'woocommerce': $arrPosts = $this->getProductsFromCategories($publishedOnly); break; default: RevSliderFunctions::throwError("getSlidesFromPosts error: This source type must be from posts."); break; } $arrSlides = array(); $templateKey = 0; $numTemplates = count($slideTemplates); foreach ($arrPosts as $postData) { $slideTemplate = clone $slideTemplates[$templateKey]; //advance the templates $templateKey++; if ($templateKey == $numTemplates) { $templateKey = 0; $slideTemplates = $this->getSlidesFromGallery($publishedOnly); //reset as clone did not work properly $slideTemplates = RevSliderFunctions::assocToArray($slideTemplates); } $slide = new RevSlide(); $slide->initByPostData($postData, $slideTemplate, $this->id); $arrSlides[] = $slide; } $this->arrSlides = $arrSlides; return $arrSlides; }
/** * * get slides from posts */ private function getSlidesFromPosts($publishedOnly = false) { $slideTemplates = $this->getSlideTemplates(); $slideTemplates = UniteFunctionsRev::assocToArray($slideTemplates); if (count($slideTemplates) == 0) { return array(); } $sourceType = $this->getParam("source_type", "gallery"); switch ($sourceType) { case "posts": $arrPosts = $this->getPostsFromCategoies($publishedOnly); break; case "specific_posts": $arrPosts = $this->getPostsFromSpecificList(); break; default: UniteFunctionsRev::throwError("getSlidesFromPosts error: This source type must be from posts."); break; } $arrSlides = array(); $templateKey = 0; $numTemplates = count($slideTemplates); $slideTemplate = $slideTemplates[$templateKey]; foreach ($arrPosts as $postData) { //advance the templates $templateKey++; if ($templateKey == $numTemplates) { $templateKey = 0; } $slide = new RevSlide(); $slide->initByPostData($postData, $slideTemplate, $this->id); $arrSlides[] = $slide; } $this->arrSlides = $arrSlides; return $arrSlides; }
/** * get slides from posts */ public function getSlidesFromPosts($publishedOnly = false) { $slideTemplates = $this->getSlidesFromGallery($publishedOnly); $slideTemplates = RevSliderFunctions::assocToArray($slideTemplates); if (count($slideTemplates) == 0) { return array(); } $sourceType = $this->getParam("source_type", "gallery"); switch ($sourceType) { case "posts": $arrPosts = $this->getPostsFromCategories($publishedOnly); break; case "specific_posts": $arrPosts = $this->getPostsFromSpecificList(); break; case 'woocommerce': $arrPosts = $this->getProductsFromCategories($publishedOnly); break; default: RevSliderFunctions::throwError("getSlidesFromPosts error: This source type must be from posts."); break; } $arrSlides = array(); $templateKey = 0; $numTemplates = count($slideTemplates); foreach ($arrPosts as $postData) { $slideTemplate = clone $slideTemplates[$templateKey]; //advance the templates $templateKey++; if ($templateKey == $numTemplates) { $templateKey = 0; $slideTemplates = $this->getSlidesFromGallery($publishedOnly); //reset as clone did not work properly $slideTemplates = RevSliderFunctions::assocToArray($slideTemplates); } $slide = new RevSlide(); $slide->initByPostData($postData, $slideTemplate, $this->id); $arrSlides[] = $slide; } $this->arrSlides = $arrSlides; return $arrSlides; }