Install: Only enqueue scripts when necessary.

Props flixos90 for initial patch.
Fixes #34700.

git-svn-id: https://develop.svn.wordpress.org/trunk@36176 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2016-01-05 16:41:43 +00:00
parent 9d45966095
commit e306e801a9

View File

@ -261,10 +261,12 @@ if ( ! empty( $_REQUEST['language'] ) ) {
$language = $GLOBALS['wp_local_package'];
}
$scripts_to_print = array( 'jquery' );
switch($step) {
case 0: // Step 0
if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) {
$scripts_to_print[] = 'language-chooser';
display_header( 'language-chooser' );
echo '<form id="setup" method="post" action="?step=1">';
wp_install_language_form( $languages );
@ -283,6 +285,8 @@ switch($step) {
}
}
$scripts_to_print[] = 'user-profile';
display_header();
?>
<h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1>
@ -305,6 +309,8 @@ switch($step) {
if ( ! empty( $wpdb->error ) )
wp_die( $wpdb->error->get_error_message() );
$scripts_to_print[] = 'user-profile';
display_header();
// Fill in the data we gathered
$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
@ -368,12 +374,15 @@ switch($step) {
}
break;
}
if ( !wp_is_mobile() ) {
?>
if ( ! wp_is_mobile() ) {
?>
<script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
<?php } ?>
<?php wp_print_scripts( 'user-profile' ); ?>
<?php wp_print_scripts( 'language-chooser' ); ?>
<?php
}
wp_print_scripts( $scripts_to_print );
?>
<script type="text/javascript">
jQuery( function( $ ) {
$( '.hide-if-no-js' ).removeClass( 'hide-if-no-js' );