FacebookFanpageImportShowdataShortcodes

The Facebook Fanpage Import FacebookFanpageImportShowdataShortcodes class.

Defined (1)

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

/components/showdata/shortcodes.php  
  1. class FacebookFanpageImportShowdataShortcodes{ 
  2. var $name; 
  3.  
  4. /** 
  5. * Initializes the Component. 
  6. * @since 1.0.0 
  7. */ 
  8. function __construct() { 
  9. $this->name = get_class( $this ); 
  10.  
  11. add_shortcode( 'fanpagestream', array( $this, 'show_stream' ) ); 
  12. } // end constructor 
  13.  
  14. public function show_stream( $atts ) { 
  15. global $paged, $wp_query; 
  16.  
  17. extract( shortcode_atts( array( 
  18. 'entries' => (int) get_option( 'posts_per_page' ),  
  19. ), $atts ) ); 
  20.  
  21. $args = array( 
  22. 'posts_per_page' => $entries,  
  23. 'orderby' => 'post_date',  
  24. 'post_type' => 'fanpage-entries',  
  25. 'paged' => fbfpi_get_url_var( 'page' ) 
  26. ); 
  27.  
  28. $wp_query = new WP_Query( $args ); 
  29.  
  30. $paged_old = $paged; 
  31. $paged = ( get_query_var('paged')) ? get_query_var('paged') : 1; 
  32.  
  33. $content = '<div class="fbfpi_stream">'; 
  34. if ($wp_query->have_posts()) :  
  35. while ( $wp_query->have_posts() ) : 
  36. $wp_query->the_post(); 
  37.  
  38. // setup_postdata( $post ); 
  39. $post_id = $wp_query->post->ID; 
  40.  
  41. $fanpage_id = get_post_meta( $post_id, 'fanpage_id', TRUE ); 
  42. $fanpage_name = get_post_meta( $post_id, 'fanpage_name', TRUE ); 
  43. $fanpage_link = get_post_meta( $post_id, 'fanpage_link', TRUE ); 
  44.  
  45. $id = get_post_meta( $post_id, 'post_id', TRUE ); 
  46. $entry_id = get_post_meta( $post_id, 'entry_id', TRUE ); 
  47. $message = nl2br( get_post_meta( $post_id, 'message', TRUE ) ); 
  48. $description = get_post_meta( $post_id, 'description', TRUE ); 
  49. $permalink = get_post_meta( $post_id, 'permalink', TRUE ); 
  50. $type = get_post_meta( $post_id, 'type', TRUE ); 
  51.  
  52. $link_target = skip_value( 'fbfpi_settings', 'link_target' ); 
  53.  
  54. switch ( $type ) { 
  55. case 'link': 
  56. $action = sprintf( __( '<a href="%s" target="%s">%s</a> shared a link.', 'fbfpi' ), $fanpage_link, $link_target, $fanpage_name ); 
  57. break; 
  58. case 'photo': 
  59. $action = sprintf( __( '<a href="%s" target="%s">%s</a> shared a photo.', 'fbfpi' ), $fanpage_link, $link_target, $fanpage_name ); 
  60. break; 
  61. default: 
  62. if( '' != $description ) $action = $description; 
  63. else $action = sprintf( __( '<a href="%s" target="%s">%s</a> shared a status.', 'fbfpi' ), $fanpage_link, $link_target, $fanpage_name ); 
  64. break; 
  65.  
  66. $has_attachment = get_post_meta( $post_id, 'has_attachment', TRUE ); 
  67.  
  68. /** 
  69. * Writing Entry 
  70. */ 
  71. $content.= '<div class="fbfpi_entry">'; 
  72.  
  73. if( $message ) $content.= '<p>' . $message . '</p>'; 
  74. else $content.= '<p>' . $action . '</p>'; 
  75.  
  76. // attachment Data  
  77. if( $has_attachment ): 
  78.  
  79. $picture = ''; 
  80.  
  81. $attachment_name = get_post_meta( $post_id, 'attachment_name', TRUE ); 
  82. $attachment_description = nl2br( substr( get_post_meta( $post_id, 'attachment_description', TRUE ), 0, 200 ) ); 
  83. $attachment_caption = get_post_meta( $post_id, 'attachment_caption', TRUE ); 
  84. $attachment_href = get_post_meta( $post_id, 'attachment_href', TRUE ); 
  85. $attachment_src = get_post_meta( $post_id, 'attachment_src', TRUE ); 
  86.  
  87. if( 'event' == $type ): 
  88. $start_time = get_post_meta( $post_id, 'attachment_start_time', TRUE ); 
  89. $location = get_post_meta( $post_id, 'attachment_location', TRUE ); 
  90. $attachment_caption = sprintf( __( 'Start %s %s.', 'fbfpi' ), date_i18n( get_option( 'date_format' ), strtotime( $start_time ) ), date_i18n( get_option( 'time_format' ), strtotime( $start_time ) ) ); 
  91. $attachment_caption.= '<br />' . $location; 
  92. endif; 
  93.  
  94. if( is_array( $attachment_src ) ) 
  95. $attachment_src = $attachment_src[ 0 ]; 
  96.  
  97. echo '<pre>'; 
  98. print_r( $attachment_src ); 
  99. echo '</pre>'; 
  100.  
  101. echo '<img src="' . $attachment_src . '">'; 
  102.  
  103. $attachment_suffix = strtolower( substr( $attachment_src, strlen( $attachment_src ) - 3, strlen( $attachment_src ) ) ); 
  104.  
  105. if( 'jpg' == $attachment_suffix || 'gif' == $attachment_suffix || 'png' == $attachment_suffix ): 
  106. $picture = str_replace( '_s.' . $attachment_suffix, '_n.' . $attachment_suffix, $attachment_src ); 
  107. endif; 
  108.  
  109. $content.= '<div class="fbfpi_content">'; 
  110.  
  111. // Picture 
  112. if( $picture ): 
  113. if( '' != $attachment_name || '' != $attachment_description ) 
  114. $content.= '<div class="fbfpi_content_picture fbfpi_content_picture_small">'; 
  115. else 
  116. $content.= '<div class="fbfpi_content_picture fbfpi_content_picture_fullsize">'; 
  117.  
  118. if( $permalink ) 
  119. $content.= '<a href="' . $permalink . '" class="fbfp_picture" target="' . $link_target . '"><img src="' . $picture . '" /></a>'; 
  120. else 
  121. $content.= '<img src="' . $picture . '" />'; 
  122.  
  123. $content.= '</div>'; 
  124.  
  125. endif;  
  126.  
  127. if( '' != $attachment_name || '' != $attachment_description ): 
  128. // Content 
  129. $content.= '<div class="fbfpi_content_text fbfpi_link_content_text">'; 
  130.  
  131. if( $attachment_href && '' != $attachment_name ) 
  132. $content.= '<h4><a href="' . $permalink . '" title="' . sprintf( __( 'Link to: %s', 'fbfpi' ), $attachment_name ) .'" target="' . $link_target . '">' . $attachment_name . '</a></h4>'; 
  133. elseif( '' != $attachment_name ) 
  134. $content.= '<h4>' . $attachment_name . '</h4>'; 
  135.  
  136. if( '' != $attachment_description ) 
  137. $content.= '<p>' . $attachment_description . ' ...</p>';# 
  138.  
  139. if( '' != $attachment_caption && $attachment_href && '' != $attachment_name ) 
  140. $content.= '<small><a href="' . $permalink . '" title="' . sprintf( __( 'Link to: %s', 'fbfpi' ), $attachment_name ) .'" target="' . $link_target . '">' . $attachment_caption . '</a></small>'; 
  141. elseif ( '' != $attachment_caption ) 
  142. $content.= '<small>' . $attachment_caption . '</small>'; 
  143.  
  144. $content.= '</div>'; 
  145. endif; 
  146.  
  147. $content.= '<div class="fbfpi_clear"></div>'; 
  148. $content.= '</div>'; 
  149.  
  150. endif; 
  151.  
  152. $content.= '<div class="fbfpi_clear"></div>'; 
  153. $content.= '</div>'; 
  154.  
  155. endwhile; 
  156.  
  157.  
  158. $content.= '<div id="nav-below" class="navigation">'; 
  159. $content.= '<div class="nav-previous">' . get_next_posts_link( __( '<span class="meta-nav">←</span>Older entries', 'fbfpi' ) ) . '</div>'; 
  160. $content.= '<div class="nav-next">' . get_previous_posts_link( __( 'Newer entries <span class="meta-nav">→</span>', 'fbfpi' ) ) . '</div>'; 
  161. $content.= '<div class="fbfpi_clear"></div></div>'; 
  162.  
  163. $content.= '</div>'; 
  164.  
  165. endif; 
  166. $paged = $paged_old; 
  167. wp_reset_query(); 
  168.  
  169. return $content;