web/wp-admin/update-core.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    16 if ( is_multisite() && ! is_network_admin() ) {
    16 if ( is_multisite() && ! is_network_admin() ) {
    17 	wp_redirect( network_admin_url( 'update-core.php' ) );
    17 	wp_redirect( network_admin_url( 'update-core.php' ) );
    18 	exit();
    18 	exit();
    19 }
    19 }
    20 
    20 
    21 if ( ! current_user_can( 'update_core' ) )
    21 if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) )
    22 	wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
    22 	wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
    23 
    23 
    24 function list_core_update( $update ) {
    24 function list_core_update( $update ) {
    25 	global $wp_local_package, $wpdb;
    25 	global $wp_local_package, $wpdb;
    26 	static $first_pass = true;
    26 	static $first_pass = true;
    72 	echo '<p>';
    72 	echo '<p>';
    73 	echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
    73 	echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
    74 	echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
    74 	echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
    75 	if ( $show_buttons ) {
    75 	if ( $show_buttons ) {
    76 		if ( $first_pass ) {
    76 		if ( $first_pass ) {
    77 			submit_button( $submit, $current ? 'button' : 'primary', 'upgrade', false );
    77 			submit_button( $submit, $current ? 'button' : 'primary regular', 'upgrade', false );
    78 			$first_pass = false;
    78 			$first_pass = false;
    79 		} else {
    79 		} else {
    80 			submit_button( $submit, 'button', 'upgrade', false );
    80 			submit_button( $submit, 'button', 'upgrade', false );
    81 		}
    81 		}
    82 		echo '&nbsp;<a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a>&nbsp;';
    82 		echo '&nbsp;<a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a>&nbsp;';
   129  * @since 2.7
   129  * @since 2.7
   130  *
   130  *
   131  * @return null
   131  * @return null
   132  */
   132  */
   133 function core_upgrade_preamble() {
   133 function core_upgrade_preamble() {
   134 	global $upgrade_error, $wp_version;
   134 	global $wp_version;
   135 
   135 
   136 	$updates = get_core_updates();
   136 	$updates = get_core_updates();
   137 ?>
       
   138 	<div class="wrap">
       
   139 	<?php screen_icon('tools'); ?>
       
   140 	<h2><?php _e('WordPress Updates'); ?></h2>
       
   141 <?php
       
   142 	if ( $upgrade_error ) {
       
   143 		echo '<div class="error"><p>';
       
   144 		if ( $upgrade_error == 'themes' )
       
   145 			_e('Please select one or more themes to update.');
       
   146 		else
       
   147 			_e('Please select one or more plugins to update.');
       
   148 		echo '</p></div>';
       
   149 	}
       
   150 
       
   151 	echo '<p>';
       
   152 	/* translators: %1 date, %2 time. */
       
   153 	printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
       
   154 	echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
       
   155 	echo '</p>';
       
   156 
   137 
   157 	if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
   138 	if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
   158 		echo '<h3>';
   139 		echo '<h3>';
   159 		_e('You have the latest version of WordPress.');
   140 		_e('You have the latest version of WordPress.');
   160 		echo '</h3>';
   141 		echo '</h3>';
   181 	} else {
   162 	} else {
   182 		list( $normalized_version ) = explode( '-', $wp_version );
   163 		list( $normalized_version ) = explode( '-', $wp_version );
   183 		echo '<p>' . sprintf( __( '<a href="%s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>';
   164 		echo '<p>' . sprintf( __( '<a href="%s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>';
   184 	}
   165 	}
   185 	dismissed_updates();
   166 	dismissed_updates();
   186 
       
   187 	if ( current_user_can( 'update_plugins' ) )
       
   188 		list_plugin_updates();
       
   189 	if ( current_user_can( 'update_themes' ) )
       
   190 		list_theme_updates();
       
   191 	do_action('core_upgrade_preamble');
       
   192 	echo '</div>';
       
   193 }
   167 }
   194 
   168 
   195 function list_plugin_updates() {
   169 function list_plugin_updates() {
   196 	global $wp_version;
   170 	global $wp_version;
   197 
   171 
   378 		echo '</div>';
   352 		echo '</div>';
   379 		return;
   353 		return;
   380 	}
   354 	}
   381 
   355 
   382 	show_message( __('WordPress updated successfully') );
   356 	show_message( __('WordPress updated successfully') );
   383 	show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%s">here</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
   357 	show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
   384 	show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
   358 	show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
   385 	?>
   359 	?>
   386 	</div>
   360 	</div>
   387 	<script type="text/javascript">
   361 	<script type="text/javascript">
   388 	window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
   362 	window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
   452 
   426 
   453 if ( 'upgrade-core' == $action ) {
   427 if ( 'upgrade-core' == $action ) {
   454 
   428 
   455 	wp_version_check();
   429 	wp_version_check();
   456 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   430 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   457 	core_upgrade_preamble();
   431 	?>
       
   432 	<div class="wrap">
       
   433 	<?php screen_icon('tools'); ?>
       
   434 	<h2><?php _e('WordPress Updates'); ?></h2>
       
   435 	<?php
       
   436 	if ( $upgrade_error ) {
       
   437 		echo '<div class="error"><p>';
       
   438 		if ( $upgrade_error == 'themes' )
       
   439 			_e('Please select one or more themes to update.');
       
   440 		else
       
   441 			_e('Please select one or more plugins to update.');
       
   442 		echo '</p></div>';
       
   443 	}
       
   444 
       
   445 	echo '<p>';
       
   446 	/* translators: %1 date, %2 time. */
       
   447 	printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
       
   448 	echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
       
   449 	echo '</p>';
       
   450 
       
   451 	if ( current_user_can( 'update_core' ) )
       
   452 		core_upgrade_preamble();
       
   453 	if ( current_user_can( 'update_plugins' ) )
       
   454 		list_plugin_updates();
       
   455 	if ( current_user_can( 'update_themes' ) )
       
   456 		list_theme_updates();
       
   457 	do_action('core_upgrade_preamble');
       
   458 	echo '</div>';
   458 	include(ABSPATH . 'wp-admin/admin-footer.php');
   459 	include(ABSPATH . 'wp-admin/admin-footer.php');
   459 
   460 
   460 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
   461 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
       
   462 
       
   463 	if ( ! current_user_can( 'update_core' ) )
       
   464 		wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
       
   465 
   461 	check_admin_referer('upgrade-core');
   466 	check_admin_referer('upgrade-core');
   462 
   467 
   463 	// do the (un)dismiss actions before headers,
   468 	// do the (un)dismiss actions before headers,
   464 	// so that they can redirect
   469 	// so that they can redirect
   465 	if ( isset( $_POST['dismiss'] ) )
   470 	if ( isset( $_POST['dismiss'] ) )