Exemplo n.º 1
0
 /**
  * 
  * replace layer placeholders by post data
  */
 private function setLayersByPostData($postData, $sliderID)
 {
     $postID = $postData["ID"];
     $attr = array();
     $attr['title'] = RevSliderFunctions::getVal($postData, "post_title");
     $excerpt_limit = $this->getSliderParam($sliderID, "excerpt_limit", 55, RevSlider::VALIDATE_NUMERIC);
     $excerpt_limit = (int) $excerpt_limit;
     $attr['excerpt'] = RevSliderFunctionsWP::getExcerptById($postID, $excerpt_limit);
     $attr['alias'] = RevSliderFunctions::getVal($postData, "post_name");
     $attr['content'] = RevSliderFunctions::getVal($postData, "post_content");
     $attr['link'] = get_permalink($postID);
     $postDate = RevSliderFunctions::getVal($postData, "post_date_gmt");
     $attr['postDate'] = RevSliderFunctionsWP::convertPostDate($postDate);
     $dateModified = RevSliderFunctions::getVal($postData, "post_modified");
     $attr['dateModified'] = RevSliderFunctionsWP::convertPostDate($dateModified);
     $authorID = RevSliderFunctions::getVal($postData, "post_author");
     $attr['authorName'] = RevSliderFunctionsWP::getUserDisplayName($authorID);
     $postCatsIDs = $postData["post_category"];
     $attr['catlist'] = RevSliderFunctionsWP::getCategoriesHtmlList($postCatsIDs);
     $attr['taglist'] = RevSliderFunctionsWP::getTagsHtmlList($postID);
     $ptid = get_post_thumbnail_id($postID);
     $img_sizes = RevSliderBase::get_all_image_sizes();
     $attr['img_urls'] = array();
     foreach ($img_sizes as $img_handle => $img_name) {
         $featured_image_url = wp_get_attachment_image_src($ptid, $img_handle);
         if ($featured_image_url !== false) {
             $attr['img_urls'][$img_handle] = array('url' => $featured_image_url[0], 'tag' => '<img src="' . $featured_image_url[0] . '" width="' . $featured_image_url[1] . '" height="' . $featured_image_url[2] . '" data-no-retina />');
         }
     }
     $numComments = RevSliderFunctions::getVal($postData, "comment_count");
     foreach ($this->arrLayers as $key => $layer) {
         $text = RevSliderFunctions::getVal($layer, "text");
         $text = apply_filters('revslider_mod_meta', $text, $postID, $postData);
         //option to add your own filter here to modify meta to your likings
         $text = $this->set_post_data($text, $attr, $postID);
         $layer["text"] = $text;
         $all_actions = RevSliderFunctions::getVal($layer, 'layer_action', array());
         if (!empty($all_actions)) {
             $a_image_link = RevSliderFunctions::cleanStdClassToArray(RevSliderFunctions::getVal($all_actions, 'image_link', array()));
             if (!empty($a_image_link)) {
                 foreach ($a_image_link as $ik => $ilink) {
                     $ilink = $this->set_post_data($ilink, $attr, $postID);
                     $a_image_link[$ik] = $ilink;
                 }
                 $layer['layer_action']->image_link = $a_image_link;
             }
         }
         $this->arrLayers[$key] = $layer;
     }
     for ($mi = 1; $mi <= 10; $mi++) {
         //set params to the post data
         $pa = $this->getParam('params_' . $mi, '');
         $pa = $this->set_post_data($pa, $attr, $postID);
         $this->setParam('params_' . $mi, $pa);
     }
 }