wp/wp-includes/ms-deprecated.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    89 function graceful_fail( $message ) {
    89 function graceful_fail( $message ) {
    90 	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_die()' );
    90 	_deprecated_function( __FUNCTION__, '3.0.0', 'wp_die()' );
    91 	$message = apply_filters( 'graceful_fail', $message );
    91 	$message = apply_filters( 'graceful_fail', $message );
    92 	$message_template = apply_filters( 'graceful_fail_template',
    92 	$message_template = apply_filters( 'graceful_fail_template',
    93 '<!DOCTYPE html>
    93 '<!DOCTYPE html>
    94 <html xmlns="http://www.w3.org/1999/xhtml"><head>
    94 <html><head>
    95 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    95 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    96 <title>Error!</title>
    96 <title>Error!</title>
    97 <style type="text/css">
    97 <style type="text/css">
    98 img {
    98 img {
    99 	border: 0;
    99 	border: 0;
   163  * @deprecated 3.0.0 Use is_email()
   163  * @deprecated 3.0.0 Use is_email()
   164  * @see is_email()
   164  * @see is_email()
   165  *
   165  *
   166  * @param string $email        Email address to verify.
   166  * @param string $email        Email address to verify.
   167  * @param bool   $check_domain Deprecated.
   167  * @param bool   $check_domain Deprecated.
   168  * @return string|bool Either false or the valid email address.
   168  * @return string|false Valid email address on success, false on failure.
   169  */
   169  */
   170 function validate_email( $email, $check_domain = true) {
   170 function validate_email( $email, $check_domain = true) {
   171 	_deprecated_function( __FUNCTION__, '3.0.0', 'is_email()' );
   171 	_deprecated_function( __FUNCTION__, '3.0.0', 'is_email()' );
   172 	return is_email( $email, $check_domain );
   172 	return is_email( $email, $check_domain );
   173 }
   173 }
   197 
   197 
   198 	if ( ! $blog_list ) {
   198 	if ( ! $blog_list ) {
   199 		return array();
   199 		return array();
   200 	}
   200 	}
   201 
   201 
   202 	if ( $num == 'all' ) {
   202 	if ( 'all' === $num ) {
   203 		return array_slice( $blog_list, $start, count( $blog_list ) );
   203 		return array_slice( $blog_list, $start, count( $blog_list ) );
   204 	} else {
   204 	} else {
   205 		return array_slice( $blog_list, $start, $num );
   205 		return array_slice( $blog_list, $start, $num );
   206 	}
   206 	}
   207 }
   207 }
   224 		reset( $blogs );
   224 		reset( $blogs );
   225 		$most_active = array();
   225 		$most_active = array();
   226 		$blog_list = array();
   226 		$blog_list = array();
   227 		foreach ( (array) $blogs as $key => $details ) {
   227 		foreach ( (array) $blogs as $key => $details ) {
   228 			$most_active[ $details['blog_id'] ] = $details['postcount'];
   228 			$most_active[ $details['blog_id'] ] = $details['postcount'];
   229 			$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
   229 			$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!
   230 		}
   230 		}
   231 		arsort( $most_active );
   231 		arsort( $most_active );
   232 		reset( $most_active );
   232 		reset( $most_active );
   233 		$t = array();
   233 		$t = array();
   234 		foreach ( (array) $most_active as $key => $details ) {
   234 		foreach ( (array) $most_active as $key => $details ) {
   272 
   272 
   273 	$ref = '';
   273 	$ref = '';
   274 	if ( isset( $_GET['ref'] ) && isset( $_POST['ref'] ) && $_GET['ref'] !== $_POST['ref'] ) {
   274 	if ( isset( $_GET['ref'] ) && isset( $_POST['ref'] ) && $_GET['ref'] !== $_POST['ref'] ) {
   275 		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
   275 		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
   276 	} elseif ( isset( $_POST['ref'] ) ) {
   276 	} elseif ( isset( $_POST['ref'] ) ) {
   277 		$ref = $_POST[ 'ref' ];
   277 		$ref = $_POST['ref'];
   278 	} elseif ( isset( $_GET['ref'] ) ) {
   278 	} elseif ( isset( $_GET['ref'] ) ) {
   279 		$ref = $_GET[ 'ref' ];
   279 		$ref = $_GET['ref'];
   280 	}
   280 	}
   281 
   281 
   282 	if ( $ref ) {
   282 	if ( $ref ) {
   283 		$ref = wpmu_admin_redirect_add_updated_param( $ref );
   283 		$ref = wpmu_admin_redirect_add_updated_param( $ref );
   284 		wp_redirect( $ref );
   284 		wp_redirect( $ref );
   285 		exit();
   285 		exit;
   286 	}
   286 	}
   287 	if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
   287 	if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
   288 		wp_redirect( $_SERVER['HTTP_REFERER'] );
   288 		wp_redirect( $_SERVER['HTTP_REFERER'] );
   289 		exit();
   289 		exit;
   290 	}
   290 	}
   291 
   291 
   292 	$url = wpmu_admin_redirect_add_updated_param( $url );
   292 	$url = wpmu_admin_redirect_add_updated_param( $url );
   293 	if ( isset( $_GET['redirect'] ) && isset( $_POST['redirect'] ) && $_GET['redirect'] !== $_POST['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 );
   294 		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
   295 	} elseif ( isset( $_GET['redirect'] ) ) {
   295 	} elseif ( isset( $_GET['redirect'] ) ) {
   296 		if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
   296 		if ( 's_' === substr( $_GET['redirect'], 0, 2 ) )
   297 			$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
   297 			$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
   298 	} elseif ( isset( $_POST['redirect'] ) ) {
   298 	} elseif ( isset( $_POST['redirect'] ) ) {
   299 		$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
   299 		$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
   300 	}
   300 	}
   301 	wp_redirect( $url );
   301 	wp_redirect( $url );
   302 	exit();
   302 	exit;
   303 }
   303 }
   304 
   304 
   305 /**
   305 /**
   306  * Adds an 'updated=true' argument to a URL.
   306  * Adds an 'updated=true' argument to a URL.
   307  *
   307  *
   369 		$url = "http://" . $domain.$path;
   369 		$url = "http://" . $domain.$path;
   370 	} else {
   370 	} else {
   371 		if ( $domain != $_SERVER['HTTP_HOST'] ) {
   371 		if ( $domain != $_SERVER['HTTP_HOST'] ) {
   372 			$blogname = substr( $domain, 0, strpos( $domain, '.' ) );
   372 			$blogname = substr( $domain, 0, strpos( $domain, '.' ) );
   373 			$url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
   373 			$url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
   374 			// we're not installing the main blog
   374 			// We're not installing the main blog.
   375 			if ( $blogname != 'www.' )
   375 			if ( 'www.' !== $blogname )
   376 				$url .= $blogname . '/';
   376 				$url .= $blogname . '/';
   377 		} else { // main blog
   377 		} else { // Main blog.
   378 			$url = 'http://' . $domain . $path;
   378 			$url = 'http://' . $domain . $path;
   379 		}
   379 		}
   380 	}
   380 	}
   381 	return esc_url_raw( $url );
   381 	return esc_url_raw( $url );
   382 }
   382 }
   399 	if ( empty($path) )
   399 	if ( empty($path) )
   400 		$path = '/';
   400 		$path = '/';
   401 
   401 
   402 	// Check if the domain has been used already. We should return an error message.
   402 	// Check if the domain has been used already. We should return an error message.
   403 	if ( domain_exists($domain, $path, $site_id) )
   403 	if ( domain_exists($domain, $path, $site_id) )
   404 		return __( '<strong>ERROR</strong>: Site URL already taken.' );
   404 		return __( '<strong>Error</strong>: Site URL you&#8217;ve entered is already taken.' );
   405 
   405 
   406 	// Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
   406 	/*
   407 	// Need to get blog_id from wp_blogs, and create new table names.
   407 	 * Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
   408 	// Must restore table names at the end of function.
   408 	 * Need to get blog_id from wp_blogs, and create new table names.
       
   409 	 * Must restore table names at the end of function.
       
   410 	 */
   409 
   411 
   410 	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
   412 	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
   411 		return __( '<strong>ERROR</strong>: problem creating site entry.' );
   413 		return __( '<strong>Error</strong>: There was a problem creating site entry.' );
   412 
   414 
   413 	switch_to_blog($blog_id);
   415 	switch_to_blog($blog_id);
   414 	install_blog($blog_id);
   416 	install_blog($blog_id);
   415 	restore_current_blog();
   417 	restore_current_blog();
   416 
   418 
   470  *     @type int       $spam       Retrieve spam or non-spam sites. Default null, for any.
   472  *     @type int       $spam       Retrieve spam or non-spam sites. Default null, for any.
   471  *     @type int       $deleted    Retrieve deleted or non-deleted sites. Default null, for any.
   473  *     @type int       $deleted    Retrieve deleted or non-deleted sites. Default null, for any.
   472  *     @type int       $limit      Number of sites to limit the query to. Default 100.
   474  *     @type int       $limit      Number of sites to limit the query to. Default 100.
   473  *     @type int       $offset     Exclude the first x sites. Used in combination with the $limit parameter. Default 0.
   475  *     @type int       $offset     Exclude the first x sites. Used in combination with the $limit parameter. Default 0.
   474  * }
   476  * }
   475  * @return array An empty array if the installation is considered "large" via wp_is_large_network(). Otherwise,
   477  * @return array[] An empty array if the installation is considered "large" via wp_is_large_network(). Otherwise,
   476  *               an associative array of site data arrays, each containing the site (network) ID, blog ID,
   478  *                 an associative array of WP_Site data as arrays.
   477  *               site domain and path, dates registered and modified, and the language ID. Also, boolean
       
   478  *               values for whether the site is public, archived, mature, spam, and/or deleted.
       
   479  */
   479  */
   480 function wp_get_sites( $args = array() ) {
   480 function wp_get_sites( $args = array() ) {
   481 	_deprecated_function( __FUNCTION__, '4.6.0', 'get_sites()' );
   481 	_deprecated_function( __FUNCTION__, '4.6.0', 'get_sites()' );
   482 
   482 
   483 	if ( wp_is_large_network() )
   483 	if ( wp_is_large_network() )
   494 		'offset'     => 0,
   494 		'offset'     => 0,
   495 	);
   495 	);
   496 
   496 
   497 	$args = wp_parse_args( $args, $defaults );
   497 	$args = wp_parse_args( $args, $defaults );
   498 
   498 
   499 	// Backwards compatibility
   499 	// Backward compatibility.
   500 	if( is_array( $args['network_id'] ) ){
   500 	if( is_array( $args['network_id'] ) ){
   501 		$args['network__in'] = $args['network_id'];
   501 		$args['network__in'] = $args['network_id'];
   502 		$args['network_id'] = null;
   502 		$args['network_id'] = null;
   503 	}
   503 	}
   504 
   504 
   594  * points to the new blog.
   594  * points to the new blog.
   595  *
   595  *
   596  * @since MU (3.0.0)
   596  * @since MU (3.0.0)
   597  * @deprecated 5.1.0
   597  * @deprecated 5.1.0
   598  *
   598  *
   599  * @global wpdb     $wpdb
   599  * @global wpdb     $wpdb     WordPress database abstraction object.
   600  * @global WP_Roles $wp_roles
   600  * @global WP_Roles $wp_roles WordPress role management object.
   601  *
   601  *
   602  * @param int    $blog_id    The value returned by wp_insert_site().
   602  * @param int    $blog_id    The value returned by wp_insert_site().
   603  * @param string $blog_title The title of the new site.
   603  * @param string $blog_title The title of the new site.
   604  */
   604  */
   605 function install_blog( $blog_id, $blog_title = '' ) {
   605 function install_blog( $blog_id, $blog_title = '' ) {
   606 	global $wpdb, $wp_roles;
   606 	global $wpdb, $wp_roles;
   607 
   607 
   608 	_deprecated_function( __FUNCTION__, '5.1.0' );
   608 	_deprecated_function( __FUNCTION__, '5.1.0' );
   609 
   609 
   610 	// Cast for security
   610 	// Cast for security.
   611 	$blog_id = (int) $blog_id;
   611 	$blog_id = (int) $blog_id;
   612 
   612 
   613 	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
   613 	require_once ABSPATH . 'wp-admin/includes/upgrade.php';
   614 
   614 
   615 	$suppress = $wpdb->suppress_errors();
   615 	$suppress = $wpdb->suppress_errors();
   616 	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
   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>' );
   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 	}
   618 	}
   619 	$wpdb->suppress_errors( $suppress );
   619 	$wpdb->suppress_errors( $suppress );
   620 
   620 
   621 	$url = get_blogaddress_by_id( $blog_id );
   621 	$url = get_blogaddress_by_id( $blog_id );
   622 
   622 
   623 	// Set everything up
   623 	// Set everything up.
   624 	make_db_current_silent( 'blog' );
   624 	make_db_current_silent( 'blog' );
   625 	populate_options();
   625 	populate_options();
   626 	populate_roles();
   626 	populate_roles();
   627 
   627 
   628 	// populate_roles() clears previous role definitions so we start over.
   628 	// populate_roles() clears previous role definitions so we start over.
   650 	}
   650 	}
   651 
   651 
   652 	update_option( 'blogname', wp_unslash( $blog_title ) );
   652 	update_option( 'blogname', wp_unslash( $blog_title ) );
   653 	update_option( 'admin_email', '' );
   653 	update_option( 'admin_email', '' );
   654 
   654 
   655 	// remove all perms
   655 	// Remove all permissions.
   656 	$table_prefix = $wpdb->get_blog_prefix();
   656 	$table_prefix = $wpdb->get_blog_prefix();
   657 	delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
   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
   658 	delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // Delete all.
   659 }
   659 }
   660 
   660 
   661 /**
   661 /**
   662  * Set blog defaults.
   662  * Set blog defaults.
   663  *
   663  *
   675 function install_blog_defaults( $blog_id, $user_id ) {
   675 function install_blog_defaults( $blog_id, $user_id ) {
   676 	global $wpdb;
   676 	global $wpdb;
   677 
   677 
   678 	_deprecated_function( __FUNCTION__, 'MU' );
   678 	_deprecated_function( __FUNCTION__, 'MU' );
   679 
   679 
   680 	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
   680 	require_once ABSPATH . 'wp-admin/includes/upgrade.php';
   681 
   681 
   682 	$suppress = $wpdb->suppress_errors();
   682 	$suppress = $wpdb->suppress_errors();
   683 
   683 
   684 	wp_install_defaults( $user_id );
   684 	wp_install_defaults( $user_id );
   685 
   685 
   686 	$wpdb->suppress_errors( $suppress );
   686 	$wpdb->suppress_errors( $suppress );
   687 }
   687 }
       
   688 
       
   689 /**
       
   690  * Update the status of a user in the database.
       
   691  *
       
   692  * Previously used in core to mark a user as spam or "ham" (not spam) in Multisite.
       
   693  *
       
   694  * @since 3.0.0
       
   695  * @deprecated 5.3.0 Use wp_update_user()
       
   696  * @see wp_update_user()
       
   697  *
       
   698  * @global wpdb $wpdb WordPress database abstraction object.
       
   699  *
       
   700  * @param int    $id         The user ID.
       
   701  * @param string $pref       The column in the wp_users table to update the user's status
       
   702  *                           in (presumably user_status, spam, or deleted).
       
   703  * @param int    $value      The new status for the user.
       
   704  * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
       
   705  * @return int   The initially passed $value.
       
   706  */
       
   707 function update_user_status( $id, $pref, $value, $deprecated = null ) {
       
   708 	global $wpdb;
       
   709 
       
   710 	_deprecated_function( __FUNCTION__, '5.3.0', 'wp_update_user()' );
       
   711 
       
   712 	if ( null !== $deprecated ) {
       
   713 		_deprecated_argument( __FUNCTION__, '3.0.2' );
       
   714 	}
       
   715 
       
   716 	$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
       
   717 
       
   718 	$user = new WP_User( $id );
       
   719 	clean_user_cache( $user );
       
   720 
       
   721 	if ( 'spam' === $pref ) {
       
   722 		if ( $value == 1 ) {
       
   723 			/** This filter is documented in wp-includes/user.php */
       
   724 			do_action( 'make_spam_user', $id );
       
   725 		} else {
       
   726 			/** This filter is documented in wp-includes/user.php */
       
   727 			do_action( 'make_ham_user', $id );
       
   728 		}
       
   729 	}
       
   730 
       
   731 	return $value;
       
   732 }