Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/09/2012 10:36:36 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Remove unneeded globals and clean up some code in Blogs component. See #3989.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs/bp-blogs-actions.php

    r4961 r5686  
    11<?php
     2
     3/**
     4 * BuddyPress Blogs Actions
     5 *
     6 * @package BuddyPress
     7 * @subpackage BlogsActions
     8 */
     9
    210// Exit if accessed directly
    311if ( !defined( 'ABSPATH' ) ) exit;
    412
     13/**
     14 * Redirect to a random blog in the multisite network
     15 *
     16 * @since BuddyPress (1.0)
     17 * @package BuddyPress
     18 * @subpackage BlogsActions
     19 */
    520function bp_blogs_redirect_to_random_blog() {
    6     global $bp, $wpdb;
    721
    8     if ( bp_is_blogs_component() && isset( $_GET['random-blog'] ) ) {
     22    // Bail if not looking for a random blog
     23    if ( ! bp_is_blogs_component() || ! isset( $_GET['random-blog'] ) )
     24        return;
     25
     26    // Multisite is active so find a random blog
     27    if ( is_multisite() ) {
    928        $blog = bp_blogs_get_random_blogs( 1, 1 );
     29        bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) );
    1030
    11         bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) );
     31    // No multisite and still called, always redirect to root
     32    } else {
     33        bp_core_redirect( bp_core_get_root_domain() );
    1234    }
    1335}
Note: See TracChangeset for help on using the changeset viewer.