build_my_event_html

The Facebook Feed build my event html function.

Description

build_my_event_html( $mysinglefeed, $atts, $myaccesstoken ); 

Parameters (3)

0. $mysinglefeed
The mysinglefeed.
1. $atts
The atts.
2. $myaccesstoken
The myaccesstoken.

Usage

  1. if ( !function_exists( 'build_my_event_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. // The myaccesstoken. 
  11. $myaccesstoken = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = build_my_event_html($mysinglefeed, $atts, $myaccesstoken); 
  15.  

Defined (1)

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

/facebook-feed-shortcode.php  
  1. function build_my_event_html ($mysinglefeed , $atts, $myaccesstoken) 
  2.  
  3. $theurl = parse_url($mysinglefeed->link); 
  4. $urlpart = explode('/', $theurl['path']); 
  5.  
  6. $the_event_id = $urlpart[2]; 
  7.  
  8. //now get the event json 
  9. $event_url_json = 'https://graph.facebook.com/' . $the_event_id . '?access_token=' . $myaccesstoken ; 
  10.  
  11. $event_json_data = wff_fetchUrl($event_url_json); 
  12. $event_data = json_decode($event_json_data) ;  
  13.  
  14. //get event start date 
  15. $event_start_date = $event_data->start_time; 
  16. $str_format = strtotime($event_start_date);  
  17.  
  18. //condition for date format 
  19. if($atts['author_date_format']=='default') { 
  20. $event_date_print = date('F d, Y', $str_format); 
  21. else{ 
  22. $system_date_format = $atts['author_date_format']; 
  23. $event_date_print = date($system_date_format, $str_format);  
  24.  
  25. //We will build the date string. Check if an end time is specified 
  26. if (isset($event_data->end_time)) 
  27. // get event end date 
  28. $event_end_date = $event_data->end_time; 
  29. $str_format = strtotime($event_end_date); 
  30.  
  31. if($atts['author_date_format']=='default') { 
  32. $event_end_date_print = date('F d, Y', $str_format); 
  33. else{ 
  34. $system_date_format = $atts['author_date_format']; 
  35. $event_end_date_print = date($system_date_format, $str_format); 
  36.  
  37.  
  38. $event_date_print .= " - ". $event_end_date_print;  
  39.  
  40. if (isset($mysinglefeed->story)) 
  41. // if story exists then use the story in the post text 
  42. $my_post_text = $mysinglefeed->story;  
  43.  
  44. if (array_key_exists('story_tags', $mysinglefeed )) 
  45. // now add the hyperlink to tags  
  46. foreach ( $mysinglefeed->story_tags as $mystorytag) 
  47. {  
  48. $mystorytagname = $mystorytag[0]->name;  
  49. if($atts['link_target']==1) {  
  50. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" target="_blank">' . $mystorytag[0]->name . '</a>'; 
  51. } else { 
  52. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" >' . $mystorytag[0]->name . '</a>'; 
  53. $my_post_text = str_replace($mystorytagname, $tag_link, $my_post_text); 
  54. }  
  55.  
  56. if (isset($mysinglefeed->message)) 
  57. // if story exists then use the story in the post text 
  58. $my_post_text = $mysinglefeed->message;  
  59. $my_post_text = makeLinks($my_post_text, $atts['link_target']); 
  60. 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)) { 
  61. $my_post_text = make_hash_link($my_post_text, $atts['link_target']); 
  62.  
  63. //call post text inline style 
  64. $limited_style_wrapper = limited_post_text_inline_style($atts); 
  65. $full_style_wrapper = full_post_text_inline_style($atts); 
  66. $line_height_style = feed_line_height($atts);  
  67. /**---------------------read more text---------------------------*/ 
  68.  
  69. $str_without_tag = strip_tags($my_post_text); 
  70. $char_count = strlen($str_without_tag); 
  71.  
  72. if((!empty($atts['char_limit'])) && ($atts['char_limit'] < $char_count) ) 
  73. $short_sentence = substr($str_without_tag, 0, $atts['char_limit']); 
  74.  
  75. $short_sentence = makeLinks ($short_sentence, $atts['link_target']); // link the urls 
  76. if(!preg_match('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2, 3}(\/\S*)?)#(\w*[a-zA-Z_]+\w*)/', $short_sentence)) { 
  77. $short_sentence = make_hash_link ($short_sentence, $atts['link_target']); 
  78. if (array_key_exists('story_tags', $mysinglefeed)) { 
  79. // now add the hyperlink to tags  
  80. foreach ( $mysinglefeed->story_tags as $mystorytag) 
  81. {  
  82. $mystorytagname = $mystorytag[0]->name; 
  83. if($atts['link_target']==1) {  
  84. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" target="_blank">' . $mystorytag[0]->name . '</a>'; 
  85. } else { 
  86. $tag_link = '<a class="wff-link-tab" href="http://facebook.com/' . $mystorytag[0]->id . '" style="color: indigo;" >' . $mystorytag[0]->name . '</a>'; 
  87. $short_sentence = str_replace($mystorytagname, $tag_link, $short_sentence); 
  88. }  
  89.  
  90. $finaltext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$short_sentence.'...<span><a class="wff-more-link">'.$atts['read_more'].'</a></span></p>';  
  91. $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>'; 
  92. }  
  93. else { 
  94. $finaltext = '<p class = "wff-post-text" '.$limited_style_wrapper.'>'.$my_post_text.'</p>'; 
  95. /**------------------------------------------------*/  
  96. $post_resource_link = $mysinglefeed->link; 
  97. $event_title = $event_data->name; 
  98. $event_description = $event_data->description; 
  99. //$event_location = $event_data->location; 
  100. $finaltext .= '<div class = "wff-fb-item-event-wrapper">'; 
  101. $finaltext .= '<div class = "fb-text-wrapper">';  
  102. $finaltext .= '<div class = "fb-post-data description-wrapper">'; 
  103. if($atts['link_target']==1) { 
  104. $finaltext .= '<p class="wff-event-title" '.$line_height_style.'><a class="wff-link-tab" href = '.$post_resource_link. ' target = "_blank">'.$event_title.'</a></p>'; 
  105. } else { 
  106. $finaltext .= '<p class="wff-event-title" '.$line_height_style.'><a class="wff-link-tab" href = '.$post_resource_link. ' >'.$event_title.'</a></p>'; 
  107. $finaltext .= '<p class="wff-event-content" '.$line_height_style.'>'.$event_description.'</p>';// close post data div  
  108. $finaltext .= '<div class = "event-date">'.$event_date_print.'</div></div>' ; // the date div  
  109. if($atts['link_target']==1) { 
  110. $finaltext .= '<div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '.$post_resource_link. ' target = "_blank">'.$atts['page_link_text'].'</a></div>';  
  111. } else { 
  112. $finaltext .= '<div class = "wff-view-on-facebook"><a class="wff-link-tab" href = '.$post_resource_link.' >'.$atts['page_link_text'].'</a></div>'; 
  113. $finaltext .= '</div></div>'; // close text wrapper and event wrapper 
  114.  
  115. return $finaltext ;