raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Update Core administration panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 if ( ! current_user_can('update_plugins') )
mp-wp_genesis 13 wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
mp-wp_genesis 14
mp-wp_genesis 15 function list_core_update( $update ) {
mp-wp_genesis 16 $version_string = 'en_US' == $update->locale ?
mp-wp_genesis 17 $update->current : sprintf("%s&ndash;<strong>%s</strong>", $update->current, $update->locale);
mp-wp_genesis 18 $current = false;
mp-wp_genesis 19 if ( !isset($update->response) || 'latest' == $update->response )
mp-wp_genesis 20 $current = true;
mp-wp_genesis 21 $submit = __('Upgrade Automatically');
mp-wp_genesis 22 $form_action = 'update-core.php?action=do-core-upgrade';
mp-wp_genesis 23 if ( 'development' == $update->response ) {
mp-wp_genesis 24 $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:');
mp-wp_genesis 25 $download = __('Download nightly build');
mp-wp_genesis 26 } else {
mp-wp_genesis 27 if ( $current ) {
mp-wp_genesis 28 $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);
mp-wp_genesis 29 $submit = __('Re-install Automatically');
mp-wp_genesis 30 $form_action = 'update-core.php?action=do-core-reinstall';
mp-wp_genesis 31 } else {
mp-wp_genesis 32 $message = sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
mp-wp_genesis 33 }
mp-wp_genesis 34 $download = sprintf(__('Download %s'), $version_string);
mp-wp_genesis 35 }
mp-wp_genesis 36
mp-wp_genesis 37 echo '<p>';
mp-wp_genesis 38 echo $message;
mp-wp_genesis 39 echo '</p>';
mp-wp_genesis 40 echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
mp-wp_genesis 41 wp_nonce_field('upgrade-core');
mp-wp_genesis 42 echo '<p>';
mp-wp_genesis 43 echo '<input id="upgrade" class="button" type="submit" value="' . $submit . '" name="upgrade" />&nbsp;';
mp-wp_genesis 44 echo '<input name="version" value="'.$update->current.'" type="hidden"/>';
mp-wp_genesis 45 echo '<input name="locale" value="'.$update->locale.'" type="hidden"/>';
mp-wp_genesis 46 echo '<a href="' . $update->package . '" class="button">' . $download . '</a>&nbsp;';
mp-wp_genesis 47 if ( 'en_US' != $update->locale )
mp-wp_genesis 48 if ( !isset( $update->dismissed ) || !$update->dismissed )
mp-wp_genesis 49 echo '<input id="dismiss" class="button" type="submit" value="' . attribute_escape(__('Hide this update')) . '" name="dismiss" />';
mp-wp_genesis 50 else
mp-wp_genesis 51 echo '<input id="undismiss" class="button" type="submit" value="' . attribute_escape(__('Bring back this update')) . '" name="undismiss" />';
mp-wp_genesis 52 echo '</p>';
mp-wp_genesis 53 echo '</form>';
mp-wp_genesis 54
mp-wp_genesis 55 }
mp-wp_genesis 56
mp-wp_genesis 57 function dismissed_updates() {
mp-wp_genesis 58 $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
mp-wp_genesis 59 if ( $dismissed ) {
mp-wp_genesis 60
mp-wp_genesis 61 $show_text = js_escape(__('Show hidden updates'));
mp-wp_genesis 62 $hide_text = js_escape(__('Hide hidden updates'));
mp-wp_genesis 63 ?>
mp-wp_genesis 64 <script type="text/javascript">
mp-wp_genesis 65
mp-wp_genesis 66 jQuery(function($) {
mp-wp_genesis 67 $('dismissed-updates').show();
mp-wp_genesis 68 $('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
mp-wp_genesis 69 $('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
mp-wp_genesis 70 });
mp-wp_genesis 71 </script>
mp-wp_genesis 72 <?php
mp-wp_genesis 73 echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
mp-wp_genesis 74 echo '<ul id="dismissed-updates" class="core-updates dismissed">';
mp-wp_genesis 75 foreach( (array) $dismissed as $update) {
mp-wp_genesis 76 echo '<li>';
mp-wp_genesis 77 list_core_update( $update );
mp-wp_genesis 78 echo '</li>';
mp-wp_genesis 79 }
mp-wp_genesis 80 echo '</ul>';
mp-wp_genesis 81 }
mp-wp_genesis 82 }
mp-wp_genesis 83
mp-wp_genesis 84 /**
mp-wp_genesis 85 * Display upgrade WordPress for downloading latest or upgrading automatically form.
mp-wp_genesis 86 *
mp-wp_genesis 87 * @since 2.7
mp-wp_genesis 88 *
mp-wp_genesis 89 * @return null
mp-wp_genesis 90 */
mp-wp_genesis 91 function core_upgrade_preamble() {
mp-wp_genesis 92 $updates = get_core_updates();
mp-wp_genesis 93 ?>
mp-wp_genesis 94 <div class="wrap">
mp-wp_genesis 95 <?php screen_icon(); ?>
mp-wp_genesis 96 <h2><?php _e('Upgrade WordPress'); ?></h2>
mp-wp_genesis 97 <?php
mp-wp_genesis 98 if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
mp-wp_genesis 99 echo '<h3>';
mp-wp_genesis 100 _e('You have the latest version of WordPress. You do not need to upgrade');
mp-wp_genesis 101 echo '</h3>';
mp-wp_genesis 102 } else {
mp-wp_genesis 103 echo '<div class="updated fade"><p>';
mp-wp_genesis 104 _e('<strong>Important:</strong> before upgrading, please <a href="http://codex.wordpress.org/WordPress_Backups">backup your database and files</a>.');
mp-wp_genesis 105 echo '</p></div>';
mp-wp_genesis 106
mp-wp_genesis 107 echo '<h3 class="response">';
mp-wp_genesis 108 _e( 'There is a new version of WordPress available for upgrade' );
mp-wp_genesis 109 echo '</h3>';
mp-wp_genesis 110 }
mp-wp_genesis 111
mp-wp_genesis 112 echo '<ul class="core-updates">';
mp-wp_genesis 113 $alternate = true;
mp-wp_genesis 114 foreach( (array) $updates as $update ) {
mp-wp_genesis 115 $class = $alternate? ' class="alternate"' : '';
mp-wp_genesis 116 $alternate = !$alternate;
mp-wp_genesis 117 echo "<li $class>";
mp-wp_genesis 118 list_core_update( $update );
mp-wp_genesis 119 echo '</li>';
mp-wp_genesis 120 }
mp-wp_genesis 121 echo '</ul>';
mp-wp_genesis 122 dismissed_updates();
mp-wp_genesis 123 echo '</div>';
mp-wp_genesis 124 }
mp-wp_genesis 125
mp-wp_genesis 126
mp-wp_genesis 127 /**
mp-wp_genesis 128 * Upgrade WordPress core display.
mp-wp_genesis 129 *
mp-wp_genesis 130 * @since 2.7
mp-wp_genesis 131 *
mp-wp_genesis 132 * @return null
mp-wp_genesis 133 */
mp-wp_genesis 134 function do_core_upgrade( $reinstall = false ) {
mp-wp_genesis 135 global $wp_filesystem;
mp-wp_genesis 136
mp-wp_genesis 137 $url = wp_nonce_url('update-core.php?action=do-core-upgrade', 'upgrade-core');
mp-wp_genesis 138 if ( false === ($credentials = request_filesystem_credentials($url)) )
mp-wp_genesis 139 return;
mp-wp_genesis 140
mp-wp_genesis 141 $version = isset( $_POST['version'] )? $_POST['version'] : false;
mp-wp_genesis 142 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
mp-wp_genesis 143 $update = find_core_update( $version, $locale );
mp-wp_genesis 144 if ( !$update )
mp-wp_genesis 145 return;
mp-wp_genesis 146
mp-wp_genesis 147
mp-wp_genesis 148 if ( ! WP_Filesystem($credentials) ) {
mp-wp_genesis 149 request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
mp-wp_genesis 150 return;
mp-wp_genesis 151 }
mp-wp_genesis 152 ?>
mp-wp_genesis 153 <div class="wrap">
mp-wp_genesis 154 <?php screen_icon(); ?>
mp-wp_genesis 155 <h2><?php _e('Upgrade WordPress'); ?></h2>
mp-wp_genesis 156 <?php
mp-wp_genesis 157 if ( $wp_filesystem->errors->get_error_code() ) {
mp-wp_genesis 158 foreach ( $wp_filesystem->errors->get_error_messages() as $message )
mp-wp_genesis 159 show_message($message);
mp-wp_genesis 160 echo '</div>';
mp-wp_genesis 161 return;
mp-wp_genesis 162 }
mp-wp_genesis 163
mp-wp_genesis 164 if ( $reinstall )
mp-wp_genesis 165 $update->response = 'reinstall';
mp-wp_genesis 166
mp-wp_genesis 167 $result = wp_update_core($update, 'show_message');
mp-wp_genesis 168
mp-wp_genesis 169 if ( is_wp_error($result) ) {
mp-wp_genesis 170 show_message($result);
mp-wp_genesis 171 if ('up_to_date' != $result->get_error_code() )
mp-wp_genesis 172 show_message( __('Installation Failed') );
mp-wp_genesis 173 } else {
mp-wp_genesis 174 show_message( __('WordPress upgraded successfully') );
mp-wp_genesis 175 }
mp-wp_genesis 176 echo '</div>';
mp-wp_genesis 177 }
mp-wp_genesis 178
mp-wp_genesis 179 function do_dismiss_core_update() {
mp-wp_genesis 180 $version = isset( $_POST['version'] )? $_POST['version'] : false;
mp-wp_genesis 181 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
mp-wp_genesis 182 $update = find_core_update( $version, $locale );
mp-wp_genesis 183 if ( !$update )
mp-wp_genesis 184 return;
mp-wp_genesis 185 dismiss_core_update( $update );
mp-wp_genesis 186 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
mp-wp_genesis 187 }
mp-wp_genesis 188
mp-wp_genesis 189 function do_undismiss_core_update() {
mp-wp_genesis 190 $version = isset( $_POST['version'] )? $_POST['version'] : false;
mp-wp_genesis 191 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
mp-wp_genesis 192 $update = find_core_update( $version, $locale );
mp-wp_genesis 193 if ( !$update )
mp-wp_genesis 194 return;
mp-wp_genesis 195 undismiss_core_update( $version, $locale );
mp-wp_genesis 196 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
mp-wp_genesis 197 }
mp-wp_genesis 198
mp-wp_genesis 199 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
mp-wp_genesis 200
mp-wp_genesis 201 if ( 'upgrade-core' == $action ) {
mp-wp_genesis 202 $title = __('Upgrade WordPress');
mp-wp_genesis 203 $parent_file = 'tools.php';
mp-wp_genesis 204 require_once('admin-header.php');
mp-wp_genesis 205 core_upgrade_preamble();
mp-wp_genesis 206 include('admin-footer.php');
mp-wp_genesis 207 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
mp-wp_genesis 208 check_admin_referer('upgrade-core');
mp-wp_genesis 209 $title = __('Upgrade WordPress');
mp-wp_genesis 210 $parent_file = 'tools.php';
mp-wp_genesis 211 // do the (un)dismiss actions before headers,
mp-wp_genesis 212 // so that they can redirect
mp-wp_genesis 213 if ( isset( $_POST['dismiss'] ) )
mp-wp_genesis 214 do_dismiss_core_update();
mp-wp_genesis 215 elseif ( isset( $_POST['undismiss'] ) )
mp-wp_genesis 216 do_undismiss_core_update();
mp-wp_genesis 217 require_once('admin-header.php');
mp-wp_genesis 218 if ( 'do-core-reinstall' == $action )
mp-wp_genesis 219 $reinstall = true;
mp-wp_genesis 220 else
mp-wp_genesis 221 $reinstall = false;
mp-wp_genesis 222 if ( isset( $_POST['upgrade'] ) )
mp-wp_genesis 223 do_core_upgrade($reinstall);
mp-wp_genesis 224 include('admin-footer.php');
mp-wp_genesis 225
mp-wp_genesis 226 }?>