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