build_my_status_html

The Facebook Feed build my status html function.

Description

build_my_status_html( $mysinglefeed, $atts ); 

Parameters (2)

0. $mysinglefeed
The mysinglefeed.
1. $atts
The atts.

Usage

  1. if ( !function_exists( 'build_my_status_html' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'facebook-feed/facebook-feed-shortcode.php'; 
  3.  
  4. // The mysinglefeed. 
  5. $mysinglefeed = null; 
  6.  
  7. // The atts. 
  8. $atts = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = build_my_status_html($mysinglefeed, $atts); 
  12.  

Defined (1)

The function is defined in the following location(s).

/facebook-feed-shortcode.php  
  1. function build_my_status_html ($mysinglefeed , $atts) 
  2. // every where we will check if there is no message..  
  3. //A stroy description will be used only when there is no message  
  4.  
  5. if (isset($mysinglefeed->story)) 
  6. // if story exists then use the story in the post text 
  7.  
  8. $my_post_text = $mysinglefeed->story;  
  9.  
  10. if (array_key_exists('story_tags', $mysinglefeed )) 
  11. // now add the hyperlink to tags  
  12. foreach ( $mysinglefeed->story_tags as $mystorytag) 
  13. {  
  14. $mystorytagname = $mystorytag[0]->name; 
  15. if($atts['link_target']==1) {  
  16. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" target="_blank">' . $mystorytag[0]->name . '</a>'; 
  17. } else { 
  18. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" >' . $mystorytag[0]->name . '</a>'; 
  19. $my_post_text = str_replace($mystorytagname, $tag_link, $my_post_text); 
  20. }  
  21.  
  22. if (isset($mysinglefeed->message)) 
  23. // if story exists then use the story in the post text 
  24. $my_post_text = $mysinglefeed->message;  
  25. $my_post_text = makeLinks($my_post_text, $atts['link_target']); 
  26. 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)) { 
  27. $my_post_text = make_hash_link ($my_post_text, $atts['link_target']); 
  28. // Build Post description  
  29. // first hyper link the name 
  30.  
  31. $name_var = (isset($mysinglefeed->name) ? $mysinglefeed->name : ''); 
  32. $name_url = (isset($mysinglefeed->link) ? $mysinglefeed->link : ''); 
  33.  
  34. $link_post_desc = (isset($mysinglefeed->description) ? $mysinglefeed->description : ''); 
  35. $link_post_desc = makeLinks($link_post_desc, $atts['link_target']); 
  36. 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)) { 
  37. $link_post_desc = make_hash_link($link_post_desc, $atts['link_target']); 
  38. if (array_key_exists('message_tags', $mysinglefeed )) 
  39. // now add the hyperlink to tags  
  40. foreach ( $mysinglefeed->message_tags as $mymessagetag) 
  41. {  
  42. $mymessagetagname = $mymessagetag[0]->name;  
  43. if($atts['link_target']==1) {  
  44. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag[0]->id . '" style="color: red;" target="_blank">' . $mymessagetag[0]->name . '</a>'; 
  45. } else { 
  46. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag[0]->id . '" style="color: red;" >' . $mymessagetag[0]->name . '</a>'; 
  47. $my_post_text = str_replace($mymessagetagname, $tag_link, $my_post_text); 
  48. }  
  49. $the_resource_id_array = explode("_", $mysinglefeed->id); 
  50. $the_resource_id = $the_resource_id_array[1]; 
  51. $post_resource_link = 'https://facebook.com/'.$atts['page_id'] .'/posts/'.$the_resource_id;  
  52.  
  53. //call post text inline style 
  54. $limited_style_wrapper = limited_post_text_inline_style($atts); 
  55. $full_style_wrapper = full_post_text_inline_style($atts); 
  56. $line_height_style = feed_line_height($atts); 
  57. /**---------------------read more text---------------------------*/ 
  58.  
  59. $str_without_tag = strip_tags($my_post_text); 
  60. $char_count = strlen($str_without_tag); 
  61.  
  62. if((!empty($atts['char_limit'])) && ($atts['char_limit'] < $char_count) ) 
  63. $short_sentence = substr($str_without_tag, 0, $atts['char_limit']); 
  64.  
  65. $short_sentence = makeLinks ($short_sentence, $atts['link_target']); // link the urls 
  66. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2, 3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/', $short_sentence)) { 
  67. $short_sentence = make_hash_link ($short_sentence, $atts['link_target']); 
  68. if (array_key_exists('story_tags', $mysinglefeed )) 
  69. foreach ( $mysinglefeed->story_tags as $mystorytag) 
  70. {  
  71. $mystorytagname = $mystorytag[0]->name;  
  72. if($atts['link_target']==1) { 
  73. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" target="_blank">' . $mystorytag[0]->name . '</a>'; 
  74. } else { 
  75. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" >' . $mystorytag[0]->name . '</a>'; 
  76. $short_sentence = str_replace($mystorytagname, $tag_link, $short_sentence); 
  77. }  
  78.  
  79. if (array_key_exists('message_tags', $mysinglefeed )) 
  80. foreach( $mysinglefeed->message_tags as $mymessagetag)// now add the hyperlink to tags  
  81. {  
  82. $mymessagetagname = $mymessagetag[0]->name;  
  83. if($atts['link_target']==1) { 
  84. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag[0]->id . '" style="color: red;" target="_blank">' . $mymessagetag[0]->name . '</a>'; 
  85. } else { 
  86. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag[0]->id . '" style="color: red;" >' . $mymessagetag[0]->name . '</a>'; 
  87. $short_sentence = str_replace($mymessagetagname, $tag_link, $short_sentence); 
  88. $mytext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$short_sentence.'...<span><a class="wff-more-link">'.$atts['read_more'].'</a></span></p>';  
  89. $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>'; 
  90. }  
  91. else{ 
  92. $mytext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$my_post_text.'</p>'; 
  93. /**------------------------------------------------*/ 
  94. if(isset($mysinglefeed->description)) { 
  95. if($atts['link_target']==1) {  
  96. $build_link_title = '<p class = "link-title" '.$line_height_style.'><a class="wff-link-tab" target="_blank" href =' .$name_url.'>'.$name_var.'</a></p>';  
  97. } else { 
  98. $build_link_title = '<p class = "link-title" '.$line_height_style.'><a class="wff-link-tab" href =' .$name_url.'>'.$name_var.'</a></p>';  
  99. $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>'; 
  100.  
  101. if($atts['link_target']==1) { 
  102. $mytext .= '<div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a></div>'; 
  103. } else { 
  104. $mytext .= '<div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a></div>'; 
  105. }  
  106. return $mytext;