<div class="activity single-group"> <h3><?php _e('Blog Activity', 'groupblog'); ?> </h3> <?php if (bp_has_activities('per_page=5&object=blogs&primary_id=' . get_groupblog_blog_id(bp_get_group_id()))) { ?> <div class="pagination"> <div class="pag-count"><?php bp_activity_pagination_count(); ?> </div> <div class="pagination-links"><?php bp_activity_pagination_links(); ?> </div> </div> <?php if (empty($_POST['page'])) { ?> <ul id="activity-stream" class="activity-list item-list"> <?php } ?> <?php
/** * groupblog_redirect_group_home() * * Redirect Group Home page to Blog Home page if set in admin settings. */ function groupblog_redirect_group_home() { global $bp; if ($bp->current_component == $bp->groups->slug && $bp->is_single_item && 'home' == $bp->current_action) { $checks = get_site_option('bp_groupblog_blog_defaults_options'); if ($checks['deep_group_integration']) { $blog_details = get_blog_details(get_groupblog_blog_id(), true); bp_core_redirect($blog_details->siteurl); } } }
function bp_groupblog_update_defaults() { // retrieve the old landing page slug so we know which pages to delete $oldoptions = get_site_option('bp_groupblog_blog_defaults_options'); // create an array to hold the chosen options $newoptions = array(); $newoptions['theme'] = $_POST['theme']; // groupblog validation settings $newoptions['allowdashes'] = !empty($_POST['bp_groupblog_allowdashes']) ? 1 : 0; $newoptions['allowunderscores'] = !empty($_POST['bp_groupblog_allowunderscores']) ? 1 : 0; $newoptions['allownumeric'] = !empty($_POST['bp_groupblog_allownumeric']) ? 1 : 0; $newoptions['minlength'] = isset($_POST['bp_groupblog_minlength']) && is_numeric($_POST['bp_groupblog_minlength']) == true ? $_POST['bp_groupblog_minlength'] : 4; // groupblog default settings $newoptions['default_cat_name'] = isset($_POST['default_cat_name']) ? $_POST['default_cat_name'] : ''; $newoptions['default_link_cat'] = isset($_POST['default_link_cat']) ? $_POST['default_link_cat'] : ''; if (!empty($_POST['delete_first_post'])) { $newoptions['delete_first_post'] = 1; } else { $newoptions['delete_first_post'] = 0; } if (!empty($_POST['delete_first_comment'])) { $newoptions['delete_first_comment'] = 1; } else { $newoptions['delete_first_comment'] = 0; } if (!empty($_POST['delete_blogroll_links'])) { $newoptions['delete_blogroll_links'] = 1; } else { $newoptions['delete_blogroll_links'] = 0; } // groupblog layout settings if (!empty($_POST['group_admin_layout'])) { $newoptions['group_admin_layout'] = 1; } else { $newoptions['group_admin_layout'] = 0; } // redirect group home to blog home if (!empty($_POST['deep_group_integration'])) { $newoptions['deep_group_integration'] = 1; } else { $newoptions['deep_group_integration'] = 0; } // groupblog redirect option $newoptions['redirectblog'] = isset($_POST['bp_groupblog_redirect_blog']) ? $_POST['bp_groupblog_redirect_blog'] : ''; $newoptions['pagetitle'] = isset($_POST['bp_groupblog_page_title']) ? $_POST['bp_groupblog_page_title'] : __('Blog', 'bp-groupblog'); $newoptions['pageslug'] = isset($_POST['bp_groupblog_page_title']) ? sanitize_title($_POST['bp_groupblog_page_title']) : ''; $newoptions['page_template_layout'] = isset($_POST['page_template_layout']) ? $_POST['page_template_layout'] : 'magazine'; $newoptions['rerun'] = 0; if ($newoptions['redirectblog'] == 2) { if (bp_has_groups()) { while (bp_groups()) { bp_the_group(); if ($blog_id = get_groupblog_blog_id(bp_get_group_id())) { switch_to_blog($blog_id); $change_front = new WP_Query('pagename=' . $newoptions['pageslug']); if ($change_front->have_posts()) { while ($change_front->have_posts()) { $change_front->the_post(); $blog_page_id = get_the_ID(); } } if ($newoptions['deep_group_integration'] == 1) { $page_or_posts = 'page'; update_option('page_on_front', $blog_page_id); } else { $page_or_posts = 'posts'; } update_option('show_on_front', $page_or_posts); } } } update_site_option('bp_groupblog_blog_defaults_options', $newoptions); $get_out = false; if ($newoptions['redirectblog'] != 2) { $get_out = true; } if ($oldoptions['pageslug'] == $newoptions['pageslug'] && $oldoptions['redirectblog'] == 2) { $get_out = true; } if ($get_out && $oldoptions['rerun'] == 0) { return false; } echo '<div id="message" class="updated fade">'; echo '<p><strong>The following blogs were updated</strong></p>'; $exists_in = array(); $updated_blogs = array(); if (bp_has_groups()) { while (bp_groups()) { bp_the_group(); if ($blog_id = get_groupblog_blog_id(bp_get_group_id())) { switch_to_blog($blog_id); $create = new WP_Query('pagename=' . $newoptions['pageslug']); if ($create->have_posts()) { $get_lost = 1; while ($create->have_posts()) { $create->the_post(); if (!get_post_meta(get_the_ID(), 'created_by_groupblog_dont_change')) { $exists_in[] = get_bloginfo('name'); $page_found = 1; $newoptions['rerun'] = 1; } } } else { if (!$get_lost) { $blog_page = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_name' => $newoptions['pageslug'], 'post_title' => $newoptions['pagetitle'], 'post_type' => 'page', 'post_content' => __('<p><strong>This page has been created automatically by the BuddyPress GroupBlog plugin.</strong></p><p>Please contact the site admin if you see this message instead of your blog posts. Possible solution: please advise your site admin to create the <a href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates">page template</a> needed for the BuddyPress GroupBlog plugin.<p>', 'groupblog')); $blog_page_id = wp_insert_post($blog_page); if ($blog_page_id) { add_post_meta($blog_page_id, '_wp_page_template', 'blog.php'); // add a special meta key so if we have to clean it up later we know the difference between pages // created by us and ones created by the user so we don't delete their pages. add_post_meta($blog_page_id, 'created_by_groupblog_dont_change', '1'); $updated_blogs[] = get_bloginfo('name'); } } // find the page created previously and delete it, checking first to see if it was one we created or not if ($oldoptions['pageslug'] != $newoptions['pageslug']) { $cleanup = new WP_Query('pagename=' . $oldoptions['pageslug']); if ($cleanup->have_posts()) { while ($cleanup->have_posts()) { $cleanup->the_post(); if (get_post_meta(get_the_ID(), 'created_by_groupblog_dont_change')) { wp_delete_post(get_the_ID(), $force_delete = true); } } } //cleanup } } } $get_lost = 0; } } foreach ($updated_blogs as $blog) { echo '<p>- ' . $blog . '</p>'; } if ($page_found) { echo '<div class="error">'; echo '<p style="line-height: 16px;"><strong>We skipped the following blogs</strong></p>'; foreach ($exists_in as $blog) { echo '<p>- ' . $blog . '</p>'; } echo '<p><em>These blogs already had a page named <strong>"' . $newoptions["pagetitle"] . '"</strong> which was not created by us. Please check and delete that page permanently after which you should return here and click save once more to finalize the process. Alternatively you can choose another template page name.</em></p></div>'; } echo '</div>'; } elseif ($newoptions['redirectblog'] != 2) { if (bp_has_groups()) { while (bp_groups()) { bp_the_group(); if ($blog_id = get_groupblog_blog_id(bp_get_group_id())) { switch_to_blog($blog_id); update_option('show_on_front', 'posts'); } } } } // override the site option update_site_option('bp_groupblog_blog_defaults_options', $newoptions); $options = get_site_option('bp_groupblog_blog_defaults_options'); }
<?php do_action('bp_after_group_body'); ?> </div> <?php do_action('bp_after_group_home_content'); ?> <?php } } ?> </div><!-- .padder --> </div><!-- #content --> <?php switch_to_blog(get_groupblog_blog_id()); ?> <?php locate_template(array('sidebar.php'), true); ?> <?php restore_current_blog(); ?> <?php get_footer();
function groupblog_blog_id($group_id = '') { echo get_groupblog_blog_id($group_id); }