[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-blogs/actions/ -> random.php (source)

   1  <?php
   2  /**
   3   * Blogs: Random blog action handler
   4   *
   5   * @package BuddyPress
   6   * @subpackage BlogsActions
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Redirect to a random blog in the multisite network.
  12   *
  13   * @since 1.0.0
  14   */
  15  function bp_blogs_redirect_to_random_blog() {
  16  
  17      // Bail if not looking for a random blog.
  18      if ( ! bp_is_blogs_component() || ! isset( $_GET['random-blog'] ) )
  19          return;
  20  
  21      // Multisite is active so find a random blog.
  22      if ( is_multisite() ) {
  23          $blog = bp_blogs_get_random_blogs( 1, 1 );
  24          bp_core_redirect( get_home_url( $blog['blogs'][0]->blog_id ) );
  25  
  26      // No multisite and still called, always redirect to root.
  27      } else {
  28          bp_core_redirect( bp_core_get_root_domain() );
  29      }
  30  }
  31  add_action( 'bp_actions', 'bp_blogs_redirect_to_random_blog' );


Generated: Fri Mar 29 01:01:02 2024 Cross-referenced by PHPXref 0.7.1