60 wp_redirect( $redirect ); |
60 wp_redirect( $redirect ); |
61 exit; |
61 exit; |
62 } |
62 } |
63 } |
63 } |
64 |
64 |
|
65 // Used in the HTML title tag. |
65 $title = __( 'Authorize Application' ); |
66 $title = __( 'Authorize Application' ); |
66 |
67 |
67 $app_name = ! empty( $_REQUEST['app_name'] ) ? $_REQUEST['app_name'] : ''; |
68 $app_name = ! empty( $_REQUEST['app_name'] ) ? $_REQUEST['app_name'] : ''; |
68 $app_id = ! empty( $_REQUEST['app_id'] ) ? $_REQUEST['app_id'] : ''; |
69 $app_id = ! empty( $_REQUEST['app_id'] ) ? $_REQUEST['app_id'] : ''; |
69 $success_url = ! empty( $_REQUEST['success_url'] ) ? $_REQUEST['success_url'] : null; |
70 $success_url = ! empty( $_REQUEST['success_url'] ) ? $_REQUEST['success_url'] : null; |
88 ); |
89 ); |
89 } |
90 } |
90 |
91 |
91 if ( wp_is_site_protected_by_basic_auth( 'front' ) ) { |
92 if ( wp_is_site_protected_by_basic_auth( 'front' ) ) { |
92 wp_die( |
93 wp_die( |
93 __( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ), |
94 __( 'Your website appears to use Basic Authentication, which is not currently compatible with application passwords.' ), |
94 __( 'Cannot Authorize Application' ), |
95 __( 'Cannot Authorize Application' ), |
95 array( |
96 array( |
96 'response' => 501, |
97 'response' => 501, |
97 'link_text' => __( 'Go Back' ), |
98 'link_text' => __( 'Go Back' ), |
98 'link_url' => $reject_url ? add_query_arg( 'error', 'disabled', $reject_url ) : admin_url(), |
99 'link_url' => $reject_url ? add_query_arg( 'error', 'disabled', $reject_url ) : admin_url(), |
145 <?php if ( $app_name ) : ?> |
146 <?php if ( $app_name ) : ?> |
146 <p> |
147 <p> |
147 <?php |
148 <?php |
148 printf( |
149 printf( |
149 /* translators: %s: Application name. */ |
150 /* translators: %s: Application name. */ |
150 __( 'Would you like to give the application identifying itself as %s access to your account? You should only do this if you trust the app in question.' ), |
151 __( 'Would you like to give the application identifying itself as %s access to your account? You should only do this if you trust the application in question.' ), |
151 '<strong>' . esc_html( $app_name ) . '</strong>' |
152 '<strong>' . esc_html( $app_name ) . '</strong>' |
152 ); |
153 ); |
153 ?> |
154 ?> |
154 </p> |
155 </p> |
155 <?php else : ?> |
156 <?php else : ?> |
156 <p><?php _e( 'Would you like to give this application access to your account? You should only do this if you trust the app in question.' ); ?></p> |
157 <p><?php _e( 'Would you like to give this application access to your account? You should only do this if you trust the application in question.' ); ?></p> |
157 <?php endif; ?> |
158 <?php endif; ?> |
158 |
159 |
159 <?php |
160 <?php |
160 if ( is_multisite() ) { |
161 if ( is_multisite() ) { |
161 $blogs = get_blogs_of_user( $user->ID, true ); |
162 $blogs = get_blogs_of_user( $user->ID, true ); |
162 $blogs_count = count( $blogs ); |
163 $blogs_count = count( $blogs ); |
|
164 |
163 if ( $blogs_count > 1 ) { |
165 if ( $blogs_count > 1 ) { |
164 ?> |
166 ?> |
165 <p> |
167 <p> |
166 <?php |
168 <?php |
|
169 /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ |
|
170 $message = _n( |
|
171 'This will grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.', |
|
172 'This will grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.', |
|
173 $blogs_count |
|
174 ); |
|
175 |
|
176 if ( is_super_admin() ) { |
|
177 /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ |
|
178 $message = _n( |
|
179 'This will grant access to <a href="%1$s">the %2$s site on the network as you have Super Admin rights</a>.', |
|
180 'This will grant access to <a href="%1$s">all %2$s sites on the network as you have Super Admin rights</a>.', |
|
181 $blogs_count |
|
182 ); |
|
183 } |
|
184 |
167 printf( |
185 printf( |
168 /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ |
186 $message, |
169 _n( |
|
170 'This will grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.', |
|
171 'This will grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.', |
|
172 $blogs_count |
|
173 ), |
|
174 admin_url( 'my-sites.php' ), |
187 admin_url( 'my-sites.php' ), |
175 number_format_i18n( $blogs_count ) |
188 number_format_i18n( $blogs_count ) |
176 ); |
189 ); |
177 ?> |
190 ?> |
178 </p> |
191 </p> |
222 <input type="hidden" name="success_url" value="<?php echo esc_url( $success_url ); ?>" /> |
235 <input type="hidden" name="success_url" value="<?php echo esc_url( $success_url ); ?>" /> |
223 <input type="hidden" name="reject_url" value="<?php echo esc_url( $reject_url ); ?>" /> |
236 <input type="hidden" name="reject_url" value="<?php echo esc_url( $reject_url ); ?>" /> |
224 |
237 |
225 <div class="form-field"> |
238 <div class="form-field"> |
226 <label for="app_name"><?php _e( 'New Application Password Name' ); ?></label> |
239 <label for="app_name"><?php _e( 'New Application Password Name' ); ?></label> |
227 <input type="text" id="app_name" name="app_name" value="<?php echo esc_attr( $app_name ); ?>" placeholder="<?php esc_attr_e( 'WordPress App on My Phone' ); ?>" required /> |
240 <input type="text" id="app_name" name="app_name" value="<?php echo esc_attr( $app_name ); ?>" required /> |
228 </div> |
241 </div> |
229 |
242 |
230 <?php |
243 <?php |
231 /** |
244 /** |
232 * Fires in the Authorize Application Password form before the submit buttons. |
245 * Fires in the Authorize Application Password form before the submit buttons. |
245 do_action( 'wp_authorize_application_password_form', $request, $user ); |
258 do_action( 'wp_authorize_application_password_form', $request, $user ); |
246 ?> |
259 ?> |
247 |
260 |
248 <?php |
261 <?php |
249 submit_button( |
262 submit_button( |
250 __( 'Yes, I approve of this connection.' ), |
263 __( 'Yes, I approve of this connection' ), |
251 'primary', |
264 'primary', |
252 'approve', |
265 'approve', |
253 false, |
266 false, |
254 array( |
267 array( |
255 'aria-describedby' => 'description-approve', |
268 'aria-describedby' => 'description-approve', |
260 <?php |
273 <?php |
261 if ( $success_url ) { |
274 if ( $success_url ) { |
262 printf( |
275 printf( |
263 /* translators: %s: The URL the user is being redirected to. */ |
276 /* translators: %s: The URL the user is being redirected to. */ |
264 __( 'You will be sent to %s' ), |
277 __( 'You will be sent to %s' ), |
265 '<strong><kbd>' . esc_html( |
278 '<strong><code>' . esc_html( |
266 add_query_arg( |
279 add_query_arg( |
267 array( |
280 array( |
268 'site_url' => site_url(), |
281 'site_url' => site_url(), |
269 'user_login' => $user->user_login, |
282 'user_login' => $user->user_login, |
270 'password' => '[------]', |
283 'password' => '[------]', |
271 ), |
284 ), |
272 $success_url |
285 $success_url |
273 ) |
286 ) |
274 ) . '</kbd></strong>' |
287 ) . '</code></strong>' |
275 ); |
288 ); |
276 } else { |
289 } else { |
277 _e( 'You will be given a password to manually enter into the application in question.' ); |
290 _e( 'You will be given a password to manually enter into the application in question.' ); |
278 } |
291 } |
279 ?> |
292 ?> |
280 </p> |
293 </p> |
281 |
294 |
282 <?php |
295 <?php |
283 submit_button( |
296 submit_button( |
284 __( 'No, I do not approve of this connection.' ), |
297 __( 'No, I do not approve of this connection' ), |
285 'secondary', |
298 'secondary', |
286 'reject', |
299 'reject', |
287 false, |
300 false, |
288 array( |
301 array( |
289 'aria-describedby' => 'description-reject', |
302 'aria-describedby' => 'description-reject', |
294 <?php |
307 <?php |
295 if ( $reject_url ) { |
308 if ( $reject_url ) { |
296 printf( |
309 printf( |
297 /* translators: %s: The URL the user is being redirected to. */ |
310 /* translators: %s: The URL the user is being redirected to. */ |
298 __( 'You will be sent to %s' ), |
311 __( 'You will be sent to %s' ), |
299 '<strong><kbd>' . esc_html( $reject_url ) . '</kbd></strong>' |
312 '<strong><code>' . esc_html( $reject_url ) . '</code></strong>' |
300 ); |
313 ); |
301 } else { |
314 } else { |
302 _e( 'You will be returned to the WordPress Dashboard, and no changes will be made.' ); |
315 _e( 'You will be returned to the WordPress Dashboard, and no changes will be made.' ); |
303 } |
316 } |
304 ?> |
317 ?> |