wp/wp-includes/ms-functions.php
author ymh <ymh.work@gmail.com>
Mon, 08 Sep 2025 19:44:41 +0200
changeset 23 417f20492bf7
parent 22 8c2e4d02f4ef
permissions -rw-r--r--
Update Docker configuration and plugin versions - Upgrade MariaDB from 10.6 to 11 with auto-upgrade support - Add WordPress debug environment variable to FPM container - Update PHP-FPM Dockerfile base image - Update Include Mastodon Feed plugin with bug fixes and improvements - Update Portfolio plugin (v2.58) with latest translations and demo data enhancements - Remove old README.md from Mastodon Feed plugin 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Multisite WordPress API
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Multisite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 * Gets the network's site and user counts.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    13
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    15
 * @return int[] {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    16
 *     Site and user count for the network.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    17
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    18
 *     @type int $blogs Number of sites on the network.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    19
 *     @type int $users Number of users on the network.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    20
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
function get_sitestats() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
	$stats = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
		'blogs' => get_blog_count(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
		'users' => get_user_count(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
	return $stats;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    32
 * Gets one of a user's active blogs.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    34
 * Returns the user's primary blog, if they have one and
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
 * it is active. If it's inactive, function returns another
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
 * active blog of the user. If none are found, the user
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
 * is added as a Subscriber to the Dashboard Blog and that blog
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
 * is returned.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    40
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
 * @param int $user_id The unique ID of the user
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    43
 * @return WP_Site|void The blog object
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
function get_active_blog_for_user( $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
	$blogs = get_blogs_of_user( $user_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    47
	if ( empty( $blogs ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    48
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    49
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    51
	if ( ! is_multisite() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    52
		return $blogs[ get_current_blog_id() ];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    53
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
	$primary_blog = get_user_meta( $user_id, 'primary_blog', true );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    56
	$first_blog   = current( $blogs );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
	if ( false !== $primary_blog ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
		if ( ! isset( $blogs[ $primary_blog ] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
			update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    60
			$primary = get_site( $first_blog->userblog_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
		} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    62
			$primary = get_site( $primary_blog );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
	} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    65
		// TODO: Review this call to add_user_to_blog too - to get here the user must have a role on this blog?
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    66
		$result = add_user_to_blog( $first_blog->userblog_id, $user_id, 'subscriber' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    67
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    68
		if ( ! is_wp_error( $result ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    69
			update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    70
			$primary = $first_blog;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    71
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    74
	if ( ( ! is_object( $primary ) )
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    75
		|| ( '1' === $primary->archived || '1' === $primary->spam || '1' === $primary->deleted )
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    76
	) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    77
		$blogs = get_blogs_of_user( $user_id, true ); // If a user's primary blog is shut down, check their other blogs.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    78
		$ret   = false;
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    79
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
		if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    81
			$current_network_id = get_current_network_id();
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    82
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
			foreach ( (array) $blogs as $blog_id => $blog ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    84
				if ( $blog->site_id !== $current_network_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
					continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    86
				}
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    87
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    88
				$details = get_site( $blog_id );
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    89
				if ( is_object( $details )
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    90
					&& '0' === $details->archived && '0' === $details->spam && '0' === $details->deleted
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    91
				) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    92
					$ret = $details;
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    93
					if ( (int) get_user_meta( $user_id, 'primary_blog', true ) !== $blog_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
						update_user_meta( $user_id, 'primary_blog', $blog_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    95
					}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    96
					if ( ! get_user_meta( $user_id, 'source_domain', true ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    97
						update_user_meta( $user_id, 'source_domain', $details->domain );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    98
					}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
		} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   103
			return;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
		}
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   105
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
		return $ret;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
		return $primary;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   113
 * Gets the number of active sites on the installation.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
 * The count is cached and updated twice daily. This is not a live count.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   117
 * @since MU (3.0.0)
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   118
 * @since 3.7.0 The `$network_id` parameter has been deprecated.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   119
 * @since 4.8.0 The `$network_id` parameter is now being used.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   121
 * @param int|null $network_id ID of the network. Default is the current network.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   122
 * @return int Number of active sites on the network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   124
function get_blog_count( $network_id = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   125
	return get_network_option( $network_id, 'blog_count' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   129
 * Gets a blog post from any site on the network.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   130
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   131
 * This function is similar to get_post(), except that it can retrieve a post
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   132
 * from any site on the network, not just the current site.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   134
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
 * @param int $blog_id ID of the blog.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   137
 * @param int $post_id ID of the post being looked for.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   138
 * @return WP_Post|null WP_Post object on success, null on failure
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
function get_blog_post( $blog_id, $post_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
	switch_to_blog( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
	$post = get_post( $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
	restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
	return $post;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   149
 * Adds a user to a blog, along with specifying the user's role.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   151
 * Use the {@see 'add_user_to_blog'} action to fire an event when users are added to a blog.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   153
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   155
 * @param int    $blog_id ID of the blog the user is being added to.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   156
 * @param int    $user_id ID of the user being added.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   157
 * @param string $role    User role.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   158
 * @return true|WP_Error True on success or a WP_Error object if the user doesn't exist
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   159
 *                       or could not be added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
function add_user_to_blog( $blog_id, $user_id, $role ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   162
	switch_to_blog( $blog_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
	$user = get_userdata( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
	if ( ! $user ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
		restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
		return new WP_Error( 'user_does_not_exist', __( 'The requested user does not exist.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   171
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   172
	 * Filters whether a user should be added to a site.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   173
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   174
	 * @since 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   175
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   176
	 * @param true|WP_Error $retval  True if the user should be added to the site, error
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   177
	 *                               object otherwise.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   178
	 * @param int           $user_id User ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   179
	 * @param string        $role    User role.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   180
	 * @param int           $blog_id Site ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   181
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   182
	$can_add_user = apply_filters( 'can_add_user_to_blog', true, $user_id, $role, $blog_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   183
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   184
	if ( true !== $can_add_user ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   185
		restore_current_blog();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   186
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   187
		if ( is_wp_error( $can_add_user ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   188
			return $can_add_user;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   189
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   190
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   191
		return new WP_Error( 'user_cannot_be_added', __( 'User cannot be added to this site.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   192
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   193
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   194
	if ( ! get_user_meta( $user_id, 'primary_blog', true ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   195
		update_user_meta( $user_id, 'primary_blog', $blog_id );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   196
		$site = get_site( $blog_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   197
		update_user_meta( $user_id, 'source_domain', $site->domain );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   200
	$user->set_role( $role );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   203
	 * Fires immediately after a user is added to a site.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   205
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   207
	 * @param int    $user_id User ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   208
	 * @param string $role    User role.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
	 * @param int    $blog_id Blog ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   211
	do_action( 'add_user_to_blog', $user_id, $role, $blog_id );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   212
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   213
	clean_user_cache( $user_id );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   214
	wp_cache_delete( $blog_id . '_user_count', 'blog-details' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   215
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
	restore_current_blog();
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   217
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   222
 * Removes a user from a blog.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   224
 * Use the {@see 'remove_user_from_blog'} action to fire an event when
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
 * users are removed from a blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   227
 * Accepts an optional `$reassign` parameter, if you want to
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
 * reassign the user's blog posts to another user upon removal.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   230
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   231
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   232
 * @global wpdb $wpdb WordPress database abstraction object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   234
 * @param int $user_id  ID of the user being removed.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   235
 * @param int $blog_id  Optional. ID of the blog the user is being removed from. Default 0.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   236
 * @param int $reassign Optional. ID of the user to whom to reassign posts. Default 0.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   237
 * @return true|WP_Error True on success or a WP_Error object if the user doesn't exist.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   239
function remove_user_from_blog( $user_id, $blog_id = 0, $reassign = 0 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
	global $wpdb;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   241
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   242
	$user_id = (int) $user_id;
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   243
	$blog_id = (int) $blog_id;
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   244
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   245
	switch_to_blog( $blog_id );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   246
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   247
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   248
	 * Fires before a user is removed from a site.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   249
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   250
	 * @since MU (3.0.0)
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   251
	 * @since 5.4.0 Added the `$reassign` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   253
	 * @param int $user_id  ID of the user being removed.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   254
	 * @param int $blog_id  ID of the blog the user is being removed from.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   255
	 * @param int $reassign ID of the user to whom to reassign posts.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   256
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   257
	do_action( 'remove_user_from_blog', $user_id, $blog_id, $reassign );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   259
	/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   260
	 * If being removed from the primary blog, set a new primary
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   261
	 * if the user is assigned to multiple blogs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   262
	 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   263
	$primary_blog = (int) get_user_meta( $user_id, 'primary_blog', true );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   264
	if ( $primary_blog === $blog_id ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   265
		$new_id     = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
		$new_domain = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   267
		$blogs      = get_blogs_of_user( $user_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
		foreach ( (array) $blogs as $blog ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   269
			if ( $blog->userblog_id === $blog_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   271
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   272
			$new_id     = $blog->userblog_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
			$new_domain = $blog->domain;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   277
		update_user_meta( $user_id, 'primary_blog', $new_id );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   278
		update_user_meta( $user_id, 'source_domain', $new_domain );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
	$user = get_userdata( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
	if ( ! $user ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
		restore_current_blog();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   284
		return new WP_Error( 'user_does_not_exist', __( 'That user does not exist.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
	$user->remove_all_caps();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   289
	$blogs = get_blogs_of_user( $user_id );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   290
	if ( count( $blogs ) === 0 ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   291
		update_user_meta( $user_id, 'primary_blog', '' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   292
		update_user_meta( $user_id, 'source_domain', '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   295
	if ( $reassign ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
		$reassign = (int) $reassign;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   297
		$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   298
		$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $user_id ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   299
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   300
		if ( ! empty( $post_ids ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   301
			$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   302
			array_walk( $post_ids, 'clean_post_cache' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   303
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   304
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   305
		if ( ! empty( $link_ids ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   306
			$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   307
			array_walk( $link_ids, 'clean_bookmark_cache' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   308
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   311
	clean_user_cache( $user_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
	restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   318
 * Gets the permalink for a post on another blog.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   320
 * @since MU (3.0.0) 1.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
 * @param int $blog_id ID of the source blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
 * @param int $post_id ID of the desired post.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   324
 * @return string The post's permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
function get_blog_permalink( $blog_id, $post_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
	switch_to_blog( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
	$link = get_permalink( $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
	restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
	return $link;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   335
 * Gets a blog's numeric ID from its URL.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
 * On a subdirectory installation like example.com/blog1/,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
 * $domain will be the root 'example.com' and $path the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
 * subdirectory '/blog1/'. With subdomains like blog1.example.com,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
 * $domain is 'blog1.example.com' and $path is '/'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   342
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   343
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   344
 * @global wpdb $wpdb WordPress database abstraction object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   346
 * @param string $domain Website domain.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   347
 * @param string $path   Optional. Not required for subdomain installations. Default '/'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   348
 * @return int 0 if no blog found, otherwise the ID of the matching blog.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
function get_blog_id_from_url( $domain, $path = '/' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
	$domain = strtolower( $domain );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   352
	$path   = strtolower( $path );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   353
	$id     = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   355
	if ( -1 === $id ) { // Blog does not exist.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
		return 0;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   357
	} elseif ( $id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
		return (int) $id;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   359
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   361
	$args   = array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   362
		'domain'                 => $domain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   363
		'path'                   => $path,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   364
		'fields'                 => 'ids',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   365
		'number'                 => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   366
		'update_site_meta_cache' => false,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   367
	);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   368
	$result = get_sites( $args );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   369
	$id     = array_shift( $result );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
	if ( ! $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
		wp_cache_set( md5( $domain . $path ), -1, 'blog-id-cache' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
		return 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
	wp_cache_set( md5( $domain . $path ), $id, 'blog-id-cache' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
	return $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   381
//
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   382
// Admin functions.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   383
//
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
 * Checks an email address against a list of banned domains.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
 * This function checks against the Banned Email Domains list
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
 * at wp-admin/network/settings.php. The check is only run on
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
 * self-registrations; user creation at wp-admin/network/users.php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
 * bypasses this check.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   393
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
 * @param string $user_email The email provided by the user at registration.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   396
 * @return bool True when the email address is banned, false otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
function is_email_address_unsafe( $user_email ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
	$banned_names = get_site_option( 'banned_email_domains' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   400
	if ( $banned_names && ! is_array( $banned_names ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
		$banned_names = explode( "\n", $banned_names );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   402
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
	$is_email_address_unsafe = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   406
	if ( $banned_names && is_array( $banned_names ) && false !== strpos( $user_email, '@', 1 ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   407
		$banned_names     = array_map( 'strtolower', $banned_names );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
		$normalized_email = strtolower( $user_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
		list( $email_local_part, $email_domain ) = explode( '@', $normalized_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
		foreach ( $banned_names as $banned_domain ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   413
			if ( ! $banned_domain ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   415
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   417
			if ( $email_domain === $banned_domain ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
				$is_email_address_unsafe = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   422
			if ( str_ends_with( $normalized_email, ".$banned_domain" ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
				$is_email_address_unsafe = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   429
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   430
	 * Filters whether an email address is unsafe.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   431
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   432
	 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   433
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   434
	 * @param bool   $is_email_address_unsafe Whether the email address is "unsafe". Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   435
	 * @param string $user_email              User email address.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   436
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
	return apply_filters( 'is_email_address_unsafe', $is_email_address_unsafe, $user_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   441
 * Sanitizes and validates data required for a user sign-up.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   443
 * Verifies the validity and uniqueness of user names and user email addresses,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   444
 * and checks email addresses against allowed and disallowed domains provided by
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   445
 * administrators.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   447
 * The {@see 'wpmu_validate_user_signup'} hook provides an easy way to modify the sign-up
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   448
 * process. The value $result, which is passed to the hook, contains both the user-provided
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   449
 * info and the error messages created by the function. {@see 'wpmu_validate_user_signup'}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   450
 * allows you to process the data in any way you'd like, and unset the relevant errors if
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   451
 * necessary.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   453
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   454
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   455
 * @global wpdb $wpdb WordPress database abstraction object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   457
 * @param string $user_name  The login name provided by the user.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
 * @param string $user_email The email provided by the user.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   459
 * @return array {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   460
 *     The array of user name, email, and the error messages.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   461
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   462
 *     @type string   $user_name     Sanitized and unique username.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   463
 *     @type string   $orig_username Original username.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   464
 *     @type string   $user_email    User email address.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   465
 *     @type WP_Error $errors        WP_Error object containing any errors found.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   466
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   468
function wpmu_validate_user_signup( $user_name, $user_email ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
	$errors = new WP_Error();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
	$orig_username = $user_name;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   474
	$user_name     = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   476
	if ( $user_name !== $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   477
		$errors->add( 'user_name', __( 'Usernames can only contain lowercase letters (a-z) and numbers.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
		$user_name = $orig_username;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
	$user_email = sanitize_email( $user_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   483
	if ( empty( $user_name ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   484
		$errors->add( 'user_name', __( 'Please enter a username.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   485
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
	$illegal_names = get_site_option( 'illegal_names' );
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   488
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   489
	if ( ! is_array( $illegal_names ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   490
		$illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
		add_site_option( 'illegal_names', $illegal_names );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
	}
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   493
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   494
	if ( in_array( $user_name, $illegal_names, true ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   495
		$errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   496
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   497
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   498
	/** This filter is documented in wp-includes/user.php */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   499
	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   501
	if ( in_array( strtolower( $user_name ), array_map( 'strtolower', $illegal_logins ), true ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   502
		$errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   503
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   504
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   505
	if ( ! is_email( $user_email ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   506
		$errors->add( 'user_email', __( 'Please enter a valid email address.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   507
	} elseif ( is_email_address_unsafe( $user_email ) ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   508
		$errors->add( 'user_email', __( 'You cannot use that email address to signup. There are problems with them blocking some emails from WordPress. Please use another email provider.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   509
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   511
	if ( strlen( $user_name ) < 4 ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   512
		$errors->add( 'user_name', __( 'Username must be at least 4 characters.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   513
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   515
	if ( strlen( $user_name ) > 60 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   516
		$errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   517
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   519
	// All numeric?
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   520
	if ( preg_match( '/^[0-9]*$/', $user_name ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   521
		$errors->add( 'user_name', __( 'Sorry, usernames must have letters too!' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   522
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
	$limited_email_domains = get_site_option( 'limited_email_domains' );
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   525
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   526
	if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   527
		$limited_email_domains = array_map( 'strtolower', $limited_email_domains );
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   528
		$email_domain          = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   529
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   530
		if ( ! in_array( $email_domain, $limited_email_domains, true ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   531
			$errors->add( 'user_email', __( 'Sorry, that email address is not allowed!' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   532
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
	// Check if the username has been used already.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   536
	if ( username_exists( $user_name ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
		$errors->add( 'user_name', __( 'Sorry, that username already exists!' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   538
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
	// Check if the email address has been used already.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   541
	if ( email_exists( $user_email ) ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   542
		$errors->add(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   543
			'user_email',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   544
			sprintf(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   545
				/* translators: %s: Link to the login page. */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   546
				__( '<strong>Error:</strong> This email address is already registered. <a href="%s">Log in</a> with this address or choose another one.' ),
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   547
				wp_login_url()
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   548
			)
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   549
		);
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   550
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
	// Has someone already signed up for this username?
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   553
	$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name ) );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   554
	if ( $signup instanceof stdClass ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   555
		$registered_at = mysql2date( 'U', $signup->registered );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   556
		$now           = time();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   557
		$diff          = $now - $registered_at;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
		// If registered more than two days ago, cancel registration and let this signup go through.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   559
		if ( $diff > 2 * DAY_IN_SECONDS ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
			$wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   561
		} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   562
			$errors->add( 'user_name', __( 'That username is currently reserved but may be available in a couple of days.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   563
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   566
	$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email ) );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   567
	if ( $signup instanceof stdClass ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   568
		$diff = time() - mysql2date( 'U', $signup->registered );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
		// If registered more than two days ago, cancel registration and let this signup go through.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   570
		if ( $diff > 2 * DAY_IN_SECONDS ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
			$wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   572
		} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   573
			$errors->add( 'user_email', __( 'That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   574
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   577
	$result = array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   578
		'user_name'     => $user_name,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   579
		'orig_username' => $orig_username,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   580
		'user_email'    => $user_email,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   581
		'errors'        => $errors,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   582
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   584
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   585
	 * Filters the validated user registration details.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   586
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   587
	 * This does not allow you to override the username or email of the user during
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   588
	 * registration. The values are solely used for validation and error handling.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   589
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   590
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   591
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   592
	 * @param array $result {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   593
	 *     The array of user name, email, and the error messages.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   594
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   595
	 *     @type string   $user_name     Sanitized and unique username.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
	 *     @type string   $orig_username Original username.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   597
	 *     @type string   $user_email    User email address.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   598
	 *     @type WP_Error $errors        WP_Error object containing any errors found.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   599
	 * }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   600
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
	return apply_filters( 'wpmu_validate_user_signup', $result );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   604
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
 * Processes new site registrations.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
 * Checks the data provided by the user during blog signup. Verifies
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
 * the validity and uniqueness of blog paths and domains.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
 * This function prevents the current user from registering a new site
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
 * with a blogname equivalent to another user's login name. Passing the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
 * $user parameter to the function, where $user is the other user, is
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   613
 * effectively an override of this limitation.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   615
 * Filter {@see 'wpmu_validate_blog_signup'} if you want to modify
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   616
 * the way that WordPress validates new site signups.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   618
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   620
 * @global wpdb   $wpdb   WordPress database abstraction object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   621
 * @global string $domain
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   622
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   623
 * @param string         $blogname   The site name provided by the user. Must be unique.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   624
 * @param string         $blog_title The site title provided by the user.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   625
 * @param WP_User|string $user       Optional. The user object to check against the new site name.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   626
 *                                   Default empty string.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   627
 * @return array {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   628
 *     Array of domain, path, site name, site title, user and error messages.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   629
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   630
 *     @type string         $domain     Domain for the site.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   631
 *     @type string         $path       Path for the site. Used in subdirectory installations.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   632
 *     @type string         $blogname   The unique site name (slug).
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   633
 *     @type string         $blog_title Blog title.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   634
 *     @type string|WP_User $user       By default, an empty string. A user object if provided.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   635
 *     @type WP_Error       $errors     WP_Error containing any errors found.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   636
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   638
function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   639
	global $wpdb, $domain;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   641
	$current_network = get_network();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   642
	$base            = $current_network->path;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
	$blog_title = strip_tags( $blog_title );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   646
	$errors        = new WP_Error();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
	$illegal_names = get_site_option( 'illegal_names' );
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   648
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   649
	if ( ! is_array( $illegal_names ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
		$illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
		add_site_option( 'illegal_names', $illegal_names );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   652
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   654
	/*
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   655
	 * On sub dir installations, some names are so illegal, only a filter can
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   656
	 * spring them from jail.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   657
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   658
	if ( ! is_subdomain_install() ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   659
		$illegal_names = array_merge( $illegal_names, get_subdirectory_reserved_names() );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   660
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   662
	if ( empty( $blogname ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   663
		$errors->add( 'blogname', __( 'Please enter a site name.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   664
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   666
	if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   667
		$errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   668
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   670
	if ( in_array( $blogname, $illegal_names, true ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   671
		$errors->add( 'blogname', __( 'That name is not allowed.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   672
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   674
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   675
	 * Filters the minimum site name length required when validating a site signup.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   676
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   677
	 * @since 4.8.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   678
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   679
	 * @param int $length The minimum site name length. Default 4.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   680
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   681
	$minimum_site_name_length = apply_filters( 'minimum_site_name_length', 4 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   683
	if ( strlen( $blogname ) < $minimum_site_name_length ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   684
		/* translators: %s: Minimum site name length. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   685
		$errors->add( 'blogname', sprintf( _n( 'Site name must be at least %s character.', 'Site name must be at least %s characters.', $minimum_site_name_length ), number_format_i18n( $minimum_site_name_length ) ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   686
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   688
	// Do not allow users to create a site that conflicts with a page on the main blog.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   689
	if ( ! is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( 'SELECT post_name FROM ' . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
		$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   691
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   693
	// All numeric?
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   694
	if ( preg_match( '/^[0-9]*$/', $blogname ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   695
		$errors->add( 'blogname', __( 'Sorry, site names must have letters too!' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   696
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   698
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   699
	 * Filters the new site name during registration.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   700
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   701
	 * The name is the site's subdomain or the site's subdirectory
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   702
	 * path depending on the network settings.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   703
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   704
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   705
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   706
	 * @param string $blogname Site name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   707
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
	$blogname = apply_filters( 'newblogname', $blogname );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   710
	$blog_title = wp_unslash( $blog_title );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   712
	if ( empty( $blog_title ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   713
		$errors->add( 'blog_title', __( 'Please enter a site title.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   714
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
	// Check if the domain/path has been used already.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
	if ( is_subdomain_install() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
		$mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   719
		$path     = $base;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
	} else {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   721
		$mydomain = $domain;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   722
		$path     = $base . $blogname . '/';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
	}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   724
	if ( domain_exists( $mydomain, $path, $current_network->id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
		$errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   726
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   728
	/*
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   729
	 * Do not allow users to create a site that matches an existing user's login name,
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   730
	 * unless it's the user's own username.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   731
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   732
	if ( username_exists( $blogname ) ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   733
		if ( ! is_object( $user ) || ( is_object( $user ) && $user->user_login !== $blogname ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
			$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   735
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   738
	/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   739
	 * Has someone already signed up for this domain?
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   740
	 * TODO: Check email too?
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   741
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   742
	$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   743
	if ( $signup instanceof stdClass ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   744
		$diff = time() - mysql2date( 'U', $signup->registered );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
		// If registered more than two days ago, cancel registration and let this signup go through.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   746
		if ( $diff > 2 * DAY_IN_SECONDS ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   747
			$wpdb->delete(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   748
				$wpdb->signups,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   749
				array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   750
					'domain' => $mydomain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   751
					'path'   => $path,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   752
				)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   753
			);
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   754
		} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   755
			$errors->add( 'blogname', __( 'That site is currently reserved but may be available in a couple days.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   756
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   759
	$result = array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   760
		'domain'     => $mydomain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   761
		'path'       => $path,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   762
		'blogname'   => $blogname,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   763
		'blog_title' => $blog_title,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   764
		'user'       => $user,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   765
		'errors'     => $errors,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   766
	);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   767
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   768
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   769
	 * Filters site details and error messages following registration.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   770
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   771
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   772
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   773
	 * @param array $result {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   774
	 *     Array of domain, path, site name, site title, user and error messages.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   775
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   776
	 *     @type string         $domain     Domain for the site.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   777
	 *     @type string         $path       Path for the site. Used in subdirectory installations.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   778
	 *     @type string         $blogname   The unique site name (slug).
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   779
	 *     @type string         $blog_title Site title.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   780
	 *     @type string|WP_User $user       By default, an empty string. A user object if provided.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   781
	 *     @type WP_Error       $errors     WP_Error containing any errors found.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   782
	 * }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   783
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   784
	return apply_filters( 'wpmu_validate_blog_signup', $result );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   788
 * Records site signup information for future activation.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   790
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   791
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   792
 * @global wpdb $wpdb WordPress database abstraction object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   794
 * @param string $domain     The requested domain.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   795
 * @param string $path       The requested path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   796
 * @param string $title      The requested site title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   797
 * @param string $user       The user's requested login name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
 * @param string $user_email The user's email address.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   799
 * @param array  $meta       Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   801
function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   804
	$key = substr( md5( time() . wp_rand() . $domain ), 0, 16 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   805
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   806
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   807
	 * Filters the metadata for a site signup.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   808
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   809
	 * The metadata will be serialized prior to storing it in the database.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   810
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   811
	 * @since 4.8.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   812
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   813
	 * @param array  $meta       Signup meta data. Default empty array.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   814
	 * @param string $domain     The requested domain.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   815
	 * @param string $path       The requested path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   816
	 * @param string $title      The requested site title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   817
	 * @param string $user       The user's requested login name.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   818
	 * @param string $user_email The user's email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   819
	 * @param string $key        The user's activation key.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   820
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   821
	$meta = apply_filters( 'signup_site_meta', $meta, $domain, $path, $title, $user, $user_email, $key );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   823
	$wpdb->insert(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   824
		$wpdb->signups,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   825
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   826
			'domain'         => $domain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   827
			'path'           => $path,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   828
			'title'          => $title,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   829
			'user_login'     => $user,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   830
			'user_email'     => $user_email,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   831
			'registered'     => current_time( 'mysql', true ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   832
			'activation_key' => $key,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   833
			'meta'           => serialize( $meta ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   834
		)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   835
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   836
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   837
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   838
	 * Fires after site signup information has been written to the database.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   839
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   840
	 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   841
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   842
	 * @param string $domain     The requested domain.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   843
	 * @param string $path       The requested path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   844
	 * @param string $title      The requested site title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   845
	 * @param string $user       The user's requested login name.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   846
	 * @param string $user_email The user's email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   847
	 * @param string $key        The user's activation key.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   848
	 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   849
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   850
	do_action( 'after_signup_site', $domain, $path, $title, $user, $user_email, $key, $meta );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   852
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   853
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   854
 * Records user signup information for future activation.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   856
 * This function is used when user registration is open but
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
 * new site registration is not.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   858
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   859
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   860
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   861
 * @global wpdb $wpdb WordPress database abstraction object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   862
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   863
 * @param string $user       The user's requested login name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
 * @param string $user_email The user's email address.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   865
 * @param array  $meta       Optional. Signup meta data. Default empty array.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   867
function wpmu_signup_user( $user, $user_email, $meta = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   870
	// Format data.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   871
	$user       = preg_replace( '/\s+/', '', sanitize_user( $user, true ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   872
	$user_email = sanitize_email( $user_email );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   873
	$key        = substr( md5( time() . wp_rand() . $user_email ), 0, 16 );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   874
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   875
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   876
	 * Filters the metadata for a user signup.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   877
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   878
	 * The metadata will be serialized prior to storing it in the database.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   879
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   880
	 * @since 4.8.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   881
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   882
	 * @param array  $meta       Signup meta data. Default empty array.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   883
	 * @param string $user       The user's requested login name.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   884
	 * @param string $user_email The user's email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   885
	 * @param string $key        The user's activation key.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   886
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   887
	$meta = apply_filters( 'signup_user_meta', $meta, $user, $user_email, $key );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   888
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   889
	$wpdb->insert(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   890
		$wpdb->signups,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   891
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   892
			'domain'         => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   893
			'path'           => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   894
			'title'          => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   895
			'user_login'     => $user,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   896
			'user_email'     => $user_email,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   897
			'registered'     => current_time( 'mysql', true ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   898
			'activation_key' => $key,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   899
			'meta'           => serialize( $meta ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   900
		)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   901
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   903
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   904
	 * Fires after a user's signup information has been written to the database.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   905
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   906
	 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   907
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   908
	 * @param string $user       The user's requested login name.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   909
	 * @param string $user_email The user's email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   910
	 * @param string $key        The user's activation key.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   911
	 * @param array  $meta       Signup meta data. Default empty array.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   912
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   913
	do_action( 'after_signup_user', $user, $user_email, $key, $meta );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   914
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   915
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   916
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   917
 * Sends a confirmation request email to a user when they sign up for a new site. The new site will not become active
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   918
 * until the confirmation link is clicked.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
 * This is the notification function used when site registration
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
 * is enabled.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   923
 * Filter {@see 'wpmu_signup_blog_notification'} to bypass this function or
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
 * replace it with your own notification behavior.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   926
 * Filter {@see 'wpmu_signup_blog_notification_email'} and
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   927
 * {@see 'wpmu_signup_blog_notification_subject'} to change the content
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   928
 * and subject line of the email sent to newly registered users.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   929
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   930
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   932
 * @param string $domain     The new blog domain.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   933
 * @param string $path       The new blog path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   934
 * @param string $title      The site title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   935
 * @param string $user_login The user's login name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
 * @param string $user_email The user's email address.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   937
 * @param string $key        The activation key created in wpmu_signup_blog().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   938
 * @param array  $meta       Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
 * @return bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   941
function wpmu_signup_blog_notification(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   942
	$domain,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   943
	$path,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   944
	$title,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   945
	$user_login,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   946
	$user_email,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   947
	#[\SensitiveParameter]
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   948
	$key,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   949
	$meta = array()
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   950
) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   951
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   952
	 * Filters whether to bypass the new site email notification.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   953
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   954
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   955
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   956
	 * @param string|false $domain     Site domain, or false to prevent the email from sending.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   957
	 * @param string       $path       Site path.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   958
	 * @param string       $title      Site title.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   959
	 * @param string       $user_login User login name.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   960
	 * @param string       $user_email User email address.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   961
	 * @param string       $key        Activation key created in wpmu_signup_blog().
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   962
	 * @param array        $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   963
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   964
	if ( ! apply_filters( 'wpmu_signup_blog_notification', $domain, $path, $title, $user_login, $user_email, $key, $meta ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   965
		return false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   966
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
	// Send email with activation link.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   969
	if ( ! is_subdomain_install() || get_current_network_id() !== 1 ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   970
		$activate_url = network_site_url( "wp-activate.php?key=$key" );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   971
	} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   972
		$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo Use *_url() API.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   973
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   975
	$activate_url = esc_url( $activate_url );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   976
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   977
	$admin_email = get_site_option( 'admin_email' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   978
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   979
	if ( '' === $admin_email ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   980
		$admin_email = 'support@' . wp_parse_url( network_home_url(), PHP_URL_HOST );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   981
	}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   982
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   983
	$from_name       = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   984
	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   985
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   986
	$user            = get_user_by( 'login', $user_login );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   987
	$switched_locale = $user && switch_to_user_locale( $user->ID );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   988
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   989
	$message = sprintf(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   990
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   991
		 * Filters the message content of the new blog notification email.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   992
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   993
		 * Content should be formatted for transmission via wp_mail().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   994
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   995
		 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   996
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   997
		 * @param string $content    Content of the notification email.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   998
		 * @param string $domain     Site domain.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   999
		 * @param string $path       Site path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1000
		 * @param string $title      Site title.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1001
		 * @param string $user_login User login name.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1002
		 * @param string $user_email User email address.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1003
		 * @param string $key        Activation key created in wpmu_signup_blog().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1004
		 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1005
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1006
		apply_filters(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1007
			'wpmu_signup_blog_notification_email',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1008
			/* translators: New site notification email. 1: Activation URL, 2: New site URL. */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1009
			__( "To activate your site, please click the following link:\n\n%1\$s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%2\$s" ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1010
			$domain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1011
			$path,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1012
			$title,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1013
			$user_login,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1014
			$user_email,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1015
			$key,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1016
			$meta
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
		),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
		$activate_url,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
		esc_url( "http://{$domain}{$path}" ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
		$key
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
	);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1022
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
	$subject = sprintf(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1024
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1025
		 * Filters the subject of the new blog notification email.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1026
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1027
		 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1028
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1029
		 * @param string $subject    Subject of the notification email.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1030
		 * @param string $domain     Site domain.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1031
		 * @param string $path       Site path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1032
		 * @param string $title      Site title.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1033
		 * @param string $user_login User login name.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1034
		 * @param string $user_email User email address.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1035
		 * @param string $key        Activation key created in wpmu_signup_blog().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1036
		 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1037
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1038
		apply_filters(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1039
			'wpmu_signup_blog_notification_subject',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1040
			/* translators: New site notification email subject. 1: Network title, 2: New site URL. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1041
			_x( '[%1$s] Activate %2$s', 'New site notification email subject' ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1042
			$domain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1043
			$path,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1044
			$title,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1045
			$user_login,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1046
			$user_email,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1047
			$key,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1048
			$meta
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1049
		),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
		$from_name,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1051
		esc_url( 'http://' . $domain . $path )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1052
	);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1053
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1054
	wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1055
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1056
	if ( $switched_locale ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1057
		restore_previous_locale();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1058
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1059
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1060
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1061
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1063
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1064
 * Sends a confirmation request email to a user when they sign up for a new user account (without signing up for a site
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1065
 * at the same time). The user account will not become active until the confirmation link is clicked.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1066
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1067
 * This is the notification function used when no new site has
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1068
 * been requested.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1069
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1070
 * Filter {@see 'wpmu_signup_user_notification'} to bypass this function or
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
 * replace it with your own notification behavior.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1073
 * Filter {@see 'wpmu_signup_user_notification_email'} and
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1074
 * {@see 'wpmu_signup_user_notification_subject'} to change the content
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
 * and subject line of the email sent to newly registered users.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1077
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1079
 * @param string $user_login The user's login name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
 * @param string $user_email The user's email address.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1081
 * @param string $key        The activation key created in wpmu_signup_user()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1082
 * @param array  $meta       Optional. Signup meta data. Default empty array.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1083
 * @return bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1084
 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1085
function wpmu_signup_user_notification(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1086
	$user_login,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1087
	$user_email,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1088
	#[\SensitiveParameter]
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1089
	$key,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1090
	$meta = array()
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1091
) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1092
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1093
	 * Filters whether to bypass the email notification for new user sign-up.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1094
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1095
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1096
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1097
	 * @param string $user_login User login name.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1098
	 * @param string $user_email User email address.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1099
	 * @param string $key        Activation key created in wpmu_signup_user().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1100
	 * @param array  $meta       Signup meta data. Default empty array.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1101
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1102
	if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1104
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1106
	$user            = get_user_by( 'login', $user_login );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1107
	$switched_locale = $user && switch_to_user_locale( $user->ID );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1108
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1109
	// Send email with activation link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
	$admin_email = get_site_option( 'admin_email' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1111
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1112
	if ( '' === $admin_email ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1113
		$admin_email = 'support@' . wp_parse_url( network_home_url(), PHP_URL_HOST );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1114
	}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1115
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1116
	$from_name       = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1117
	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1118
	$message         = sprintf(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1119
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1120
		 * Filters the content of the notification email for new user sign-up.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1121
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1122
		 * Content should be formatted for transmission via wp_mail().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1123
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1124
		 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1125
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1126
		 * @param string $content    Content of the notification email.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1127
		 * @param string $user_login User login name.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1128
		 * @param string $user_email User email address.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1129
		 * @param string $key        Activation key created in wpmu_signup_user().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1130
		 * @param array  $meta       Signup meta data. Default empty array.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1131
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1132
		apply_filters(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1133
			'wpmu_signup_user_notification_email',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1134
			/* translators: New user notification email. %s: Activation URL. */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1135
			__( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1136
			$user_login,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1137
			$user_email,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1138
			$key,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1139
			$meta
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1140
		),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1141
		site_url( "wp-activate.php?key=$key" )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1142
	);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1143
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1144
	$subject = sprintf(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1145
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1146
		 * Filters the subject of the notification email of new user signup.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1147
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1148
		 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1149
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1150
		 * @param string $subject    Subject of the notification email.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1151
		 * @param string $user_login User login name.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1152
		 * @param string $user_email User email address.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1153
		 * @param string $key        Activation key created in wpmu_signup_user().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1154
		 * @param array  $meta       Signup meta data. Default empty array.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1155
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1156
		apply_filters(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1157
			'wpmu_signup_user_notification_subject',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1158
			/* translators: New user notification email subject. 1: Network title, 2: New user login. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1159
			_x( '[%1$s] Activate %2$s', 'New user notification email subject' ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1160
			$user_login,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1161
			$user_email,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1162
			$key,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1163
			$meta
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1164
		),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1165
		$from_name,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1166
		$user_login
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1167
	);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1168
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1169
	wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1170
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1171
	if ( $switched_locale ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1172
		restore_previous_locale();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1173
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1174
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1175
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1176
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1177
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1178
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1179
 * Activates a signup.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1181
 * Hook to {@see 'wpmu_activate_user'} or {@see 'wpmu_activate_blog'} for events
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1182
 * that should happen only when users or sites are self-created (since
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1183
 * those actions are not called when users and sites are created
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1184
 * by a Super Admin).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1186
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1187
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1188
 * @global wpdb $wpdb WordPress database abstraction object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1189
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1190
 * @param string $key The activation key provided to the user.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1191
 * @return array|WP_Error An array containing information about the activated user and/or blog.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1192
 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1193
function wpmu_activate_signup(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1194
	#[\SensitiveParameter]
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1195
	$key
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1196
) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1197
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1198
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1199
	$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1200
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1201
	if ( empty( $signup ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1202
		return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1203
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1204
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1205
	if ( $signup->active ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1206
		if ( empty( $signup->domain ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1207
			return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1208
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1209
			return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1210
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1211
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1212
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1213
	$meta     = maybe_unserialize( $signup->meta );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1214
	$password = wp_generate_password( 12, false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1215
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1216
	$user_id = username_exists( $signup->user_login );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1217
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1218
	if ( ! $user_id ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1219
		$user_id = wpmu_create_user( $signup->user_login, $password, $signup->user_email );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1220
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1221
		$user_already_exists = true;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1222
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1223
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1224
	if ( ! $user_id ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1225
		return new WP_Error( 'create_user', __( 'Could not create user' ), $signup );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1226
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1227
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1228
	$now = current_time( 'mysql', true );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1229
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1230
	if ( empty( $signup->domain ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1231
		$wpdb->update(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1232
			$wpdb->signups,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1233
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1234
				'active'    => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1235
				'activated' => $now,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1236
			),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1237
			array( 'activation_key' => $key )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1238
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1239
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1240
		if ( isset( $user_already_exists ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1241
			return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1242
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1243
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1244
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1245
		 * Fires immediately after a new user is activated.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1246
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1247
		 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1248
		 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1249
		 * @param int    $user_id  User ID.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1250
		 * @param string $password User password.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1251
		 * @param array  $meta     Signup meta data.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1252
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1253
		do_action( 'wpmu_activate_user', $user_id, $password, $meta );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1254
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1255
		return array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1256
			'user_id'  => $user_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1257
			'password' => $password,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1258
			'meta'     => $meta,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1259
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1260
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1262
	$blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id, $meta, get_current_network_id() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1263
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1264
	// TODO: What to do if we create a user but cannot create a blog?
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1265
	if ( is_wp_error( $blog_id ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1266
		/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1267
		 * If blog is taken, that means a previous attempt to activate this blog
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1268
		 * failed in between creating the blog and setting the activation flag.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1269
		 * Let's just set the active flag and instruct the user to reset their password.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1270
		 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1271
		if ( 'blog_taken' === $blog_id->get_error_code() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1272
			$blog_id->add_data( $signup );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1273
			$wpdb->update(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1274
				$wpdb->signups,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1275
				array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1276
					'active'    => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1277
					'activated' => $now,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1278
				),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1279
				array( 'activation_key' => $key )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1280
			);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1281
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1282
		return $blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1283
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1284
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1285
	$wpdb->update(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1286
		$wpdb->signups,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1287
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1288
			'active'    => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1289
			'activated' => $now,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1290
		),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1291
		array( 'activation_key' => $key )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1292
	);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1293
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1294
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1295
	 * Fires immediately after a site is activated.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1296
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1297
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1298
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1299
	 * @param int    $blog_id       Blog ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1300
	 * @param int    $user_id       User ID.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1301
	 * @param string $password      User password.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1302
	 * @param string $signup_title  Site title.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1303
	 * @param array  $meta          Signup meta data. By default, contains the requested privacy setting and lang_id.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1304
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1305
	do_action( 'wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1306
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1307
	return array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1308
		'blog_id'  => $blog_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1309
		'user_id'  => $user_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1310
		'password' => $password,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1311
		'title'    => $signup->title,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1312
		'meta'     => $meta,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1313
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1314
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1315
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1316
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1317
 * Deletes an associated signup entry when a user is deleted from the database.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1318
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1319
 * @since 5.5.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1320
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1321
 * @global wpdb $wpdb WordPress database abstraction object.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1322
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1323
 * @param int      $id       ID of the user to delete.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1324
 * @param int|null $reassign ID of the user to reassign posts and links to.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1325
 * @param WP_User  $user     User object.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1326
 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1327
function wp_delete_signup_on_user_delete( $id, $reassign, $user ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1328
	global $wpdb;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1329
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1330
	$wpdb->delete( $wpdb->signups, array( 'user_login' => $user->user_login ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1331
}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1332
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1333
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1334
 * Creates a user.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1335
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1336
 * This function runs when a user self-registers as well as when
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1337
 * a Super Admin creates a new user. Hook to {@see 'wpmu_new_user'} for events
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1338
 * that should affect all new users, but only on Multisite (otherwise
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1339
 * use {@see 'user_register'}).
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1340
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1341
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1342
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1343
 * @param string $user_name The new user's login name.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1344
 * @param string $password  The new user's password.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1345
 * @param string $email     The new user's email address.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1346
 * @return int|false Returns false on failure, or int $user_id on success.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1347
 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1348
function wpmu_create_user(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1349
	$user_name,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1350
	#[\SensitiveParameter]
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1351
	$password,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1352
	$email
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1353
) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1354
	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1355
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1356
	$user_id = wp_create_user( $user_name, $password, $email );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1357
	if ( is_wp_error( $user_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1358
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1359
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
	// Newly created users have no roles or caps until they are added to a blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1362
	delete_user_option( $user_id, 'capabilities' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1363
	delete_user_option( $user_id, 'user_level' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1364
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1365
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1366
	 * Fires immediately after a new user is created.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1367
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1368
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1369
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1370
	 * @param int $user_id User ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1371
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1372
	do_action( 'wpmu_new_user', $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1373
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1374
	return $user_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1375
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1376
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1377
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1378
 * Creates a site.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1379
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1380
 * This function runs when a user self-registers a new site as well
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1381
 * as when a Super Admin creates a new site. Hook to {@see 'wpmu_new_blog'}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1382
 * for events that should affect all new sites.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1383
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1384
 * On subdirectory installations, $domain is the same as the main site's
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1385
 * domain, and the path is the subdirectory name (eg 'example.com'
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1386
 * and '/blog1/'). On subdomain installations, $domain is the new subdomain +
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1387
 * root domain (eg 'blog1.example.com'), and $path is '/'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1388
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1389
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1390
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1391
 * @param string $domain     The new site's domain.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1392
 * @param string $path       The new site's path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1393
 * @param string $title      The new site's title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1394
 * @param int    $user_id    The user ID of the new site's admin.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1395
 * @param array  $options    Optional. Array of key=>value pairs used to set initial site options.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1396
 *                           If valid status keys are included ('public', 'archived', 'mature',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1397
 *                           'spam', 'deleted', or 'lang_id') the given site status(es) will be
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1398
 *                           updated. Otherwise, keys and values will be used to set options for
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1399
 *                           the new site. Default empty array.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1400
 * @param int    $network_id Optional. Network ID. Only relevant on multi-network installations.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1401
 *                           Default 1.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1402
 * @return int|WP_Error Returns WP_Error object on failure, the new site ID on success.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1403
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1404
function wpmu_create_blog( $domain, $path, $title, $user_id, $options = array(), $network_id = 1 ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1405
	$defaults = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1406
		'public' => 0,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1407
	);
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1408
	$options  = wp_parse_args( $options, $defaults );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1409
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1410
	$title   = strip_tags( $title );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1411
	$user_id = (int) $user_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1412
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1413
	// Check if the domain has been used already. We should return an error message.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1414
	if ( domain_exists( $domain, $path, $network_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1415
		return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1416
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1417
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1418
	if ( ! wp_installing() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1419
		wp_installing( true );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1420
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1421
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1422
	$allowed_data_fields = array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1423
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1424
	$site_data = array_merge(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1425
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1426
			'domain'     => $domain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1427
			'path'       => $path,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1428
			'network_id' => $network_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1429
		),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1430
		array_intersect_key( $options, array_flip( $allowed_data_fields ) )
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1431
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1432
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1433
	// Data to pass to wp_initialize_site().
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1434
	$site_initialization_data = array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1435
		'title'   => $title,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1436
		'user_id' => $user_id,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1437
		'options' => array_diff_key( $options, array_flip( $allowed_data_fields ) ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1438
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1439
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1440
	$blog_id = wp_insert_site( array_merge( $site_data, $site_initialization_data ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1441
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1442
	if ( is_wp_error( $blog_id ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1443
		return $blog_id;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1444
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1445
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1446
	wp_cache_set_sites_last_changed();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1447
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1448
	return $blog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1449
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1450
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1451
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
 * Notifies the network admin that a new site has been activated.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1453
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1454
 * Filter {@see 'newblog_notify_siteadmin'} to change the content of
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1455
 * the notification email.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1456
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1457
 * @since MU (3.0.0)
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1458
 * @since 5.1.0 $blog_id now supports input from the {@see 'wp_initialize_site'} action.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1460
 * @param WP_Site|int $blog_id    The new site's object or ID.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1461
 * @param string      $deprecated Not used.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1462
 * @return bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1463
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1464
function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1465
	if ( is_object( $blog_id ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1466
		$blog_id = $blog_id->blog_id;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1467
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1468
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1469
	if ( 'yes' !== get_site_option( 'registrationnotification' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1470
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1471
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1472
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1473
	$email = get_site_option( 'admin_email' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1474
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1475
	if ( ! is_email( $email ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1476
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1477
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1478
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1479
	$options_site_url = esc_url( network_admin_url( 'settings.php' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1480
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1481
	switch_to_blog( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1482
	$blogname = get_option( 'blogname' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1483
	$siteurl  = site_url();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1484
	restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1485
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1486
	$msg = sprintf(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1487
		/* translators: New site notification email. 1: Site URL, 2: User IP address, 3: URL to Network Settings screen. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1488
		__(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1489
			'New Site: %1$s
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1490
URL: %2$s
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1491
Remote IP address: %3$s
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1492
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1493
Disable these notifications: %4$s'
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1494
		),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1495
		$blogname,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1496
		$siteurl,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1497
		wp_unslash( $_SERVER['REMOTE_ADDR'] ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1498
		$options_site_url
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1499
	);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1500
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1501
	 * Filters the message body of the new site activation email sent
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1502
	 * to the network administrator.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1503
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1504
	 * @since MU (3.0.0)
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1505
	 * @since 5.4.0 The `$blog_id` parameter was added.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1506
	 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1507
	 * @param string     $msg     Email body.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1508
	 * @param int|string $blog_id The new site's ID as an integer or numeric string.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1509
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1510
	$msg = apply_filters( 'newblog_notify_siteadmin', $msg, $blog_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1511
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1512
	/* translators: New site notification email subject. %s: New site URL. */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1513
	wp_mail( $email, sprintf( __( 'New Site Registration: %s' ), $siteurl ), $msg );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1514
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1515
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1516
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1517
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1518
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1519
 * Notifies the network admin that a new user has been activated.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1520
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1521
 * Filter {@see 'newuser_notify_siteadmin'} to change the content of
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1522
 * the notification email.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1523
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1524
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1525
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1526
 * @param int $user_id The new user's ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1527
 * @return bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1528
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1529
function newuser_notify_siteadmin( $user_id ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1530
	if ( 'yes' !== get_site_option( 'registrationnotification' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1531
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1532
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1533
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1534
	$email = get_site_option( 'admin_email' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1535
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1536
	if ( ! is_email( $email ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1537
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1538
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1539
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1540
	$user = get_userdata( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1541
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1542
	$options_site_url = esc_url( network_admin_url( 'settings.php' ) );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1543
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1544
	$msg = sprintf(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1545
		/* translators: New user notification email. 1: User login, 2: User IP address, 3: URL to Network Settings screen. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1546
		__(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1547
			'New User: %1$s
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1548
Remote IP address: %2$s
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1549
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1550
Disable these notifications: %3$s'
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1551
		),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1552
		$user->user_login,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1553
		wp_unslash( $_SERVER['REMOTE_ADDR'] ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1554
		$options_site_url
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1555
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1556
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1557
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1558
	 * Filters the message body of the new user activation email sent
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1559
	 * to the network administrator.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1560
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1561
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1562
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1563
	 * @param string  $msg  Email body.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1564
	 * @param WP_User $user WP_User instance of the new user.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1565
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1566
	$msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1567
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1568
	/* translators: New user notification email subject. %s: User login. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1569
	wp_mail( $email, sprintf( __( 'New User Registration: %s' ), $user->user_login ), $msg );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1570
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1571
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1572
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1573
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1574
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1575
 * Checks whether a site name is already taken.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1576
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1577
 * The name is the site's subdomain or the site's subdirectory
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1578
 * path depending on the network settings.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1579
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1580
 * Used during the new site registration process to ensure
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1581
 * that each site name is unique.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1582
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1583
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1584
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1585
 * @param string $domain     The domain to be checked.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1586
 * @param string $path       The path to be checked.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1587
 * @param int    $network_id Optional. Network ID. Only relevant on multi-network installations.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1588
 *                           Default 1.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1589
 * @return int|null The site ID if the site name exists, null otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1590
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1591
function domain_exists( $domain, $path, $network_id = 1 ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1592
	$path   = trailingslashit( $path );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1593
	$args   = array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1594
		'network_id'             => $network_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1595
		'domain'                 => $domain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1596
		'path'                   => $path,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1597
		'fields'                 => 'ids',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1598
		'number'                 => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1599
		'update_site_meta_cache' => false,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1600
	);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1601
	$result = get_sites( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1602
	$result = array_shift( $result );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1603
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1604
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1605
	 * Filters whether a site name is taken.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1606
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1607
	 * The name is the site's subdomain or the site's subdirectory
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1608
	 * path depending on the network settings.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1609
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1610
	 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1611
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1612
	 * @param int|null $result     The site ID if the site name exists, null otherwise.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1613
	 * @param string   $domain     Domain to be checked.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1614
	 * @param string   $path       Path to be checked.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1615
	 * @param int      $network_id Network ID. Only relevant on multi-network installations.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1616
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1617
	return apply_filters( 'domain_exists', $result, $domain, $path, $network_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1618
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1619
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1620
/**
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1621
 * Notifies the site administrator that their site activation was successful.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1622
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1623
 * Filter {@see 'wpmu_welcome_notification'} to disable or bypass.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1624
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1625
 * Filter {@see 'update_welcome_email'} and {@see 'update_welcome_subject'} to
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1626
 * modify the content and subject line of the notification email.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1627
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1628
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1629
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1630
 * @param int    $blog_id  Site ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1631
 * @param int    $user_id  User ID.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1632
 * @param string $password User password, or "N/A" if the user account is not new.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1633
 * @param string $title    Site title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1634
 * @param array  $meta     Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1635
 * @return bool Whether the email notification was sent.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1636
 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1637
function wpmu_welcome_notification(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1638
	$blog_id,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1639
	$user_id,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1640
	#[\SensitiveParameter]
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1641
	$password,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1642
	$title,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1643
	$meta = array()
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1644
) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1645
	$current_network = get_network();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1646
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1647
	/**
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1648
	 * Filters whether to bypass the welcome email sent to the site administrator after site activation.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1649
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1650
	 * Returning false disables the welcome email.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1651
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1652
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1653
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1654
	 * @param int|false $blog_id  Site ID, or false to prevent the email from sending.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1655
	 * @param int       $user_id  User ID of the site administrator.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1656
	 * @param string    $password User password, or "N/A" if the user account is not new.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1657
	 * @param string    $title    Site title.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1658
	 * @param array     $meta     Signup meta data. By default, contains the requested privacy setting and lang_id.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1659
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1660
	if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1661
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1662
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1663
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1664
	$user = get_userdata( $user_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1665
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1666
	$switched_locale = switch_to_user_locale( $user_id );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1667
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1668
	$welcome_email = get_site_option( 'welcome_email' );
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1669
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1670
	if ( ! $welcome_email ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1671
		/* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1672
		$welcome_email = __(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1673
			'Howdy USERNAME,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1674
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1675
Your new SITE_NAME site has been successfully set up at:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1676
BLOG_URL
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1677
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1678
You can log in to the administrator account with the following information:
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1679
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1680
Username: USERNAME
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1681
Password: PASSWORD
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1682
Log in here: BLOG_URLwp-login.php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1683
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1684
We hope you enjoy your new site. Thanks!
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1685
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1686
--The Team @ SITE_NAME'
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1687
		);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1688
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1689
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1690
	$url = get_blogaddress_by_id( $blog_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1691
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1692
	$welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1693
	$welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1694
	$welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1695
	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1696
	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1697
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1698
	/**
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1699
	 * Filters the content of the welcome email sent to the site administrator after site activation.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1700
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1701
	 * Content should be formatted for transmission via wp_mail().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1702
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1703
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1704
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1705
	 * @param string $welcome_email Message body of the email.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1706
	 * @param int    $blog_id       Site ID.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1707
	 * @param int    $user_id       User ID of the site administrator.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1708
	 * @param string $password      User password, or "N/A" if the user account is not new.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1709
	 * @param string $title         Site title.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1710
	 * @param array  $meta          Signup meta data. By default, contains the requested privacy setting and lang_id.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1711
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1712
	$welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1713
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1714
	$admin_email = get_site_option( 'admin_email' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1715
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1716
	if ( '' === $admin_email ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1717
		$admin_email = 'support@' . wp_parse_url( network_home_url(), PHP_URL_HOST );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1718
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1719
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1720
	$from_name       = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1721
	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1722
	$message         = $welcome_email;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1723
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1724
	if ( empty( $current_network->site_name ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1725
		$current_network->site_name = 'WordPress';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1726
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1727
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1728
	/* translators: New site notification email subject. 1: Network title, 2: New site title. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1729
	$subject = __( 'New %1$s Site: %2$s' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1730
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1731
	/**
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1732
	 * Filters the subject of the welcome email sent to the site administrator after site activation.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1733
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1734
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1735
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1736
	 * @param string $subject Subject of the email.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1737
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1738
	$subject = apply_filters( 'update_welcome_subject', sprintf( $subject, $current_network->site_name, wp_unslash( $title ) ) );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1739
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1740
	wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1741
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1742
	if ( $switched_locale ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1743
		restore_previous_locale();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1744
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1745
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1746
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1747
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1748
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1749
/**
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1750
 * Notifies the Multisite network administrator that a new site was created.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1751
 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1752
 * Filter {@see 'send_new_site_email'} to disable or bypass.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1753
 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1754
 * Filter {@see 'new_site_email'} to filter the contents.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1755
 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1756
 * @since 5.6.0
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1757
 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1758
 * @param int $site_id Site ID of the new site.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1759
 * @param int $user_id User ID of the administrator of the new site.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1760
 * @return bool Whether the email notification was sent.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1761
 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1762
function wpmu_new_site_admin_notification( $site_id, $user_id ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1763
	$site  = get_site( $site_id );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1764
	$user  = get_userdata( $user_id );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1765
	$email = get_site_option( 'admin_email' );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1766
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1767
	if ( ! $site || ! $user || ! $email ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1768
		return false;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1769
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1770
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1771
	/**
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1772
	 * Filters whether to send an email to the Multisite network administrator when a new site is created.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1773
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1774
	 * Return false to disable sending the email.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1775
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1776
	 * @since 5.6.0
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1777
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1778
	 * @param bool    $send Whether to send the email.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1779
	 * @param WP_Site $site Site object of the new site.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1780
	 * @param WP_User $user User object of the administrator of the new site.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1781
	 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1782
	if ( ! apply_filters( 'send_new_site_email', true, $site, $user ) ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1783
		return false;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1784
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1785
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1786
	$switched_locale = false;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1787
	$network_admin   = get_user_by( 'email', $email );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1788
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1789
	if ( $network_admin ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1790
		// If the network admin email address corresponds to a user, switch to their locale.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1791
		$switched_locale = switch_to_user_locale( $network_admin->ID );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1792
	} else {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1793
		// Otherwise switch to the locale of the current site.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1794
		$switched_locale = switch_to_locale( get_locale() );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1795
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1796
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1797
	$subject = sprintf(
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1798
		/* translators: New site notification email subject. %s: Network title. */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1799
		__( '[%s] New Site Created' ),
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1800
		get_network()->site_name
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1801
	);
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1802
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1803
	$message = sprintf(
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1804
		/* translators: New site notification email. 1: User login, 2: Site URL, 3: Site title. */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1805
		__(
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1806
			'New site created by %1$s
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1807
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1808
Address: %2$s
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1809
Name: %3$s'
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1810
		),
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1811
		$user->user_login,
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1812
		get_site_url( $site->id ),
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1813
		get_blog_option( $site->id, 'blogname' )
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1814
	);
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1815
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1816
	$header = sprintf(
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1817
		'From: "%1$s" <%2$s>',
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1818
		_x( 'Site Admin', 'email "From" field' ),
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1819
		$email
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1820
	);
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1821
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1822
	$new_site_email = array(
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1823
		'to'      => $email,
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1824
		'subject' => $subject,
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1825
		'message' => $message,
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1826
		'headers' => $header,
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1827
	);
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1828
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1829
	/**
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1830
	 * Filters the content of the email sent to the Multisite network administrator when a new site is created.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1831
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1832
	 * Content should be formatted for transmission via wp_mail().
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1833
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1834
	 * @since 5.6.0
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1835
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1836
	 * @param array $new_site_email {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1837
	 *     Used to build wp_mail().
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1838
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1839
	 *     @type string $to      The email address of the recipient.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1840
	 *     @type string $subject The subject of the email.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1841
	 *     @type string $message The content of the email.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1842
	 *     @type string $headers Headers.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1843
	 * }
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1844
	 * @param WP_Site $site         Site object of the new site.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1845
	 * @param WP_User $user         User object of the administrator of the new site.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1846
	 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1847
	$new_site_email = apply_filters( 'new_site_email', $new_site_email, $site, $user );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1848
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1849
	wp_mail(
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1850
		$new_site_email['to'],
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1851
		wp_specialchars_decode( $new_site_email['subject'] ),
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1852
		$new_site_email['message'],
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1853
		$new_site_email['headers']
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1854
	);
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1855
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1856
	if ( $switched_locale ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1857
		restore_previous_locale();
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1858
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1859
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1860
	return true;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1861
}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1862
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1863
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1864
 * Notifies a user that their account activation has been successful.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1865
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1866
 * Filter {@see 'wpmu_welcome_user_notification'} to disable or bypass.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1867
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1868
 * Filter {@see 'update_welcome_user_email'} and {@see 'update_welcome_user_subject'} to
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1869
 * modify the content and subject line of the notification email.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1870
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1871
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1872
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1873
 * @param int    $user_id  User ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1874
 * @param string $password User password.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1875
 * @param array  $meta     Optional. Signup meta data. Default empty array.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1876
 * @return bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1877
 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1878
function wpmu_welcome_user_notification(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1879
	$user_id,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1880
	#[\SensitiveParameter]
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1881
	$password,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1882
	$meta = array()
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1883
) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1884
	$current_network = get_network();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1885
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1886
	/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1887
	 * Filters whether to bypass the welcome email after user activation.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1888
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1889
	 * Returning false disables the welcome email.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1890
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1891
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1892
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1893
	 * @param int    $user_id  User ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1894
	 * @param string $password User password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1895
	 * @param array  $meta     Signup meta data. Default empty array.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1896
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1897
	if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1898
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1899
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1900
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1901
	$welcome_email = get_site_option( 'welcome_user_email' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1902
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1903
	$user = get_userdata( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1904
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1905
	$switched_locale = switch_to_user_locale( $user_id );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1906
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1907
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1908
	 * Filters the content of the welcome email after user activation.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1909
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1910
	 * Content should be formatted for transmission via wp_mail().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1911
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1912
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1913
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1914
	 * @param string $welcome_email The message body of the account activation success email.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1915
	 * @param int    $user_id       User ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1916
	 * @param string $password      User password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1917
	 * @param array  $meta          Signup meta data. Default empty array.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1918
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1919
	$welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1920
	$welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1921
	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1922
	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1923
	$welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1924
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1925
	$admin_email = get_site_option( 'admin_email' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1926
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1927
	if ( '' === $admin_email ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1928
		$admin_email = 'support@' . wp_parse_url( network_home_url(), PHP_URL_HOST );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1929
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1930
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1931
	$from_name       = ( '' !== get_site_option( 'site_name' ) ) ? esc_html( get_site_option( 'site_name' ) ) : 'WordPress';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1932
	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1933
	$message         = $welcome_email;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1934
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1935
	if ( empty( $current_network->site_name ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1936
		$current_network->site_name = 'WordPress';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1937
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1938
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1939
	/* translators: New user notification email subject. 1: Network title, 2: New user login. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1940
	$subject = __( 'New %1$s User: %2$s' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1941
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1942
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1943
	 * Filters the subject of the welcome email after user activation.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1944
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1945
	 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1946
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1947
	 * @param string $subject Subject of the email.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1948
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1949
	$subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login ) );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1950
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1951
	wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1952
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1953
	if ( $switched_locale ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1954
		restore_previous_locale();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1955
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1956
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1957
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1958
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1959
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1960
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1961
 * Gets the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1962
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1963
 * Returns an object containing the 'id', 'domain', 'path', and 'site_name'
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1964
 * properties of the network being viewed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1965
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1966
 * @see wpmu_current_site()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1967
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1968
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1969
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1970
 * @global WP_Network $current_site The current network.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1971
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1972
 * @return WP_Network The current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1973
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1974
function get_current_site() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1975
	global $current_site;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1976
	return $current_site;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1977
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1978
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1979
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1980
 * Gets a user's most recent post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1981
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1982
 * Walks through each of a user's blogs to find the post with
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1983
 * the most recent post_date_gmt.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1984
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1985
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1986
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1987
 * @global wpdb $wpdb WordPress database abstraction object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1988
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1989
 * @param int $user_id User ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1990
 * @return array Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1991
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1992
function get_most_recent_post_of_user( $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1993
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1994
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1995
	$user_blogs       = get_blogs_of_user( (int) $user_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1996
	$most_recent_post = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1997
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1998
	/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1999
	 * Walk through each blog and get the most recent post
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2000
	 * published by $user_id.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2001
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2002
	foreach ( (array) $user_blogs as $blog ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2003
		$prefix      = $wpdb->get_blog_prefix( $blog->userblog_id );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2004
		$recent_post = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2005
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2006
		// Make sure we found a post.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2007
		if ( isset( $recent_post['ID'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2008
			$post_gmt_ts = strtotime( $recent_post['post_date_gmt'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2009
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2010
			/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2011
			 * If this is the first post checked
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2012
			 * or if this post is newer than the current recent post,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2013
			 * make it the new most recent post.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2014
			 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2015
			if ( ! isset( $most_recent_post['post_gmt_ts'] ) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2016
				$most_recent_post = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2017
					'blog_id'       => $blog->userblog_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2018
					'post_id'       => $recent_post['ID'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2019
					'post_date_gmt' => $recent_post['post_date_gmt'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2020
					'post_gmt_ts'   => $post_gmt_ts,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2021
				);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2022
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2023
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2024
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2025
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2026
	return $most_recent_post;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2027
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2028
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2029
//
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2030
// Misc functions.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2031
//
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2032
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2033
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2034
 * Checks an array of MIME types against a list of allowed types.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2035
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2036
 * WordPress ships with a set of allowed upload filetypes,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2037
 * which is defined in wp-includes/functions.php in
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2038
 * get_allowed_mime_types(). This function is used to filter
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2039
 * that list against the filetypes allowed provided by Multisite
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2040
 * Super Admins at wp-admin/network/settings.php.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2041
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2042
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2043
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2044
 * @param array $mimes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2045
 * @return array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2046
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2047
function check_upload_mimes( $mimes ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2048
	$site_exts  = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2049
	$site_mimes = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2050
	foreach ( $site_exts as $ext ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2051
		foreach ( $mimes as $ext_pattern => $mime ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2052
			if ( '' !== $ext && str_contains( $ext_pattern, $ext ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2053
				$site_mimes[ $ext_pattern ] = $mime;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2054
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2055
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2056
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2057
	return $site_mimes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2058
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2059
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2060
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2061
 * Updates a blog's post count.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2062
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2063
 * WordPress MS stores a blog's post count as an option so as
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2064
 * to avoid extraneous COUNTs when a blog's details are fetched
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2065
 * with get_site(). This function is called when posts are published
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2066
 * or unpublished to make sure the count stays current.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2067
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2068
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2069
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2070
 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2071
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2072
 * @param string $deprecated Not used.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2073
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2074
function update_posts_count( $deprecated = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2075
	global $wpdb;
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  2076
	update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ), true );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2077
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2078
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2079
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2080
 * Logs the user email, IP, and registration date of a new site.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2081
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2082
 * @since MU (3.0.0)
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2083
 * @since 5.1.0 Parameters now support input from the {@see 'wp_initialize_site'} action.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2084
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2085
 * @global wpdb $wpdb WordPress database abstraction object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2086
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2087
 * @param WP_Site|int $blog_id The new site's object or ID.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2088
 * @param int|array   $user_id User ID, or array of arguments including 'user_id'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2089
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2090
function wpmu_log_new_registrations( $blog_id, $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2091
	global $wpdb;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2092
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2093
	if ( is_object( $blog_id ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2094
		$blog_id = $blog_id->blog_id;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2095
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2096
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2097
	if ( is_array( $user_id ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2098
		$user_id = ! empty( $user_id['user_id'] ) ? $user_id['user_id'] : 0;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2099
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2100
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2101
	$user = get_userdata( (int) $user_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2102
	if ( $user ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2103
		$wpdb->insert(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2104
			$wpdb->registration_log,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2105
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2106
				'email'           => $user->user_email,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2107
				'IP'              => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2108
				'blog_id'         => $blog_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2109
				'date_registered' => current_time( 'mysql' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2110
			)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2111
		);
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2112
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2113
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2114
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2115
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2116
 * Ensures that the current site's domain is listed in the allowed redirect host list.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2117
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2118
 * @see wp_validate_redirect()
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2119
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2120
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2121
 * @param array|string $deprecated Not used.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2122
 * @return string[] {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2123
 *     An array containing the current site's domain.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2124
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2125
 *     @type string $0 The current site's domain.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2126
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2127
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2128
function redirect_this_site( $deprecated = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2129
	return array( get_network()->domain );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2130
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2131
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2132
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2133
 * Checks whether an upload is too big.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2134
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2135
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2136
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2137
 * @param array $upload An array of information about the newly-uploaded file.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2138
 * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2139
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2140
function upload_is_file_too_big( $upload ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2141
	if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2142
		return $upload;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2143
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2144
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2145
	if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2146
		/* translators: %s: Maximum allowed file size in kilobytes. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2147
		return sprintf( __( 'This file is too big. Files must be less than %s KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2148
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2149
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2150
	return $upload;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2151
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2152
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2153
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2154
 * Adds a nonce field to the signup page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2155
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2156
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2157
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2158
function signup_nonce_fields() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2159
	$id = mt_rand();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2160
	echo "<input type='hidden' name='signup_form_id' value='{$id}' />";
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2161
	wp_nonce_field( 'signup_form_' . $id, '_signup_form', false );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2162
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2163
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2164
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2165
 * Processes the signup nonce created in signup_nonce_fields().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2166
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2167
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2168
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2169
 * @param array $result
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2170
 * @return array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2171
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2172
function signup_nonce_check( $result ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2173
	if ( ! strpos( $_SERVER['PHP_SELF'], 'wp-signup.php' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2174
		return $result;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2175
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2176
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2177
	if ( ! wp_verify_nonce( $_POST['_signup_form'], 'signup_form_' . $_POST['signup_form_id'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2178
		$result['errors']->add( 'invalid_nonce', __( 'Unable to submit this form, please try again.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2179
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2180
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2181
	return $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2182
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2183
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2184
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2185
 * Corrects 404 redirects when NOBLOGREDIRECT is defined.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2186
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2187
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2188
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2189
function maybe_redirect_404() {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2190
	if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2191
		/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2192
		 * Filters the redirect URL for 404s on the main site.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2193
		 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2194
		 * The filter is only evaluated if the NOBLOGREDIRECT constant is defined.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2195
		 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2196
		 * @since 3.0.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2197
		 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2198
		 * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2199
		 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2200
		$destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2201
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2202
		if ( $destination ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2203
			if ( '%siteurl%' === $destination ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2204
				$destination = network_home_url();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2205
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2206
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2207
			wp_redirect( $destination );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2208
			exit;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2209
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2210
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2211
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2212
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2213
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2214
 * Adds a new user to a blog by visiting /newbloguser/{key}/.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2215
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2216
 * This will only work when the user's details are saved as an option
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2217
 * keyed as 'new_user_{key}', where '{key}' is a hash generated for the user to be
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2218
 * added, as when a user is invited through the regular WP Add User interface.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2219
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2220
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2221
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2222
function maybe_add_existing_user_to_blog() {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2223
	if ( ! str_contains( $_SERVER['REQUEST_URI'], '/newbloguser/' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2224
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2225
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2226
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2227
	$parts = explode( '/', $_SERVER['REQUEST_URI'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2228
	$key   = array_pop( $parts );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2229
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2230
	if ( '' === $key ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2231
		$key = array_pop( $parts );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2232
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2233
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2234
	$details = get_option( 'new_user_' . $key );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2235
	if ( ! empty( $details ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2236
		delete_option( 'new_user_' . $key );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2237
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2238
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2239
	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2240
		wp_die(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2241
			sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2242
				/* translators: %s: Home URL. */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2243
				__( 'An error occurred adding you to this site. Go to the <a href="%s">homepage</a>.' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2244
				home_url()
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2245
			)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2246
		);
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2247
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2248
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2249
	wp_die(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2250
		sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2251
			/* translators: 1: Home URL, 2: Admin URL. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2252
			__( 'You have been added to this site. Please visit the <a href="%1$s">homepage</a> or <a href="%2$s">log in</a> using your username and password.' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2253
			home_url(),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2254
			admin_url()
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2255
		),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2256
		__( 'WordPress &rsaquo; Success' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2257
		array( 'response' => 200 )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2258
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2259
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2260
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2261
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2262
 * Adds a user to a blog based on details from maybe_add_existing_user_to_blog().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2263
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2264
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2265
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2266
 * @param array|false $details {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2267
 *     User details. Must at least contain values for the keys listed below.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2268
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2269
 *     @type int    $user_id The ID of the user being added to the current blog.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2270
 *     @type string $role    The role to be assigned to the user.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2271
 * }
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2272
 * @return true|WP_Error|void True on success or a WP_Error object if the user doesn't exist
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2273
 *                            or could not be added. Void if $details array was not provided.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2274
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2275
function add_existing_user_to_blog( $details = false ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2276
	if ( is_array( $details ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2277
		$blog_id = get_current_blog_id();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2278
		$result  = add_user_to_blog( $blog_id, $details['user_id'], $details['role'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2279
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2280
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2281
		 * Fires immediately after an existing user is added to a site.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2282
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2283
		 * @since MU (3.0.0)
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2284
		 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2285
		 * @param int           $user_id User ID.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2286
		 * @param true|WP_Error $result  True on success or a WP_Error object if the user doesn't exist
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2287
		 *                               or could not be added.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2288
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2289
		do_action( 'added_existing_user', $details['user_id'], $result );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2290
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2291
		return $result;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2292
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2293
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2294
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2295
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2296
 * Adds a newly created user to the appropriate blog
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2297
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2298
 * To add a user in general, use add_user_to_blog(). This function
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2299
 * is specifically hooked into the {@see 'wpmu_activate_user'} action.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2300
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2301
 * @since MU (3.0.0)
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2302
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2303
 * @see add_user_to_blog()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2304
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2305
 * @param int    $user_id  User ID.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2306
 * @param string $password User password. Ignored.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2307
 * @param array  $meta     Signup meta data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2308
 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  2309
function add_new_user_to_blog(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  2310
	$user_id,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  2311
	#[\SensitiveParameter]
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  2312
	$password,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  2313
	$meta
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  2314
) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2315
	if ( ! empty( $meta['add_to_blog'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2316
		$blog_id = $meta['add_to_blog'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2317
		$role    = $meta['new_role'];
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2318
		remove_user_from_blog( $user_id, get_network()->site_id ); // Remove user from main blog.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2319
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2320
		$result = add_user_to_blog( $blog_id, $user_id, $role );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2321
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2322
		if ( ! is_wp_error( $result ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2323
			update_user_meta( $user_id, 'primary_blog', $blog_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2324
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2325
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2326
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2327
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2328
/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2329
 * Corrects From host on outgoing mail to match the site domain.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2330
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2331
 * @since MU (3.0.0)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2332
 *
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  2333
 * @param PHPMailer\PHPMailer\PHPMailer $phpmailer The PHPMailer instance (passed by reference).
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2334
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2335
function fix_phpmailer_messageid( $phpmailer ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2336
	$phpmailer->Hostname = get_network()->domain;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2337
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2338
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2339
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2340
 * Determines whether a user is marked as a spammer, based on user login.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2341
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2342
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2343
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2344
 * @param string|WP_User $user Optional. Defaults to current user. WP_User object,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2345
 *                             or user login name as a string.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2346
 * @return bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2347
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2348
function is_user_spammy( $user = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2349
	if ( ! ( $user instanceof WP_User ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2350
		if ( $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2351
			$user = get_user_by( 'login', $user );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2352
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2353
			$user = wp_get_current_user();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2354
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2355
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2356
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  2357
	return $user && isset( $user->spam ) && '1' === $user->spam;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2358
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2359
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2360
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2361
 * Updates this blog's 'public' setting in the global blogs table.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2362
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2363
 * Public blogs have a setting of 1, private blogs are 0.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2364
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2365
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2366
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2367
 * @param int $old_value The old public value.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2368
 * @param int $value     The new public value.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2369
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2370
function update_blog_public( $old_value, $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2371
	update_blog_status( get_current_blog_id(), 'public', (int) $value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2372
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2373
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2374
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2375
 * Determines whether users can self-register, based on Network settings.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2376
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2377
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2378
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2379
 * @return bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2380
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2381
function users_can_register_signup_filter() {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2382
	$registration = get_site_option( 'registration' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2383
	return ( 'all' === $registration || 'user' === $registration );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2384
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2385
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2386
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2387
 * Ensures that the welcome message is not empty. Currently unused.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2388
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2389
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2390
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2391
 * @param string $text
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2392
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2393
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2394
function welcome_user_msg_filter( $text ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2395
	if ( ! $text ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2396
		remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2397
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2398
		/* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2399
		$text = __(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2400
			'Howdy USERNAME,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2401
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2402
Your new account is set up.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2403
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2404
You can log in with the following information:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2405
Username: USERNAME
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2406
Password: PASSWORD
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2407
LOGINLINK
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2408
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2409
Thanks!
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2410
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2411
--The Team @ SITE_NAME'
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2412
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2413
		update_site_option( 'welcome_user_email', $text );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2414
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2415
	return $text;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2416
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2417
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2418
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2419
 * Determines whether to force SSL on content.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2420
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2421
 * @since 2.8.5
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2422
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2423
 * @param bool $force
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2424
 * @return bool True if forced, false if not forced.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2425
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2426
function force_ssl_content( $force = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2427
	static $forced_content = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2428
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2429
	if ( ! $force ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2430
		$old_forced     = $forced_content;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2431
		$forced_content = $force;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2432
		return $old_forced;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2433
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2434
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2435
	return $forced_content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2436
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2437
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2438
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2439
 * Formats a URL to use https.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2440
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2441
 * Useful as a filter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2442
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2443
 * @since 2.8.5
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2444
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2445
 * @param string $url URL.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2446
 * @return string URL with https as the scheme.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2447
 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2448
function filter_SSL( $url ) {  // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2449
	if ( ! is_string( $url ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2450
		return get_bloginfo( 'url' ); // Return home site URL with proper scheme.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2451
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2452
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2453
	if ( force_ssl_content() && is_ssl() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2454
		$url = set_url_scheme( $url, 'https' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2455
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2456
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2457
	return $url;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2458
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2459
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2460
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2461
 * Schedules update of the network-wide counts for the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2462
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2463
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2464
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2465
function wp_schedule_update_network_counts() {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2466
	if ( ! is_main_site() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2467
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2468
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2469
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2470
	if ( ! wp_next_scheduled( 'update_network_counts' ) && ! wp_installing() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2471
		wp_schedule_event( time(), 'twicedaily', 'update_network_counts' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2472
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2473
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2474
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2475
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2476
 * Updates the network-wide counts for the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2477
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2478
 * @since 3.1.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2479
 * @since 4.8.0 The `$network_id` parameter has been added.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2480
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2481
 * @param int|null $network_id ID of the network. Default is the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2482
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2483
function wp_update_network_counts( $network_id = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2484
	wp_update_network_user_counts( $network_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2485
	wp_update_network_site_counts( $network_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2486
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2487
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2488
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2489
 * Updates the count of sites for the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2490
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2491
 * If enabled through the {@see 'enable_live_network_counts'} filter, update the sites count
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2492
 * on a network when a site is created or its status is updated.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2493
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2494
 * @since 3.7.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2495
 * @since 4.8.0 The `$network_id` parameter has been added.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2496
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2497
 * @param int|null $network_id ID of the network. Default is the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2498
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2499
function wp_maybe_update_network_site_counts( $network_id = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2500
	$is_small_network = ! wp_is_large_network( 'sites', $network_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2501
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2502
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2503
	 * Filters whether to update network site or user counts when a new site is created.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2504
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2505
	 * @since 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2506
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2507
	 * @see wp_is_large_network()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2508
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2509
	 * @param bool   $small_network Whether the network is considered small.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2510
	 * @param string $context       Context. Either 'users' or 'sites'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2511
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2512
	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2513
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2514
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2515
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2516
	wp_update_network_site_counts( $network_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2517
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2518
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2519
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2520
 * Updates the network-wide users count.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2521
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2522
 * If enabled through the {@see 'enable_live_network_counts'} filter, update the users count
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2523
 * on a network when a user is created or its status is updated.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2524
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2525
 * @since 3.7.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2526
 * @since 4.8.0 The `$network_id` parameter has been added.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2527
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2528
 * @param int|null $network_id ID of the network. Default is the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2529
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2530
function wp_maybe_update_network_user_counts( $network_id = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2531
	$is_small_network = ! wp_is_large_network( 'users', $network_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2532
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2533
	/** This filter is documented in wp-includes/ms-functions.php */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2534
	if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2535
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2536
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2537
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2538
	wp_update_network_user_counts( $network_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2539
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2540
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2541
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2542
 * Updates the network-wide site count.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2543
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2544
 * @since 3.7.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2545
 * @since 4.8.0 The `$network_id` parameter has been added.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2546
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2547
 * @param int|null $network_id ID of the network. Default is the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2548
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2549
function wp_update_network_site_counts( $network_id = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2550
	$network_id = (int) $network_id;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2551
	if ( ! $network_id ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2552
		$network_id = get_current_network_id();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2553
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2554
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2555
	$count = get_sites(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2556
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2557
			'network_id'             => $network_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2558
			'spam'                   => 0,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2559
			'deleted'                => 0,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2560
			'archived'               => 0,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2561
			'count'                  => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2562
			'update_site_meta_cache' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2563
		)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2564
	);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2565
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2566
	update_network_option( $network_id, 'blog_count', $count );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2567
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2568
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2569
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2570
 * Updates the network-wide user count.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2571
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2572
 * @since 3.7.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2573
 * @since 4.8.0 The `$network_id` parameter has been added.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2574
 * @since 6.0.0 This function is now a wrapper for wp_update_user_counts().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2575
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2576
 * @param int|null $network_id ID of the network. Default is the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2577
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2578
function wp_update_network_user_counts( $network_id = null ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2579
	wp_update_user_counts( $network_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2580
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2581
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2582
/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2583
 * Returns the space used by the current site.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2584
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2585
 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2586
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2587
 * @return int Used space in megabytes.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2588
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2589
function get_space_used() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2590
	/**
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2591
	 * Filters the amount of storage space used by the current site, in megabytes.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2592
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2593
	 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2594
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2595
	 * @param int|false $space_used The amount of used space, in megabytes. Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2596
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2597
	$space_used = apply_filters( 'pre_get_space_used', false );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2598
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2599
	if ( false === $space_used ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2600
		$upload_dir = wp_upload_dir();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2601
		$space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2602
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2603
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2604
	return $space_used;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2605
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2606
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2607
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2608
 * Returns the upload quota for the current blog.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2609
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2610
 * @since MU (3.0.0)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2611
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2612
 * @return int Quota in megabytes.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2613
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2614
function get_space_allowed() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2615
	$space_allowed = get_option( 'blog_upload_space' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2616
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2617
	if ( ! is_numeric( $space_allowed ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2618
		$space_allowed = get_site_option( 'blog_upload_space' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2619
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2620
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2621
	if ( ! is_numeric( $space_allowed ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2622
		$space_allowed = 100;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2623
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2624
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2625
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2626
	 * Filters the upload quota for the current site.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2627
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2628
	 * @since 3.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2629
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2630
	 * @param int $space_allowed Upload quota in megabytes for the current blog.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2631
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2632
	return apply_filters( 'get_space_allowed', $space_allowed );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2633
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2634
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2635
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2636
 * Determines if there is any upload space left in the current blog's quota.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2637
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2638
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2639
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2640
 * @return int of upload space available in bytes.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2641
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2642
function get_upload_space_available() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2643
	$allowed = get_space_allowed();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2644
	if ( $allowed < 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2645
		$allowed = 0;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2646
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2647
	$space_allowed = $allowed * MB_IN_BYTES;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2648
	if ( get_site_option( 'upload_space_check_disabled' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2649
		return $space_allowed;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2650
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2651
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2652
	$space_used = get_space_used() * MB_IN_BYTES;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2653
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2654
	if ( ( $space_allowed - $space_used ) <= 0 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2655
		return 0;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2656
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2657
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2658
	return $space_allowed - $space_used;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2659
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2660
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2661
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2662
 * Determines if there is any upload space left in the current blog's quota.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2663
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2664
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2665
 * @return bool True if space is available, false otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2666
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2667
function is_upload_space_available() {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2668
	if ( get_site_option( 'upload_space_check_disabled' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2669
		return true;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2670
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2671
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2672
	return (bool) get_upload_space_available();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2673
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2674
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2675
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2676
 * Filters the maximum upload file size allowed, in bytes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2677
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2678
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2679
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2680
 * @param int $size Upload size limit in bytes.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2681
 * @return int Upload size limit in bytes.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2682
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2683
function upload_size_limit_filter( $size ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2684
	$fileupload_maxk         = (int) get_site_option( 'fileupload_maxk', 1500 );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2685
	$max_fileupload_in_bytes = KB_IN_BYTES * $fileupload_maxk;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2686
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2687
	if ( get_site_option( 'upload_space_check_disabled' ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2688
		return min( $size, $max_fileupload_in_bytes );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2689
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2690
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2691
	return min( $size, $max_fileupload_in_bytes, get_upload_space_available() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2692
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2693
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2694
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2695
 * Determines whether or not we have a large network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2696
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2697
 * The default criteria for a large network is either more than 10,000 users or more than 10,000 sites.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2698
 * Plugins can alter this criteria using the {@see 'wp_is_large_network'} filter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2699
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2700
 * @since 3.3.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2701
 * @since 4.8.0 The `$network_id` parameter has been added.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2702
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2703
 * @param string   $using      'sites' or 'users'. Default is 'sites'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2704
 * @param int|null $network_id ID of the network. Default is the current network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2705
 * @return bool True if the network meets the criteria for large. False otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2706
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2707
function wp_is_large_network( $using = 'sites', $network_id = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2708
	$network_id = (int) $network_id;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2709
	if ( ! $network_id ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2710
		$network_id = get_current_network_id();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2711
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2712
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2713
	if ( 'users' === $using ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2714
		$count = get_user_count( $network_id );
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2715
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2716
		$is_large_network = wp_is_large_user_count( $network_id );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2717
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2718
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2719
		 * Filters whether the network is considered large.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2720
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2721
		 * @since 3.3.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2722
		 * @since 4.8.0 The `$network_id` parameter has been added.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2723
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2724
		 * @param bool   $is_large_network Whether the network has more than 10000 users or sites.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2725
		 * @param string $component        The component to count. Accepts 'users', or 'sites'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2726
		 * @param int    $count            The count of items for the component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2727
		 * @param int    $network_id       The ID of the network being checked.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2728
		 */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2729
		return apply_filters( 'wp_is_large_network', $is_large_network, 'users', $count, $network_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2730
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2731
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2732
	$count = get_blog_count( $network_id );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2733
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2734
	/** This filter is documented in wp-includes/ms-functions.php */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2735
	return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count, $network_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2736
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2737
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2738
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2739
 * Retrieves a list of reserved site on a sub-directory Multisite installation.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2740
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2741
 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2742
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2743
 * @return string[] Array of reserved names.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2744
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2745
function get_subdirectory_reserved_names() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2746
	$names = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2747
		'page',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2748
		'comments',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2749
		'blog',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2750
		'files',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2751
		'feed',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2752
		'wp-admin',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2753
		'wp-content',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2754
		'wp-includes',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2755
		'wp-json',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2756
		'embed',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2757
	);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2758
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2759
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2760
	 * Filters reserved site names on a sub-directory Multisite installation.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2761
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2762
	 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2763
	 * @since 4.4.0 'wp-admin', 'wp-content', 'wp-includes', 'wp-json', and 'embed' were added
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2764
	 *              to the reserved names list.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2765
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2766
	 * @param string[] $subdirectory_reserved_names Array of reserved names.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2767
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2768
	return apply_filters( 'subdirectory_reserved_names', $names );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2769
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2770
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2771
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2772
 * Sends a confirmation request email when a change of network admin email address is attempted.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2773
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2774
 * The new network admin address will not become active until confirmed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2775
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2776
 * @since 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2777
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2778
 * @param string $old_value The old network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2779
 * @param string $value     The proposed new network admin email address.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2780
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2781
function update_network_option_new_admin_email( $old_value, $value ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2782
	if ( get_site_option( 'admin_email' ) === $value || ! is_email( $value ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2783
		return;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2784
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2785
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2786
	$hash            = md5( $value . time() . mt_rand() );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2787
	$new_admin_email = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2788
		'hash'     => $hash,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2789
		'newemail' => $value,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2790
	);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2791
	update_site_option( 'network_admin_hash', $new_admin_email );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2792
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2793
	$switched_locale = switch_to_user_locale( get_current_user_id() );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2794
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2795
	/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2796
	$email_text = __(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2797
		'Howdy ###USERNAME###,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2798
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2799
You recently requested to have the network admin email address on
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2800
your network changed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2801
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2802
If this is correct, please click on the following link to change it:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2803
###ADMIN_URL###
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2804
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2805
You can safely ignore and delete this email if you do not want to
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2806
take this action.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2807
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2808
This email has been sent to ###EMAIL###
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2809
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2810
Regards,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2811
All at ###SITENAME###
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2812
###SITEURL###'
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2813
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2814
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2815
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2816
	 * Filters the text of the email sent when a change of network admin email address is attempted.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2817
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2818
	 * The following strings have a special meaning and will get replaced dynamically:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2819
	 * ###USERNAME###  The current user's username.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2820
	 * ###ADMIN_URL### The link to click on to confirm the email change.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2821
	 * ###EMAIL###     The proposed new network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2822
	 * ###SITENAME###  The name of the network.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2823
	 * ###SITEURL###   The URL to the network.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2824
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2825
	 * @since 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2826
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2827
	 * @param string $email_text      Text in the email.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2828
	 * @param array  $new_admin_email {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2829
	 *     Data relating to the new network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2830
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2831
	 *     @type string $hash     The secure hash used in the confirmation link URL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2832
	 *     @type string $newemail The proposed new network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2833
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2834
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2835
	$content = apply_filters( 'new_network_admin_email_content', $email_text, $new_admin_email );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2836
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2837
	$current_user = wp_get_current_user();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2838
	$content      = str_replace( '###USERNAME###', $current_user->user_login, $content );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2839
	$content      = str_replace( '###ADMIN_URL###', esc_url( network_admin_url( 'settings.php?network_admin_hash=' . $hash ) ), $content );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2840
	$content      = str_replace( '###EMAIL###', $value, $content );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2841
	$content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ), $content );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2842
	$content      = str_replace( '###SITEURL###', network_home_url(), $content );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2843
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2844
	wp_mail(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2845
		$value,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2846
		sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2847
			/* translators: Email change notification email subject. %s: Network title. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2848
			__( '[%s] Network Admin Email Change Request' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2849
			wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2850
		),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2851
		$content
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2852
	);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2853
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2854
	if ( $switched_locale ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2855
		restore_previous_locale();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2856
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2857
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2858
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2859
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2860
 * Sends an email to the old network admin email address when the network admin email address changes.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2861
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2862
 * @since 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2863
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2864
 * @param string $option_name The relevant database option name.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2865
 * @param string $new_email   The new network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2866
 * @param string $old_email   The old network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2867
 * @param int    $network_id  ID of the network.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2868
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2869
function wp_network_admin_email_change_notification( $option_name, $new_email, $old_email, $network_id ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2870
	$send = true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2871
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2872
	// Don't send the notification to the default 'admin_email' value.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2873
	if ( 'you@example.com' === $old_email ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2874
		$send = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2875
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2876
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2877
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2878
	 * Filters whether to send the network admin email change notification email.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2879
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2880
	 * @since 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2881
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2882
	 * @param bool   $send       Whether to send the email notification.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2883
	 * @param string $old_email  The old network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2884
	 * @param string $new_email  The new network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2885
	 * @param int    $network_id ID of the network.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2886
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2887
	$send = apply_filters( 'send_network_admin_email_change_email', $send, $old_email, $new_email, $network_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2888
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2889
	if ( ! $send ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2890
		return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2891
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2892
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2893
	/* translators: Do not translate OLD_EMAIL, NEW_EMAIL, SITENAME, SITEURL: those are placeholders. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2894
	$email_change_text = __(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2895
		'Hi,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2896
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2897
This notice confirms that the network admin email address was changed on ###SITENAME###.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2898
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2899
The new network admin email address is ###NEW_EMAIL###.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2900
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2901
This email has been sent to ###OLD_EMAIL###
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2902
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2903
Regards,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2904
All at ###SITENAME###
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2905
###SITEURL###'
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2906
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2907
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2908
	$email_change_email = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2909
		'to'      => $old_email,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2910
		/* translators: Network admin email change notification email subject. %s: Network title. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2911
		'subject' => __( '[%s] Network Admin Email Changed' ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2912
		'message' => $email_change_text,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2913
		'headers' => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2914
	);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2915
	// Get network name.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2916
	$network_name = wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2917
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2918
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2919
	 * Filters the contents of the email notification sent when the network admin email address is changed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2920
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2921
	 * @since 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2922
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2923
	 * @param array $email_change_email {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2924
	 *     Used to build wp_mail().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2925
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2926
	 *     @type string $to      The intended recipient.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2927
	 *     @type string $subject The subject of the email.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2928
	 *     @type string $message The content of the email.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2929
	 *         The following strings have a special meaning and will get replaced dynamically:
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2930
	 *         - ###OLD_EMAIL### The old network admin email address.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2931
	 *         - ###NEW_EMAIL### The new network admin email address.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2932
	 *         - ###SITENAME###  The name of the network.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2933
	 *         - ###SITEURL###   The URL to the site.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2934
	 *     @type string $headers Headers.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2935
	 * }
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2936
	 * @param string $old_email  The old network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2937
	 * @param string $new_email  The new network admin email address.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2938
	 * @param int    $network_id ID of the network.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2939
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2940
	$email_change_email = apply_filters( 'network_admin_email_change_email', $email_change_email, $old_email, $new_email, $network_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2941
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2942
	$email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2943
	$email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2944
	$email_change_email['message'] = str_replace( '###SITENAME###', $network_name, $email_change_email['message'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2945
	$email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2946
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2947
	wp_mail(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2948
		$email_change_email['to'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2949
		sprintf(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2950
			$email_change_email['subject'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2951
			$network_name
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2952
		),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2953
		$email_change_email['message'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2954
		$email_change_email['headers']
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2955
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2956
}