/** * Set the content part of the template * * @package WP Idea Stream * @subpackage buddypress/screens * * @since 2.0.0 * * @uses bp_action_variable() to get an action variable * @uses wp_idea_stream_cpage_slug() to get the pagination slug for user comments * @uses wp_idea_stream_paged_slug() to get the pagination slug * @uses bp_is_my_profile() to check if logged in user is displaying his own profile * @uses add_filter() to temporarly customize IdeaStream Loop * @uses wp_idea_stream_template_part() to get the needed IdeaStream template part * @uses remove_filter() to remove the temporary filters */ public function set_content() { // Init vars $this->user_args = array(); $template_slug = 'idea'; $template_name = 'loop'; $filters = array('is_user_profile', 'ideas_query_args'); /** * Make sure the pagination is set * * For idea queries the pagination slug is the same than WordPress * the paged query var is set to it's not necessary. * For comments queries, as the pagination slug is different then the one * of WordPress, it's necessary. */ if (in_array(bp_action_variable(0), array(wp_idea_stream_cpage_slug(), wp_idea_stream_paged_slug())) && is_numeric(bp_action_variable(1))) { $this->user_args['page'] = (int) bp_action_variable(1); } /** * About rates, we don't need the ideas the user submitted * but the ideas he rated, so the author must not be set. */ if ('rates' == $this->screen) { // Building the meta query, no need to edit query orderby // for user rates. $this->user_args['meta_query'] = array(array('key' => '_ideastream_rates', 'value' => ';i:' . $this->user_id . ';', 'compare' => 'LIKE')); $filters = array_merge($filters, array('is_user_profile_rates', 'users_displayed_user_id')); /** * About comments, we are using specific loop, template * and filter. */ } else { if ('comments' == $this->screen) { $template_slug = 'user'; $template_name = 'comments'; $this->user_args['user_id'] = $this->user_id; $filters = array('comments_query_args'); // Default is user ideas, we need to set the author. } else { $this->user_args['author'] = $this->user_id; // Show private ideas only if on current user is on his profile if (bp_is_my_profile()) { $filters = array_merge($filters, array('ideas_get_status')); } } } // Add temporary filters foreach ($filters as $filter) { $this_filter = str_replace(array('ideas', 'comments', '_rates', 'users_'), array('filter', 'filter', '', ''), $filter); add_filter('wp_idea_stream_' . $filter, array($this, $this_filter), 10, 1); } ?> <div id="wp-idea-stream"> <?php wp_idea_stream_template_part($template_slug, $template_name); ?> </div> <?php // Remove temporary filters foreach ($filters as $filter) { $this_filter = str_replace(array('ideas', 'comments', '_rates', 'users_'), array('filter', 'filter', '', ''), $filter); remove_filter('wp_idea_stream_' . $filter, array($this, $this_filter), 10, 1); } }
<?php if (wp_idea_stream_is_user_profile_comments()) { ?> <?php wp_idea_stream_template_part('user', 'comments'); ?> <?php do_action('wp_idea_stream_user_profile_after_comments'); ?> <?php } else { ?> <?php wp_idea_stream_template_part('idea', 'loop'); ?> <?php do_action('wp_idea_stream_user_profile_after_loop'); ?> <?php } ?> </div>
/** * Loads needed IdeaStream template parts * * - new form * - single idea * - ideas loop * * @package WP Idea Stream * @subpackage buddypress/groups * * @since 2.0.0 * * @global $wp_query * @uses bp_get_current_group_id() to get the group id * @uses wp_idea_stream_tag_get_slug() to get the ideas tag taxonomy slug * @uses wp_idea_stream_category_get_slug() to get the ideas category taxonomy slug * @uses get_query_var() to get the value of the needed query var * @uses wp_idea_stream_search_rewrite_id() to get the search ideas rewrite id * @uses add_filter() to temporarly override some IdeaStream vars * @uses wp_idea_stream_template_part() to load the needed template part * @uses remove_filter() to remove the temporary filters * @return string html output */ public function display($group_id = null) { global $wp_query; // Catch BuddyPress group's query post settings if (!empty($wp_query->post)) { $this->group_post = $wp_query->post; } if (empty($this->group_ideastream->is_action)) { return; } // Default vars $template_slug = 'archive'; $template_name = ''; $filters = array('ideas_query_args'); $this->group_ideastream->query_args = array('meta_query' => array(array('key' => '_ideastream_group_id', 'value' => bp_get_current_group_id(), 'compare' => '='))); switch ($this->group_ideastream->is_action) { case 'new': case 'edit': $template_slug = 'idea'; $template_name = 'form'; $filters = array(); break; case 'idea': $template_slug = 'idea'; $template_name = 'group'; $this->group_ideastream->query_args = array('idea_name' => $this->group_ideastream->idea_name); break; case wp_idea_stream_tag_get_slug(): case wp_idea_stream_category_get_slug(): $this->group_ideastream->query_args['tax_query'] = array(array('field' => 'term_id', 'taxonomy' => $this->group_ideastream->current_taxonomy, 'terms' => $this->group_ideastream->current_term->term_id)); break; } $search_terms = get_query_var(wp_idea_stream_search_rewrite_id()); if (!empty($search_terms) && 'archive' == $this->group_ideastream->is_action) { $this->group_ideastream->query_args['search'] = $search_terms; } if (!empty($this->group_ideastream->is_paged)) { $this->group_ideastream->query_args['page'] = $this->group_ideastream->is_paged; } $orderby = get_query_var('orderby'); if (!empty($orderby)) { $this->group_ideastream->query_args['orderby'] = $orderby; } // Loop in filters to temporarly add needed ones foreach ($filters as $filter) { add_filter('wp_idea_stream_' . $filter, array($this, $filter), 10, 1); } // remove all filters to content, we'll use custom filters remove_all_filters('the_content'); wp_idea_stream_template_part($template_slug, $template_name); // Loop in filters to remove foreach ($filters as $filter) { remove_filter('wp_idea_stream_' . $filter, array($this, $filter), 10, 1); } }
<?php wp_idea_stream_template_part('idea', 'header'); ?> <div class="idea-description"> <?php wp_idea_stream_ideas_the_content(); ?> </div> <?php do_action('wp_idea_stream_idea_entry_before_footer'); ?> <?php wp_idea_stream_template_part('idea', 'footer'); ?> <?php do_action('wp_idea_stream_idea_entry_after_footer'); ?> </article> <?php comments_template('', true); ?> <?php } ?>
<ul class="idea-list"> <?php while (wp_idea_stream_ideas_the_ideas()) { wp_idea_stream_ideas_the_idea(); ?> <li id="idea-<?php wp_idea_stream_ideas_the_id(); ?> " <?php wp_idea_stream_ideas_the_classes(); ?> > <?php wp_idea_stream_template_part('idea', 'entry'); ?> </li> <?php } ?> </ul> <div id="pag-bottom" class="pagination no-ajax"> <div class="pag-count" id="idea-count-bottom"> <?php wp_idea_stream_ideas_pagination_count();