$app_name ) ); if ( is_wp_error( $created ) ) { $error = $created; } else { list( $new_password ) = $created; if ( $success_url ) { $redirect = add_query_arg( array( 'username' => urlencode( wp_get_current_user()->user_login ), 'password' => urlencode( $new_password ), ), $success_url ); } } } if ( $redirect ) { // Explicitly not using wp_safe_redirect b/c sends to arbitrary domain. wp_redirect( $redirect ); exit; } } $title = __( 'Authorize Application' ); $app_name = ! empty( $_REQUEST['app_name'] ) ? $_REQUEST['app_name'] : ''; $success_url = ! empty( $_REQUEST['success_url'] ) ? $_REQUEST['success_url'] : null; $reject_url = ! empty( $_REQUEST['reject_url'] ) ? $_REQUEST['reject_url'] : $success_url; $user = wp_get_current_user(); $request = compact( 'app_name', 'success_url', 'reject_url' ); $is_valid = wp_is_authorize_application_password_request_valid( $request, $user ); if ( is_wp_error( $is_valid ) ) { wp_die( __( 'The Authorize Application request is not allowed.' ) . ' ' . implode( ' ', $is_valid->get_error_messages() ), __( 'Cannot Authorize Application' ) ); } if ( ! wp_is_application_passwords_available_for_user( $user ) ) { if ( wp_is_application_passwords_available() ) { $message = __( 'Application passwords are not enabled for your account. Please contact the site administrator for assistance.' ); } else { $message = __( 'Application passwords are not enabled.' ); } wp_die( $message, __( 'Cannot Authorize Application' ), array( 'link_text' => __( 'Go Back' ), 'link_url' => $reject_url ? add_query_arg( 'error', 'disabled', $reject_url ) : admin_url(), ) ); } wp_enqueue_script( 'auth-app' ); wp_localize_script( 'auth-app', 'authApp', array( 'user_login' => $user->user_login, 'success' => $success_url, 'reject' => $reject_url ? $reject_url : admin_url(), ) ); require_once ABSPATH . 'wp-admin/admin-header.php'; ?>

get_error_message(); ?>

' . esc_html( $app_name ) . '' ); ?>

' . esc_html( $app_name ) . '', '' . esc_html( WP_Application_Passwords::chunk_password( $new_password ) ) . '' ); ?>


' . esc_html( add_query_arg( array( 'username' => $user->user_login, 'password' => '[------]', ), $success_url ) ) . '' ); } else { _e( 'You will be given a password to manually enter into the application in question.' ); } ?>


' . esc_html( add_query_arg( array( 'success' => 'false', ), $reject_url ) ) . '' ); } else { _e( 'You will be returned to the WordPress Dashboard, and no changes will be made.' ); } ?>