Advertisement
Guest User

Activity loop

a guest
Sep 23rd, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. <?php
  2.  
  3. if ( ! function_exists( 'gp_activity' ) ) {
  4. function gp_activity($atts, $content = null) {
  5. extract(shortcode_atts(array(
  6. 'header' => 'Latest Activity',
  7. 'scope' => '',
  8. 'per_page' => '5',
  9. 'comments' => 'threaded',
  10. 'allow_comments' => 'false',
  11. 'order' => 'desc',
  12. 'pagination' => 'true',
  13. 'max' => '',
  14. 'user_id' => '',
  15. ), $atts));
  16.  
  17. ob_start(); ?>
  18.  
  19. <?php if(function_exists('bp_is_active') && bp_is_active('activity')) { ?>
  20.  
  21. <?php if($header) { ?><h3 class="post-header"><?php echo $header; ?></h3><?php } ?>
  22.  
  23. <div class="bp-wrapper gp-activity-stream activity post-wrapper<?php if($allow_comments == "true") { ?> gp-allow-comments<?php } ?>">
  24.  
  25. <?php
  26.  
  27. do_action( 'bp_before_activity_loop' ); ?>
  28.  
  29. <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . "scope=$scope&per_page=$per_page&display_comments=$comments&sort=$order&max=$max&user_id=$user_id&count_total=count_query" ) ) : ?>
  30.  
  31. <?php if ( empty( $_POST['page'] ) ) : ?>
  32.  
  33. <ul id="activity-stream" class="activity-list item-list">
  34.  
  35. <?php endif; ?>
  36.  
  37. <?php while ( bp_activities() ) : bp_the_activity(); ?>
  38.  
  39. <?php bp_get_template_part( 'activity/entry' ); ?>
  40.  
  41. <?php endwhile; ?>
  42.  
  43. <?php if ( bp_activity_has_more_items() ) : ?>
  44.  
  45. <li class="load-more">
  46. <a href="<?php bp_activity_load_more_link() ?>"><?php _e( 'Load More', 'buddypress' ); ?></a>
  47. </li>
  48.  
  49. <?php endif; ?>
  50.  
  51. <?php if ( empty( $_POST['page'] ) ) : ?>
  52.  
  53. </ul>
  54.  
  55. <?php endif; ?>
  56.  
  57. <?php if($pagination == 'true') : ?>
  58.  
  59. <div class="wp-pagenavi cat-navi">
  60. <div class="pages"><?php bp_activity_pagination_count(); ?></div>
  61. <div class="pagination-links"><?php bp_activity_pagination_links(); ?></div>
  62. </div>
  63.  
  64. <?php endif; ?>
  65.  
  66. <?php else : ?>
  67.  
  68. <div id="message" class="info">
  69. <p><?php _e( 'Sorry, there was no activity found. Please try a different filter.', 'buddypress' ); ?></p>
  70. </div>
  71.  
  72. <?php endif; ?>
  73.  
  74. <?php do_action( 'bp_after_activity_loop' ); ?>
  75.  
  76. <?php if ( empty( $_POST['page'] ) ) : ?>
  77.  
  78. <form action="" name="activity-loop-form" id="activity-loop-form" method="post">
  79.  
  80. <?php wp_nonce_field( 'activity_filter', '_wpnonce_activity_filter' ); ?>
  81.  
  82. </form>
  83.  
  84. <?php endif; ?>
  85.  
  86. </div>
  87.  
  88. <?php } ?>
  89.  
  90. <?php
  91.  
  92. $output_string = ob_get_contents();
  93. ob_end_clean();
  94.  
  95. return $output_string;
  96.  
  97. }
  98. }
  99. add_shortcode("activity", "gp_activity");
  100.  
  101. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement