build_my_photo_html

The Facebook Feed build my photo html function.

Description

build_my_photo_html( $mysinglefeed, $atts ); 

Parameters (2)

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

Usage

  1. if ( !function_exists( 'build_my_photo_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_photo_html($mysinglefeed, $atts); 
  12.  

Defined (1)

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

/facebook-feed-shortcode.php  
  1. function build_my_photo_html ($mysinglefeed, $atts) 
  2. if (isset($mysinglefeed->story)) 
  3. // if story exists then use the story in the post text 
  4. $my_post_photo_text = $mysinglefeed->story;  
  5. // we also need to handle story tags 
  6. if (array_key_exists('story_tags', $mysinglefeed )) 
  7. // now add the hyperlink to tags  
  8. foreach ( $mysinglefeed->story_tags as $mystorytag) 
  9. {  
  10. $mystorytagname = $mystorytag[0]->name;  
  11. if($atts['link_target']==1) { 
  12. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" target="_blank">' . $mystorytag[0]->name . '</a>'; 
  13. } else { 
  14. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" >' . $mystorytag[0]->name . '</a>'; 
  15. $my_post_photo_text = str_replace($mystorytagname, $tag_link, $my_post_photo_text); 
  16. }  
  17.  
  18. if (isset($mysinglefeed->message) && !empty($mysinglefeed->message)) 
  19. // if story exists then use the story in the post text 
  20. $my_post_photo_text = $mysinglefeed->message;  
  21.  
  22. $my_post_photo_text = makeLinks ($my_post_photo_text, $atts['link_target']); // link the urls 
  23.  
  24. 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)) { 
  25. $my_post_photo_text = make_hash_link ($my_post_photo_text, $atts['link_target']);  
  26.  
  27.  
  28. // If if there are message tags  
  29. $resourceid = $mysinglefeed->object_id; 
  30. if (array_key_exists('message_tags', $mysinglefeed )) 
  31. // now add the hyperlink to tags  
  32. foreach ( $mysinglefeed->message_tags as $mymessagetag) 
  33. {  
  34. $mymessagetagname = $mymessagetag[0]->name;  
  35. if($atts['link_target']==1) {  
  36. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag[0]->id . '" style="color: red;" target="_blank">' . $mymessagetag[0]->name . '</a>'; 
  37. } else { 
  38. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag[0]->id . '" style="color: red;" >' . $mymessagetag[0]->name . '</a>'; 
  39. $my_post_photo_text = str_replace($mymessagetagname, $tag_link, $my_post_photo_text); 
  40. }  
  41.  
  42. //call post text inline style 
  43. $limited_style_wrapper = limited_post_text_inline_style($atts); 
  44. $full_style_wrapper = full_post_text_inline_style($atts); 
  45. $line_height_style = feed_line_height($atts); 
  46. /**---------------------read more text---------------------------*/ 
  47. $str_without_tag = strip_tags($my_post_photo_text); 
  48. $char_count = strlen($str_without_tag); 
  49.  
  50. if((!empty($atts['char_limit'])) && ($atts['char_limit'] < $char_count) ) 
  51. $short_sentence = substr($str_without_tag, 0, $atts['char_limit']); 
  52.  
  53. $short_sentence = makeLinks ($short_sentence, $atts['link_target']); //link the urls 
  54. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2, 3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/', $short_sentence)) { 
  55. $short_sentence = make_hash_link ($short_sentence, $atts['link_target']); 
  56. if (array_key_exists('story_tags', $mysinglefeed )) 
  57. foreach ( $mysinglefeed->story_tags as $mystorytag) 
  58. {  
  59. $mystorytagname = $mystorytag[0]->name; 
  60. if($atts['link_target']==1) {  
  61. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" target="_blank">' . $mystorytag[0]->name . '</a>'; 
  62. } else { 
  63. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" >' . $mystorytag[0]->name . '</a>'; 
  64. $short_sentence = str_replace($mystorytagname, $tag_link, $short_sentence); 
  65. }  
  66. if (array_key_exists('message_tags', $mysinglefeed )) 
  67. foreach( $mysinglefeed->message_tags as $mymessagetag)// now add the hyperlink to tags  
  68. {  
  69. $mymessagetagname = $mymessagetag[0]->name;  
  70. if($atts['link_target']==1) { 
  71. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag[0]->id . '" style="color: red;" target="_blank">' . $mymessagetag[0]->name . '</a>'; 
  72. } else { 
  73. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mymessagetag[0]->id . '" style="color: red;" >' . $mymessagetag[0]->name . '</a>'; 
  74. $short_sentence = str_replace($mymessagetagname, $tag_link, $short_sentence); 
  75. }  
  76. $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>';  
  77. $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>'; 
  78. }  
  79. else{ 
  80. $build_photo_html = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$my_post_photo_text.'</p>'; 
  81. /**-----------------------------------------------*/ 
  82.  
  83. $the_resource_id = $mysinglefeed->object_id; 
  84. $post_resource_link = 'https://facebook.com/'.$the_resource_id;  
  85.  
  86. // Now build The post description  
  87. if (isset($mysinglefeed->name)) 
  88. $name_var = $mysinglefeed->name; 
  89. $name_url = $mysinglefeed->link; 
  90.  
  91. if (isset($mysinglefeed->description)) 
  92.  
  93. $link_post_desc = $mysinglefeed->description; 
  94. $link_post_desc = makeLinks($link_post_desc, $atts['link_target']); 
  95. 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)) { 
  96. $link_post_desc = make_hash_link($link_post_desc, $atts['link_target']); 
  97. else { 
  98. $link_post_desc= ""; 
  99.  
  100. }  
  101. // now I will include inline style rules while building the HTML. They can be passed via shortcode attributes 
  102. $build_post_desc_html = ''; 
  103. if(isset($mysinglefeed->description)) { 
  104. if($atts['link_target']==1) {  
  105. $build_link_title = '<p class = "link-title" '.$line_height_style.'><a class="wff-link-tab" target="_blank" href =' .$name_url.'>'.$name_var.' </a></p>';  
  106. } else { 
  107. $build_link_title = '<p class = "link-title" '.$line_height_style.'><a class="wff-link-tab" href =' .$name_url.'>'.$name_var.'</a></p>'; 
  108.  
  109. $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>'.$build_post_desc_html; 
  110. }  
  111. $build_photo_html .= $build_post_desc_html; 
  112.  
  113. if($atts['link_target']==1) { 
  114. $build_photo_html .= '<div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' target = "_blank">'.$atts['page_link_text'].'</a></div>';  
  115. } else { 
  116. $build_photo_html .= '<div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '. $post_resource_link.' >'.$atts['page_link_text'].'</a></div>';  
  117. return $build_photo_html;