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