wp/wp-includes/ms-deprecated.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- a/wp/wp-includes/ms-deprecated.php	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/ms-deprecated.php	Tue Dec 15 13:49:49 2020 +0100
@@ -91,7 +91,7 @@
 	$message = apply_filters( 'graceful_fail', $message );
 	$message_template = apply_filters( 'graceful_fail_template',
 '<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<html><head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <title>Error!</title>
 <style type="text/css">
@@ -165,7 +165,7 @@
  *
  * @param string $email        Email address to verify.
  * @param bool   $check_domain Deprecated.
- * @return string|bool Either false or the valid email address.
+ * @return string|false Valid email address on success, false on failure.
  */
 function validate_email( $email, $check_domain = true) {
 	_deprecated_function( __FUNCTION__, '3.0.0', 'is_email()' );
@@ -199,7 +199,7 @@
 		return array();
 	}
 
-	if ( $num == 'all' ) {
+	if ( 'all' === $num ) {
 		return array_slice( $blog_list, $start, count( $blog_list ) );
 	} else {
 		return array_slice( $blog_list, $start, $num );
@@ -226,7 +226,7 @@
 		$blog_list = array();
 		foreach ( (array) $blogs as $key => $details ) {
 			$most_active[ $details['blog_id'] ] = $details['postcount'];
-			$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
+			$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!
 		}
 		arsort( $most_active );
 		reset( $most_active );
@@ -274,32 +274,32 @@
 	if ( isset( $_GET['ref'] ) && isset( $_POST['ref'] ) && $_GET['ref'] !== $_POST['ref'] ) {
 		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
 	} elseif ( isset( $_POST['ref'] ) ) {
-		$ref = $_POST[ 'ref' ];
+		$ref = $_POST['ref'];
 	} elseif ( isset( $_GET['ref'] ) ) {
-		$ref = $_GET[ 'ref' ];
+		$ref = $_GET['ref'];
 	}
 
 	if ( $ref ) {
 		$ref = wpmu_admin_redirect_add_updated_param( $ref );
 		wp_redirect( $ref );
-		exit();
+		exit;
 	}
 	if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
 		wp_redirect( $_SERVER['HTTP_REFERER'] );
-		exit();
+		exit;
 	}
 
 	$url = wpmu_admin_redirect_add_updated_param( $url );
 	if ( isset( $_GET['redirect'] ) && isset( $_POST['redirect'] ) && $_GET['redirect'] !== $_POST['redirect'] ) {
 		wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 );
 	} elseif ( isset( $_GET['redirect'] ) ) {
-		if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
+		if ( 's_' === substr( $_GET['redirect'], 0, 2 ) )
 			$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
 	} elseif ( isset( $_POST['redirect'] ) ) {
 		$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
 	}
 	wp_redirect( $url );
-	exit();
+	exit;
 }
 
 /**
@@ -371,10 +371,10 @@
 		if ( $domain != $_SERVER['HTTP_HOST'] ) {
 			$blogname = substr( $domain, 0, strpos( $domain, '.' ) );
 			$url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
-			// we're not installing the main blog
-			if ( $blogname != 'www.' )
+			// We're not installing the main blog.
+			if ( 'www.' !== $blogname )
 				$url .= $blogname . '/';
-		} else { // main blog
+		} else { // Main blog.
 			$url = 'http://' . $domain . $path;
 		}
 	}
@@ -401,14 +401,16 @@
 
 	// Check if the domain has been used already. We should return an error message.
 	if ( domain_exists($domain, $path, $site_id) )
-		return __( '<strong>ERROR</strong>: Site URL already taken.' );
+		return __( '<strong>Error</strong>: Site URL you&#8217;ve entered is already taken.' );
 
-	// Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
-	// Need to get blog_id from wp_blogs, and create new table names.
-	// Must restore table names at the end of function.
+	/*
+	 * Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
+	 * Need to get blog_id from wp_blogs, and create new table names.
+	 * Must restore table names at the end of function.
+	 */
 
 	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
-		return __( '<strong>ERROR</strong>: problem creating site entry.' );
+		return __( '<strong>Error</strong>: There was a problem creating site entry.' );
 
 	switch_to_blog($blog_id);
 	install_blog($blog_id);
@@ -472,10 +474,8 @@
  *     @type int       $limit      Number of sites to limit the query to. Default 100.
  *     @type int       $offset     Exclude the first x sites. Used in combination with the $limit parameter. Default 0.
  * }
- * @return array An empty array if the installation is considered "large" via wp_is_large_network(). Otherwise,
- *               an associative array of site data arrays, each containing the site (network) ID, blog ID,
- *               site domain and path, dates registered and modified, and the language ID. Also, boolean
- *               values for whether the site is public, archived, mature, spam, and/or deleted.
+ * @return array[] An empty array if the installation is considered "large" via wp_is_large_network(). Otherwise,
+ *                 an associative array of WP_Site data as arrays.
  */
 function wp_get_sites( $args = array() ) {
 	_deprecated_function( __FUNCTION__, '4.6.0', 'get_sites()' );
@@ -496,7 +496,7 @@
 
 	$args = wp_parse_args( $args, $defaults );
 
-	// Backwards compatibility
+	// Backward compatibility.
 	if( is_array( $args['network_id'] ) ){
 		$args['network__in'] = $args['network_id'];
 		$args['network_id'] = null;
@@ -596,8 +596,8 @@
  * @since MU (3.0.0)
  * @deprecated 5.1.0
  *
- * @global wpdb     $wpdb
- * @global WP_Roles $wp_roles
+ * @global wpdb     $wpdb     WordPress database abstraction object.
+ * @global WP_Roles $wp_roles WordPress role management object.
  *
  * @param int    $blog_id    The value returned by wp_insert_site().
  * @param string $blog_title The title of the new site.
@@ -607,10 +607,10 @@
 
 	_deprecated_function( __FUNCTION__, '5.1.0' );
 
-	// Cast for security
+	// Cast for security.
 	$blog_id = (int) $blog_id;
 
-	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
+	require_once ABSPATH . 'wp-admin/includes/upgrade.php';
 
 	$suppress = $wpdb->suppress_errors();
 	if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
@@ -620,7 +620,7 @@
 
 	$url = get_blogaddress_by_id( $blog_id );
 
-	// Set everything up
+	// Set everything up.
 	make_db_current_silent( 'blog' );
 	populate_options();
 	populate_roles();
@@ -652,10 +652,10 @@
 	update_option( 'blogname', wp_unslash( $blog_title ) );
 	update_option( 'admin_email', '' );
 
-	// remove all perms
+	// Remove all permissions.
 	$table_prefix = $wpdb->get_blog_prefix();
-	delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
-	delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
+	delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true );   // Delete all.
+	delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // Delete all.
 }
 
 /**
@@ -677,7 +677,7 @@
 
 	_deprecated_function( __FUNCTION__, 'MU' );
 
-	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
+	require_once ABSPATH . 'wp-admin/includes/upgrade.php';
 
 	$suppress = $wpdb->suppress_errors();
 
@@ -685,3 +685,48 @@
 
 	$wpdb->suppress_errors( $suppress );
 }
+
+/**
+ * Update the status of a user in the database.
+ *
+ * Previously used in core to mark a user as spam or "ham" (not spam) in Multisite.
+ *
+ * @since 3.0.0
+ * @deprecated 5.3.0 Use wp_update_user()
+ * @see wp_update_user()
+ *
+ * @global wpdb $wpdb WordPress database abstraction object.
+ *
+ * @param int    $id         The user ID.
+ * @param string $pref       The column in the wp_users table to update the user's status
+ *                           in (presumably user_status, spam, or deleted).
+ * @param int    $value      The new status for the user.
+ * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
+ * @return int   The initially passed $value.
+ */
+function update_user_status( $id, $pref, $value, $deprecated = null ) {
+	global $wpdb;
+
+	_deprecated_function( __FUNCTION__, '5.3.0', 'wp_update_user()' );
+
+	if ( null !== $deprecated ) {
+		_deprecated_argument( __FUNCTION__, '3.0.2' );
+	}
+
+	$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
+
+	$user = new WP_User( $id );
+	clean_user_cache( $user );
+
+	if ( 'spam' === $pref ) {
+		if ( $value == 1 ) {
+			/** This filter is documented in wp-includes/user.php */
+			do_action( 'make_spam_user', $id );
+		} else {
+			/** This filter is documented in wp-includes/user.php */
+			do_action( 'make_ham_user', $id );
+		}
+	}
+
+	return $value;
+}