Advertisement
Guest User

add bp activity plus links to whats-new-form?

a guest
Jul 10th, 2014
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. <?php
  2. /**
  3. * Plugin Name: BuddyPress Activity Shortcode
  4. * Author: Brajesh Singh(BuddyDev)
  5. * Plugin URI: http://buddydev.com/plugins/bp-activity-shortcode/
  6. * Author URI: http://buddydev.com/members/sbrajesh/
  7. * Version: 1.0.2
  8. * License: GPL
  9. */
  10. class BD_Activity_Stream_Shortcodes_Helper{
  11.  
  12. private static $instance;
  13.  
  14. private function __construct() {
  15.  
  16. //register shortcodes
  17. $this->register_shortcodes();
  18.  
  19. }
  20.  
  21. /**
  22. * Register shortcodes
  23. *
  24. */
  25. private function register_shortcodes() {
  26. //[activity-stream display_comments=threaded|none title=somethimg per_page=something]
  27.  
  28. add_shortcode( 'activity-stream', array( $this, 'generate_activity_stream' ) );
  29.  
  30.  
  31.  
  32. }
  33. /**
  34. * Get Instance
  35. *
  36. *
  37. * @return BD_Activity_Stream_Shortcodes_Helper
  38. */
  39. public static function get_instance() {
  40.  
  41. if ( !isset( self::$instance ) )
  42. self::$instance = new self();
  43.  
  44. return self::$instance;
  45. }
  46.  
  47.  
  48.  
  49. public function generate_activity_stream( $atts, $content = null ) {
  50. //allow to use all those args awesome!
  51. $atts=shortcode_atts(array(
  52. 'title' => 'Latest Activity',//title of the section
  53. 'pagination' => 'true',//show or not
  54. 'display_comments' => 'threaded',
  55. 'include' => false, // pass an activity_id or string of IDs comma-separated
  56. 'exclude' => false, // pass an activity_id or string of IDs comma-separated
  57. 'in' => false, // comma-separated list or array of activity IDs among which to search
  58. 'sort' => 'DESC', // sort DESC or ASC
  59. 'page' => 1, // which page to load
  60. 'per_page' => 5, //how many per page
  61. 'max' => false, // max number to return
  62.  
  63. // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
  64. 'scope' => false,
  65.  
  66. // Filtering
  67. 'user_id' => false, // user_id to filter on
  68. 'object' => false, // object to filter on e.g. groups, profile, status, friends
  69. 'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated
  70. 'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
  71. 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
  72.  
  73. // Searching
  74. 'search_terms' => false, // specify terms to search on
  75. 'use_compat' => bp_use_theme_compat_with_current_theme()
  76. ), $atts );
  77.  
  78. extract( $atts );
  79.  
  80.  
  81.  
  82. ob_start(); ?>
  83.  
  84. <?php if ( is_user_logged_in() ) : ?>
  85. <?php include_once( WP_PLUGIN_DIR.'/buddypress/bp-templates/bp-legacy/buddypress/activity/post-form.php'); ?>
  86. <?php endif; ?><br />
  87. <?php if( $use_compat):?>
  88. <div id="buddypress">
  89. <?php endif;?>
  90.  
  91. <?php if($title): ?>
  92. <h3 class="activity-shortcode-title"><?php echo $title; ?></h3>
  93. <?php endif;?>
  94.  
  95. <?php do_action( 'bp_before_activity_loop' ); ?>
  96.  
  97. <?php if ( bp_has_activities($atts) ) : ?>
  98. <div class="activity <?php if(!$display_comments): ?> hide-activity-comments<?php endif; ?> shortcode-activity-stream">
  99.  
  100. <?php if ( empty( $_POST['page'] ) ) : ?>
  101.  
  102. <ul id="activity-stream" class="activity-list item-list">
  103.  
  104. <?php endif; ?>
  105.  
  106. <?php while ( bp_activities() ) : bp_the_activity(); ?>
  107.  
  108. <?php bp_get_template_part( 'activity/entry'); ?>
  109.  
  110. <?php endwhile; ?>
  111.  
  112. <?php if ( empty( $_POST['page'] ) ) : ?>
  113. </ul>
  114. <?php endif; ?>
  115.  
  116. <?php if($pagination):?>
  117. <div class="pagination">
  118. <div class="pag-count"><?php bp_activity_pagination_count(); ?></div>
  119. <div class="pagination-links"><?php bp_activity_pagination_links(); ?></div>
  120. </div>
  121. <?php endif;?>
  122. </div>
  123.  
  124.  
  125. <?php else : ?>
  126.  
  127. <div id="message" class="info">
  128. <p><?php _e( 'Sorry, there was no activity found. Please try a different filter.', 'buddypress' ); ?></p>
  129. </div>
  130.  
  131.  
  132. <?php endif; ?>
  133.  
  134. <?php do_action( 'bp_after_activity_loop' ); ?>
  135.  
  136. <form action="" name="activity-loop-form" id="activity-loop-form" method="post">
  137.  
  138. <?php wp_nonce_field( 'activity_filter', '_wpnonce_activity_filter' ); ?>
  139.  
  140. </form>
  141. <?php if( $use_compat ):?>
  142. </div>
  143. <?php endif;?>
  144. <?php
  145.  
  146. $output = ob_get_clean();
  147.  
  148.  
  149. return $output;
  150.  
  151. }
  152.  
  153. }
  154.  
  155. BD_Activity_Stream_Shortcodes_Helper::get_instance();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement