-
+ 477CF24BBA6E08C7F12ED452E116335DCF1C374E61838CCBE3687009649FF8B2EE10A34315C33248EFD20B8EECA582BEB1D9946351DC4BE79E148999A5124266
mp-wp/wp-admin/update-core.php
(0 . 0)(1 . 226)
57990 <?php
57991 /**
57992 * Update Core administration panel.
57993 *
57994 * @package WordPress
57995 * @subpackage Administration
57996 */
57997
57998 /** WordPress Administration Bootstrap */
57999 require_once('admin.php');
58000
58001 if ( ! current_user_can('update_plugins') )
58002 wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
58003
58004 function list_core_update( $update ) {
58005 $version_string = 'en_US' == $update->locale ?
58006 $update->current : sprintf("%s–<strong>%s</strong>", $update->current, $update->locale);
58007 $current = false;
58008 if ( !isset($update->response) || 'latest' == $update->response )
58009 $current = true;
58010 $submit = __('Upgrade Automatically');
58011 $form_action = 'update-core.php?action=do-core-upgrade';
58012 if ( 'development' == $update->response ) {
58013 $message = __('You are using a development version of WordPress. You can upgrade to the latest nightly build automatically or download the nightly build and install it manually:');
58014 $download = __('Download nightly build');
58015 } else {
58016 if ( $current ) {
58017 $message = sprintf(__('You have the latest version of WordPress. You do not need to upgrade. However, if you want to re-install version %s, you can do so automatically or download the package and re-install manually:'), $version_string);
58018 $submit = __('Re-install Automatically');
58019 $form_action = 'update-core.php?action=do-core-reinstall';
58020 } else {
58021 $message = sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
58022 }
58023 $download = sprintf(__('Download %s'), $version_string);
58024 }
58025
58026 echo '<p>';
58027 echo $message;
58028 echo '</p>';
58029 echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
58030 wp_nonce_field('upgrade-core');
58031 echo '<p>';
58032 echo '<input id="upgrade" class="button" type="submit" value="' . $submit . '" name="upgrade" /> ';
58033 echo '<input name="version" value="'.$update->current.'" type="hidden"/>';
58034 echo '<input name="locale" value="'.$update->locale.'" type="hidden"/>';
58035 echo '<a href="' . $update->package . '" class="button">' . $download . '</a> ';
58036 if ( 'en_US' != $update->locale )
58037 if ( !isset( $update->dismissed ) || !$update->dismissed )
58038 echo '<input id="dismiss" class="button" type="submit" value="' . attribute_escape(__('Hide this update')) . '" name="dismiss" />';
58039 else
58040 echo '<input id="undismiss" class="button" type="submit" value="' . attribute_escape(__('Bring back this update')) . '" name="undismiss" />';
58041 echo '</p>';
58042 echo '</form>';
58043
58044 }
58045
58046 function dismissed_updates() {
58047 $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
58048 if ( $dismissed ) {
58049
58050 $show_text = js_escape(__('Show hidden updates'));
58051 $hide_text = js_escape(__('Hide hidden updates'));
58052 ?>
58053 <script type="text/javascript">
58054
58055 jQuery(function($) {
58056 $('dismissed-updates').show();
58057 $('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
58058 $('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
58059 });
58060 </script>
58061 <?php
58062 echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
58063 echo '<ul id="dismissed-updates" class="core-updates dismissed">';
58064 foreach( (array) $dismissed as $update) {
58065 echo '<li>';
58066 list_core_update( $update );
58067 echo '</li>';
58068 }
58069 echo '</ul>';
58070 }
58071 }
58072
58073 /**
58074 * Display upgrade WordPress for downloading latest or upgrading automatically form.
58075 *
58076 * @since 2.7
58077 *
58078 * @return null
58079 */
58080 function core_upgrade_preamble() {
58081 $updates = get_core_updates();
58082 ?>
58083 <div class="wrap">
58084 <?php screen_icon(); ?>
58085 <h2><?php _e('Upgrade WordPress'); ?></h2>
58086 <?php
58087 if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
58088 echo '<h3>';
58089 _e('You have the latest version of WordPress. You do not need to upgrade');
58090 echo '</h3>';
58091 } else {
58092 echo '<div class="updated fade"><p>';
58093 _e('<strong>Important:</strong> before upgrading, please <a href="http://codex.wordpress.org/WordPress_Backups">backup your database and files</a>.');
58094 echo '</p></div>';
58095
58096 echo '<h3 class="response">';
58097 _e( 'There is a new version of WordPress available for upgrade' );
58098 echo '</h3>';
58099 }
58100
58101 echo '<ul class="core-updates">';
58102 $alternate = true;
58103 foreach( (array) $updates as $update ) {
58104 $class = $alternate? ' class="alternate"' : '';
58105 $alternate = !$alternate;
58106 echo "<li $class>";
58107 list_core_update( $update );
58108 echo '</li>';
58109 }
58110 echo '</ul>';
58111 dismissed_updates();
58112 echo '</div>';
58113 }
58114
58115
58116 /**
58117 * Upgrade WordPress core display.
58118 *
58119 * @since 2.7
58120 *
58121 * @return null
58122 */
58123 function do_core_upgrade( $reinstall = false ) {
58124 global $wp_filesystem;
58125
58126 $url = wp_nonce_url('update-core.php?action=do-core-upgrade', 'upgrade-core');
58127 if ( false === ($credentials = request_filesystem_credentials($url)) )
58128 return;
58129
58130 $version = isset( $_POST['version'] )? $_POST['version'] : false;
58131 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
58132 $update = find_core_update( $version, $locale );
58133 if ( !$update )
58134 return;
58135
58136
58137 if ( ! WP_Filesystem($credentials) ) {
58138 request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
58139 return;
58140 }
58141 ?>
58142 <div class="wrap">
58143 <?php screen_icon(); ?>
58144 <h2><?php _e('Upgrade WordPress'); ?></h2>
58145 <?php
58146 if ( $wp_filesystem->errors->get_error_code() ) {
58147 foreach ( $wp_filesystem->errors->get_error_messages() as $message )
58148 show_message($message);
58149 echo '</div>';
58150 return;
58151 }
58152
58153 if ( $reinstall )
58154 $update->response = 'reinstall';
58155
58156 $result = wp_update_core($update, 'show_message');
58157
58158 if ( is_wp_error($result) ) {
58159 show_message($result);
58160 if ('up_to_date' != $result->get_error_code() )
58161 show_message( __('Installation Failed') );
58162 } else {
58163 show_message( __('WordPress upgraded successfully') );
58164 }
58165 echo '</div>';
58166 }
58167
58168 function do_dismiss_core_update() {
58169 $version = isset( $_POST['version'] )? $_POST['version'] : false;
58170 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
58171 $update = find_core_update( $version, $locale );
58172 if ( !$update )
58173 return;
58174 dismiss_core_update( $update );
58175 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
58176 }
58177
58178 function do_undismiss_core_update() {
58179 $version = isset( $_POST['version'] )? $_POST['version'] : false;
58180 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
58181 $update = find_core_update( $version, $locale );
58182 if ( !$update )
58183 return;
58184 undismiss_core_update( $version, $locale );
58185 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
58186 }
58187
58188 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
58189
58190 if ( 'upgrade-core' == $action ) {
58191 $title = __('Upgrade WordPress');
58192 $parent_file = 'tools.php';
58193 require_once('admin-header.php');
58194 core_upgrade_preamble();
58195 include('admin-footer.php');
58196 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
58197 check_admin_referer('upgrade-core');
58198 $title = __('Upgrade WordPress');
58199 $parent_file = 'tools.php';
58200 // do the (un)dismiss actions before headers,
58201 // so that they can redirect
58202 if ( isset( $_POST['dismiss'] ) )
58203 do_dismiss_core_update();
58204 elseif ( isset( $_POST['undismiss'] ) )
58205 do_undismiss_core_update();
58206 require_once('admin-header.php');
58207 if ( 'do-core-reinstall' == $action )
58208 $reinstall = true;
58209 else
58210 $reinstall = false;
58211 if ( isset( $_POST['upgrade'] ) )
58212 do_core_upgrade($reinstall);
58213 include('admin-footer.php');
58214
58215 }?>