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