author | ymh <ymh.work@gmail.com> |
Wed, 21 Sep 2022 18:19:35 +0200 | |
changeset 18 | be944660c56a |
parent 16 | a86126ab1dd4 |
child 19 | 3d72ae0968f4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
||
3 |
/** Sets up the WordPress Environment. */ |
|
16 | 4 |
require __DIR__ . '/wp-load.php'; |
0 | 5 |
|
18 | 6 |
add_filter( 'wp_robots', 'wp_robots_no_robots' ); |
0 | 7 |
|
16 | 8 |
require __DIR__ . '/wp-blog-header.php'; |
0 | 9 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
nocache_headers(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
|
16 | 12 |
if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_site_option( 'illegal_names' ), true ) ) { |
0 | 13 |
wp_redirect( network_home_url() ); |
14 |
die(); |
|
15 |
} |
|
16 |
||
17 |
/** |
|
18 |
* Prints signup_header via wp_head |
|
19 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
* @since MU (3.0.0) |
0 | 21 |
*/ |
22 |
function do_signup_header() { |
|
23 |
/** |
|
5 | 24 |
* Fires within the head section of the site sign-up screen. |
0 | 25 |
* |
26 |
* @since 3.0.0 |
|
27 |
*/ |
|
28 |
do_action( 'signup_header' ); |
|
29 |
} |
|
30 |
add_action( 'wp_head', 'do_signup_header' ); |
|
31 |
||
9 | 32 |
if ( ! is_multisite() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
wp_redirect( wp_registration_url() ); |
0 | 34 |
die(); |
35 |
} |
|
36 |
||
9 | 37 |
if ( ! is_main_site() ) { |
0 | 38 |
wp_redirect( network_site_url( 'wp-signup.php' ) ); |
39 |
die(); |
|
40 |
} |
|
41 |
||
16 | 42 |
// Fix for page title. |
0 | 43 |
$wp_query->is_404 = false; |
44 |
||
45 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
* Fires before the Site Signup page is loaded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
do_action( 'before_signup_header' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
/** |
0 | 53 |
* Prints styles for front-end Multisite signup pages |
54 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
* @since MU (3.0.0) |
0 | 56 |
*/ |
57 |
function wpmu_signup_stylesheet() { |
|
58 |
?> |
|
59 |
<style type="text/css"> |
|
60 |
.mu_register { width: 90%; margin:0 auto; } |
|
61 |
.mu_register form { margin-top: 2em; } |
|
9 | 62 |
.mu_register .error { font-weight: 600; padding: 10px; color: #333333; background: #FFEBE8; border: 1px solid #CC0000; } |
0 | 63 |
.mu_register input[type="submit"], |
64 |
.mu_register #blog_title, |
|
65 |
.mu_register #user_email, |
|
66 |
.mu_register #blogname, |
|
67 |
.mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; } |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
.mu_register #site-language { display: block; } |
0 | 69 |
.mu_register .prefix_address, |
9 | 70 |
.mu_register .suffix_address { font-size: 18px; display:inline; } |
71 |
.mu_register label { font-weight: 600; font-size: 15px; display: block; margin: 10px 0; } |
|
0 | 72 |
.mu_register label.checkbox { display:inline; } |
9 | 73 |
.mu_register .mu_alert { font-weight: 600; padding: 10px; color: #333333; background: #ffffe0; border: 1px solid #e6db55; } |
0 | 74 |
</style> |
75 |
<?php |
|
76 |
} |
|
77 |
||
78 |
add_action( 'wp_head', 'wpmu_signup_stylesheet' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
get_header( 'wp-signup' ); |
0 | 80 |
|
81 |
/** |
|
82 |
* Fires before the site sign-up form. |
|
83 |
* |
|
84 |
* @since 3.0.0 |
|
85 |
*/ |
|
86 |
do_action( 'before_signup_form' ); |
|
87 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
<div id="signup-content" class="widecolumn"> |
16 | 89 |
<div class="mu_register wp-signup-container" role="main"> |
0 | 90 |
<?php |
91 |
/** |
|
92 |
* Generates and displays the Signup and Create Site forms |
|
93 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
* @since MU (3.0.0) |
0 | 95 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
* @param string $blogname The new site name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
* @param string $blog_title The new site title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. |
0 | 99 |
*/ |
5 | 100 |
function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
if ( ! is_wp_error( $errors ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
$errors = new WP_Error(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
$current_network = get_network(); |
9 | 106 |
// Blog name. |
107 |
if ( ! is_subdomain_install() ) { |
|
108 |
echo '<label for="blogname">' . __( 'Site Name:' ) . '</label>'; |
|
109 |
} else { |
|
110 |
echo '<label for="blogname">' . __( 'Site Domain:' ) . '</label>'; |
|
111 |
} |
|
0 | 112 |
|
9 | 113 |
$errmsg = $errors->get_error_message( 'blogname' ); |
114 |
if ( $errmsg ) { |
|
115 |
?> |
|
116 |
<p class="error"><?php echo $errmsg; ?></p> |
|
117 |
<?php |
|
118 |
} |
|
0 | 119 |
|
9 | 120 |
if ( ! is_subdomain_install() ) { |
121 |
echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><br />'; |
|
122 |
} else { |
|
123 |
$site_domain = preg_replace( '|^www\.|', '', $current_network->domain ); |
|
124 |
echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><span class="suffix_address">.' . esc_html( $site_domain ) . '</span><br />'; |
|
125 |
} |
|
0 | 126 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
if ( ! is_user_logged_in() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
if ( ! is_subdomain_install() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
$site = $current_network->domain . $current_network->path . __( 'sitename' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
$site = __( 'domain' ) . '.' . $site_domain . $current_network->path; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
|
16 | 134 |
printf( |
135 |
'<p>(<strong>%s</strong>) %s</p>', |
|
136 |
/* translators: %s: Site address. */ |
|
137 |
sprintf( __( 'Your address will be %s.' ), $site ), |
|
138 |
__( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) |
|
139 |
); |
|
0 | 140 |
} |
141 |
||
16 | 142 |
// Site Title. |
0 | 143 |
?> |
9 | 144 |
<label for="blog_title"><?php _e( 'Site Title:' ); ?></label> |
145 |
<?php |
|
146 |
$errmsg = $errors->get_error_message( 'blog_title' ); |
|
147 |
if ( $errmsg ) { |
|
148 |
?> |
|
149 |
<p class="error"><?php echo $errmsg; ?></p> |
|
150 |
<?php |
|
151 |
} |
|
152 |
echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" />'; |
|
0 | 153 |
?> |
154 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
// Site Language. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
$languages = signup_get_available_languages(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
159 |
if ( ! empty( $languages ) ) : |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
<p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
162 |
<label for="site-language"><?php _e( 'Site Language:' ); ?></label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
// Network default. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
165 |
$lang = get_site_option( 'WPLANG' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
if ( isset( $_POST['WPLANG'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
$lang = $_POST['WPLANG']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
// Use US English if the default isn't available. |
16 | 172 |
if ( ! in_array( $lang, $languages, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
$lang = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
|
9 | 176 |
wp_dropdown_languages( |
177 |
array( |
|
178 |
'name' => 'WPLANG', |
|
179 |
'id' => 'site-language', |
|
180 |
'selected' => $lang, |
|
181 |
'languages' => $languages, |
|
182 |
'show_available_translations' => false, |
|
183 |
) |
|
184 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
</p> |
9 | 187 |
<?php |
188 |
endif; // Languages. |
|
189 |
||
190 |
$blog_public_on_checked = ''; |
|
191 |
$blog_public_off_checked = ''; |
|
16 | 192 |
if ( isset( $_POST['blog_public'] ) && '0' === $_POST['blog_public'] ) { |
9 | 193 |
$blog_public_off_checked = 'checked="checked"'; |
194 |
} else { |
|
195 |
$blog_public_on_checked = 'checked="checked"'; |
|
196 |
} |
|
197 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
|
0 | 199 |
<div id="privacy"> |
9 | 200 |
<p class="privacy-intro"> |
16 | 201 |
<?php _e( 'Privacy:' ); ?> |
9 | 202 |
<?php _e( 'Allow search engines to index this site.' ); ?> |
203 |
<br style="clear:both" /> |
|
204 |
<label class="checkbox" for="blog_public_on"> |
|
205 |
<input type="radio" id="blog_public_on" name="blog_public" value="1" <?php echo $blog_public_on_checked; ?> /> |
|
206 |
<strong><?php _e( 'Yes' ); ?></strong> |
|
207 |
</label> |
|
208 |
<label class="checkbox" for="blog_public_off"> |
|
209 |
<input type="radio" id="blog_public_off" name="blog_public" value="0" <?php echo $blog_public_off_checked; ?> /> |
|
210 |
<strong><?php _e( 'No' ); ?></strong> |
|
211 |
</label> |
|
212 |
</p> |
|
0 | 213 |
</div> |
214 |
||
215 |
<?php |
|
216 |
/** |
|
217 |
* Fires after the site sign-up form. |
|
218 |
* |
|
219 |
* @since 3.0.0 |
|
220 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
221 |
* @param WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. |
0 | 222 |
*/ |
223 |
do_action( 'signup_blogform', $errors ); |
|
224 |
} |
|
225 |
||
226 |
/** |
|
227 |
* Validate the new site signup |
|
228 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
229 |
* @since MU (3.0.0) |
0 | 230 |
* |
231 |
* @return array Contains the new site data and error messages. |
|
18 | 232 |
* See wpmu_validate_blog_signup() for details. |
0 | 233 |
*/ |
234 |
function validate_blog_form() { |
|
235 |
$user = ''; |
|
9 | 236 |
if ( is_user_logged_in() ) { |
0 | 237 |
$user = wp_get_current_user(); |
9 | 238 |
} |
0 | 239 |
|
9 | 240 |
return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user ); |
0 | 241 |
} |
242 |
||
243 |
/** |
|
18 | 244 |
* Displays the fields for the new user account registration form. |
0 | 245 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
* @since MU (3.0.0) |
0 | 247 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
* @param string $user_name The entered username. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
* @param string $user_email The entered email address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. |
0 | 251 |
*/ |
9 | 252 |
function show_user_form( $user_name = '', $user_email = '', $errors = '' ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
if ( ! is_wp_error( $errors ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
$errors = new WP_Error(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
|
16 | 257 |
// Username. |
9 | 258 |
echo '<label for="user_name">' . __( 'Username:' ) . '</label>'; |
259 |
$errmsg = $errors->get_error_message( 'user_name' ); |
|
260 |
if ( $errmsg ) { |
|
261 |
echo '<p class="error">' . $errmsg . '</p>'; |
|
0 | 262 |
} |
9 | 263 |
echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" autocapitalize="none" autocorrect="off" maxlength="60" /><br />'; |
0 | 264 |
_e( '(Must be at least 4 characters, letters and numbers only.)' ); |
265 |
?> |
|
266 |
||
9 | 267 |
<label for="user_email"><?php _e( 'Email Address:' ); ?></label> |
268 |
<?php |
|
269 |
$errmsg = $errors->get_error_message( 'user_email' ); |
|
270 |
if ( $errmsg ) { |
|
271 |
?> |
|
272 |
<p class="error"><?php echo $errmsg; ?></p> |
|
0 | 273 |
<?php } ?> |
9 | 274 |
<input name="user_email" type="email" id="user_email" value="<?php echo esc_attr( $user_email ); ?>" maxlength="200" /><br /><?php _e( 'We send your registration email to this address. (Double-check your email address before continuing.)' ); ?> |
0 | 275 |
<?php |
9 | 276 |
$errmsg = $errors->get_error_message( 'generic' ); |
277 |
if ( $errmsg ) { |
|
0 | 278 |
echo '<p class="error">' . $errmsg . '</p>'; |
279 |
} |
|
280 |
/** |
|
18 | 281 |
* Fires at the end of the new user account registration form. |
0 | 282 |
* |
283 |
* @since 3.0.0 |
|
284 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
* @param WP_Error $errors A WP_Error object containing 'user_name' or 'user_email' errors. |
0 | 286 |
*/ |
287 |
do_action( 'signup_extra_fields', $errors ); |
|
288 |
} |
|
289 |
||
290 |
/** |
|
291 |
* Validate user signup name and email |
|
292 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
* @since MU (3.0.0) |
0 | 294 |
* |
295 |
* @return array Contains username, email, and error messages. |
|
18 | 296 |
* See wpmu_validate_user_signup() for details. |
0 | 297 |
*/ |
298 |
function validate_user_form() { |
|
9 | 299 |
return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); |
0 | 300 |
} |
301 |
||
302 |
/** |
|
303 |
* Allow returning users to sign up for another site |
|
304 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
* @since MU (3.0.0) |
0 | 306 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
* @param string $blogname The new site name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
* @param string $blog_title The new site title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. |
0 | 310 |
*/ |
5 | 311 |
function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { |
0 | 312 |
$current_user = wp_get_current_user(); |
313 |
||
9 | 314 |
if ( ! is_wp_error( $errors ) ) { |
0 | 315 |
$errors = new WP_Error(); |
316 |
} |
|
317 |
||
318 |
$signup_defaults = array( |
|
319 |
'blogname' => $blogname, |
|
320 |
'blog_title' => $blog_title, |
|
9 | 321 |
'errors' => $errors, |
0 | 322 |
); |
323 |
||
324 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
* Filters the default site sign-up variables. |
0 | 326 |
* |
327 |
* @since 3.0.0 |
|
328 |
* |
|
329 |
* @param array $signup_defaults { |
|
330 |
* An array of default site sign-up variables. |
|
331 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
* @type string $blogname The site blogname. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
* @type string $blog_title The site title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
* @type WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. |
0 | 335 |
* } |
336 |
*/ |
|
337 |
$filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); |
|
338 |
||
9 | 339 |
$blogname = $filtered_results['blogname']; |
0 | 340 |
$blog_title = $filtered_results['blog_title']; |
9 | 341 |
$errors = $filtered_results['errors']; |
0 | 342 |
|
16 | 343 |
/* translators: %s: Network title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>'; |
0 | 345 |
|
9 | 346 |
if ( $errors->has_errors() ) { |
0 | 347 |
echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; |
348 |
} |
|
349 |
?> |
|
9 | 350 |
<p> |
351 |
<?php |
|
352 |
printf( |
|
353 |
/* translators: %s: Current user's display name. */ |
|
354 |
__( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ), |
|
355 |
$current_user->display_name |
|
356 |
); |
|
357 |
?> |
|
358 |
</p> |
|
0 | 359 |
|
360 |
<?php |
|
9 | 361 |
$blogs = get_blogs_of_user( $current_user->ID ); |
362 |
if ( ! empty( $blogs ) ) { |
|
363 |
?> |
|
0 | 364 |
|
9 | 365 |
<p><?php _e( 'Sites you are already a member of:' ); ?></p> |
0 | 366 |
<ul> |
9 | 367 |
<?php |
368 |
foreach ( $blogs as $blog ) { |
|
0 | 369 |
$home_url = get_home_url( $blog->userblog_id ); |
370 |
echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; |
|
9 | 371 |
} |
372 |
?> |
|
0 | 373 |
</ul> |
374 |
<?php } ?> |
|
375 |
||
9 | 376 |
<p><?php _e( 'If you’re not going to use a great site domain, leave it for a new user. Now have at it!' ); ?></p> |
0 | 377 |
<form id="setupform" method="post" action="wp-signup.php"> |
378 |
<input type="hidden" name="stage" value="gimmeanotherblog" /> |
|
379 |
<?php |
|
380 |
/** |
|
381 |
* Hidden sign-up form fields output when creating another site or user. |
|
382 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
* @since MU (3.0.0) |
0 | 384 |
* |
385 |
* @param string $context A string describing the steps of the sign-up process. The value can be |
|
386 |
* 'create-another-site', 'validate-user', or 'validate-site'. |
|
387 |
*/ |
|
388 |
do_action( 'signup_hidden_fields', 'create-another-site' ); |
|
389 |
?> |
|
9 | 390 |
<?php show_blog_form( $blogname, $blog_title, $errors ); ?> |
391 |
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ); ?>" /></p> |
|
0 | 392 |
</form> |
393 |
<?php |
|
394 |
} |
|
395 |
||
396 |
/** |
|
9 | 397 |
* Validate a new site signup for an existing user. |
398 |
* |
|
399 |
* @global string $blogname The new site's subdomain or directory name. |
|
400 |
* @global string $blog_title The new site's title. |
|
401 |
* @global WP_Error $errors Existing errors in the global scope. |
|
402 |
* @global string $domain The new site's domain. |
|
403 |
* @global string $path The new site's path. |
|
0 | 404 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
* @since MU (3.0.0) |
0 | 406 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
* @return null|bool True if site signup was validated, false if error. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
* The function halts all execution if the user is not logged in. |
0 | 409 |
*/ |
410 |
function validate_another_blog_signup() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
global $blogname, $blog_title, $errors, $domain, $path; |
0 | 412 |
$current_user = wp_get_current_user(); |
5 | 413 |
if ( ! is_user_logged_in() ) { |
0 | 414 |
die(); |
5 | 415 |
} |
0 | 416 |
|
417 |
$result = validate_blog_form(); |
|
5 | 418 |
|
419 |
// Extracted values set/overwrite globals. |
|
9 | 420 |
$domain = $result['domain']; |
421 |
$path = $result['path']; |
|
422 |
$blogname = $result['blogname']; |
|
5 | 423 |
$blog_title = $result['blog_title']; |
9 | 424 |
$errors = $result['errors']; |
0 | 425 |
|
9 | 426 |
if ( $errors->has_errors() ) { |
427 |
signup_another_blog( $blogname, $blog_title, $errors ); |
|
0 | 428 |
return false; |
429 |
} |
|
430 |
||
431 |
$public = (int) $_POST['blog_public']; |
|
432 |
||
433 |
$blog_meta_defaults = array( |
|
434 |
'lang_id' => 1, |
|
9 | 435 |
'public' => $public, |
0 | 436 |
); |
437 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
// Handle the language setting for the new site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
if ( ! empty( $_POST['WPLANG'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
$languages = signup_get_available_languages(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
|
16 | 443 |
if ( in_array( $_POST['WPLANG'], $languages, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
$language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
if ( $language ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
$blog_meta_defaults['WPLANG'] = $language; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
449 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
|
0 | 452 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
* Filters the new site meta variables. |
0 | 454 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
455 |
* Use the {@see 'add_signup_meta'} filter instead. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
* @since MU (3.0.0) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
* @deprecated 3.0.0 Use the {@see 'add_signup_meta'} filter instead. |
0 | 459 |
* |
460 |
* @param array $blog_meta_defaults An array of default blog meta variables. |
|
461 |
*/ |
|
16 | 462 |
$meta_defaults = apply_filters_deprecated( 'signup_create_blog_meta', array( $blog_meta_defaults ), '3.0.0', 'add_signup_meta' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
|
0 | 464 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
* Filters the new default site meta variables. |
0 | 466 |
* |
467 |
* @since 3.0.0 |
|
468 |
* |
|
469 |
* @param array $meta { |
|
470 |
* An array of default site meta variables. |
|
471 |
* |
|
472 |
* @type int $lang_id The language ID. |
|
473 |
* @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false. |
|
474 |
* } |
|
475 |
*/ |
|
5 | 476 |
$meta = apply_filters( 'add_signup_meta', $meta_defaults ); |
0 | 477 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
478 |
$blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, get_current_network_id() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
479 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
480 |
if ( is_wp_error( $blog_id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
confirm_another_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id ); |
0 | 485 |
return true; |
486 |
} |
|
487 |
||
488 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
* Confirm a new site signup. |
0 | 490 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
491 |
* @since MU (3.0.0) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
* @since 4.4.0 Added the `$blog_id` parameter. |
0 | 493 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
494 |
* @param string $domain The domain URL. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
495 |
* @param string $path The site root path. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
* @param string $blog_title The site title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
* @param string $user_name The username. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
498 |
* @param string $user_email The user's email address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
499 |
* @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
500 |
* @param int $blog_id The site ID. |
0 | 501 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
502 |
function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) { |
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 |
if ( $blog_id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
switch_to_blog( $blog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
506 |
$home_url = home_url( '/' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
507 |
$login_url = wp_login_url(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
restore_current_blog(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
509 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
$home_url = 'http://' . $domain . $path; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
511 |
$login_url = 'http://' . $domain . $path . 'wp-login.php'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
513 |
|
9 | 514 |
$site = sprintf( |
515 |
'<a href="%1$s">%2$s</a>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
esc_url( $home_url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
$blog_title |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
519 |
|
0 | 520 |
?> |
9 | 521 |
<h2> |
522 |
<?php |
|
16 | 523 |
/* translators: %s: Site title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
524 |
printf( __( 'The site %s is yours.' ), $site ); |
9 | 525 |
?> |
526 |
</h2> |
|
0 | 527 |
<p> |
9 | 528 |
<?php |
529 |
printf( |
|
16 | 530 |
/* translators: 1: Link to new site, 2: Login URL, 3: Username. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
531 |
__( '%1$s is your new site. <a href="%2$s">Log in</a> as “%3$s” using your existing password.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
532 |
sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
'<a href="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
534 |
esc_url( $home_url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
untrailingslashit( $domain . $path ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
537 |
esc_url( $login_url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
538 |
$user_name |
9 | 539 |
); |
540 |
?> |
|
0 | 541 |
</p> |
542 |
<?php |
|
543 |
/** |
|
544 |
* Fires when the site or user sign-up process is complete. |
|
545 |
* |
|
546 |
* @since 3.0.0 |
|
547 |
*/ |
|
548 |
do_action( 'signup_finished' ); |
|
549 |
} |
|
550 |
||
551 |
/** |
|
18 | 552 |
* Shows a form for a visitor to sign up for a new user account. |
0 | 553 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
554 |
* @since MU (3.0.0) |
0 | 555 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
556 |
* @param string $user_name The username. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
557 |
* @param string $user_email The user's email. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. |
0 | 559 |
*/ |
5 | 560 |
function signup_user( $user_name = '', $user_email = '', $errors = '' ) { |
561 |
global $active_signup; |
|
0 | 562 |
|
9 | 563 |
if ( ! is_wp_error( $errors ) ) { |
0 | 564 |
$errors = new WP_Error(); |
9 | 565 |
} |
0 | 566 |
|
9 | 567 |
$signup_for = isset( $_POST['signup_for'] ) ? esc_html( $_POST['signup_for'] ) : 'blog'; |
0 | 568 |
|
569 |
$signup_user_defaults = array( |
|
570 |
'user_name' => $user_name, |
|
571 |
'user_email' => $user_email, |
|
572 |
'errors' => $errors, |
|
573 |
); |
|
574 |
||
575 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
* Filters the default user variables used on the user sign-up form. |
0 | 577 |
* |
578 |
* @since 3.0.0 |
|
579 |
* |
|
580 |
* @param array $signup_user_defaults { |
|
581 |
* An array of default user variables. |
|
582 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
583 |
* @type string $user_name The user username. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
584 |
* @type string $user_email The user email address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
* @type WP_Error $errors A WP_Error object with possible errors relevant to the sign-up user. |
0 | 586 |
* } |
587 |
*/ |
|
588 |
$filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); |
|
9 | 589 |
$user_name = $filtered_results['user_name']; |
590 |
$user_email = $filtered_results['user_email']; |
|
591 |
$errors = $filtered_results['errors']; |
|
0 | 592 |
|
593 |
?> |
|
594 |
||
9 | 595 |
<h2> |
596 |
<?php |
|
16 | 597 |
/* translators: %s: Name of the network. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
598 |
printf( __( 'Get your own %s account in seconds' ), get_network()->site_name ); |
9 | 599 |
?> |
600 |
</h2> |
|
5 | 601 |
<form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> |
0 | 602 |
<input type="hidden" name="stage" value="validate-user-signup" /> |
603 |
<?php |
|
604 |
/** This action is documented in wp-signup.php */ |
|
605 |
do_action( 'signup_hidden_fields', 'validate-user' ); |
|
606 |
?> |
|
9 | 607 |
<?php show_user_form( $user_name, $user_email, $errors ); ?> |
0 | 608 |
|
609 |
<p> |
|
9 | 610 |
<?php if ( 'blog' === $active_signup ) { ?> |
0 | 611 |
<input id="signupblog" type="hidden" name="signup_for" value="blog" /> |
9 | 612 |
<?php } elseif ( 'user' === $active_signup ) { ?> |
0 | 613 |
<input id="signupblog" type="hidden" name="signup_for" value="user" /> |
614 |
<?php } else { ?> |
|
615 |
<input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> /> |
|
9 | 616 |
<label class="checkbox" for="signupblog"><?php _e( 'Gimme a site!' ); ?></label> |
0 | 617 |
<br /> |
618 |
<input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> /> |
|
9 | 619 |
<label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.' ); ?></label> |
0 | 620 |
<?php } ?> |
621 |
</p> |
|
622 |
||
9 | 623 |
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Next' ); ?>" /></p> |
0 | 624 |
</form> |
625 |
<?php |
|
626 |
} |
|
627 |
||
628 |
/** |
|
629 |
* Validate the new user signup |
|
630 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
631 |
* @since MU (3.0.0) |
0 | 632 |
* |
633 |
* @return bool True if new user signup was validated, false if error |
|
634 |
*/ |
|
635 |
function validate_user_signup() { |
|
9 | 636 |
$result = validate_user_form(); |
637 |
$user_name = $result['user_name']; |
|
5 | 638 |
$user_email = $result['user_email']; |
9 | 639 |
$errors = $result['errors']; |
0 | 640 |
|
9 | 641 |
if ( $errors->has_errors() ) { |
642 |
signup_user( $user_name, $user_email, $errors ); |
|
0 | 643 |
return false; |
644 |
} |
|
645 |
||
16 | 646 |
if ( 'blog' === $_POST['signup_for'] ) { |
9 | 647 |
signup_blog( $user_name, $user_email ); |
0 | 648 |
return false; |
649 |
} |
|
650 |
||
651 |
/** This filter is documented in wp-signup.php */ |
|
652 |
wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) ); |
|
653 |
||
9 | 654 |
confirm_user_signup( $user_name, $user_email ); |
0 | 655 |
return true; |
656 |
} |
|
657 |
||
658 |
/** |
|
659 |
* New user signup confirmation |
|
660 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
* @since MU (3.0.0) |
0 | 662 |
* |
663 |
* @param string $user_name The username |
|
664 |
* @param string $user_email The user's email address |
|
665 |
*/ |
|
9 | 666 |
function confirm_user_signup( $user_name, $user_email ) { |
667 |
?> |
|
668 |
<h2> |
|
669 |
<?php |
|
16 | 670 |
/* translators: %s: Username. */ |
9 | 671 |
printf( __( '%s is your new username' ), $user_name ) |
0 | 672 |
?> |
9 | 673 |
</h2> |
674 |
<p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ); ?></p> |
|
675 |
<p> |
|
676 |
<?php |
|
16 | 677 |
/* translators: %s: Email address. */ |
9 | 678 |
printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); |
679 |
?> |
|
680 |
</p> |
|
0 | 681 |
<p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p> |
682 |
<?php |
|
683 |
/** This action is documented in wp-signup.php */ |
|
684 |
do_action( 'signup_finished' ); |
|
685 |
} |
|
686 |
||
687 |
/** |
|
18 | 688 |
* Shows a form for a user or visitor to sign up for a new site. |
0 | 689 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
690 |
* @since MU (3.0.0) |
0 | 691 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
692 |
* @param string $user_name The username. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
* @param string $user_email The user's email address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
* @param string $blogname The site name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
* @param string $blog_title The site title. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. |
0 | 697 |
*/ |
9 | 698 |
function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) { |
699 |
if ( ! is_wp_error( $errors ) ) { |
|
0 | 700 |
$errors = new WP_Error(); |
9 | 701 |
} |
0 | 702 |
|
703 |
$signup_blog_defaults = array( |
|
704 |
'user_name' => $user_name, |
|
705 |
'user_email' => $user_email, |
|
706 |
'blogname' => $blogname, |
|
707 |
'blog_title' => $blog_title, |
|
9 | 708 |
'errors' => $errors, |
0 | 709 |
); |
710 |
||
711 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
* Filters the default site creation variables for the site sign-up form. |
0 | 713 |
* |
714 |
* @since 3.0.0 |
|
715 |
* |
|
716 |
* @param array $signup_blog_defaults { |
|
717 |
* An array of default site creation variables. |
|
718 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
719 |
* @type string $user_name The user username. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
* @type string $user_email The user email address. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
721 |
* @type string $blogname The blogname. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
* @type string $blog_title The title of the site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
723 |
* @type WP_Error $errors A WP_Error object with possible errors relevant to new site creation variables. |
0 | 724 |
* } |
725 |
*/ |
|
726 |
$filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults ); |
|
727 |
||
9 | 728 |
$user_name = $filtered_results['user_name']; |
0 | 729 |
$user_email = $filtered_results['user_email']; |
9 | 730 |
$blogname = $filtered_results['blogname']; |
0 | 731 |
$blog_title = $filtered_results['blog_title']; |
9 | 732 |
$errors = $filtered_results['errors']; |
0 | 733 |
|
9 | 734 |
if ( empty( $blogname ) ) { |
0 | 735 |
$blogname = $user_name; |
9 | 736 |
} |
0 | 737 |
?> |
738 |
<form id="setupform" method="post" action="wp-signup.php"> |
|
739 |
<input type="hidden" name="stage" value="validate-blog-signup" /> |
|
9 | 740 |
<input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ); ?>" /> |
741 |
<input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ); ?>" /> |
|
0 | 742 |
<?php |
743 |
/** This action is documented in wp-signup.php */ |
|
744 |
do_action( 'signup_hidden_fields', 'validate-site' ); |
|
745 |
?> |
|
9 | 746 |
<?php show_blog_form( $blogname, $blog_title, $errors ); ?> |
747 |
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Signup' ); ?>" /></p> |
|
0 | 748 |
</form> |
749 |
<?php |
|
750 |
} |
|
751 |
||
752 |
/** |
|
753 |
* Validate new site signup |
|
754 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
755 |
* @since MU (3.0.0) |
0 | 756 |
* |
757 |
* @return bool True if the site signup was validated, false if error |
|
758 |
*/ |
|
759 |
function validate_blog_signup() { |
|
760 |
// Re-validate user info. |
|
5 | 761 |
$user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); |
9 | 762 |
$user_name = $user_result['user_name']; |
763 |
$user_email = $user_result['user_email']; |
|
5 | 764 |
$user_errors = $user_result['errors']; |
0 | 765 |
|
9 | 766 |
if ( $user_errors->has_errors() ) { |
5 | 767 |
signup_user( $user_name, $user_email, $user_errors ); |
0 | 768 |
return false; |
769 |
} |
|
770 |
||
9 | 771 |
$result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] ); |
772 |
$domain = $result['domain']; |
|
773 |
$path = $result['path']; |
|
774 |
$blogname = $result['blogname']; |
|
5 | 775 |
$blog_title = $result['blog_title']; |
9 | 776 |
$errors = $result['errors']; |
0 | 777 |
|
9 | 778 |
if ( $errors->has_errors() ) { |
779 |
signup_blog( $user_name, $user_email, $blogname, $blog_title, $errors ); |
|
0 | 780 |
return false; |
781 |
} |
|
782 |
||
9 | 783 |
$public = (int) $_POST['blog_public']; |
784 |
$signup_meta = array( |
|
785 |
'lang_id' => 1, |
|
786 |
'public' => $public, |
|
787 |
); |
|
0 | 788 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
789 |
// Handle the language setting for the new site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
790 |
if ( ! empty( $_POST['WPLANG'] ) ) { |
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 |
$languages = signup_get_available_languages(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
|
16 | 794 |
if ( in_array( $_POST['WPLANG'], $languages, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
$language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
if ( $language ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
798 |
$signup_meta['WPLANG'] = $language; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
799 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
801 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
802 |
|
0 | 803 |
/** This filter is documented in wp-signup.php */ |
5 | 804 |
$meta = apply_filters( 'add_signup_meta', $signup_meta ); |
0 | 805 |
|
9 | 806 |
wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta ); |
807 |
confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta ); |
|
0 | 808 |
return true; |
809 |
} |
|
810 |
||
811 |
/** |
|
18 | 812 |
* Shows a message confirming that the new site has been registered and is awaiting activation. |
0 | 813 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
814 |
* @since MU (3.0.0) |
0 | 815 |
* |
18 | 816 |
* @param string $domain The domain or subdomain of the site. |
817 |
* @param string $path The path of the site. |
|
818 |
* @param string $blog_title The title of the new site. |
|
16 | 819 |
* @param string $user_name The user's username. |
820 |
* @param string $user_email The user's email address. |
|
821 |
* @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup(). |
|
0 | 822 |
*/ |
823 |
function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) { |
|
824 |
?> |
|
9 | 825 |
<h2> |
826 |
<?php |
|
16 | 827 |
/* translators: %s: Site address. */ |
9 | 828 |
printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) |
829 |
?> |
|
830 |
</h2> |
|
0 | 831 |
|
9 | 832 |
<p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ); ?></p> |
833 |
<p> |
|
834 |
<?php |
|
16 | 835 |
/* translators: %s: Email address. */ |
9 | 836 |
printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); |
837 |
?> |
|
838 |
</p> |
|
0 | 839 |
<p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p> |
840 |
<h2><?php _e( 'Still waiting for your email?' ); ?></h2> |
|
841 |
<p> |
|
9 | 842 |
<?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ); ?> |
0 | 843 |
<ul id="noemail-tips"> |
9 | 844 |
<li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ); ?></strong></p></li> |
845 |
<li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ); ?></p></li> |
|
846 |
<li> |
|
847 |
<?php |
|
16 | 848 |
/* translators: %s: Email address. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
849 |
printf( __( 'Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.' ), $user_email ); |
9 | 850 |
?> |
851 |
</li> |
|
0 | 852 |
</ul> |
853 |
</p> |
|
854 |
<?php |
|
855 |
/** This action is documented in wp-signup.php */ |
|
856 |
do_action( 'signup_finished' ); |
|
857 |
} |
|
858 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
859 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
860 |
* Retrieves languages available during the site/user signup process. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
861 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
863 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
864 |
* @see get_available_languages() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
865 |
* |
18 | 866 |
* @return string[] Array of available language codes. Language codes are formed by |
867 |
* stripping the .mo extension from the language file names. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
868 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
869 |
function signup_get_available_languages() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
870 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
871 |
* Filters the list of available languages for front-end site signups. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
872 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
873 |
* Passing an empty array to this hook will disable output of the setting on the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
874 |
* signup form, and the default language will be used when creating the site. |
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 |
* Languages not already installed will be stripped. |
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 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
* |
18 | 880 |
* @param string[] $languages Array of available language codes. Language codes are formed by |
881 |
* stripping the .mo extension from the language file names. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
882 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
883 |
$languages = (array) apply_filters( 'signup_get_available_languages', get_available_languages() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
884 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
885 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
886 |
* Strip any non-installed languages and return. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
887 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
* Re-call get_available_languages() here in case a language pack was installed |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
889 |
* in a callback hooked to the 'signup_get_available_languages' filter before this point. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
890 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
891 |
return array_intersect_assoc( $languages, get_available_languages() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
892 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
893 |
|
16 | 894 |
// Main. |
0 | 895 |
$active_signup = get_site_option( 'registration', 'none' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
896 |
|
0 | 897 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
898 |
* Filters the type of site sign-up. |
0 | 899 |
* |
900 |
* @since 3.0.0 |
|
901 |
* |
|
902 |
* @param string $active_signup String that returns registration type. The value can be |
|
903 |
* 'all', 'none', 'blog', or 'user'. |
|
904 |
*/ |
|
905 |
$active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); |
|
906 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
if ( current_user_can( 'manage_network' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
908 |
echo '<div class="mu_alert">'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
909 |
_e( 'Greetings Network Administrator!' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
910 |
echo ' '; |
0 | 911 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
912 |
switch ( $active_signup ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
913 |
case 'none': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
_e( 'The network currently disallows registrations.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
916 |
case 'blog': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
_e( 'The network currently allows site registrations.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
918 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
919 |
case 'user': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
920 |
_e( 'The network currently allows user registrations.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
921 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
922 |
default: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
923 |
_e( 'The network currently allows both site and user registrations.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
924 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
925 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
926 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
927 |
echo ' '; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
928 |
|
16 | 929 |
/* translators: %s: URL to Network Settings screen. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
930 |
printf( __( 'To change or disable registration go to your <a href="%s">Options page</a>.' ), esc_url( network_admin_url( 'settings.php' ) ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
931 |
echo '</div>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
932 |
} |
0 | 933 |
|
9 | 934 |
$newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null; |
0 | 935 |
|
936 |
$current_user = wp_get_current_user(); |
|
9 | 937 |
if ( 'none' === $active_signup ) { |
0 | 938 |
_e( 'Registration has been disabled.' ); |
9 | 939 |
} elseif ( 'blog' === $active_signup && ! is_user_logged_in() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
940 |
$login_url = wp_login_url( network_site_url( 'wp-signup.php' ) ); |
16 | 941 |
/* translators: %s: Login URL. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
942 |
printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url ); |
0 | 943 |
} else { |
9 | 944 |
$stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default'; |
0 | 945 |
switch ( $stage ) { |
9 | 946 |
case 'validate-user-signup': |
947 |
if ( 'all' === $active_signup |
|
948 |
|| ( 'blog' === $_POST['signup_for'] && 'blog' === $active_signup ) |
|
949 |
|| ( 'user' === $_POST['signup_for'] && 'user' === $active_signup ) |
|
950 |
) { |
|
0 | 951 |
validate_user_signup(); |
9 | 952 |
} else { |
0 | 953 |
_e( 'User registration has been disabled.' ); |
9 | 954 |
} |
955 |
break; |
|
0 | 956 |
case 'validate-blog-signup': |
9 | 957 |
if ( 'all' === $active_signup || 'blog' === $active_signup ) { |
0 | 958 |
validate_blog_signup(); |
9 | 959 |
} else { |
0 | 960 |
_e( 'Site registration has been disabled.' ); |
9 | 961 |
} |
0 | 962 |
break; |
963 |
case 'gimmeanotherblog': |
|
964 |
validate_another_blog_signup(); |
|
965 |
break; |
|
966 |
case 'default': |
|
9 | 967 |
default: |
968 |
$user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : ''; |
|
0 | 969 |
/** |
970 |
* Fires when the site sign-up form is sent. |
|
971 |
* |
|
972 |
* @since 3.0.0 |
|
973 |
*/ |
|
974 |
do_action( 'preprocess_signup_form' ); |
|
9 | 975 |
if ( is_user_logged_in() && ( 'all' === $active_signup || 'blog' === $active_signup ) ) { |
976 |
signup_another_blog( $newblogname ); |
|
977 |
} elseif ( ! is_user_logged_in() && ( 'all' === $active_signup || 'user' === $active_signup ) ) { |
|
0 | 978 |
signup_user( $newblogname, $user_email ); |
9 | 979 |
} elseif ( ! is_user_logged_in() && ( 'blog' === $active_signup ) ) { |
0 | 980 |
_e( 'Sorry, new registrations are not allowed at this time.' ); |
9 | 981 |
} else { |
0 | 982 |
_e( 'You are logged in already. No need to register again!' ); |
9 | 983 |
} |
0 | 984 |
|
985 |
if ( $newblogname ) { |
|
986 |
$newblog = get_blogaddress_by_name( $newblogname ); |
|
987 |
||
9 | 988 |
if ( 'blog' === $active_signup || 'all' === $active_signup ) { |
989 |
printf( |
|
16 | 990 |
/* translators: %s: Site address. */ |
18 | 991 |
'<p>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</p>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
992 |
'<strong>' . $newblog . '</strong>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
993 |
); |
9 | 994 |
} else { |
995 |
printf( |
|
16 | 996 |
/* translators: %s: Site address. */ |
18 | 997 |
'<p>' . __( 'The site you were looking for, %s, does not exist.' ) . '</p>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
998 |
'<strong>' . $newblog . '</strong>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
999 |
); |
9 | 1000 |
} |
0 | 1001 |
} |
1002 |
break; |
|
1003 |
} |
|
1004 |
} |
|
1005 |
?> |
|
1006 |
</div> |
|
1007 |
</div> |
|
1008 |
<?php |
|
1009 |
/** |
|
1010 |
* Fires after the sign-up forms, before wp_footer. |
|
1011 |
* |
|
1012 |
* @since 3.0.0 |
|
1013 |
*/ |
|
9 | 1014 |
do_action( 'after_signup_form' ); |
1015 |
?> |
|
0 | 1016 |
|
9 | 1017 |
<?php |
1018 |
get_footer( 'wp-signup' ); |