Guest User

Untitled

a guest
Dec 19th, 2017
25
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // To Do..
  3. // 1. Check if Link description exists or not. In case there is no description we will not append the description wrapper
  4. // 2. Error Handling: Show a error message if we cannot fetch the feed.. Either the id is wrong or the page is private
  5. // 3. Styling issue, sometime wrong html wrapper is created. Check in Go Pro for reference.
  6. // 4.
  7. // Define variables
  8.  
  9. $page_id = "";
  10. $access_token = "";
  11.  
  12. // snippet from this url http://krasimirtsonev.com/blog/article/php--find-links-in-a-string-and-replace-them-with-actual-html-link-tags
  13. function makeLinks($str,$link_target) {
  14. $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
  15. $urls = array();
  16. $urlsToReplace = array();
  17. if(preg_match_all($reg_exUrl, $str, $urls)) {
  18. $numOfMatches = count($urls[0]);
  19. $numOfUrlsToReplace = 0;
  20. for($i=0; $i<$numOfMatches; $i++) {
  21. $alreadyAdded = false;
  22. $numOfUrlsToReplace = count($urlsToReplace);
  23. for($j=0; $j<$numOfUrlsToReplace; $j++) {
  24. if($urlsToReplace[$j] == $urls[0][$i]) {
  25. $alreadyAdded = true;
  26. }
  27. }
  28. if(!$alreadyAdded) {
  29. array_push($urlsToReplace, $urls[0][$i]);
  30. }
  31. }
  32. $numOfUrlsToReplace = count($urlsToReplace);
  33.  
  34.  
  35. for($i=0; $i<$numOfUrlsToReplace; $i++) {
  36. if($link_target == 1) {
  37. $str = str_replace($urlsToReplace[$i], '<a class="wff-link-tab" href='.$urlsToReplace[$i].' target = "_blank">'.$urlsToReplace[$i].'</a> ', $str);
  38. } else {
  39. $str = str_replace($urlsToReplace[$i], '<a class="wff-link-tab" href='.$urlsToReplace[$i].' >'.$urlsToReplace[$i].'</a> ', $str);
  40. }
  41. }
  42. return $str;
  43. } else {
  44. return $str;
  45. }
  46. }
  47.  
  48. function make_hash_link($str,$link_target)
  49. {
  50. $reg_exUrl = "/(#\w+)/";
  51. $urls = array();
  52. $urlsToReplace = array();
  53. if(preg_match_all($reg_exUrl, $str, $urls)) {
  54. $numOfMatches = count($urls[0]);
  55. $numOfUrlsToReplace = 0;
  56. for($i=0; $i<$numOfMatches; $i++) {
  57. $alreadyAdded = false;
  58. $numOfUrlsToReplace = count($urlsToReplace);
  59. for($j=0; $j<$numOfUrlsToReplace; $j++) {
  60. if($urlsToReplace[$j] == $urls[0][$i]) {
  61. $alreadyAdded = true;
  62. }
  63. }
  64. if(!$alreadyAdded) {
  65. array_push($urlsToReplace, $urls[0][$i]);
  66. }
  67. }
  68. $numOfUrlsToReplace = count($urlsToReplace);
  69. for($i=0; $i<$numOfUrlsToReplace; $i++) {
  70. $str_without_hastag[$i] = ltrim ($urlsToReplace[$i], '#');
  71. if($link_target == 1) {
  72. $str = str_replace($urlsToReplace[$i],'<a class="wff-link-tab" href="https://www.facebook.com/hashtag/'.$str_without_hastag[$i].'" target = "_blank">'.$urlsToReplace[$i].'</a>', $str);
  73. } else {
  74. $str = str_replace($urlsToReplace[$i],'<a class="wff-link-tab" href="https://www.facebook.com/hashtag/'.$str_without_hastag[$i].'" >'.$urlsToReplace[$i].'</a>', $str);
  75. }
  76. }
  77. return $str;
  78. }
  79. else{
  80. return $str;
  81. }
  82. }
  83.  
  84. // Reference URL http://stackoverflow.com/questions/10981513/stripos-issues-in-php4
  85. if(!is_callable('stripos')){
  86. function stripos($haystack, $needle){
  87. return strpos($haystack, stristr( $haystack, $needle ));
  88. }
  89. }
  90.  
  91. function wff_fetchUrl($url)
  92. {
  93. if(is_callable('curl_init')){
  94. $ch = curl_init();
  95. curl_setopt($ch, CURLOPT_URL, $url);
  96. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  97. curl_setopt($ch, CURLOPT_TIMEOUT, 20);
  98. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  99. $feedData = curl_exec($ch);
  100. curl_close($ch);
  101. //If not then use file_get_contents
  102. } elseif ( ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE ) {
  103. $feedData = @file_get_contents($url);
  104. //Or else use the WP HTTP AP
  105. } else {
  106. if( !class_exists( 'WP_Http' ) ) include_once( ABSPATH . WPINC. '/class-http.php' );
  107. $request = new WP_Http;
  108. $result = $request->request($url);
  109. $feedData = $result['body'];
  110. }
  111. return $feedData;
  112. }
  113. //inline style for post text
  114. function limited_post_text_inline_style($atts)
  115. {
  116. $style_wrapper = ' style=" ';
  117. if ( !empty($atts['post_text_size']) && $atts['post_text_size'] != 'inherit' ) $style_wrapper .= 'font-size:' . $atts['post_text_size'] . 'px;';
  118. if ( !empty($atts['line_height']) && $atts['line_height'] != 'inherit' ) $style_wrapper .= 'line-height:' . $atts['line_height'].'px;';
  119. if ( !empty($atts['post_text_align']) && $atts['post_text_align'] != 'inherit' ) $style_wrapper .= 'text-align:' . $atts['post_text_align'].';';
  120. if ( !empty($atts['post_text_weight']) && $atts['post_text_weight'] != 'inherit' ) $style_wrapper .= 'font-weight:' . $atts['post_text_weight'].';';
  121. if ( !empty($atts['post_text_color'])) $style_wrapper .= 'color:' . $atts['post_text_color'].';';
  122. if ( !empty($atts['post_background'])) $style_wrapper .= 'background:' . $atts['post_background'].';';
  123. $style_wrapper .= ' " ';
  124.  
  125. return $style_wrapper;
  126. }
  127.  
  128. function full_post_text_inline_style($atts)
  129. {
  130. $style_wrapper = ' style=" display:none; ';
  131. if ( !empty($atts['post_text_size']) && $atts['post_text_size'] != 'inherit' ) $style_wrapper .= 'font-size:' . $atts['post_text_size'] . 'px;';
  132. if ( !empty($atts['line_height']) && $atts['line_height'] != 'inherit' ) $style_wrapper .= 'line-height:' . $atts['line_height'].'px;';
  133. if ( !empty($atts['post_text_align']) && $atts['post_text_align'] != 'inherit' ) $style_wrapper .= 'text-align:' . $atts['post_text_align'].';';
  134. if ( !empty($atts['post_text_weight']) && $atts['post_text_weight'] != 'inherit' ) $style_wrapper .= 'font-weight:' . $atts['post_text_weight'].';';
  135. if ( !empty($atts['post_text_color'])) $style_wrapper .= 'color:' . $atts['post_text_color'].';';
  136. if ( !empty($atts['post_background'])) $style_wrapper .= 'background:' . $atts['post_background'].';';
  137. $style_wrapper .= ' " ';
  138.  
  139. return $style_wrapper;
  140. }
  141.  
  142. function feed_line_height($atts)
  143. {
  144. $style_wrapper = ' style=" ';
  145.  
  146. if ( !empty($atts['line_height']) && $atts['line_height'] != 'inherit' ) $style_wrapper .= 'line-height:' . $atts['line_height'].'px;';
  147.  
  148. $style_wrapper .= ' " ';
  149.  
  150. return $style_wrapper;
  151. }
  152.  
  153. function media_custom_inline_style($atts)
  154. {
  155. $media_complete_style = 'style="';
  156. if ( !empty($atts['media_border']) && $atts['media_border'] != 'none' ) $media_complete_style .= ' border:' . $atts['media_border'] . 'px solid ';
  157. if ( !empty($atts['author_text_color']) ) $media_complete_style .= $atts['author_text_color'] .';';
  158. $media_complete_style .= 'margin-bottom:0px;"';
  159.  
  160. return $media_complete_style;
  161. }
  162.  
  163. function build_share_wrapper($mysinglefeed,$feed_title)
  164. {
  165. $link = $mysinglefeed;
  166. $title = $feed_title;
  167.  
  168. //Social media sharing URLs
  169. $wff_share_facebook = 'https://www.facebook.com/sharer/sharer.php?u='.$link;
  170. $wff_share_twitter = 'https://twitter.com/intent/tweet?text='.$link;
  171. $wff_share_google = 'https://plus.google.com/share?url='.$link;
  172. $wff_share_linkedin = 'https://www.linkedin.com/shareArticle?mini=true&url='.$link.'&title='.$title;
  173.  
  174. $build_social_media_icon = '<a class="wff-facebook-icon" href=" '.$wff_share_facebook.' " target="_blank" ><i class="fa fa-facebook fa-lg"></i></a>';
  175. $build_social_media_icon .= '<a class="wff-twiiter-icon" href=" '.$wff_share_twitter.' " target="_blank" ><i class="fa fa-twitter fa-lg"></i></a>';
  176. $build_social_media_icon .= '<a class="wff-google-icon" href=" '.$wff_share_google.' " target="_blank" ><i class="fa fa-google-plus fa-lg"></i></a>';
  177. $build_social_media_icon .= '<a class="wff-linkedin-icon" href=" '.$wff_share_linkedin.' " target="_blank" ><i class="fa fa-linkedin fa-lg"></i></a>';
  178.  
  179. return $build_social_media_icon;
  180. }
  181. function build_my_photo_html ($mysinglefeed,$atts)
  182. {
  183. if (isset($mysinglefeed->story))
  184. {
  185. // if story exists then use the story in the post text
  186. $my_post_photo_text = $mysinglefeed->story;
  187. // we also need to handle story tags
  188. if (array_key_exists('story_tags',$mysinglefeed ))
  189. {
  190. // now add the hyperlink to tags
  191. foreach ( $mysinglefeed->story_tags as $mystorytag)
  192. {
  193. $mystorytagname = $mystorytag->name;
  194. if($atts['link_target']==1) {
  195. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" target="_blank">' . $mystorytag->name . '</a>';
  196. } else {
  197. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" >' . $mystorytag->name . '</a>';
  198. }
  199. $my_post_photo_text = str_replace($mystorytagname, $tag_link, $my_post_photo_text);
  200. }
  201. }
  202. }
  203.  
  204. if (isset($mysinglefeed->message) && !empty($mysinglefeed->message))
  205. {
  206. // if story exists then use the story in the post text
  207. $my_post_photo_text = $mysinglefeed->message;
  208.  
  209. $my_post_photo_text = makeLinks ($my_post_photo_text,$atts['link_target']); // link the urls
  210.  
  211. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$my_post_photo_text))
  212. $my_post_photo_text = make_hash_link ($my_post_photo_text,$atts['link_target']);
  213.  
  214. }
  215. // If if there are message tags
  216. $resourceid = $mysinglefeed->object_id;
  217. if (array_key_exists('message_tags',$mysinglefeed ))
  218. {
  219. // now add the hyperlink to tags
  220. foreach ( $mysinglefeed->message_tags as $mymessagetag)
  221. {
  222. $mymessagetagname = $mymessagetag->name;
  223. if($atts['link_target']==1) {
  224. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" target="_blank">' . $mymessagetag->name . '</a>';
  225. } else {
  226. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" >'.$mymessagetag->name . '</a>';
  227. }
  228. $my_post_photo_text = str_replace($mymessagetagname, $tag_link, $my_post_photo_text);
  229. }
  230. }
  231.  
  232. //call post text inline style
  233. $limited_style_wrapper = limited_post_text_inline_style($atts);
  234. $full_style_wrapper = full_post_text_inline_style($atts);
  235. $line_height_style = feed_line_height($atts);
  236. /*---------------------read more text---------------------------*/
  237. $str_without_tag = strip_tags($my_post_photo_text);
  238. $char_count = strlen($str_without_tag);
  239.  
  240. if((!empty($atts['char_limit'])) && ($atts['char_limit'] < $char_count) )
  241. {
  242. $short_sentence = substr($str_without_tag, 0,$atts['char_limit']);
  243.  
  244. $short_sentence = makeLinks ($short_sentence,$atts['link_target']); //link the urls
  245. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$short_sentence))
  246. $short_sentence = make_hash_link ($short_sentence,$atts['link_target']);
  247.  
  248. if (array_key_exists('story_tags',$mysinglefeed ))
  249. {
  250. foreach ( $mysinglefeed->story_tags as $mystorytag)
  251. {
  252. $mystorytagname = $mystorytag->name;
  253. if($atts['link_target']==1) {
  254. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" target="_blank">' . $mystorytag->name . '</a>';
  255. } else {
  256. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" >' . $mystorytag->name . '</a>';
  257. }
  258. $short_sentence = str_replace($mystorytagname, $tag_link, $short_sentence);
  259. }
  260. }
  261. if (array_key_exists('message_tags',$mysinglefeed ))
  262. {
  263. foreach( $mysinglefeed->message_tags as $mymessagetag)// now add the hyperlink to tags
  264. {
  265. $mymessagetagname = $mymessagetag->name;
  266. if($atts['link_target']==1) {
  267. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" target="_blank">' . $mymessagetag->name . '</a>';
  268. } else {
  269. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" >' . $mymessagetag->name . '</a>';
  270. }
  271. $short_sentence = str_replace($mymessagetagname, $tag_link, $short_sentence);
  272. }
  273. }
  274. $build_photo_html = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$short_sentence.'...<span><a class="wff-more-link" >'.$atts['read_more'].'</a></span></p>';
  275. $build_photo_html .= '<p class="more-content" '.$full_style_wrapper.'>'.$my_post_photo_text.'...<span><a class="wff-less-link" style="display:none">'.$atts['read_less'].'</a></span></p>';
  276. }
  277. else{
  278. $build_photo_html = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$my_post_photo_text.'</p>';
  279. }
  280. /*-----------------------------------------------*/
  281.  
  282. $the_resource_id = $mysinglefeed->object_id;
  283. $post_resource_link = 'https://facebook.com/'.$the_resource_id;
  284. // Now build The post description
  285. if (isset($mysinglefeed->name))
  286. {
  287. $name_var = $mysinglefeed->name;
  288. $name_url = $mysinglefeed->link;
  289.  
  290. if (isset($mysinglefeed->description))
  291. {
  292.  
  293. $link_post_desc = $mysinglefeed->description;
  294. $link_post_desc = makeLinks($link_post_desc,$atts['link_target']);
  295.  
  296. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$link_post_desc))
  297. $link_post_desc = make_hash_link($link_post_desc,$atts['link_target']);
  298.  
  299. }
  300. else {
  301. $link_post_desc= "";
  302.  
  303. }
  304. }
  305. //call media inline style function
  306. $media_complete_style = media_custom_inline_style($atts);
  307.  
  308. $build_post_desc_html = '';
  309. $build_post_layout_html = '';
  310. $build_thumb_layout_html = '';
  311.  
  312. // check for photo
  313. $picture = 'https://graph.facebook.com/'.$the_resource_id.'/picture';
  314.  
  315. $lb_data = '';
  316. if(isset($mysinglefeed->story))
  317. {
  318. $lb_data = $mysinglefeed->story;
  319. $lb_data = str_replace('"', '', $lb_data);
  320. }
  321. if (isset($mysinglefeed->message) && !empty($mysinglefeed->message))
  322. {
  323. $lb_data = $mysinglefeed->message;
  324. $lb_data = str_replace('"', '', $lb_data);
  325. }
  326. $attach_photo = '<div class="wff_showcase"><div class="wff_showcase_media">';
  327. if($atts['post_layout_type'] == 'fullwidth') {
  328. $attach_photo .= '<div class="wff-full-img"><a target="_blank"><img '.$media_complete_style.' src="'.$picture.'"></a></div><div class="wff_showcase_overlay_full">';
  329. } else {
  330. $attach_photo .= '<div class="wff-small-img"><a target="_blank" href ='.$post_resource_link.'><img '.$media_complete_style.' src="'.$picture.'"></a></div><div class="wff_showcase_overlay">';
  331. }
  332.  
  333. if($atts['post_layout_type'] == 'fullwidth') {
  334. $attach_photo .= '<div class="wff_showcase_overlay_inner"><div class="wff_showcase_icons">';
  335. }
  336. if($atts['post_layout_type'] == 'halfwidth') {
  337. $attach_photo .= '<div class="wff_showcase_half_overlay_inner"><div class="wff_showcase_half_icons">';
  338. }
  339. if($atts['post_layout_type'] == 'thumbnail') {
  340. $attach_photo .= '<div class="wff_showcase_thumbnail_overlay_inner"><div class="wff_showcase_thumbnail_icons">';
  341. }
  342. $attach_photo .='<a class="hover_thumb" rel="lightbox[group]" href="'.$picture.'" title="show Image" data-title="'.$lb_data.'" data-link="'.$post_resource_link.'" ><i class="fa fa-picture-o"></i></a><a class="hover_thumb" target="_blank" href="'.$post_resource_link.'" title="VIew on Facebook" ><i class="fa fa-link"></i></a></div></div></div></div></div>';
  343.  
  344. // call author wrapper function
  345. $my_author_text = build_author_html($mysinglefeed,$atts);
  346.  
  347. $share_link = $mysinglefeed->link;
  348. if(isset($mysinglefeed->story))
  349. $share_title = $mysinglefeed->story;
  350. if(isset($mysinglefeed->message))
  351. $share_title = $mysinglefeed->message;
  352.  
  353. $share_media = build_share_wrapper($share_link,$share_title);
  354.  
  355. if($atts['post_layout_type'] == 'fullwidth')
  356. {
  357. $build_post_desc_html = $attach_photo;
  358. if(isset($mysinglefeed->description)){
  359. $build_post_desc_html .= '<div class = "description-wrapper shared-link"><p class = "post-desc" '.$line_height_style.'>'.$link_post_desc.'</p></div>';
  360. }
  361. $build_photo_html .= $build_post_desc_html;
  362.  
  363. if($atts['link_target']==1) {
  364. $build_photo_html .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  365.  
  366. } else {
  367. $build_photo_html .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  368. }
  369. return $build_photo_html;
  370. }
  371. else if($atts['post_layout_type'] == 'halfwidth')
  372. {
  373. $build_post_layout_html = '<div class="wff-halfwidth-layout">';
  374. $build_post_layout_html .= '<div class="wff-photo-wrapper">'.$attach_photo.'</div>';
  375. $build_post_layout_html .= '<div class="wff-right-content-wrapper">'.$my_author_text;
  376. $build_post_layout_html .= $build_photo_html;
  377.  
  378. if(isset($mysinglefeed->description)){
  379. $build_post_layout_html .= '<div class = "description-wrapper shared-link"><p class = "post-desc" '.$line_height_style.'>'.$link_post_desc.'</p></div>';
  380. }
  381. $build_post_layout_html .= '</div></div><div class="clearfix"></div>';
  382.  
  383. if($atts['link_target']==1) {
  384. $build_link_html = '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle" style="display:none;">'.$share_media.'</span></div></div>';
  385. } else {
  386. $build_link_html = '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  387. }
  388.  
  389. $build_post_layout_html .= $build_link_html;
  390.  
  391. return $build_post_layout_html;
  392. }
  393.  
  394. else {
  395. $build_thumb_layout_html = '<div class="wff-thumb-layout">';
  396. $build_thumb_layout_html .= '<div class="wff-thumb-photo-wrapper">'.$attach_photo.'</div>';
  397. $build_thumb_layout_html .= '<div class="wff-thumb-right-content-wrapper">'.$my_author_text;
  398. $build_thumb_layout_html .= $build_photo_html;
  399.  
  400. if(isset($mysinglefeed->description)){
  401. $build_thumb_layout_html .= '<div class = "description-wrapper shared-link"><p class = "post-desc" '.$line_height_style.'>'.$link_post_desc.'</p></div>';
  402. }
  403.  
  404. $build_thumb_layout_html .= '</div></div><div class="clearfix"></div>';
  405. if($atts['link_target']==1) {
  406. $build_link_html = '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  407. } else {
  408. $build_link_html = '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  409. }
  410.  
  411. $build_thumb_layout_html .= $build_link_html;
  412.  
  413. return $build_thumb_layout_html;
  414. }
  415. }
  416.  
  417. function build_my_link_html ($mysinglefeed,$atts)
  418. {
  419. // first work on building html for link type
  420. if (isset($mysinglefeed->story))
  421. {
  422. // if story exists then use the story in the post text
  423. $my_post_text = $mysinglefeed->story;
  424.  
  425. if (array_key_exists('story_tags',$mysinglefeed ))
  426. {
  427. // now add the hyperlink to tags
  428. foreach ( $mysinglefeed->story_tags as $mystorytag)
  429. {
  430. $mystorytagname = $mystorytag->name;
  431. if($atts['link_target']==1) {
  432. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" target="_blank">' . $mystorytag->name . '</a>';
  433. } else {
  434. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;">' . $mystorytag->name . '</a>';
  435. }
  436. $my_post_text = str_replace($mystorytagname, $tag_link, $my_post_text);
  437. }
  438. }
  439. }
  440.  
  441. if (isset($mysinglefeed->message))
  442. {
  443. // if story exists then use the story in the post text
  444. $my_post_text = $mysinglefeed->message;
  445. $my_post_text = makeLinks($my_post_text,$atts['link_target']);
  446.  
  447. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$my_post_text))
  448. $my_post_text = make_hash_link($my_post_text,$atts['link_target']);
  449. }
  450. // Build Post description
  451. // first hyper link the name
  452.  
  453. $name_var = $mysinglefeed->name;
  454. $name_url = $mysinglefeed->link;
  455.  
  456. if(isset($mysinglefeed->description))
  457. {
  458. $link_post_desc = $mysinglefeed->description;
  459. $link_post_desc = makeLinks($link_post_desc,$atts['link_target']);
  460.  
  461. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$link_post_desc))
  462. $link_post_desc = make_hash_link($link_post_desc,$atts['link_target']);
  463. } else {
  464. $link_post_desc = "";
  465. }
  466.  
  467. // $resourceid = $mysinglefeed->object_id;
  468. if (array_key_exists('message_tags',$mysinglefeed ))
  469. {
  470. // now add the hyperlink to tags
  471. foreach ( $mysinglefeed->message_tags as $mymessagetag)
  472. {
  473. $mymessagetagname = $mymessagetag->name;
  474. if($atts['link_target']==1) {
  475. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" target="_blank">' . $mymessagetag->name . '</a>';
  476. } else {
  477. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" >' . $mymessagetag->name . '</a>';
  478. }
  479. $my_post_text = str_replace($mymessagetagname, $tag_link, $my_post_text);
  480. }
  481. }
  482.  
  483. $the_resource_id = explode('_',$mysinglefeed->id);
  484. $post_resource_link = 'https://facebook.com/'.$atts['page_id'] .'/posts/'.$the_resource_id[1];
  485.  
  486. //call post text inline style
  487. $limited_style_wrapper = limited_post_text_inline_style($atts);
  488. $full_style_wrapper = full_post_text_inline_style($atts);
  489. $line_height_style = feed_line_height($atts);
  490. /*---------------------read more text---------------------------*/
  491. $str_without_tag = strip_tags($my_post_text);
  492. $char_count = strlen($str_without_tag);
  493.  
  494. if((!empty($atts['char_limit'])) && ($atts['char_limit'] < $char_count) )
  495. {
  496. $short_sentence = substr($str_without_tag, 0,$atts['char_limit']);
  497.  
  498. $short_sentence = makeLinks ($short_sentence,$atts['link_target']); // link the urls
  499.  
  500. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$short_sentence))
  501. $short_sentence = make_hash_link ($short_sentence,$atts['link_target']);
  502.  
  503. if (array_key_exists('story_tags',$mysinglefeed ))
  504. {
  505. foreach ( $mysinglefeed->story_tags as $mystorytag)
  506. {
  507. $mystorytagname = $mystorytag->name;
  508. if($atts['link_target']==1) {
  509. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" target="_blank">' . $mystorytag->name . '</a>';
  510. } else {
  511. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" >' . $mystorytag->name . '</a>';
  512. }
  513. $short_sentence = str_replace($mystorytagname, $tag_link, $short_sentence);
  514. }
  515. }
  516.  
  517. if (array_key_exists('message_tags',$mysinglefeed ))
  518. {
  519. foreach( $mysinglefeed->message_tags as $mymessagetag)// now add the hyperlink to tags
  520. {
  521. $mymessagetagname = $mymessagetag->name;
  522. if($atts['link_target']==1) {
  523. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" target="_blank">' . $mymessagetag->name . '</a>';
  524. } else {
  525. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" >' . $mymessagetag->name . '</a>';
  526. }
  527. $short_sentence = str_replace($mymessagetagname, $tag_link, $short_sentence);
  528. }
  529. }
  530. $mytext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$short_sentence.'...<span><a class="wff-more-link">'.$atts['read_more'].'</a></span></p>';
  531. $mytext .= '<p class="more-content" '.$full_style_wrapper.'>'.$my_post_text.'...<span><a class="wff-less-link" style="display:none">'.$atts['read_less'].'</a></span></p>';
  532. }
  533. else{
  534. $mytext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$my_post_text.'</p>';
  535. }
  536. /*------------------------------------------------*/
  537. //call media inline style function
  538. $media_complete_style = media_custom_inline_style($atts);
  539. $build_media = ''; $build_photo = ''; $build_video = '';
  540. $build_post_desc_html = '';
  541.  
  542. $share_link = $mysinglefeed->link;
  543. if(isset($mysinglefeed->story))
  544. $share_title = $mysinglefeed->story;
  545. if(isset($mysinglefeed->message))
  546. $share_title = $mysinglefeed->message;
  547.  
  548. $share_media = build_share_wrapper($share_link,$share_title);
  549.  
  550. if(isset($mysinglefeed->picture)) {
  551. $picture = $mysinglefeed->picture;
  552. if($atts['link_target']==1) {
  553. $build_photo = '<div class="wff-link-img"><a href = '. $post_resource_link.' target = "_blank"><img '.$media_complete_style.' src="'.$picture.'"></a></div>';
  554. }else {
  555. $build_photo = '<div class="wff-link-img"><a href = '. $post_resource_link.'><img '.$media_complete_style.' src="'.$picture.'"></a></div>';
  556. }
  557. }
  558. if (isset($mysinglefeed->source))// check for video
  559. {
  560. $video = $mysinglefeed->source;
  561. $video = str_replace('autoplay=1','autoplay=0', $video);//autoplay disabled
  562. $build_video = '<div class="wff-link-img"><iframe '.$media_complete_style.' src="'.$video.'" ></iframe></div>';
  563. }
  564. $build_media = $build_photo.$build_video;
  565.  
  566. if(isset($mysinglefeed->description)) {
  567. if(isset($mysinglefeed->picture) || isset($mysinglefeed->source)) {
  568. $build_post_desc_html = '<div class = "wff-shared-link-main-wrapper">'.$build_media.'<div class="wff-link-main-desc" '.$line_height_style.'><p>';
  569. $build_post_desc_html .= '<a class="wff-link-tab" href='.$name_url.' target="_blank" >'.$name_var.'</a></p><p>'.$link_post_desc.'</p>';
  570. if(isset($mysinglefeed->caption)) {
  571. $build_post_desc_html .='<p><a class="wff-link-tab" href='.$name_url.' target="_blank" >'.$mysinglefeed->caption.'</a></p></div></div>';
  572. } else $build_post_desc_html .= '</div></div>';
  573. }
  574. else {
  575. $build_post_desc_html = '<div class = "wff-shared-link-main-wrapper">'.$build_media.'<p class = "wff-link-post-title">';
  576. $build_post_desc_html .= '<a class="wff-link-tab" href='.$name_url.' target="_blank">'.$name_var.'</a></p><p class = "wff-link-post-description" '.$line_height_style.'>'.$link_post_desc.'</p>';
  577. if(isset($mysinglefeed->caption)) {
  578. $build_post_desc_html .='<a class="wff-link-tab" href='.$name_url.' target="_blank" >'.$mysinglefeed->caption.'</a></div>';
  579. } else $build_post_desc_html .= '</div>';
  580. }
  581. $mytext .= $build_post_desc_html ;
  582. }
  583.  
  584. if($atts['link_target']==1) {
  585. $mytext .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  586. } else {
  587. $mytext .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  588. }
  589. return $mytext;
  590. }
  591.  
  592. function build_my_event_html ($mysinglefeed ,$atts,$myaccesstoken)
  593. {
  594. $theurl = parse_url($mysinglefeed->link);
  595. $urlpart = explode('/', $theurl['path']);
  596.  
  597. $the_event_id = $urlpart[2];
  598.  
  599. //now get the event json
  600. $event_url_json = 'https://graph.facebook.com/' . $the_event_id . '?access_token=' . $myaccesstoken ;
  601.  
  602. $event_json_data = wff_fetchUrl($event_url_json);
  603. $event_data = json_decode($event_json_data) ;
  604.  
  605.  
  606.  
  607.  
  608.  
  609. //get event start date
  610. $event_start_date = $event_data->start_time;
  611. $event_start_date = substr($event_start_date, 0, 10);
  612.  
  613.  
  614. $str_format = strtotime($event_start_date);
  615.  
  616. // call author wrapper function
  617. $finaltext = '';
  618. $my_author_text = build_author_html($mysinglefeed,$atts);
  619. if($atts['post_layout_type'] == 'halfwidth' || $atts['post_layout_type'] == 'thumbnail' ) {
  620. $finaltext .= $my_author_text;
  621. }
  622.  
  623.  
  624. //call media inline style function
  625. $media_complete_style = media_custom_inline_style($atts);
  626. $the_resource_id = explode('_',$mysinglefeed->id);
  627. $post_resource_link = 'https://facebook.com/'.$atts['page_id'] .'/posts/'.$the_resource_id[1];
  628.  
  629. $picture = $mysinglefeed->full_picture;
  630. $lb_data = '';
  631. if(isset($mysinglefeed->story))
  632. {
  633. $lb_data = $mysinglefeed->story;
  634. $lb_data = str_replace('"', '', $lb_data);
  635. }
  636. if (isset($mysinglefeed->message) && !empty($mysinglefeed->message))
  637. {
  638. $lb_data = $mysinglefeed->message;
  639. $lb_data = str_replace('"', '', $lb_data);
  640. }
  641.  
  642. $attach_photo = '<div class="wff_showcase"><div class="wff_showcase_media">';
  643. if($atts['post_layout_type'] == 'fullwidth') {
  644. $attach_photo .= '<div class="wff-full-img"><a target="_blank"><img '.$media_complete_style.' src="'.$picture.'"></a></div><div class="wff_showcase_overlay_full">';
  645. } else {
  646. $attach_photo .= '<div class="wff-small-img"><a target="_blank" href ='.$post_resource_link.'><img '.$media_complete_style.' src="'.$picture.'"></a></div><div class="wff_showcase_overlay">';
  647. }
  648.  
  649. if($atts['post_layout_type'] == 'fullwidth') {
  650. $attach_photo .= '<div class="wff_showcase_overlay_inner"><div class="wff_showcase_icons">';
  651. }
  652. if($atts['post_layout_type'] == 'halfwidth') {
  653. $attach_photo .= '<div class="wff_showcase_half_overlay_inner"><div class="wff_showcase_half_icons">';
  654. }
  655. if($atts['post_layout_type'] == 'thumbnail') {
  656. $attach_photo .= '<div class="wff_showcase_thumbnail_overlay_inner"><div class="wff_showcase_thumbnail_icons">';
  657. }
  658.  
  659. $attach_photo .='<a class="hover_thumb" rel="lightbox[group]" href="'.$picture.'" title="show Image" data-title="'.$lb_data.'" data-link="'.$post_resource_link.'" ><i class="fa fa-picture-o"></i></a><a class="hover_thumb" target="_blank" href="'.$post_resource_link.'" title="VIew on Facebook" ><i class="fa fa-link"></i></a></div></div></div></div></div>';
  660.  
  661. //condition for date format
  662. if($atts['author_date_format']=='default'){
  663. $event_date_print = date('F d, Y',$str_format);
  664. }
  665. else{
  666. $system_date_format = $atts['author_date_format'];
  667. $event_date_print = date($system_date_format, $str_format);
  668. }
  669.  
  670. //We will build the date string. Check if an end time is specified
  671. if (isset($event_data->end_time))
  672. {
  673. // get event end date
  674. $event_end_date = $event_data->end_time;
  675. $event_end_date = substr($event_end_date, 0, 10);
  676. $str_format = strtotime($event_end_date);
  677.  
  678. if($atts['author_date_format']=='default'){
  679. $event_end_date_print = date('F d, Y',$str_format);
  680. }
  681. else{
  682. $system_date_format = $atts['author_date_format'];
  683. $event_end_date_print = date($system_date_format, $str_format);
  684.  
  685. }
  686. $date1 = substr($event_data->start_time, 0, 10);
  687. $date2 = substr($event_data->end_time, 0, 10);
  688. if(strtotime($date2)!= strtotime($date1))
  689. {
  690. $event_date_print .= " - ". $event_end_date_print;
  691.  
  692. }
  693.  
  694.  
  695. }
  696.  
  697. if (isset($mysinglefeed->story))
  698. {
  699. // if story exists then use the story in the post text
  700. $my_post_text = $mysinglefeed->story;
  701.  
  702. if (array_key_exists('story_tags',$mysinglefeed ))
  703. {
  704. // now add the hyperlink to tags
  705. foreach ( $mysinglefeed->story_tags as $mystorytag)
  706. {
  707. $mystorytagname = $mystorytag->name;
  708. if($atts['link_target']==1) {
  709. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" target="_blank">' . $mystorytag->name . '</a>';
  710. } else {
  711. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" >' . $mystorytag->name . '</a>';
  712. }
  713. $my_post_text = str_replace($mystorytagname, $tag_link, $my_post_text);
  714. }
  715. }
  716. }
  717.  
  718. if (isset($mysinglefeed->message))
  719. {
  720. // if story exists then use the story in the post text
  721. $my_post_text = $mysinglefeed->message;
  722. $my_post_text = makeLinks($my_post_text,$atts['link_target']);
  723.  
  724. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$my_post_text))
  725. $my_post_text = make_hash_link($my_post_text,$atts['link_target']);
  726. }
  727.  
  728. //call post text inline style
  729. $limited_style_wrapper = limited_post_text_inline_style($atts);
  730. $full_style_wrapper = full_post_text_inline_style($atts);
  731. $line_height_style = feed_line_height($atts);
  732. /*---------------------read more text---------------------------*/
  733.  
  734. $str_without_tag = strip_tags($my_post_text);
  735. $char_count = strlen($str_without_tag);
  736.  
  737. if((!empty($atts['char_limit'])) && ($atts['char_limit'] < $char_count) )
  738. {
  739. $short_sentence = substr($str_without_tag, 0,$atts['char_limit']);
  740.  
  741. $short_sentence = makeLinks ($short_sentence,$atts['link_target']); // link the urls
  742.  
  743. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$short_sentence))
  744. $short_sentence = make_hash_link ($short_sentence,$atts['link_target']);
  745.  
  746. if (array_key_exists('story_tags',$mysinglefeed ))
  747. {
  748. // now add the hyperlink to tags
  749. foreach ( $mysinglefeed->story_tags as $mystorytag)
  750. {
  751. $mystorytagname = $mystorytag->name;
  752. if($atts['link_target']==1) {
  753. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" target="_blank">' . $mystorytag->name . '</a>';
  754. } else {
  755. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" >' . $mystorytag->name . '</a>';
  756. }
  757. $short_sentence = str_replace($mystorytagname, $tag_link, $short_sentence);
  758. }
  759. }
  760.  
  761. $finaltext .= '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$short_sentence.'...<span><a class="wff-more-link">'.$atts['read_more'].'</a></span></p>';
  762. $finaltext .= '<p class="more-content" '.$full_style_wrapper.'>'.$my_post_text.'...<span><a class="wff-less-link" style="display:none">'.$atts['read_less'].'</a></span></p>';
  763. }
  764. else {
  765. $finaltext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$my_post_text.'</p>';
  766. }
  767. /*------------------------------------------------*/
  768.  
  769. $post_resource_link = $mysinglefeed->link;
  770.  
  771. // share on social media link
  772. if(isset($mysinglefeed->story))
  773. $share_title = $mysinglefeed->story;
  774. if(isset($mysinglefeed->message))
  775. $share_title = $mysinglefeed->message;
  776.  
  777. $share_media = build_share_wrapper($post_resource_link,$share_title);
  778.  
  779. $event_title = $event_data->name;
  780. $event_description = $event_data->description;
  781. //$event_location = $event_data->location;
  782. $finaltext .= '<div class = "wff-fb-item-event-wrapper">';
  783. $finaltext .= '<div class = "fb-text-wrapper">';
  784. $finaltext .= '<div class = "fb-post-data description-wrapper">';
  785. if($atts['link_target']==1) {
  786. $finaltext .= '<p class="wff-event-title"><a class="wff-link-tab" href = '.$post_resource_link. ' target = "_blank">'.$event_title.'</a></p>';
  787. } else {
  788. $finaltext .= '<p class="wff-event-title"><a class="wff-link-tab" href = '.$post_resource_link. ' >'.$event_title.'</a></p>';
  789. }
  790. $finaltext .= '<p class="wff-event-content" '.$line_height_style.' >'.$event_description.'</p>';// close post data div
  791. $finaltext .= '<div class = "event-date">'.$event_date_print.'</div></div>' ; // the date div
  792. if($atts['link_target']==1) {
  793. $finaltext .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '.$post_resource_link. ' target = "_blank">'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  794. } else {
  795. $finaltext .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '.$post_resource_link.' >'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  796. }
  797. $finaltext .= '</div></div>'; // close text wrapper and event wrapper
  798.  
  799. $content = '';
  800. if($atts['post_layout_type'] == 'fullwidth') {
  801. $content .= $attach_photo;
  802. $content .= $finaltext;
  803. }
  804. if($atts['post_layout_type'] == 'halfwidth') {
  805. $content .= '<div class="wff-halfwidth-layout">';
  806. $content .= '<div class="wff-photo-wrapper">'.$attach_photo.'</div>';
  807. $content .= '<div class="wff-right-content-wrapper" style="word-wrap:break-word;">'.$finaltext.'</div>';
  808. $content .= '</div>';
  809. }
  810. if($atts['post_layout_type'] == 'thumbnail') {
  811. $content .= '<div class="wff-thumb-layout">';
  812. $content .= '<div class="wff-thumb-photo-wrapper">'.$attach_photo.'</div>';
  813. $content .= '<div class="wff-thumb-right-content-wrapper" style="word-wrap:break-word;">'.$finaltext.'</div>';
  814. $content .= '</div>';
  815. }
  816.  
  817. return $content;
  818. }
  819.  
  820. function build_my_status_html ($mysinglefeed ,$atts)
  821. {
  822.  
  823. if (isset($mysinglefeed->story))
  824. {
  825. // if story exists then use the story in the post text
  826.  
  827. $my_post_text = $mysinglefeed->story;
  828.  
  829. if (array_key_exists('story_tags',$mysinglefeed ))
  830. {
  831. // now add the hyperlink to tags
  832. foreach ( $mysinglefeed->story_tags as $mystorytag)
  833. {
  834. $mystorytagname = $mystorytag->name;
  835. if($atts['link_target']==1) {
  836. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" target="_blank">' . $mystorytag->name . '</a>';
  837. } else {
  838. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" >' . $mystorytag->name . '</a>';
  839. }
  840. $my_post_text = str_replace($mystorytagname, $tag_link, $my_post_text);
  841. }
  842. }
  843. }
  844.  
  845. if (isset($mysinglefeed->message))
  846. {
  847. // if story exists then use the story in the post text
  848. $my_post_text = $mysinglefeed->message;
  849. $my_post_text = makeLinks($my_post_text,$atts['link_target']);
  850.  
  851. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$my_post_text))
  852. $my_post_text = make_hash_link ($my_post_text,$atts['link_target']);
  853. }
  854. // Build Post description
  855. // first hyper link the name
  856.  
  857. $name_var = (isset($mysinglefeed->name) ? $mysinglefeed->name : '');
  858. $name_url = (isset($mysinglefeed->link) ? $mysinglefeed->link : '');
  859.  
  860. $link_post_desc = (isset($mysinglefeed->description) ? $mysinglefeed->description : '');
  861. $link_post_desc = makeLinks($link_post_desc,$atts['link_target']);
  862.  
  863. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$link_post_desc))
  864. $link_post_desc = make_hash_link($link_post_desc,$atts['link_target']);
  865.  
  866. if (array_key_exists('message_tags',$mysinglefeed ))
  867. {
  868. // now add the hyperlink to tags
  869. foreach ( $mysinglefeed->message_tags as $mymessagetag)
  870. {
  871. $mymessagetagname = $mymessagetag->name;
  872. if($atts['link_target']==1) {
  873. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" target="_blank">' . $mymessagetag->name . '</a>';
  874. } else {
  875. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" >' . $mymessagetag->name . '</a>';
  876. }
  877. $my_post_text = str_replace($mymessagetagname, $tag_link, $my_post_text);
  878. }
  879. }
  880. $the_resource_id_array = explode("_", $mysinglefeed->id);
  881. $the_resource_id = $the_resource_id_array[1];
  882. $post_resource_link = 'https://facebook.com/'.$atts['page_id'] .'/posts/'.$the_resource_id;
  883.  
  884. if(isset($mysinglefeed->story))
  885. $share_title = $mysinglefeed->story;
  886. if(isset($mysinglefeed->message))
  887. $share_title = $mysinglefeed->message;
  888. $share_media = build_share_wrapper($post_resource_link,$share_title);
  889.  
  890. //call post text inline style
  891. $limited_style_wrapper = limited_post_text_inline_style($atts);
  892. $full_style_wrapper = full_post_text_inline_style($atts);
  893. $line_height_style = feed_line_height($atts);
  894. /*---------------------read more text---------------------------*/
  895.  
  896. $str_without_tag = strip_tags($my_post_text);
  897. $char_count = strlen($str_without_tag);
  898.  
  899. if((!empty($atts['char_limit'])) && ($atts['char_limit'] < $char_count) )
  900. {
  901. $short_sentence = substr($str_without_tag, 0,$atts['char_limit']);
  902.  
  903. $short_sentence = makeLinks ($short_sentence,$atts['link_target']); // link the urls
  904.  
  905. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$short_sentence))
  906. $short_sentence = make_hash_link ($short_sentence,$atts['link_target']);
  907.  
  908. if (array_key_exists('story_tags',$mysinglefeed ))
  909. {
  910. foreach ( $mysinglefeed->story_tags as $mystorytag)
  911. {
  912. $mystorytagname = $mystorytag->name;
  913. if($atts['link_target']==1) {
  914. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" target="_blank">' . $mystorytag->name . '</a>';
  915. } else {
  916. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag->id . '" style="color: #729DB6;" >' . $mystorytag->name . '</a>';
  917. }
  918. $short_sentence = str_replace($mystorytagname, $tag_link, $short_sentence);
  919. }
  920. }
  921.  
  922. if (array_key_exists('message_tags',$mysinglefeed ))
  923. {
  924. foreach( $mysinglefeed->message_tags as $mymessagetag)// now add the hyperlink to tags
  925. {
  926. $mymessagetagname = $mymessagetag->name;
  927. if($atts['link_target']==1) {
  928. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" target="_blank">' . $mymessagetag->name . '</a>';
  929. } else {
  930. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" >' . $mymessagetag->name . '</a>';
  931. }
  932. $short_sentence = str_replace($mymessagetagname, $tag_link, $short_sentence);
  933. }
  934. }
  935. $mytext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$short_sentence.'...<span><a class="wff-more-link">'.$atts['read_more'].'</a></span></p>';
  936. $mytext .= '<p class="more-content" '.$full_style_wrapper.'>'.$my_post_text.'...<span><a class="wff-less-link" style="display:none">'.$atts['read_less'].'</a></span></p>';
  937. }
  938. else{
  939. $mytext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$my_post_text.'</p>';
  940. }
  941. /*------------------------------------------------*/
  942. $build_post_desc_html = '';
  943. if(isset($mysinglefeed->description)){
  944. if($atts['link_target']==1) {
  945. $build_link_title = '<p class = "link-title"><a class="wff-link-tab" target="_blank" href =' .$name_url.'>'.$name_var.'</a></p>';
  946. } else {
  947. $build_link_title = '<p class = "link-title"><a class="wff-link-tab" href =' .$name_url.'>'.$name_var.'</a></p>';
  948. }
  949. $build_post_desc_html = '<div class = "description-wrapper shared-link">'.$build_link_title.'<p class = "post-desc" '.$line_height_style.'>'.$link_post_desc.'</p></div>';
  950. }
  951.  
  952. $mytext .= $build_post_desc_html ;
  953. if($atts['link_target']==1) {
  954. $mytext .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  955. } else {
  956. $mytext .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  957. }
  958. return $mytext;
  959. }
  960.  
  961. /*------create snapshot from video------------------*/
  962. function video_image($video,$mysinglefeed){
  963. $image_url = parse_url($video);
  964. if($image_url['host'] == 'www.youtube.com' || $image_url['host'] == 'youtube.com'){
  965. $get_snap = explode('/',$image_url['path']);
  966. return 'http://img.youtube.com/vi/'.$get_snap[2].'/hqdefault.jpg';
  967. }
  968. else {
  969. $video_url = parse_url($mysinglefeed->link);
  970. $pic_id = explode('/',$video_url['path']);
  971.  
  972. if(isset($pic_id[3])) {
  973. return 'https://graph.facebook.com/'.$pic_id[3].'/picture';
  974. } else {
  975. return $mysinglefeed->picture;
  976. }
  977. }
  978. }
  979. function build_my_video_html ($mysinglefeed ,$atts)
  980. {
  981. if (isset($mysinglefeed->story))
  982. {
  983. // if story exists then use the story in the post text
  984. $my_post_text = $mysinglefeed->story;
  985. }
  986. if (isset($mysinglefeed->message))
  987. {
  988. // if story exists then use the story in the post text
  989. $my_post_text = $mysinglefeed->message;
  990. $my_post_text = makeLinks($my_post_text,$atts['link_target']);
  991.  
  992. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$my_post_text))
  993. $my_post_text = make_hash_link($my_post_text,$atts['link_target']);
  994. }
  995.  
  996. // Build Post description
  997. // first hyper link the name
  998. $name_var = (isset($mysinglefeed->name) ? $mysinglefeed->name : '');
  999. $name_url = (isset($mysinglefeed->link) ? $mysinglefeed->link : '');
  1000.  
  1001. $link_post_desc = (isset($mysinglefeed->description) ? $mysinglefeed->description : '');
  1002. $link_post_desc = makeLinks($link_post_desc,$atts['link_target']);
  1003.  
  1004. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$link_post_desc))
  1005. $link_post_desc = make_hash_link($link_post_desc,$atts['link_target']);
  1006.  
  1007. if (array_key_exists('message_tags',$mysinglefeed ))
  1008. {
  1009. // now add the hyperlink to tags
  1010. foreach ( $mysinglefeed->message_tags as $mymessagetag)
  1011. {
  1012. $mymessagetagname = $mymessagetag->name;
  1013. if($atts['link_target']==1) {
  1014. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" target="_blank">' . $mymessagetag->name . '</a>';
  1015. } else {
  1016. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" >' . $mymessagetag->name . '</a>';
  1017. }
  1018. $my_post_text = str_replace($mymessagetagname, $tag_link, $my_post_text);
  1019. }
  1020. }
  1021. $the_resource_id_array = explode("_", $mysinglefeed->id);
  1022. $the_resource_id = $the_resource_id_array[1];
  1023.  
  1024. $post_resource_link = 'https://facebook.com/'.$atts['page_id'] .'/posts/'.$the_resource_id;
  1025.  
  1026. //call post text inline style
  1027. $limited_style_wrapper = limited_post_text_inline_style($atts);
  1028. $full_style_wrapper = full_post_text_inline_style($atts);
  1029. $line_height_style = feed_line_height($atts);
  1030. /*---------------------read more text---------------------------*/
  1031. $str_without_tag = strip_tags($my_post_text);
  1032. $char_count = strlen($str_without_tag);
  1033.  
  1034. if((!empty($atts['char_limit'])) && ($atts['char_limit'] < $char_count) )
  1035. {
  1036. $short_sentence = substr($str_without_tag, 0,$atts['char_limit']);
  1037.  
  1038. $short_sentence = makeLinks ($short_sentence,$atts['link_target']); // link the urls
  1039.  
  1040. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/',$short_sentence))
  1041. $short_sentence = make_hash_link ($short_sentence,$atts['link_target']);
  1042.  
  1043. if (array_key_exists('message_tags',$mysinglefeed ))
  1044. {
  1045. foreach( $mysinglefeed->message_tags as $mymessagetag)// now add the hyperlink to tags
  1046. {
  1047. $mymessagetagname = $mymessagetag->name;
  1048. if($atts['link_target']==1) {
  1049. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" target="_blank">' . $mymessagetag->name . '</a>';
  1050. } else {
  1051. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag->id . '" style="color: red;" >' . $mymessagetag->name . '</a>';
  1052. }
  1053. $short_sentence = str_replace($mymessagetagname, $tag_link, $short_sentence);
  1054. }
  1055. }
  1056.  
  1057. $mytext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$short_sentence.'...<span><a class="wff-more-link">'.$atts['read_more'].'</a></span></p>';
  1058. $mytext .= '<p class="more-content" '.$full_style_wrapper.'>'.$my_post_text.'...<span><a class="wff-less-link" style="display:none">'.$atts['read_less'].'</a></span></p>';
  1059. }
  1060. else{
  1061. $mytext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$my_post_text.'</p>';
  1062. }
  1063. /*------------------------------------------------*/
  1064. //call media inline style function
  1065. $media_complete_style = media_custom_inline_style($atts);
  1066.  
  1067. // call author wrapper function
  1068. $my_author_text = build_author_html($mysinglefeed,$atts);
  1069.  
  1070. $share_link = $mysinglefeed->link;
  1071. if(isset($mysinglefeed->story))
  1072. $share_title = $mysinglefeed->story;
  1073. if(isset($mysinglefeed->message))
  1074. $share_title = $mysinglefeed->message;
  1075.  
  1076. $share_media = build_share_wrapper($share_link,$share_title);
  1077.  
  1078. $build_half_desc_html = '';
  1079. $build_thumb_desc_html = '';
  1080. $build_post_desc_html = '';
  1081.  
  1082. $lb_data = '';
  1083. /*------------------------------------------------*/
  1084. if(isset($mysinglefeed->story))
  1085. {
  1086. $lb_data = $mysinglefeed->story;
  1087. $lb_data = str_replace('"', '', $lb_data);
  1088. }
  1089. if (isset($mysinglefeed->message) && !empty($mysinglefeed->message))
  1090. {
  1091. $lb_data = $mysinglefeed->message;
  1092. $lb_data = str_replace('"', '', $lb_data);
  1093. }
  1094. if (isset($mysinglefeed->source))// check for video
  1095. {
  1096. $video = $mysinglefeed->source;
  1097.  
  1098. $view = video_image($video,$mysinglefeed);
  1099. }
  1100.  
  1101. $build_video = '<div class="wff_showcase"><div class="wff_showcase_media">';
  1102.  
  1103. if($atts['post_layout_type'] == 'fullwidth') {
  1104. $build_video .= '<div class="wff-full-img"><i class="fa fa-play fa-2x wff-playbtn"></i><a target="_blank"><img '.$media_complete_style.' src="'.$view.'"></a></div><div class="wff_showcase_overlay_full">';
  1105. }
  1106. if($atts['post_layout_type'] == 'halfwidth') {
  1107. $build_video .= '<div class="wff-small-img"><i class="fa fa-play fa-lg wff-playbtn-half"></i><a target="_blank" href ='.$post_resource_link.'><img '.$media_complete_style.' src="'.$view.'"></a></div><div class="wff_showcase_overlay">';
  1108. }
  1109. if($atts['post_layout_type'] == 'thumbnail') {
  1110. $build_video .= '<div class="wff-small-img"><i class="fa fa-play wff-playbtn-thumb"></i><a target="_blank" href ='.$post_resource_link.'><img '.$media_complete_style.' src="'.$view.'"></a></div><div class="wff_showcase_overlay">';
  1111. }
  1112.  
  1113. if($atts['post_layout_type'] == 'fullwidth') {
  1114. $build_video .= '<div class="wff_showcase_overlay_inner"><div class="wff_showcase_icons">';
  1115. }
  1116. if($atts['post_layout_type'] == 'halfwidth') {
  1117. $build_video .= '<div class="wff_showcase_half_overlay_inner"><div class="wff_showcase_half_icons">';
  1118. }
  1119. if($atts['post_layout_type'] == 'thumbnail') {
  1120. $build_video .= '<div class="wff_showcase_thumbnail_overlay_inner"><div class="wff_showcase_thumbnail_icons">';
  1121. }
  1122.  
  1123. $build_video .='<a class="hover_thumb" rel="lightbox[group]" href="'.$view.'" feed_video='.$video.' media-type="vedio" title="show Video" data-title="'.$lb_data.'" ><i class="fa fa-play"></i></a><a class="hover_thumb" target="_blank" href="'.$post_resource_link.'" title="VIew on Facebook" ><i class="fa fa-link"></i></a></div></div></div></div></div>';
  1124.  
  1125. if($atts['post_layout_type']=='fullwidth') {
  1126. $mytext .= $build_video;
  1127. if(isset($mysinglefeed->description)) {
  1128. $mytext .= '<div class = "wff-shared-link-wrapper"><p class = "wff-post-description" '.$line_height_style.' >'.$link_post_desc.'</p></div>';
  1129. }
  1130. if($atts['link_target']==1) {
  1131. $mytext .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  1132. } else {
  1133. $mytext .= '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  1134. }
  1135. return $mytext;
  1136. }
  1137. else if($atts['post_layout_type']=='halfwidth')
  1138. {
  1139. $build_half_desc_html = '<div class="wff-halfwidth-layout">';
  1140. $build_half_desc_html .= '<div class="wff-photo-wrapper">'.$build_video.'</div>';
  1141. $build_half_desc_html .= '<div class="wff-right-content-wrapper">'.$my_author_text;
  1142. $build_half_desc_html .= $mytext;
  1143.  
  1144. if(isset($mysinglefeed->description)){
  1145. $build_half_desc_html .= '<div class = "wff-shared-link-wrapper"><p class = "wff-post-description" '.$line_height_style.'>'.$link_post_desc.'</p></div>';
  1146. }
  1147. $build_half_desc_html .= '</div></div><div class="clearfix"></div>';
  1148.  
  1149. if($atts['link_target']==1) {
  1150. $build_link_html = '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  1151. } else {
  1152. $build_link_html = '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  1153. }
  1154.  
  1155. $build_half_desc_html .= $build_link_html;
  1156.  
  1157. return $build_half_desc_html;
  1158. }
  1159. else
  1160. {
  1161. $build_thumb_desc_html = '<div class="wff-thumb-layout">';
  1162. $build_thumb_desc_html .= '<div class="wff-thumb-photo-wrapper">'.$build_video.'</div>';
  1163. $build_thumb_desc_html .= '<div class="wff-thumb-right-content-wrapper">'.$my_author_text;
  1164. $build_thumb_desc_html .= $mytext;
  1165.  
  1166. if(isset($mysinglefeed->description)){
  1167. $build_thumb_desc_html .= '<div class = "wff-shared-link-wrapper"><p class = "wff-post-description" '.$line_height_style.'>'.$link_post_desc.'</p></div>';
  1168. }
  1169. $build_thumb_desc_html .= '</div></div><div class="clearfix"></div>';
  1170.  
  1171. if($atts['link_target']==1) {
  1172. $build_link_html = '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  1173. } else {
  1174. $build_link_html = '<div class = "wff-bottom-wrapper"><div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a><a class="wff-social-media wff-link-tab">'.$atts['share_text'].'</a><span style="display:none;"><i class="fa fa-caret-left fa-lg wff-right-arrow"></i></span><span class="wff-share-toggle " style="display:none;">'.$share_media.'</span></div></div>';
  1175. }
  1176. $build_thumb_desc_html .= $build_link_html;
  1177.  
  1178. return $build_thumb_desc_html;
  1179. }
  1180. }
  1181. // function: to calculate difference b/w current time and post updated time in different time units.
  1182. function posted_time($time)
  1183. {
  1184. $time = time() - $time; // to get the time since that moment
  1185.  
  1186. $time_units = array (
  1187. 31536000 => 'year',
  1188. 2592000 => 'month',
  1189. 604800 => 'week',
  1190. 86400 => 'day',
  1191. 3600 => 'hour',
  1192. 60 => 'minute',
  1193. 1 => 'second'
  1194. );
  1195.  
  1196. foreach ($time_units as $unit => $text) {
  1197. if ($time < $unit) continue;
  1198. $numberOfUnits = floor($time / $unit);
  1199. return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
  1200. }
  1201.  
  1202. }
  1203. function build_author_html($mysinglefeed,$atts)
  1204. {
  1205. // Check if we need to apply inline styles
  1206. //Author
  1207. $wff_author_inline_style = 'style="';
  1208. if ( !empty($atts['author_text_size']) && $atts['author_text_size'] != 'inherit' ) $wff_author_inline_style .= 'font-size:' . $atts['author_text_size'] . 'px; line-height:' . $atts['author_text_size'] . 'px; ';
  1209. if ( !empty($atts['line_height']) && $atts['line_height'] != 'inherit' ) $wff_author_inline_style .= 'line-height:' . $atts['line_height'].'px;';
  1210. if ( !empty($atts['author_text_color']) ) $wff_author_inline_style .= 'color:' .$atts['author_text_color'] . ';';
  1211. $wff_author_inline_style .= '"';
  1212.  
  1213. //img border size and color style
  1214. $wff_author_image_style = 'style="';
  1215. if ( !empty($atts['author_img_border']) && $atts['author_img_border'] != 'none' ) $wff_author_image_style .= 'border:' . $atts['author_img_border'] . 'px solid ';
  1216. if ( !empty($atts['author_text_color']) ) $wff_author_image_style .= $atts['author_text_color'] .';';
  1217. $wff_author_image_style .= '"';
  1218.  
  1219. $link_to_page = 'https://facebook.com/'.$atts['page_id'];
  1220.  
  1221. // get update date
  1222. $time = strtotime($mysinglefeed->updated_time);
  1223.  
  1224. //condition for date format
  1225. if($atts['author_date_format']=='default'){
  1226. $post_date_print = 'posted '.posted_time($time).' ago';
  1227. }
  1228. else{
  1229. $system_date_format = $atts['author_date_format'];
  1230. $post_date_print = date_i18n($system_date_format,$time);
  1231. }
  1232. if($atts['post_layout_type']=='fullwidth') {
  1233. $authorname = '<div class = "wff-author-name"><p '.$wff_author_inline_style.' >'. $mysinglefeed->from->name . '</p><p class = "wff-date">'.$post_date_print.'</p></div>';
  1234.  
  1235. $authorimage = '<div class = "wff-author-image"><img '.$wff_author_image_style.' src = https://graph.facebook.com/' . $mysinglefeed->from->id . '/picture?type=square></div>';
  1236.  
  1237. $authortext = '<div class = "wff-fb-author-data" ><div class="wff-row">
  1238. <div class="wff-facebook-feed-image-div">'.$authorimage.'</div>
  1239. <div class="wff-facebook-feed-title-div">'.$authorname.'</div>
  1240. </div></div><div class="clearfix"></div>';
  1241.  
  1242. if($atts['link_target']==1){
  1243. $authortext = '<a class="wff-link-tab" href ='. $link_to_page .' target="_blank" >'.$authortext.'</a>';
  1244. } else {
  1245. $authortext = '<a class="wff-link-tab" href ='. $link_to_page .'>'.$authortext.'</a>';
  1246. }
  1247. $authortext = '<div class = "wff-author-wrapper">'.$authortext.'</div>';
  1248. }
  1249. else if($atts['post_layout_type']=='halfwidth'){
  1250.  
  1251. $authorname = '<div class = "wff-author-name"><p '.$wff_author_inline_style.' >'. $mysinglefeed->from->name . '</p><p class = "wff-date">'.$post_date_print.'</p></div>';
  1252.  
  1253. $authorimage = '<div class = "wff-author-image"><img '.$wff_author_image_style.' src = https://graph.facebook.com/' . $mysinglefeed->from->id . '/picture?type=square></div>';
  1254.  
  1255. $authortext = '<div class = "wff-fb-author-data" ><div class="wff-hw-row">
  1256. <div class="wff-hw-feed-image-div">'.$authorimage.'</div>
  1257. <div class="wff-hw-feed-title-div">'.$authorname.'</div>
  1258. </div></div><div class="clearfix"></div>';
  1259.  
  1260. if($atts['link_target']==1){
  1261. $authortext = '<a class="wff-link-tab" href ='. $link_to_page .' target="_blank" >'.$authortext.'</a>';
  1262. } else {
  1263. $authortext = '<a class="wff-link-tab" href ='. $link_to_page .'>'.$authortext.'</a>';
  1264. }
  1265. }
  1266. else{
  1267.  
  1268. $authorname = '<div class = "wff-author-name"><p '.$wff_author_inline_style.' >'. $mysinglefeed->from->name . '</p><p class = "wff-date">'.$post_date_print.'</p></div>';
  1269.  
  1270. $authorimage = '<div class = "wff-author-image"><img '.$wff_author_image_style.' src = https://graph.facebook.com/' . $mysinglefeed->from->id . '/picture?type=square></div>';
  1271.  
  1272. $authortext = '<div class = "wff-fb-author-data" ><div class="wff-hw-row">
  1273. <div class="wff-thumb-feed-image-div">'.$authorimage.'</div>
  1274. <div class="wff-thumb-feed-title-div">'.$authorname.'</div>
  1275. </div></div><div class="clearfix"></div>';
  1276.  
  1277. if($atts['link_target']==1){
  1278. $authortext = '<a class="wff-link-tab" href ='. $link_to_page .' target="_blank" >'.$authortext.'</a>';
  1279. } else {
  1280. $authortext = '<a class="wff-link-tab" href ='. $link_to_page .'>'.$authortext.'</a>';
  1281. }
  1282. }
  1283. return $authortext;
  1284. }
  1285.  
  1286. //add easy facebook feed shortcode
  1287. add_shortcode('facebook-feed','wff_shortcode_display');
  1288.  
  1289. function wff_shortcode_display ($atts) {
  1290.  
  1291. if(!function_exists('wff_custom_js_code')){
  1292. add_action( 'wp_footer', 'wff_custom_js_code' );
  1293. function wff_custom_js_code() {
  1294.  
  1295. $custom_js_setting = get_option ('wff_design_settings');
  1296. $custom_js = ($custom_js_setting['wff_custom_js_data']) ? $custom_js_setting['wff_custom_js_data'] : '' ;
  1297. $custom_js_snippet = isset($custom_js) ? $custom_js : '';
  1298.  
  1299. echo '<script type="text/javascript">';
  1300. if( !empty($custom_js_snippet) ) echo stripslashes($custom_js_snippet);
  1301. echo '</script>';
  1302. }
  1303. }
  1304. // add custom styles
  1305. if(!function_exists('wff_custom_css_code')){
  1306. add_action( 'wp_footer', 'wff_custom_css_code' );
  1307. function wff_custom_css_code() {
  1308. $custom_css_setting = get_option ('wff_design_settings');
  1309. $custom_css = ($custom_css_setting['wff_custom_css_data']) ? $custom_css_setting['wff_custom_css_data'] : '' ;
  1310. $custom_css_snippet = isset($custom_css) ? stripslashes($custom_css) : '';
  1311. echo '<style type="text/css">'.$custom_css_snippet.'</style>';
  1312. }
  1313. }
  1314. // enqueue script for character count
  1315. if(!function_exists('wff_load_custom_scripts')){
  1316. add_action( 'wp_footer', 'wff_load_custom_scripts' );
  1317. function wff_load_custom_scripts() {
  1318. wp_register_script( 'wff_custom_js', plugin_dir_url( __FILE__ ) . 'js/text-count.js',array('jquery'), false, true );
  1319. wp_enqueue_script ('wff_custom_js');
  1320. wp_register_script( 'wff_lightbox_js', plugin_dir_url( __FILE__ ) . 'js/lightbox-2.6.min.js',array('jquery'), false, true );
  1321. wp_enqueue_script ('wff_lightbox_js');
  1322. }
  1323. }
  1324. if(!function_exists('add_my_stylesheet')){
  1325. add_action( 'wp_footer', 'add_my_stylesheet' );
  1326. function add_my_stylesheet() {
  1327. wp_register_style( 'wff-mystyle', plugins_url('css/style.css', __FILE__) );
  1328. wp_enqueue_style( 'wff-mystyle' );
  1329. wp_register_style( 'wff-lightbox_style', plugins_url('css/lightbox.css', __FILE__) );
  1330. wp_enqueue_style( 'wff-lightbox_style' );
  1331. wp_register_style( 'wff-fa-style', plugins_url('font-awesome/css/font-awesome.min.css', __FILE__) );
  1332. wp_enqueue_style( 'wff-fa-style' );
  1333. }
  1334. }
  1335.  
  1336. //default app token
  1337. $design_setting_array = get_option ('wff_design_settings');
  1338. $general_setting_array = get_option ('wff_general_settings');
  1339. $post_type_array = get_option('wff_post_type_settings');
  1340.  
  1341. $all_array =array(
  1342. 'page_id' => get_option('wff_page_id') ? get_option('wff_page_id') : '',
  1343. 'post_limit' => ($general_setting_array['wff_num_posts']) ? $general_setting_array['wff_num_posts'] : '',
  1344. 'cache_time' => ($general_setting_array['wff_cache_time']) ? $general_setting_array['wff_cache_time'] : '',
  1345. 'link_target' => ($general_setting_array['wff_link_target']) ? 1 : 0,
  1346.  
  1347. 'post_type_status' => ($post_type_array['wff_status_type']) ? 1 : 0,
  1348. 'post_type_video' => ($post_type_array['wff_video_type']) ? 1 : 0,
  1349. 'post_type_photo' => ($post_type_array['wff_photo_type']) ? 1 : 0,
  1350. 'post_type_link' => ($post_type_array['wff_link_type']) ? 1 : 0,
  1351. 'post_type_event' => ($post_type_array['wff_event_type']) ? 1 : 0,
  1352.  
  1353. 'author_date_format' => (get_option('wff_author_date')) ? get_option('wff_author_date') : '',
  1354. 'post_layout_type' => ($design_setting_array['wff_layout_type']) ? $design_setting_array['wff_layout_type'] : 'halfwidth',
  1355. 'author_text_size' => ($design_setting_array['wff_author_text_size']) ? $design_setting_array['wff_author_text_size'] : '',
  1356. 'line_height' => ($design_setting_array['wff_line_height']) ? $design_setting_array['wff_line_height'] : '',
  1357. 'author_text_color' => ($design_setting_array['wff_author_text_color']) ? $design_setting_array['wff_author_text_color'] : '',
  1358. 'author_img_border' => ($design_setting_array['wff_img_border']) ? $design_setting_array['wff_img_border'] : '',
  1359. 'feed_seprator' => ($design_setting_array['wff_feed_seprator']) ? $design_setting_array['wff_feed_seprator'] : '',
  1360.  
  1361. 'media_border' => ($design_setting_array['wff_media_border']) ? $design_setting_array['wff_media_border'] : '',
  1362.  
  1363. 'char_limit' => ($design_setting_array['wff_char_limit']) ? $design_setting_array['wff_char_limit'] : '',
  1364. 'post_text_color' => ($design_setting_array['wff_text_color']) ? $design_setting_array['wff_text_color'] : '',
  1365. 'post_background' => ($design_setting_array['wff_post_back_color']) ? $design_setting_array['wff_post_back_color'] : '',
  1366. 'post_text_weight' => ($design_setting_array['wff_text_weight']) ? $design_setting_array['wff_text_weight'] : '',
  1367. 'post_text_size' => ($design_setting_array['wff_text_size']) ? $design_setting_array['wff_text_size'] : '',
  1368. 'post_text_align' => ($design_setting_array['wff_text_align']) ? $design_setting_array['wff_text_align'] : '',
  1369.  
  1370. 'page_link_text' => ($design_setting_array['wff_page_link_text']) ? $design_setting_array['wff_page_link_text'] : '',
  1371. 'read_more' => ($design_setting_array['wff_read_more_text']) ? $design_setting_array['wff_read_more_text'] : '',
  1372. 'read_less' => ($design_setting_array['wff_read_less_text']) ? $design_setting_array['wff_read_less_text'] : '',
  1373. 'share_text' => ($design_setting_array['wff_share_text']) ? $design_setting_array['wff_share_text'] : '',
  1374. );
  1375.  
  1376. $atts = shortcode_atts($all_array,$atts,'facebook-feed');
  1377.  
  1378. extract($atts);
  1379.  
  1380. // Get the Page ID
  1381. if( empty($page_id) )
  1382. {
  1383. $error_message = '<p style = "color:red;" > Please enter valid Facebook Page ID</p>'; // error if a user does not enter page id
  1384. return $error_message ;
  1385. }
  1386.  
  1387. $wff_app_token=array('1505917499687703|2133Lp1cLt6Zk0N2por8X8QJf9k',
  1388. '393872077427061|ghfVBzNUFnMdFLAGlJbWAOVOelI',
  1389. '1377619605888926|LxwTNNAeRtn9nYhYS0VDkVDs0mI'); // We will provide support for user token in future updates
  1390.  
  1391. $access_token = $wff_app_token[rand(0, 2)];
  1392.  
  1393. //initialise facepress object
  1394. //$wff_posts_json_url = 'https://graph.facebook.com/' . $page_id . '/posts?access_token=' . $access_token . '&limit=' . $post_limit;
  1395. $wff_posts_json_url = 'https://graph.facebook.com/' . $page_id . '/posts?fields=id,from,message,message_tags,story,story_tags,link,picture,full_picture,attachments,source,updated_time,name,caption,description,type,status_type,object_id,created_time,shares,comments.limit(0).summary(true),likes.limit(0).summary(true)&access_token=' . $access_token . '&limit=' . $post_limit;
  1396.  
  1397. if($cache_time == 'none') {
  1398.  
  1399. $feeddata = wff_fetchUrl($wff_posts_json_url);
  1400. $feedjson = json_decode($feeddata);
  1401. $fbfeed = $feedjson->data;
  1402. }
  1403. else {
  1404. // this code runs when there is no valid transient set
  1405. if ( false === ($feeddata = get_transient('fb_feed_query'))) {
  1406. $feeddata = wff_fetchUrl($wff_posts_json_url);
  1407. $feeddata = set_transient('fb_feed_query', $feeddata, $cache_time*60);
  1408. $feeddata = get_transient('fb_feed_query');
  1409. }
  1410. $feedjson = json_decode($feeddata);
  1411. $fbfeed = $feedjson->data;
  1412. }
  1413.  
  1414. if( empty($fbfeed) )
  1415. {
  1416. $error_message = '<p style = "color:red;" >'._e('Cannot display feed','facebook-feed-pro').'</p><p style = "color:red;"> '._e('please check if the Facebook page exists or not.','facebook-feed-pro').' </p>'; // To do display message as per the error code
  1417. return $error_message ;
  1418. }
  1419.  
  1420. // Start Building HTML
  1421. $my_final_post_text = '';
  1422. $my_final_post_text_item_wrapper = '';
  1423. $my_final_post_text_item_wrapper_complete = '';
  1424. $my_post_content_text = '';
  1425.  
  1426. foreach ($fbfeed as $singlefeed)
  1427. {
  1428. $my_final_post_text = ''; // this var will hold author data + post text + post desc.. We will wrap this var in item wrapper
  1429.  
  1430. $my_author_text = build_author_html($singlefeed,$atts);
  1431.  
  1432. $what_is_post_type = $singlefeed->type;
  1433.  
  1434. if($what_is_post_type == 'link')
  1435. {
  1436. if($post_type_link==1){
  1437. $my_post_content_text = build_my_link_html ($singlefeed,$atts);
  1438. }
  1439. }
  1440.  
  1441. if ($what_is_post_type == 'photo')
  1442. {
  1443. if($post_type_photo==1){
  1444. $my_post_content_text = build_my_photo_html($singlefeed,$atts);
  1445. }
  1446. }
  1447. if($what_is_post_type == 'video')
  1448. {
  1449. if($post_type_video==1){
  1450. $my_post_content_text = build_my_video_html ($singlefeed,$atts);
  1451. }
  1452. }
  1453.  
  1454. if($what_is_post_type == 'status')
  1455. {
  1456. if($post_type_status==1){
  1457. if (!empty($singlefeed->message))
  1458. {
  1459. $my_post_content_text = build_my_status_html ($singlefeed,$atts);
  1460. }
  1461. }
  1462. // You will cehck if this post has a message. Likes and commnts etc are not to be displayed with the feed
  1463. }
  1464.  
  1465. if ($what_is_post_type == 'event')
  1466. {
  1467. if($post_type_event==1){
  1468. $my_post_content_text = build_my_event_html ($singlefeed,$atts,$access_token);
  1469. }
  1470. }
  1471.  
  1472. //feed seprator inline style
  1473. $wff_feed_seprator_style = 'style="';
  1474. if ( !empty($feed_seprator) && $feed_seprator != 'none' ) $wff_feed_seprator_style .= 'border-bottom:' . $feed_seprator . 'px solid ';
  1475. if ( !empty($author_text_color) ) $wff_feed_seprator_style .= $author_text_color .';';
  1476. $wff_feed_seprator_style .= '"';
  1477.  
  1478. // the final post text
  1479. if($atts['post_layout_type']=='fullwidth')
  1480. {
  1481. $my_final_post_text .= $my_author_text.$my_post_content_text;
  1482. }
  1483. if($atts['post_layout_type']=='halfwidth')
  1484. {
  1485. if($what_is_post_type != 'photo' && $what_is_post_type != 'video' && $what_is_post_type != 'event' ) {
  1486. $my_final_post_text .= $my_author_text.$my_post_content_text;
  1487. }
  1488. else {
  1489. $my_final_post_text .= $my_post_content_text;
  1490. }
  1491. }
  1492. if($atts['post_layout_type']=='thumbnail')
  1493. {
  1494. if($what_is_post_type != 'photo' && $what_is_post_type != 'video' && $what_is_post_type != 'event' ) {
  1495. $my_final_post_text .= $my_author_text.$my_post_content_text;
  1496. }
  1497. else {
  1498. $my_final_post_text .= $my_post_content_text;
  1499. }
  1500. }
  1501.  
  1502. switch ($what_is_post_type) {
  1503.  
  1504. case 'link':
  1505. if($post_type_link==1){
  1506. $my_final_post_text_item_wrapper = '<div '.$wff_feed_seprator_style.' class = "wff-fb-item wff-fb-item-link" id ='.$singlefeed->id.'>'.$my_final_post_text.'</div>';
  1507. $my_final_post_text_item_wrapper_complete .= $my_final_post_text_item_wrapper;
  1508. }
  1509. break;
  1510.  
  1511. case 'status':
  1512. if($post_type_status==1){
  1513. $my_final_post_text_item_wrapper = '<div '.$wff_feed_seprator_style.' class = "wff-fb-item wff-fb-item-status" id ='.$singlefeed->id.' >'.$my_final_post_text.'</div>';
  1514. $my_final_post_text_item_wrapper_complete .= $my_final_post_text_item_wrapper;
  1515. }
  1516. break;
  1517.  
  1518. case 'event':
  1519. if($post_type_event==1){
  1520. $my_final_post_text_item_wrapper = '<div '.$wff_feed_seprator_style.' class = "wff-fb-item wff-fb-item-event" id ='.$singlefeed->id.'>'.$my_final_post_text.'</div>';
  1521. $my_final_post_text_item_wrapper_complete .= $my_final_post_text_item_wrapper;
  1522. }
  1523. break;
  1524.  
  1525. case 'video':
  1526. if($post_type_video==1){
  1527. $my_final_post_text_item_wrapper = '<div '.$wff_feed_seprator_style.' class = "wff-fb-item wff-fb-item-video" id ='.$singlefeed->id.'>'.$my_final_post_text.'</div>';
  1528. $my_final_post_text_item_wrapper_complete .= $my_final_post_text_item_wrapper;
  1529. }
  1530. break;
  1531.  
  1532. case 'photo':
  1533. if($post_type_photo==1){
  1534. $my_final_post_text_item_wrapper = '<div '.$wff_feed_seprator_style.' class = "wff-fb-item wff-fb-item-photo" id ='.$singlefeed->id.'>'.$my_final_post_text.'</div>';
  1535. $my_final_post_text_item_wrapper_complete .= $my_final_post_text_item_wrapper;
  1536. }
  1537. break;
  1538.  
  1539. }
  1540. }
  1541. $my_final_post_text = '<div class = "wff-feed-wrapper"><div id = "wff-id">'.$my_final_post_text_item_wrapper_complete.'</div></div>'; // Add a feed wrapper to the complete feed html
  1542.  
  1543. // Return the complete html
  1544. return $my_final_post_text;
  1545. }
  1546. ?>
RAW Paste Data