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