wp/wp-includes/ms-deprecated.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
   269  */
   269  */
   270 function wpmu_admin_do_redirect( $url = '' ) {
   270 function wpmu_admin_do_redirect( $url = '' ) {
   271 	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_redirect()' );
   271 	_deprecated_function( __FUNCTION__, '3.3.0', 'wp_redirect()' );
   272 
   272 
   273 	$ref = '';
   273 	$ref = '';
   274 	if ( isset( $_GET['ref'] ) )
   274 	if ( isset( $_GET['ref'] ) && isset( $_POST['ref'] ) && $_GET['ref'] !== $_POST['ref'] ) {
   275 		$ref = $_GET['ref'];
   275 		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
   276 	if ( isset( $_POST['ref'] ) )
   276 	} elseif ( isset( $_POST['ref'] ) ) {
   277 		$ref = $_POST['ref'];
   277 		$ref = $_POST[ 'ref' ];
       
   278 	} elseif ( isset( $_GET['ref'] ) ) {
       
   279 		$ref = $_GET[ 'ref' ];
       
   280 	}
   278 
   281 
   279 	if ( $ref ) {
   282 	if ( $ref ) {
   280 		$ref = wpmu_admin_redirect_add_updated_param( $ref );
   283 		$ref = wpmu_admin_redirect_add_updated_param( $ref );
   281 		wp_redirect( $ref );
   284 		wp_redirect( $ref );
   282 		exit();
   285 		exit();
   285 		wp_redirect( $_SERVER['HTTP_REFERER'] );
   288 		wp_redirect( $_SERVER['HTTP_REFERER'] );
   286 		exit();
   289 		exit();
   287 	}
   290 	}
   288 
   291 
   289 	$url = wpmu_admin_redirect_add_updated_param( $url );
   292 	$url = wpmu_admin_redirect_add_updated_param( $url );
   290 	if ( isset( $_GET['redirect'] ) ) {
   293 	if ( isset( $_GET['redirect'] ) && isset( $_POST['redirect'] ) && $_GET['redirect'] !== $_POST['redirect'] ) {
       
   294 		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
       
   295 	} elseif ( isset( $_GET['redirect'] ) ) {
   291 		if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
   296 		if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
   292 			$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
   297 			$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
   293 	} elseif ( isset( $_POST['redirect'] ) ) {
   298 	} elseif ( isset( $_POST['redirect'] ) ) {
   294 		$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
   299 		$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
   295 	}
   300 	}
   544 	}
   549 	}
   545 	$local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
   550 	$local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
   546 
   551 
   547 	return isset( $current_user->$local_key );
   552 	return isset( $current_user->$local_key );
   548 }
   553 }
       
   554 
       
   555 /**
       
   556  * Store basic site info in the blogs table.
       
   557  *
       
   558  * This function creates a row in the wp_blogs table and returns
       
   559  * the new blog's ID. It is the first step in creating a new blog.
       
   560  *
       
   561  * @since MU (3.0.0)
       
   562  * @deprecated 5.1.0 Use `wp_insert_site()`
       
   563  * @see wp_insert_site()
       
   564  *
       
   565  * @param string $domain  The domain of the new site.
       
   566  * @param string $path    The path of the new site.
       
   567  * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
       
   568  * @return int|false The ID of the new row
       
   569  */
       
   570 function insert_blog($domain, $path, $site_id) {
       
   571 	_deprecated_function( __FUNCTION__, '5.1.0', 'wp_insert_site()' );
       
   572 
       
   573 	$data = array(
       
   574 		'domain'  => $domain,
       
   575 		'path'    => $path,
       
   576 		'site_id' => $site_id,
       
   577 	);
       
   578 
       
   579 	$site_id = wp_insert_site( $data );
       
   580 	if ( is_wp_error( $site_id ) ) {
       
   581 		return false;
       
   582 	}
       
   583 
       
   584 	clean_blog_cache( $site_id );
       
   585 
       
   586 	return $site_id;
       
   587 }
       
   588 
       
   589 /**
       
   590  * Install an empty blog.
       
   591  *
       
   592  * Creates the new blog tables and options. If calling this function
       
   593  * directly, be sure to use switch_to_blog() first, so that $wpdb
       
   594  * points to the new blog.
       
   595  *
       
   596  * @since MU (3.0.0)
       
   597  * @deprecated 5.1.0
       
   598  *
       
   599  * @global wpdb     $wpdb
       
   600  * @global WP_Roles $wp_roles
       
   601  *
       
   602  * @param int    $blog_id    The value returned by wp_insert_site().
       
   603  * @param string $blog_title The title of the new site.
       
   604  */
       
   605 function install_blog( $blog_id, $blog_title = '' ) {
       
   606 	global $wpdb, $wp_roles;
       
   607 
       
   608 	_deprecated_function( __FUNCTION__, '5.1.0' );
       
   609 
       
   610 	// Cast for security
       
   611 	$blog_id = (int) $blog_id;
       
   612 
       
   613 	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
       
   614 
       
   615 	$suppress = $wpdb->suppress_errors();
       
   616 	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
       
   617 		die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
       
   618 	}
       
   619 	$wpdb->suppress_errors( $suppress );
       
   620 
       
   621 	$url = get_blogaddress_by_id( $blog_id );
       
   622 
       
   623 	// Set everything up
       
   624 	make_db_current_silent( 'blog' );
       
   625 	populate_options();
       
   626 	populate_roles();
       
   627 
       
   628 	// populate_roles() clears previous role definitions so we start over.
       
   629 	$wp_roles = new WP_Roles();
       
   630 
       
   631 	$siteurl = $home = untrailingslashit( $url );
       
   632 
       
   633 	if ( ! is_subdomain_install() ) {
       
   634 
       
   635 		if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
       
   636 			$siteurl = set_url_scheme( $siteurl, 'https' );
       
   637 		}
       
   638 		if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
       
   639 			$home = set_url_scheme( $home, 'https' );
       
   640 		}
       
   641 	}
       
   642 
       
   643 	update_option( 'siteurl', $siteurl );
       
   644 	update_option( 'home', $home );
       
   645 
       
   646 	if ( get_site_option( 'ms_files_rewriting' ) ) {
       
   647 		update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
       
   648 	} else {
       
   649 		update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
       
   650 	}
       
   651 
       
   652 	update_option( 'blogname', wp_unslash( $blog_title ) );
       
   653 	update_option( 'admin_email', '' );
       
   654 
       
   655 	// remove all perms
       
   656 	$table_prefix = $wpdb->get_blog_prefix();
       
   657 	delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
       
   658 	delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
       
   659 }
       
   660 
       
   661 /**
       
   662  * Set blog defaults.
       
   663  *
       
   664  * This function creates a row in the wp_blogs table.
       
   665  *
       
   666  * @since MU (3.0.0)
       
   667  * @deprecated MU
       
   668  * @deprecated Use wp_install_defaults()
       
   669  *
       
   670  * @global wpdb $wpdb WordPress database abstraction object.
       
   671  *
       
   672  * @param int $blog_id Ignored in this function.
       
   673  * @param int $user_id
       
   674  */
       
   675 function install_blog_defaults( $blog_id, $user_id ) {
       
   676 	global $wpdb;
       
   677 
       
   678 	_deprecated_function( __FUNCTION__, 'MU' );
       
   679 
       
   680 	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
       
   681 
       
   682 	$suppress = $wpdb->suppress_errors();
       
   683 
       
   684 	wp_install_defaults( $user_id );
       
   685 
       
   686 	$wpdb->suppress_errors( $suppress );
       
   687 }