Ejemplo n.º 1
0
 public function set_stream_data($text, $attr, $stream_type, $additions = array(), $is_action = false)
 {
     $img_sizes = RevSliderBase::get_all_image_sizes($stream_type);
     $text = str_replace(array('%title%', '{{title}}'), $attr['title'], $text);
     $text = str_replace(array('%excerpt%', '{{excerpt}}'), $attr['excerpt'], $text);
     $text = str_replace(array('%alias%', '{{alias}}'), $attr['alias'], $text);
     $text = str_replace(array('%content%', '{{content}}'), $attr['content'], $text);
     $text = str_replace(array('%link%', '{{link}}'), $attr['link'], $text);
     $text = str_replace(array('%date_published%', '{{date_published}}', '%date%', '{{date}}'), $attr['date'], $text);
     $text = str_replace(array('%date_modified%', '{{date_modified}}'), $attr['date_modified'], $text);
     $text = str_replace(array('%author_name%', '{{author_name}}'), $attr['author_name'], $text);
     $text = str_replace(array('%num_comments%', '{{num_comments}}'), $attr['num_comments'], $text);
     $text = str_replace(array('%catlist%', '{{catlist}}'), $attr['catlist'], $text);
     $text = str_replace(array('%taglist%', '{{taglist}}'), $attr['taglist'], $text);
     $text = str_replace(array('%likes%', '{{likes}}'), $attr['likes'], $text);
     $text = str_replace(array('%retweet_count%', '{{retweet_count}}'), $attr['retweet_count'], $text);
     $text = str_replace(array('%favorite_count%', '{{favorite_count}}'), $attr['favorite_count'], $text);
     $text = str_replace(array('%views%', '{{views}}'), $attr['views'], $text);
     if ($stream_type == 'twitter' && $is_action === false) {
         $text = RevSliderBase::add_wrap_around_url($text);
     }
     switch ($stream_type) {
         case 'facebook':
             foreach ($img_sizes as $img_handle => $img_name) {
                 if (!isset($attr['img_urls'])) {
                     $attr['img_urls'] = array();
                 }
                 if (!isset($attr['img_urls'][$img_handle])) {
                     $attr['img_urls'][$img_handle] = array();
                 }
                 if (!isset($attr['img_urls'][$img_handle]['url'])) {
                     $attr['img_urls'][$img_handle]['url'] = '';
                 }
                 if (!isset($attr['img_urls'][$img_handle]['tag'])) {
                     $attr['img_urls'][$img_handle]['tag'] = '';
                 }
                 if ($additions['fb_type'] == 'album') {
                     $text = str_replace(array('%image_url_' . $img_handle . '%', '{{image_url_' . $img_handle . '}}'), $attr['img_urls'][$img_handle]['url'], $text);
                     $text = str_replace(array('%image_' . $img_handle . '%', '{{image_' . $img_handle . '}}'), $attr['img_urls'][$img_handle]['tag'], $text);
                 } else {
                     $text = str_replace(array('%image_url_' . $img_handle . '%', '{{image_url_' . $img_handle . '}}'), $attr['img_urls']['url'], $text);
                     $text = str_replace(array('%image_' . $img_handle . '%', '{{image_' . $img_handle . '}}'), $attr['img_urls']['tag'], $text);
                 }
             }
             break;
         case 'youtube':
         case 'vimeo':
             //$text = str_replace(array('%image_url_'.$img_handle.'%', '{{image_url_'.$img_handle.'}}'), @$attr['img_urls'][$img_handle]['url'], $text);
             //$text = str_replace(array('%image_'.$img_handle.'%', '{{image_'.$img_handle.'}}'), @$attr['img_urls'][$img_handle]['tag'], $text);
         //$text = str_replace(array('%image_url_'.$img_handle.'%', '{{image_url_'.$img_handle.'}}'), @$attr['img_urls'][$img_handle]['url'], $text);
         //$text = str_replace(array('%image_'.$img_handle.'%', '{{image_'.$img_handle.'}}'), @$attr['img_urls'][$img_handle]['tag'], $text);
         case 'twitter':
         case 'instagram':
         case 'flickr':
             foreach ($img_sizes as $img_handle => $img_name) {
                 if (!isset($attr['img_urls'])) {
                     $attr['img_urls'] = array();
                 }
                 if (!isset($attr['img_urls'][$img_handle])) {
                     $attr['img_urls'][$img_handle] = array();
                 }
                 if (!isset($attr['img_urls'][$img_handle]['url'])) {
                     $attr['img_urls'][$img_handle]['url'] = '';
                 }
                 if (!isset($attr['img_urls'][$img_handle]['tag'])) {
                     $attr['img_urls'][$img_handle]['tag'] = '';
                 }
                 $text = str_replace(array('%image_url_' . $img_handle . '%', '{{image_url_' . $img_handle . '}}'), $attr['img_urls'][$img_handle]['url'], $text);
                 $text = str_replace(array('%image_' . $img_handle . '%', '{{image_' . $img_handle . '}}'), $attr['img_urls'][$img_handle]['tag'], $text);
             }
             break;
     }
     return $text;
 }
Ejemplo n.º 2
0
 public function set_stream_data($text, $attr, $stream_type, $additions = array(), $is_action = false)
 {
     $img_sizes = RevSliderBase::get_all_image_sizes($stream_type);
     $text = apply_filters('revslider_slide_set_stream_data_pre', $text, $attr, $stream_type, $additions, $is_action, $img_sizes);
     $title = $stream_type == 'twitter' && $is_action === false ? RevSliderBase::add_wrap_around_url($attr['title']) : $attr['title'];
     $excerpt = $stream_type == 'twitter' && $is_action === false ? RevSliderBase::add_wrap_around_url($attr['excerpt']) : $attr['excerpt'];
     $content = $stream_type == 'twitter' && $is_action === false ? RevSliderBase::add_wrap_around_url($attr['content']) : $attr['content'];
     $text = str_replace(array('%title%', '{{title}}'), $title, $text);
     $text = str_replace(array('%excerpt%', '{{excerpt}}'), $excerpt, $text);
     $text = str_replace(array('%alias%', '{{alias}}'), $attr['alias'], $text);
     $text = str_replace(array('%content%', '{{content}}'), $content, $text);
     $text = str_replace(array('%link%', '{{link}}'), $attr['link'], $text);
     $text = str_replace(array('%date_published%', '{{date_published}}', '%date%', '{{date}}'), $attr['date'], $text);
     $text = str_replace(array('%date_modified%', '{{date_modified}}'), $attr['date_modified'], $text);
     $text = str_replace(array('%author_name%', '{{author_name}}'), $attr['author_name'], $text);
     $text = str_replace(array('%num_comments%', '{{num_comments}}'), $attr['num_comments'], $text);
     $text = str_replace(array('%catlist%', '{{catlist}}'), $attr['catlist'], $text);
     $text = str_replace(array('%catlist_raw%', '{{catlist_raw}}'), $attr['catlist_raw'], $text);
     $text = str_replace(array('%taglist%', '{{taglist}}'), $attr['taglist'], $text);
     $text = str_replace(array('%likes%', '{{likes}}'), $attr['likes'], $text);
     $text = str_replace(array('%retweet_count%', '{{retweet_count}}'), $attr['retweet_count'], $text);
     $text = str_replace(array('%favorite_count%', '{{favorite_count}}'), $attr['favorite_count'], $text);
     $text = str_replace(array('%views%', '{{views}}'), $attr['views'], $text);
     $arrMatches = array();
     preg_match_all("/{{content:\\w+[\\:]\\w+}}/", $text, $arrMatches);
     foreach ($arrMatches as $matched) {
         foreach ($matched as $match) {
             //now check length and type
             $meta = str_replace("{{content:", "", $match);
             $meta = str_replace("}}", "", $meta);
             $meta = str_replace('_REVSLIDER_', '-', $meta);
             $vals = explode(':', $meta);
             if (count($vals) !== 2) {
                 continue;
             }
             //not correct values
             $vals[1] = intval($vals[1]);
             //get real number
             if ($vals[1] === 0 || $vals[1] < 0) {
                 continue;
             }
             //needs to be at least 1
             if ($vals[0] == 'words') {
                 $metaValue = explode(' ', strip_tags($content), $vals[1] + 1);
                 if (is_array($metaValue) && count($metaValue) > $vals[1]) {
                     array_pop($metaValue);
                 }
                 $metaValue = implode(' ', $metaValue);
             } elseif ($vals[0] == 'chars') {
                 $metaValue = substr(strip_tags($content), 0, $vals[1]);
             } else {
                 continue;
             }
             $text = str_replace($match, $metaValue, $text);
         }
     }
     switch ($stream_type) {
         case 'facebook':
             foreach ($img_sizes as $img_handle => $img_name) {
                 if (!isset($attr['img_urls'])) {
                     $attr['img_urls'] = array();
                 }
                 if (!isset($attr['img_urls'][$img_handle])) {
                     $attr['img_urls'][$img_handle] = array();
                 }
                 if (!isset($attr['img_urls'][$img_handle]['url'])) {
                     $attr['img_urls'][$img_handle]['url'] = '';
                 }
                 if (!isset($attr['img_urls'][$img_handle]['tag'])) {
                     $attr['img_urls'][$img_handle]['tag'] = '';
                 }
                 if ($additions['fb_type'] == 'album') {
                     $text = str_replace(array('%image_url_' . $img_handle . '%', '{{image_url_' . $img_handle . '}}'), $attr['img_urls'][$img_handle]['url'], $text);
                     $text = str_replace(array('%image_' . $img_handle . '%', '{{image_' . $img_handle . '}}'), $attr['img_urls'][$img_handle]['tag'], $text);
                 } else {
                     $text = str_replace(array('%image_url_' . $img_handle . '%', '{{image_url_' . $img_handle . '}}'), $attr['img_urls']['url'], $text);
                     $text = str_replace(array('%image_' . $img_handle . '%', '{{image_' . $img_handle . '}}'), $attr['img_urls']['tag'], $text);
                 }
             }
             break;
         case 'youtube':
         case 'vimeo':
             //$text = str_replace(array('%image_url_'.$img_handle.'%', '{{image_url_'.$img_handle.'}}'), @$attr['img_urls'][$img_handle]['url'], $text);
             //$text = str_replace(array('%image_'.$img_handle.'%', '{{image_'.$img_handle.'}}'), @$attr['img_urls'][$img_handle]['tag'], $text);
         //$text = str_replace(array('%image_url_'.$img_handle.'%', '{{image_url_'.$img_handle.'}}'), @$attr['img_urls'][$img_handle]['url'], $text);
         //$text = str_replace(array('%image_'.$img_handle.'%', '{{image_'.$img_handle.'}}'), @$attr['img_urls'][$img_handle]['tag'], $text);
         case 'twitter':
         case 'instagram':
         case 'flickr':
             foreach ($img_sizes as $img_handle => $img_name) {
                 if (!isset($attr['img_urls'])) {
                     $attr['img_urls'] = array();
                 }
                 if (!isset($attr['img_urls'][$img_handle])) {
                     $attr['img_urls'][$img_handle] = array();
                 }
                 if (!isset($attr['img_urls'][$img_handle]['url'])) {
                     $attr['img_urls'][$img_handle]['url'] = '';
                 }
                 if (!isset($attr['img_urls'][$img_handle]['tag'])) {
                     $attr['img_urls'][$img_handle]['tag'] = '';
                 }
                 $text = str_replace(array('%image_url_' . $img_handle . '%', '{{image_url_' . $img_handle . '}}'), $attr['img_urls'][$img_handle]['url'], $text);
                 $text = str_replace(array('%image_' . $img_handle . '%', '{{image_' . $img_handle . '}}'), $attr['img_urls'][$img_handle]['tag'], $text);
             }
             break;
     }
     return apply_filters('revslider_slide_set_stream_data_post', $text, $attr, $stream_type, $additions, $is_action, $img_sizes);
 }