wp/wp-admin/setup-config.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    90  * @since 2.3.0
    90  * @since 2.3.0
    91  *
    91  *
    92  * @global string    $wp_local_package Locale code of the package.
    92  * @global string    $wp_local_package Locale code of the package.
    93  * @global WP_Locale $wp_locale        WordPress date and time locale object.
    93  * @global WP_Locale $wp_locale        WordPress date and time locale object.
    94  *
    94  *
    95  * @param string|array $body_classes
    95  * @param string|string[] $body_classes Class attribute values for the body tag.
    96  */
    96  */
    97 function setup_config_display_header( $body_classes = array() ) {
    97 function setup_config_display_header( $body_classes = array() ) {
    98 	$body_classes   = (array) $body_classes;
    98 	$body_classes   = (array) $body_classes;
    99 	$body_classes[] = 'wp-core-ui';
    99 	$body_classes[] = 'wp-core-ui';
   100 	$dir_attr       = '';
   100 	$dir_attr       = '';
   424 	el.select();
   424 	el.select();
   425 }
   425 }
   426 })();
   426 })();
   427 </script>
   427 </script>
   428 			<?php
   428 			<?php
   429 	else :
   429 		else :
   430 		/*
   430 			/*
   431 		 * If this file doesn't exist, then we are using the wp-config-sample.php
   431 			 * If this file doesn't exist, then we are using the wp-config-sample.php
   432 		 * file one level up, which is for the develop repo.
   432 			 * file one level up, which is for the develop repo.
   433 		 */
   433 			 */
   434 		if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) {
   434 			if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) {
   435 			$path_to_wp_config = ABSPATH . 'wp-config.php';
   435 				$path_to_wp_config = ABSPATH . 'wp-config.php';
   436 		} else {
   436 			} else {
   437 			$path_to_wp_config = dirname( ABSPATH ) . '/wp-config.php';
   437 				$path_to_wp_config = dirname( ABSPATH ) . '/wp-config.php';
   438 		}
   438 			}
   439 
   439 
   440 		$handle = fopen( $path_to_wp_config, 'w' );
   440 			$error_message = '';
   441 		foreach ( $config_file as $line ) {
   441 			$handle        = fopen( $path_to_wp_config, 'w' );
   442 			fwrite( $handle, $line );
   442 			/*
   443 		}
   443 			 * Why check for the absence of false instead of checking for resource with is_resource()?
   444 		fclose( $handle );
   444 			 * To future-proof the check for when fopen returns object instead of resource, i.e. a known
   445 		chmod( $path_to_wp_config, 0666 );
   445 			 * change coming in PHP.
   446 		setup_config_display_header();
   446 			 */
   447 		?>
   447 			if ( false !== $handle ) {
       
   448 				foreach ( $config_file as $line ) {
       
   449 					fwrite( $handle, $line );
       
   450 				}
       
   451 				fclose( $handle );
       
   452 			} else {
       
   453 				$wp_config_perms = fileperms( $path_to_wp_config );
       
   454 				if ( ! empty( $wp_config_perms ) && ! is_writable( $path_to_wp_config ) ) {
       
   455 					$error_message = sprintf(
       
   456 						/* translators: 1: wp-config.php, 2: Documentation URL. */
       
   457 						__( 'You need to make the file %1$s writable before you can save your changes. See <a href="%2$s">Changing File Permissions</a> for more information.' ),
       
   458 						'<code>wp-config.php</code>',
       
   459 						__( 'https://wordpress.org/support/article/changing-file-permissions/' )
       
   460 					);
       
   461 				} else {
       
   462 					$error_message = sprintf(
       
   463 						/* translators: %s: wp-config.php */
       
   464 						__( 'Unable to write to %s file.' ),
       
   465 						'<code>wp-config.php</code>'
       
   466 					);
       
   467 				}
       
   468 			}
       
   469 
       
   470 			chmod( $path_to_wp_config, 0666 );
       
   471 			setup_config_display_header();
       
   472 
       
   473 			if ( false !== $handle ) :
       
   474 				?>
   448 <h1 class="screen-reader-text"><?php _e( 'Successful database connection' ); ?></h1>
   475 <h1 class="screen-reader-text"><?php _e( 'Successful database connection' ); ?></h1>
   449 <p><?php _e( 'All right, sparky! You&#8217;ve made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;' ); ?></p>
   476 <p><?php _e( 'All right, sparky! You&#8217;ve made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to&hellip;' ); ?></p>
   450 
   477 
   451 <p class="step"><a href="<?php echo $install; ?>" class="button button-large"><?php _e( 'Run the installation' ); ?></a></p>
   478 <p class="step"><a href="<?php echo $install; ?>" class="button button-large"><?php _e( 'Run the installation' ); ?></a></p>
   452 		<?php
   479 				<?php
   453 	endif;
   480 			else :
       
   481 				printf( '<p>%s</p>', $error_message );
       
   482 			endif;
       
   483 		endif;
   454 		break;
   484 		break;
   455 }
   485 } // End of the steps switch.
   456 ?>
   486 ?>
   457 <?php wp_print_scripts( 'language-chooser' ); ?>
   487 <?php wp_print_scripts( 'language-chooser' ); ?>
   458 </body>
   488 </body>
   459 </html>
   489 </html>