display_setup_form( string|null $error = null )

Display installer setup form.


Parameters

$error

(Optional)

Default value: null


Source

File: wp-admin/install.php

function display_setup_form( $error = null ) {

	// Check for users table.
	global $wpdb;
	$sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->users ) );
	$user_table = ( $wpdb->get_var( $sql ) != null );

	// Ensure that sites appear in search engines by default.
	$blog_public = 1;

	// Get and parse submitted data.
	if ( isset( $_POST['weblog_title'] ) ) {
		$blog_public = isset( $_POST['blog_public'] ) ? 1 : 0;
	}
	$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
	$user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
	$admin_email  = isset( $_POST['admin_email']  ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';

	// Print input error, if any.
	if ( ! is_null( $error ) ) {
		echo '<h1>' . __( 'Admin Setup' ) . '</h1>' . "\n";
		echo '<p class="message">' . $error . '</p>' . "\n";
	}

	// Form for site title and admin user setup.
	echo '<form id="setup" method="post" action="install.php?step=2" novalidate="novalidate">' . "\n";
	echo '<table class="form-table">' . "\n";
	// Site title.
	echo '	<tr>' . "\n";
	echo '		<th scope="row"><label for="weblog_title">' . __( 'Site Title' ) . '</label></th>' . "\n";
	echo '		<td><input name="weblog_title" type="text" id="weblog_title" size="25" value="' . esc_attr( $weblog_title ) . '" /></td>' . "\n";
	echo '	</tr>' . "\n";
	// Admin username.
	echo '	<tr>' . "\n";
	echo '		<th scope="row"><label for="user_login">' . __( 'Admin Username' ) . '</label></th>' . "\n";
	echo '		<td>';
	// Desired user already exists?
	if ( $user_table ) {
		_e( 'User(s) already exists.' );
		echo '<input name="user_name" type="hidden" value="admin" />';
	} else { // ...no?
		echo '<input name="user_name" type="text" id="user_login" size="25" value="' . esc_attr( sanitize_user( $user_name, true ) ) . '" />';
		echo '<p class="description" style="max-width:300px;">' . __( 'Letters, numbers, spaces, underscores, hyphens, periods, and the @ symbol only. Usernames cannot be changed.' ) . '</p>';
	}
	echo '</td>' . "\n";
	echo '	</tr>' . "\n";
	// Non-existing user? Great. Add the admin password fields.
	if ( ! $user_table ) {
		// Create a random password to suggest.
		$initial_password = isset( $_POST['admin_password'] ) ? stripslashes( $_POST['admin_password'] ) : wp_generate_password( 18 );
		// Admin password.
		echo '	<tr class="form-field form-required user-pass1-wrap">' . "\n";
		echo '		<th scope="row">' . "\n";
		echo '			<label for="pass1">' . __( 'Admin Password' ) . '</label>' . "\n";
		echo '		</th>' . "\n";
		echo '		<td>' . "\n";
		echo '			<div>' . "\n";
		echo '				<input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="' . esc_attr( $initial_password ) . '" aria-describedby="pass-strength-result" />' . "\n";
		echo '				<button type="button" class="button wp-hide-pw hide-if-no-js" data-start-masked="' . (int) isset( $_POST['admin_password'] ) . '" data-toggle="0" aria-label="' . esc_attr( 'Hide password' ) . '">' . "\n";
		echo '					<span class="dashicons dashicons-hidden"></span>' . "\n";
		echo '					<span class="text">' . __( 'Hide' ) . '</span>' . "\n";
		echo '				</button>' . "\n";
		echo '				<div id="pass-strength-result" aria-live="polite"></div>' . "\n";
		echo '			</div>' . "\n";
		echo '		</td>' . "\n";
		echo '	</tr>' . "\n";
		// Repeat password.
		echo '	<tr class="form-field form-required user-pass2-wrap hide-if-js">' . "\n";
		echo '		<th scope="row">' . "\n";
		echo '			<label for="pass2">' . __( 'Repeat Password' );
		echo '				<span class="description">' . __( '(required)' ) . '</span>' . "\n";
		echo '			</label>' . "\n";
		echo '		</th>' . "\n";
		echo '		<td>' . "\n";
		echo '			<input name="admin_password2" type="password" id="pass2" autocomplete="off" />' . "\n";
		echo '		</td>' . "\n";
		echo '	</tr>' . "\n";
		// Weak password confirmation.
		echo '	<tr class="pw-weak">' . "\n";
		echo '		<th scope="row">' . __( 'Confirm Password' ) . '</th>' . "\n";
		echo '		<td>' . "\n";
		echo '			<label>' . "\n";
		echo '			<input type="checkbox" name="pw_weak" class="pw-checkbox" />' . __( 'Confirm use of weak password' );
		echo '			</label>' . "\n";
		echo '		</td>' . "\n";
		echo '	</tr>' . "\n";
	} // end ( ! $user_table )
	// Admin email.
	echo '	<tr>' . "\n";
	echo '		<th scope="row"><label for="admin_email">' . __( 'Admin Email' ) . '</label></th>' . "\n";
	echo '		<td><input name="admin_email" type="email" id="admin_email" size="25" value="' . esc_attr( $admin_email ) . '" />' . "\n";
	echo '			<p class="description">' . __( 'Double-check your email address.' ) . '</p></td>' . "\n";
	echo '	</tr>' . "\n";
	// Search engine privacy.
	echo '	<tr>' . "\n";
	echo '		<th scope="row"><label for="blog_public">' . ( has_action( 'blog_privacy_selector' ) ? __( 'Site Visibility' ) : __( 'Search Engine Visibility' ) ) . '</label></th>' . "\n";
	echo '		<td>' . "\n";
	echo '			<fieldset>' . "\n";
	echo '				<legend class="screen-reader-text"><span>' . ( has_action( 'blog_privacy_selector' ) ? __( 'Site Visibility' ) : __( 'Search Engine Visibility' ) ) . '</span></legend>' . "\n";
	if ( has_action( 'blog_privacy_selector' ) ) {
		echo '				<input id="blog_public" type="radio" name="blog_public" value="1" ' . checked( 1, $blog_public, false ) . ' />' . "\n";
		echo '				<label for="blog_public">' . __( 'Allow search engines to index this site' ) . '</label><br/>' . "\n";
		echo '				<input id="blog-norobots" type="radio" name="blog_public" value="0" ' . checked( 0, $blog_public, false ) . ' />' . "\n";
		echo '				<label for="blog-norobots">' . __( 'Discourage search engines from indexing this site' ) . '</label>' . "\n";
		echo '				<p class="description">' . __( 'Note: Neither of these options blocks access to your site &mdash; it is up to search engines to honor your request.' ) . '</p>' . "\n";
		/** This action is documented in wp-admin/options-reading.php */
		do_action( 'blog_privacy_selector' );
	} else {
		echo '				<input name="blog_public" type="checkbox" id="blog_public" value="0" ' . checked( 0, $blog_public, false ) . ' /> ';
		echo '<label for="blog_public">' . __( 'Discourage search engines from indexing this site' ) . '</label>' . "\n";
	}
	echo '			</fieldset>' . "\n";
	echo '		</td>' . "\n";
	echo '	</tr>' . "\n";
	// Close the table; add a submit button; add hidden lang arg; close form.
	echo '</table>' . "\n";
	echo '<p class="step"><input name="submit" id="submit" type="submit" value="' . htmlspecialchars( __( 'Install ClassicPress' ), ENT_QUOTES ) . '" class="button button-primary button-hero cp-button" /></p>' . "\n";
	echo '<input type="hidden" name="language" value="' . ( isset( $_REQUEST['language'] ) ? esc_attr( $_REQUEST['language'] ) : '' ) . '" />' . "\n";
	echo '</form>' . "\n";
}


Changelog

Changelog
Version Description
WP-2.8.0 Introduced.