wp/wp-admin/authorize-application.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
   135 
   135 
   136 ?>
   136 ?>
   137 <div class="wrap">
   137 <div class="wrap">
   138 	<h1><?php echo esc_html( $title ); ?></h1>
   138 	<h1><?php echo esc_html( $title ); ?></h1>
   139 
   139 
   140 	<?php if ( is_wp_error( $error ) ) : ?>
   140 	<?php
   141 		<div class="notice notice-error"><p><?php echo $error->get_error_message(); ?></p></div>
   141 	if ( is_wp_error( $error ) ) {
   142 	<?php endif; ?>
   142 		wp_admin_notice(
       
   143 			$error->get_error_message(),
       
   144 			array(
       
   145 				'type' => 'error',
       
   146 			)
       
   147 		);
       
   148 	}
       
   149 	?>
   143 
   150 
   144 	<div class="card auth-app-card">
   151 	<div class="card auth-app-card">
   145 		<h2 class="title"><?php _e( 'An application would like to connect to your account.' ); ?></h2>
   152 		<h2 class="title"><?php _e( 'An application would like to connect to your account.' ); ?></h2>
   146 		<?php if ( $app_name ) : ?>
   153 		<?php if ( $app_name ) : ?>
   147 			<p>
   154 			<p>
   192 				<?php
   199 				<?php
   193 			}
   200 			}
   194 		}
   201 		}
   195 		?>
   202 		?>
   196 
   203 
   197 		<?php if ( $new_password ) : ?>
   204 		<?php
   198 			<div class="notice notice-success notice-alt below-h2">
   205 		if ( $new_password ) :
   199 				<p class="application-password-display">
   206 			$message = '<p class="application-password-display">
   200 					<label for="new-application-password-value">
   207 				<label for="new-application-password-value">' . sprintf(
   201 						<?php
   208 				/* translators: %s: Application name. */
   202 						printf(
   209 				esc_html__( 'Your new password for %s is:' ),
   203 							/* translators: %s: Application name. */
   210 				'<strong>' . esc_html( $app_name ) . '</strong>'
   204 							esc_html__( 'Your new password for %s is:' ),
   211 			) . '
   205 							'<strong>' . esc_html( $app_name ) . '</strong>'
   212 				</label>
   206 						);
   213 				<input id="new-application-password-value" type="text" class="code" readonly="readonly" value="' . esc_attr( WP_Application_Passwords::chunk_password( $new_password ) ) . '" />
   207 						?>
   214 			</p>
   208 					</label>
   215 			<p>' . __( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ) . '</p>';
   209 					<input id="new-application-password-value" type="text" class="code" readonly="readonly" value="<?php esc_attr( WP_Application_Passwords::chunk_password( $new_password ) ); ?>" />
   216 			$args = array(
   210 				</p>
   217 				'type'               => 'success',
   211 				<p><?php _e( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ); ?></p>
   218 				'additional_classes' => array( 'notice-alt', 'below-h2' ),
   212 			</div>
   219 				'paragraph_wrap'     => false,
   213 
   220 			);
   214 			<?php
   221 			wp_admin_notice( $message, $args );
       
   222 
   215 			/**
   223 			/**
   216 			 * Fires in the Authorize Application Password new password section in the no-JS version.
   224 			 * Fires in the Authorize Application Password new password section in the no-JS version.
   217 			 *
   225 			 *
   218 			 * In most cases, this should be used in combination with the {@see 'wp_application_passwords_approve_app_request_success'}
   226 			 * In most cases, this should be used in combination with the {@see 'wp_application_passwords_approve_app_request_success'}
   219 			 * action to ensure that both the JS and no-JS variants are handled.
   227 			 * action to ensure that both the JS and no-JS variants are handled.
   224 			 * @param string  $new_password The newly generated application password.
   232 			 * @param string  $new_password The newly generated application password.
   225 			 * @param array   $request      The array of request data. All arguments are optional and may be empty.
   233 			 * @param array   $request      The array of request data. All arguments are optional and may be empty.
   226 			 * @param WP_User $user         The user authorizing the application.
   234 			 * @param WP_User $user         The user authorizing the application.
   227 			 */
   235 			 */
   228 			do_action( 'wp_authorize_application_password_form_approved_no_js', $new_password, $request, $user );
   236 			do_action( 'wp_authorize_application_password_form_approved_no_js', $new_password, $request, $user );
       
   237 		else :
   229 			?>
   238 			?>
   230 		<?php else : ?>
       
   231 			<form action="<?php echo esc_url( admin_url( 'authorize-application.php' ) ); ?>" method="post" class="form-wrap">
   239 			<form action="<?php echo esc_url( admin_url( 'authorize-application.php' ) ); ?>" method="post" class="form-wrap">
   232 				<?php wp_nonce_field( 'authorize_application_password' ); ?>
   240 				<?php wp_nonce_field( 'authorize_application_password' ); ?>
   233 				<input type="hidden" name="action" value="authorize_application_password" />
   241 				<input type="hidden" name="action" value="authorize_application_password" />
   234 				<input type="hidden" name="app_id" value="<?php echo esc_attr( $app_id ); ?>" />
   242 				<input type="hidden" name="app_id" value="<?php echo esc_attr( $app_id ); ?>" />
   235 				<input type="hidden" name="success_url" value="<?php echo esc_url( $success_url ); ?>" />
   243 				<input type="hidden" name="success_url" value="<?php echo esc_url( $success_url ); ?>" />
   248 				 *
   256 				 *
   249 				 * @param array   $request {
   257 				 * @param array   $request {
   250 				 *     The array of request data. All arguments are optional and may be empty.
   258 				 *     The array of request data. All arguments are optional and may be empty.
   251 				 *
   259 				 *
   252 				 *     @type string $app_name    The suggested name of the application.
   260 				 *     @type string $app_name    The suggested name of the application.
   253 				 *     @type string $success_url The url the user will be redirected to after approving the application.
   261 				 *     @type string $success_url The URL the user will be redirected to after approving the application.
   254 				 *     @type string $reject_url  The url the user will be redirected to after rejecting the application.
   262 				 *     @type string $reject_url  The URL the user will be redirected to after rejecting the application.
   255 				 * }
   263 				 * }
   256 				 * @param WP_User $user The user authorizing the application.
   264 				 * @param WP_User $user The user authorizing the application.
   257 				 */
   265 				 */
   258 				do_action( 'wp_authorize_application_password_form', $request, $user );
   266 				do_action( 'wp_authorize_application_password_form', $request, $user );
   259 				?>
   267 				?>