HEX
Server: nginx/1.27.1
System: Linux in-4 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User: ilikadirect (1186)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v6964/mangomitra/public_html/wp-content/plugins/buddypress/bp-blogs/actions/random.php
<?php
/**
 * Blogs: Random blog action handler
 *
 * @package BuddyPress
 * @subpackage BlogsActions
 * @since 3.0.0
 */

/**
 * Redirect to a random blog in the multisite network.
 *
 * @since 1.0.0
 */
function bp_blogs_redirect_to_random_blog() {

	// Bail if not looking for a random blog.
	if ( ! bp_is_blogs_component() || ! isset( $_GET['random-blog'] ) )
		return;

	// Multisite is active so find a random blog.
	if ( is_multisite() ) {
		$blog = bp_blogs_get_random_blogs( 1, 1 );
		bp_core_redirect( get_home_url( $blog['blogs'][0]->blog_id ) );

	// No multisite and still called, always redirect to root.
	} else {
		bp_core_redirect( bp_core_get_root_domain() );
	}
}
add_action( 'bp_actions', 'bp_blogs_redirect_to_random_blog' );