author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Update Core administration panel. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** WordPress Administration Bootstrap */ |
|
10 |
require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
11 |
||
12 |
wp_enqueue_style( 'plugin-install' ); |
|
13 |
wp_enqueue_script( 'plugin-install' ); |
|
5 | 14 |
wp_enqueue_script( 'updates' ); |
0 | 15 |
add_thickbox(); |
16 |
||
17 |
if ( is_multisite() && ! is_network_admin() ) { |
|
18 |
wp_redirect( network_admin_url( 'update-core.php' ) ); |
|
19 |
exit(); |
|
20 |
} |
|
21 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
0 | 24 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
* @global string $wp_local_package |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
* @global wpdb $wpdb |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
* @staticvar bool $first_pass |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
* @param object $update |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
*/ |
0 | 34 |
function list_core_update( $update ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
global $wp_local_package, $wpdb; |
0 | 36 |
static $first_pass = true; |
37 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
$wp_version = get_bloginfo( 'version' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
|
0 | 40 |
if ( 'en_US' == $update->locale && 'en_US' == get_locale() ) |
41 |
$version_string = $update->current; |
|
42 |
// If the only available update is a partial builds, it doesn't need a language-specific version string. |
|
43 |
elseif ( 'en_US' == $update->locale && $update->packages->partial && $wp_version == $update->partial_version && ( $updates = get_core_updates() ) && 1 == count( $updates ) ) |
|
44 |
$version_string = $update->current; |
|
45 |
else |
|
46 |
$version_string = sprintf( "%s–<strong>%s</strong>", $update->current, $update->locale ); |
|
47 |
||
48 |
$current = false; |
|
49 |
if ( !isset($update->response) || 'latest' == $update->response ) |
|
50 |
$current = true; |
|
51 |
$submit = __('Update Now'); |
|
52 |
$form_action = 'update-core.php?action=do-core-upgrade'; |
|
53 |
$php_version = phpversion(); |
|
54 |
$mysql_version = $wpdb->db_version(); |
|
55 |
$show_buttons = true; |
|
56 |
if ( 'development' == $update->response ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
$message = __('You are using a development version of WordPress. You can update to the latest nightly build automatically:'); |
0 | 58 |
} else { |
59 |
if ( $current ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
$message = sprintf( __( 'If you need to re-install version %s, you can do so here:' ), $version_string ); |
0 | 61 |
$submit = __('Re-install Now'); |
62 |
$form_action = 'update-core.php?action=do-core-reinstall'; |
|
63 |
} else { |
|
64 |
$php_compat = version_compare( $php_version, $update->php_version, '>=' ); |
|
65 |
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) |
|
66 |
$mysql_compat = true; |
|
67 |
else |
|
68 |
$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ); |
|
69 |
||
70 |
if ( !$mysql_compat && !$php_compat ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
/* translators: 1: WordPress version number, 2: Minimum required PHP version number, 3: Minimum required MySQL version number, 4: Current PHP version number, 5: Current MySQL version number */ |
5 | 72 |
$message = sprintf( __('You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version ); |
0 | 73 |
elseif ( !$php_compat ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
/* translators: 1: WordPress version number, 2: Minimum required PHP version number, 3: Current PHP version number */ |
5 | 75 |
$message = sprintf( __('You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version ); |
0 | 76 |
elseif ( !$mysql_compat ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
/* translators: 1: WordPress version number, 2: Minimum required MySQL version number, 3: Current MySQL version number */ |
5 | 78 |
$message = sprintf( __('You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version ); |
0 | 79 |
else |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
/* translators: 1: WordPress version number, 2: WordPress version number including locale if necessary */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
$message = sprintf(__('You can update to <a href="https://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically:'), $update->current, $version_string); |
0 | 82 |
if ( !$mysql_compat || !$php_compat ) |
83 |
$show_buttons = false; |
|
84 |
} |
|
85 |
} |
|
86 |
||
87 |
echo '<p>'; |
|
88 |
echo $message; |
|
89 |
echo '</p>'; |
|
90 |
echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">'; |
|
91 |
wp_nonce_field('upgrade-core'); |
|
92 |
echo '<p>'; |
|
93 |
echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>'; |
|
94 |
echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>'; |
|
95 |
if ( $show_buttons ) { |
|
96 |
if ( $first_pass ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
submit_button( $submit, $current ? '' : 'primary regular', 'upgrade', false ); |
0 | 98 |
$first_pass = false; |
99 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
submit_button( $submit, '', 'upgrade', false ); |
0 | 101 |
} |
102 |
} |
|
103 |
if ( 'en_US' != $update->locale ) |
|
104 |
if ( !isset( $update->dismissed ) || !$update->dismissed ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
submit_button( __( 'Hide this update' ), '', 'dismiss', false ); |
0 | 106 |
else |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
submit_button( __( 'Bring back this update' ), '', 'undismiss', false ); |
0 | 108 |
echo '</p>'; |
109 |
if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) ) |
|
110 |
echo '<p class="hint">'.__('This localized version contains both the translation and various other localization fixes. You can skip upgrading if you want to keep your current translation.').'</p>'; |
|
111 |
// Partial builds don't need language-specific warnings. |
|
112 |
elseif ( 'en_US' == $update->locale && get_locale() != 'en_US' && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) { |
|
113 |
echo '<p class="hint">'.sprintf( __('You are about to install WordPress %s <strong>in English (US).</strong> There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.'), $update->response != 'development' ? $update->current : '' ).'</p>'; |
|
114 |
} |
|
115 |
echo '</form>'; |
|
116 |
||
117 |
} |
|
118 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
120 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
*/ |
0 | 122 |
function dismissed_updates() { |
123 |
$dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) ); |
|
124 |
if ( $dismissed ) { |
|
125 |
||
126 |
$show_text = esc_js(__('Show hidden updates')); |
|
127 |
$hide_text = esc_js(__('Hide hidden updates')); |
|
128 |
?> |
|
129 |
<script type="text/javascript"> |
|
130 |
||
131 |
jQuery(function($) { |
|
132 |
$('dismissed-updates').show(); |
|
133 |
$('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')}); |
|
134 |
$('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');}); |
|
135 |
}); |
|
136 |
</script> |
|
137 |
<?php |
|
138 |
echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>'; |
|
139 |
echo '<ul id="dismissed-updates" class="core-updates dismissed">'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
foreach ( (array) $dismissed as $update) { |
0 | 141 |
echo '<li>'; |
142 |
list_core_update( $update ); |
|
143 |
echo '</li>'; |
|
144 |
} |
|
145 |
echo '</ul>'; |
|
146 |
} |
|
147 |
} |
|
148 |
||
149 |
/** |
|
150 |
* Display upgrade WordPress for downloading latest or upgrading automatically form. |
|
151 |
* |
|
5 | 152 |
* @since 2.7.0 |
0 | 153 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
* @global string $required_php_version |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
* @global string $required_mysql_version |
0 | 156 |
*/ |
157 |
function core_upgrade_preamble() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
global $required_php_version, $required_mysql_version; |
0 | 159 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
$wp_version = get_bloginfo( 'version' ); |
0 | 161 |
$updates = get_core_updates(); |
162 |
||
163 |
if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
echo '<h2>'; |
0 | 165 |
_e('You have the latest version of WordPress.'); |
166 |
||
167 |
if ( wp_http_supports( array( 'ssl' ) ) ) { |
|
168 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
169 |
$upgrader = new WP_Automatic_Updater; |
|
170 |
$future_minor_update = (object) array( |
|
171 |
'current' => $wp_version . '.1.next.minor', |
|
172 |
'version' => $wp_version . '.1.next.minor', |
|
173 |
'php_version' => $required_php_version, |
|
174 |
'mysql_version' => $required_mysql_version, |
|
175 |
); |
|
176 |
$should_auto_update = $upgrader->should_update( 'core', $future_minor_update, ABSPATH ); |
|
177 |
if ( $should_auto_update ) |
|
178 |
echo ' ' . __( 'Future security updates will be applied automatically.' ); |
|
179 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
echo '</h2>'; |
0 | 181 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
echo '<div class="notice notice-warning"><p>'; |
5 | 183 |
_e('<strong>Important:</strong> before updating, please <a href="https://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="https://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.'); |
0 | 184 |
echo '</p></div>'; |
185 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
echo '<h2 class="response">'; |
0 | 187 |
_e( 'An updated version of WordPress is available.' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
echo '</h2>'; |
0 | 189 |
} |
190 |
||
191 |
if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) { |
|
192 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
|
193 |
$upgrader = new WP_Automatic_Updater; |
|
5 | 194 |
if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) ) { |
195 |
echo '<div class="updated inline"><p>'; |
|
196 |
echo '<strong>' . __( 'BETA TESTERS:' ) . '</strong> ' . __( 'This site is set up to install updates of future beta versions automatically.' ); |
|
197 |
echo '</p></div>'; |
|
198 |
} |
|
0 | 199 |
} |
200 |
||
201 |
echo '<ul class="core-updates">'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
foreach ( (array) $updates as $update ) { |
0 | 203 |
echo '<li>'; |
204 |
list_core_update( $update ); |
|
205 |
echo '</li>'; |
|
206 |
} |
|
207 |
echo '</ul>'; |
|
208 |
// Don't show the maintenance mode notice when we are only showing a single re-install option. |
|
209 |
if ( $updates && ( count( $updates ) > 1 || $updates[0]->response != 'latest' ) ) { |
|
210 |
echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.' ) . '</p>'; |
|
211 |
} elseif ( ! $updates ) { |
|
212 |
list( $normalized_version ) = explode( '-', $wp_version ); |
|
213 |
echo '<p>' . sprintf( __( '<a href="%s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>'; |
|
214 |
} |
|
215 |
dismissed_updates(); |
|
216 |
} |
|
217 |
||
218 |
function list_plugin_updates() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
$wp_version = get_bloginfo( 'version' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
$cur_wp_version = preg_replace( '/-.*$/', '', $wp_version ); |
0 | 221 |
|
222 |
require_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); |
|
223 |
$plugins = get_plugin_updates(); |
|
224 |
if ( empty( $plugins ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
echo '<h2>' . __( 'Plugins' ) . '</h2>'; |
0 | 226 |
echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>'; |
227 |
return; |
|
228 |
} |
|
229 |
$form_action = 'update-core.php?action=do-plugin-upgrade'; |
|
230 |
||
231 |
$core_updates = get_core_updates(); |
|
232 |
if ( !isset($core_updates[0]->response) || 'latest' == $core_updates[0]->response || 'development' == $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=') ) |
|
233 |
$core_update_version = false; |
|
234 |
else |
|
235 |
$core_update_version = $core_updates[0]->current; |
|
236 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
<h2><?php _e( 'Plugins' ); ?></h2> |
0 | 238 |
<p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p> |
239 |
<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade"> |
|
240 |
<?php wp_nonce_field('upgrade-core'); ?> |
|
241 |
<p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
242 |
<table class="widefat updates-table" id="update-plugins-table"> |
0 | 243 |
<thead> |
244 |
<tr> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
245 |
<td class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
<td class="manage-column"><label for="plugins-select-all"><?php _e( 'Select All' ); ?></label></td> |
0 | 247 |
</tr> |
248 |
</thead> |
|
249 |
||
250 |
<tbody class="plugins"> |
|
251 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
foreach ( (array) $plugins as $plugin_file => $plugin_data ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
$plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
$icon = '<span class="dashicons dashicons-admin-plugins"></span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
$preferred_icons = array( 'svg', '1x', '2x', 'default' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
foreach ( $preferred_icons as $preferred_icon ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
$icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
} |
5 | 262 |
} |
263 |
||
0 | 264 |
// Get plugin compat for running version of WordPress. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
if ( isset($plugin_data->update->tested) && version_compare($plugin_data->update->tested, $cur_wp_version, '>=') ) { |
0 | 266 |
$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
} elseif ( isset($plugin_data->update->compatibility->{$cur_wp_version}) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
$compat = $plugin_data->update->compatibility->{$cur_wp_version}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat->percent, $compat->votes, $compat->total_votes); |
0 | 270 |
} else { |
271 |
$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version); |
|
272 |
} |
|
273 |
// Get plugin compat for updated version of WordPress. |
|
274 |
if ( $core_update_version ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
$compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $core_update_version ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
} elseif ( isset( $plugin_data->update->compatibility->{$core_update_version} ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
$update_compat = $plugin_data->update->compatibility->{$core_update_version}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
$compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat->percent, $update_compat->votes, $update_compat->total_votes); |
0 | 280 |
} else { |
281 |
$compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version); |
|
282 |
} |
|
283 |
} |
|
284 |
// Get the upgrade notice for the new plugin version. |
|
285 |
if ( isset($plugin_data->update->upgrade_notice) ) { |
|
286 |
$upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice); |
|
287 |
} else { |
|
288 |
$upgrade_notice = ''; |
|
289 |
} |
|
290 |
||
291 |
$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '§ion=changelog&TB_iframe=true&width=640&height=662'); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
$details = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
'<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
esc_url( $details_url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
/* translators: 1: plugin name, 2: version number */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
296 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
/* translators: %s: plugin version */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
); |
0 | 300 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
$checkbox_id = "checkbox_" . md5( $plugin_data->Name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
<tr> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
<td class="check-column"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
<label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"><?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
/* translators: %s: plugin name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
printf( __( 'Select %s' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
$plugin_data->Name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
?></label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
</td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
<td class="plugin-title"><p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
<?php echo $icon; ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
<strong><?php echo $plugin_data->Name; ?></strong> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
/* translators: 1: plugin version, 2: new version */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
printf( __( 'You have version %1$s installed. Update to %2$s.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
$plugin_data->Version, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
$plugin_data->update->new_version |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
echo ' ' . $details . $compat . $upgrade_notice; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
</p></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
</tr> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
<?php |
0 | 327 |
} |
328 |
?> |
|
329 |
</tbody> |
|
5 | 330 |
|
331 |
<tfoot> |
|
332 |
<tr> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
<td class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
<td class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></td> |
5 | 335 |
</tr> |
336 |
</tfoot> |
|
0 | 337 |
</table> |
338 |
<p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> |
|
339 |
</form> |
|
340 |
<?php |
|
341 |
} |
|
342 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
* @since 2.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
*/ |
0 | 346 |
function list_theme_updates() { |
347 |
$themes = get_theme_updates(); |
|
348 |
if ( empty( $themes ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
echo '<h2>' . __( 'Themes' ) . '</h2>'; |
0 | 350 |
echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>'; |
351 |
return; |
|
352 |
} |
|
353 |
||
354 |
$form_action = 'update-core.php?action=do-theme-upgrade'; |
|
355 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
<h2><?php _e( 'Themes' ); ?></h2> |
0 | 357 |
<p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click “Update Themes”.' ); ?></p> |
5 | 358 |
<p><?php printf( __( '<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.' ), __( 'https://codex.wordpress.org/Child_Themes' ) ); ?></p> |
0 | 359 |
<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade"> |
360 |
<?php wp_nonce_field('upgrade-core'); ?> |
|
361 |
<p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
<table class="widefat updates-table" id="update-themes-table"> |
0 | 363 |
<thead> |
364 |
<tr> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
<td class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
<td class="manage-column"><label for="themes-select-all"><?php _e( 'Select All' ); ?></label></td> |
0 | 367 |
</tr> |
368 |
</thead> |
|
369 |
||
370 |
<tbody class="plugins"> |
|
371 |
<?php |
|
372 |
foreach ( $themes as $stylesheet => $theme ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
<tr> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
<td class="check-column"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
<label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"><?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
/* translators: %s: theme name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
printf( __( 'Select %s' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
$theme->display( 'Name' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
?></label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
</td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
<td class="plugin-title"><p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
<img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
<strong><?php echo $theme->display( 'Name' ); ?></strong> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
/* translators: 1: theme version, 2: new version */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
printf( __( 'You have version %1$s installed. Update to %2$s.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
$theme->display( 'Version' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
392 |
$theme->update['new_version'] |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
</p></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
</tr> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
<?php |
0 | 398 |
} |
399 |
?> |
|
400 |
</tbody> |
|
5 | 401 |
|
402 |
<tfoot> |
|
403 |
<tr> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
<td class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
<td class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></td> |
5 | 406 |
</tr> |
407 |
</tfoot> |
|
0 | 408 |
</table> |
409 |
<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p> |
|
410 |
</form> |
|
411 |
<?php |
|
412 |
} |
|
413 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
415 |
* @since 3.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
416 |
*/ |
0 | 417 |
function list_translation_updates() { |
418 |
$updates = wp_get_translation_updates(); |
|
419 |
if ( ! $updates ) { |
|
420 |
if ( 'en_US' != get_locale() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
echo '<h2>' . __( 'Translations' ) . '</h2>'; |
0 | 422 |
echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>'; |
423 |
} |
|
424 |
return; |
|
425 |
} |
|
426 |
||
427 |
$form_action = 'update-core.php?action=do-translation-upgrade'; |
|
428 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
<h2><?php _e( 'Translations' ); ?></h2> |
5 | 430 |
<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade"> |
431 |
<p><?php _e( 'New translations are available.' ); ?></p> |
|
432 |
<?php wp_nonce_field( 'upgrade-translations' ); ?> |
|
0 | 433 |
<p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p> |
434 |
</form> |
|
435 |
<?php |
|
436 |
} |
|
437 |
||
438 |
/** |
|
439 |
* Upgrade WordPress core display. |
|
440 |
* |
|
5 | 441 |
* @since 2.7.0 |
0 | 442 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
443 |
* @global WP_Filesystem_Base $wp_filesystem Subclass |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
* @param bool $reinstall |
0 | 446 |
*/ |
447 |
function do_core_upgrade( $reinstall = false ) { |
|
448 |
global $wp_filesystem; |
|
449 |
||
5 | 450 |
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
0 | 451 |
|
452 |
if ( $reinstall ) |
|
453 |
$url = 'update-core.php?action=do-core-reinstall'; |
|
454 |
else |
|
455 |
$url = 'update-core.php?action=do-core-upgrade'; |
|
456 |
$url = wp_nonce_url($url, 'upgrade-core'); |
|
457 |
||
458 |
$version = isset( $_POST['version'] )? $_POST['version'] : false; |
|
459 |
$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; |
|
460 |
$update = find_core_update( $version, $locale ); |
|
461 |
if ( !$update ) |
|
462 |
return; |
|
463 |
||
5 | 464 |
// Allow relaxed file ownership writes for User-initiated upgrades when the API specifies |
465 |
// that it's safe to do so. This only happens when there are no new files to create. |
|
466 |
$allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files; |
|
467 |
||
0 | 468 |
?> |
469 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
<h1><?php _e( 'Update WordPress' ); ?></h1> |
0 | 471 |
<?php |
472 |
||
5 | 473 |
if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) { |
0 | 474 |
echo '</div>'; |
475 |
return; |
|
476 |
} |
|
477 |
||
5 | 478 |
if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) { |
0 | 479 |
// Failed to connect, Error and request again |
5 | 480 |
request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); |
0 | 481 |
echo '</div>'; |
482 |
return; |
|
483 |
} |
|
484 |
||
485 |
if ( $wp_filesystem->errors->get_error_code() ) { |
|
486 |
foreach ( $wp_filesystem->errors->get_error_messages() as $message ) |
|
487 |
show_message($message); |
|
488 |
echo '</div>'; |
|
489 |
return; |
|
490 |
} |
|
491 |
||
492 |
if ( $reinstall ) |
|
493 |
$update->response = 'reinstall'; |
|
494 |
||
495 |
add_filter( 'update_feedback', 'show_message' ); |
|
496 |
||
497 |
$upgrader = new Core_Upgrader(); |
|
5 | 498 |
$result = $upgrader->upgrade( $update, array( |
499 |
'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership |
|
500 |
) ); |
|
0 | 501 |
|
502 |
if ( is_wp_error($result) ) { |
|
503 |
show_message($result); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
504 |
if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) |
0 | 505 |
show_message( __('Installation Failed') ); |
506 |
echo '</div>'; |
|
507 |
return; |
|
508 |
} |
|
509 |
||
510 |
show_message( __('WordPress updated successfully') ); |
|
511 |
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>' ); |
|
512 |
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>' ); |
|
513 |
?> |
|
514 |
</div> |
|
515 |
<script type="text/javascript"> |
|
516 |
window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>'; |
|
517 |
</script> |
|
518 |
<?php |
|
519 |
} |
|
520 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
522 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
523 |
*/ |
0 | 524 |
function do_dismiss_core_update() { |
525 |
$version = isset( $_POST['version'] )? $_POST['version'] : false; |
|
526 |
$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; |
|
527 |
$update = find_core_update( $version, $locale ); |
|
528 |
if ( !$update ) |
|
529 |
return; |
|
530 |
dismiss_core_update( $update ); |
|
531 |
wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') ); |
|
532 |
exit; |
|
533 |
} |
|
534 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
537 |
*/ |
0 | 538 |
function do_undismiss_core_update() { |
539 |
$version = isset( $_POST['version'] )? $_POST['version'] : false; |
|
540 |
$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; |
|
541 |
$update = find_core_update( $version, $locale ); |
|
542 |
if ( !$update ) |
|
543 |
return; |
|
544 |
undismiss_core_update( $version, $locale ); |
|
545 |
wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') ); |
|
546 |
exit; |
|
547 |
} |
|
548 |
||
549 |
$action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core'; |
|
550 |
||
551 |
$upgrade_error = false; |
|
552 |
if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) ) |
|
553 |
&& ! isset( $_POST['checked'] ) ) { |
|
554 |
$upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins'; |
|
555 |
$action = 'upgrade-core'; |
|
556 |
} |
|
557 |
||
558 |
$title = __('WordPress Updates'); |
|
5 | 559 |
$parent_file = 'index.php'; |
560 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
561 |
$updates_overview = '<p>' . __( 'On this screen, you can update to the latest version of WordPress, as well as update your themes, plugins, and translations from the WordPress.org repositories.' ) . '</p>'; |
5 | 562 |
$updates_overview .= '<p>' . __( 'If an update is available, you᾿ll see a notification appear in the Toolbar and navigation menu.' ) . ' ' . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' ) . '</p>'; |
0 | 563 |
|
564 |
get_current_screen()->add_help_tab( array( |
|
5 | 565 |
'id' => 'overview', |
566 |
'title' => __( 'Overview' ), |
|
567 |
'content' => $updates_overview |
|
0 | 568 |
) ); |
569 |
||
5 | 570 |
$updates_howto = '<p>' . __( '<strong>WordPress</strong> — Updating your WordPress installation is a simple one-click procedure: just <strong>click on the “Update Now” button</strong> when you are notified that a new version is available.' ) . ' ' . __( 'In most cases, WordPress will automatically apply maintenance and security updates in the background for you.' ) . '</p>'; |
571 |
$updates_howto .= '<p>' . __( '<strong>Themes and Plugins</strong> — To update individual themes or plugins from this screen, use the checkboxes to make your selection, then <strong>click on the appropriate “Update” button</strong>. To update all of your themes or plugins at once, you can check the box at the top of the section to select all before clicking the update button.' ) . '</p>'; |
|
572 |
||
573 |
if ( 'en_US' != get_locale() ) { |
|
574 |
$updates_howto .= '<p>' . __( '<strong>Translations</strong> — The files translating WordPress into your language are updated for you whenever any other updates occur. But if these files are out of date, you can <strong>click the “Update Translations”</strong> button.' ) . '</p>'; |
|
575 |
} |
|
576 |
||
0 | 577 |
get_current_screen()->add_help_tab( array( |
5 | 578 |
'id' => 'how-to-update', |
579 |
'title' => __( 'How to Update' ), |
|
580 |
'content' => $updates_howto |
|
0 | 581 |
) ); |
582 |
||
583 |
get_current_screen()->set_help_sidebar( |
|
584 |
'<p><strong>' . __('For more information:') . '</strong></p>' . |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
'<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_Updates_Screen">Documentation on Updating WordPress</a>' ) . '</p>' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' |
0 | 587 |
); |
588 |
||
589 |
if ( 'upgrade-core' == $action ) { |
|
5 | 590 |
// Force a update check when requested |
591 |
$force_check = ! empty( $_GET['force-check'] ); |
|
592 |
wp_version_check( array(), $force_check ); |
|
0 | 593 |
|
594 |
require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
595 |
?> |
|
596 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
597 |
<h1><?php _e( 'WordPress Updates' ); ?></h1> |
0 | 598 |
<?php |
599 |
if ( $upgrade_error ) { |
|
600 |
echo '<div class="error"><p>'; |
|
601 |
if ( $upgrade_error == 'themes' ) |
|
602 |
_e('Please select one or more themes to update.'); |
|
603 |
else |
|
604 |
_e('Please select one or more plugins to update.'); |
|
605 |
echo '</p></div>'; |
|
606 |
} |
|
607 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
$last_update_check = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
$current = get_site_transient( 'update_core' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
611 |
if ( $current && isset ( $current->last_checked ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
$last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
|
0 | 615 |
echo '<p>'; |
616 |
/* translators: %1 date, %2 time. */ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
printf( __( 'Last checked on %1$s at %2$s.' ), date_i18n( __( 'F j, Y' ), $last_update_check ), date_i18n( __( 'g:i a' ), $last_update_check ) ); |
5 | 618 |
echo ' <a class="button" href="' . esc_url( self_admin_url('update-core.php?force-check=1') ) . '">' . __( 'Check Again' ) . '</a>'; |
0 | 619 |
echo '</p>'; |
620 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
if ( current_user_can( 'update_core' ) ) { |
0 | 622 |
core_upgrade_preamble(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
if ( current_user_can( 'update_plugins' ) ) { |
0 | 625 |
list_plugin_updates(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
626 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
if ( current_user_can( 'update_themes' ) ) { |
0 | 628 |
list_theme_updates(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
629 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
630 |
if ( current_user_can( 'update_languages' ) ) { |
0 | 631 |
list_translation_updates(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
632 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
633 |
|
5 | 634 |
/** |
635 |
* Fires after the core, plugin, and theme update tables. |
|
636 |
* |
|
637 |
* @since 2.9.0 |
|
638 |
*/ |
|
639 |
do_action( 'core_upgrade_preamble' ); |
|
0 | 640 |
echo '</div>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
641 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
'totals' => wp_get_update_data(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
644 |
) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
645 |
|
0 | 646 |
include(ABSPATH . 'wp-admin/admin-footer.php'); |
647 |
||
648 |
} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) { |
|
649 |
||
650 |
if ( ! current_user_can( 'update_core' ) ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
0 | 652 |
|
653 |
check_admin_referer('upgrade-core'); |
|
654 |
||
5 | 655 |
// Do the (un)dismiss actions before headers, so that they can redirect. |
0 | 656 |
if ( isset( $_POST['dismiss'] ) ) |
657 |
do_dismiss_core_update(); |
|
658 |
elseif ( isset( $_POST['undismiss'] ) ) |
|
659 |
do_undismiss_core_update(); |
|
660 |
||
661 |
require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
662 |
if ( 'do-core-reinstall' == $action ) |
|
663 |
$reinstall = true; |
|
664 |
else |
|
665 |
$reinstall = false; |
|
666 |
||
667 |
if ( isset( $_POST['upgrade'] ) ) |
|
668 |
do_core_upgrade($reinstall); |
|
669 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
'totals' => wp_get_update_data(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
|
0 | 674 |
include(ABSPATH . 'wp-admin/admin-footer.php'); |
675 |
||
676 |
} elseif ( 'do-plugin-upgrade' == $action ) { |
|
677 |
||
678 |
if ( ! current_user_can( 'update_plugins' ) ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
0 | 680 |
|
681 |
check_admin_referer('upgrade-core'); |
|
682 |
||
683 |
if ( isset( $_GET['plugins'] ) ) { |
|
684 |
$plugins = explode( ',', $_GET['plugins'] ); |
|
685 |
} elseif ( isset( $_POST['checked'] ) ) { |
|
686 |
$plugins = (array) $_POST['checked']; |
|
687 |
} else { |
|
688 |
wp_redirect( admin_url('update-core.php') ); |
|
689 |
exit; |
|
690 |
} |
|
691 |
||
692 |
$url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); |
|
693 |
$url = wp_nonce_url($url, 'bulk-update-plugins'); |
|
694 |
||
695 |
$title = __('Update Plugins'); |
|
696 |
||
697 |
require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
698 |
echo '<div class="wrap">'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
echo '<h1>' . __( 'Update Plugins' ) . '</h1>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="' . esc_attr__( 'Update progress' ) . '"></iframe>'; |
0 | 701 |
echo '</div>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
'totals' => wp_get_update_data(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
|
0 | 707 |
include(ABSPATH . 'wp-admin/admin-footer.php'); |
708 |
||
709 |
} elseif ( 'do-theme-upgrade' == $action ) { |
|
710 |
||
711 |
if ( ! current_user_can( 'update_themes' ) ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
0 | 713 |
|
714 |
check_admin_referer('upgrade-core'); |
|
715 |
||
716 |
if ( isset( $_GET['themes'] ) ) { |
|
717 |
$themes = explode( ',', $_GET['themes'] ); |
|
718 |
} elseif ( isset( $_POST['checked'] ) ) { |
|
719 |
$themes = (array) $_POST['checked']; |
|
720 |
} else { |
|
721 |
wp_redirect( admin_url('update-core.php') ); |
|
722 |
exit; |
|
723 |
} |
|
724 |
||
725 |
$url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes)); |
|
726 |
$url = wp_nonce_url($url, 'bulk-update-themes'); |
|
727 |
||
728 |
$title = __('Update Themes'); |
|
729 |
||
730 |
require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
5 | 731 |
?> |
732 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
<h1><?php _e( 'Update Themes' ); ?></h1> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
734 |
<iframe src="<?php echo $url ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php esc_attr_e( 'Update progress' ); ?>"></iframe> |
5 | 735 |
</div> |
736 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
738 |
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
'totals' => wp_get_update_data(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
740 |
) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
|
0 | 742 |
include(ABSPATH . 'wp-admin/admin-footer.php'); |
743 |
||
744 |
} elseif ( 'do-translation-upgrade' == $action ) { |
|
745 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
746 |
if ( ! current_user_can( 'update_languages' ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
wp_die( __( 'Sorry, you are not allowed to update this site.' ) ); |
0 | 748 |
|
749 |
check_admin_referer( 'upgrade-translations' ); |
|
750 |
||
751 |
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
752 |
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
753 |
||
754 |
$url = 'update-core.php?action=do-translation-upgrade'; |
|
755 |
$nonce = 'upgrade-translations'; |
|
756 |
$title = __( 'Update Translations' ); |
|
757 |
$context = WP_LANG_DIR; |
|
758 |
||
759 |
$upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) ); |
|
760 |
$result = $upgrader->bulk_upgrade(); |
|
761 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
'totals' => wp_get_update_data(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
765 |
|
0 | 766 |
require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
767 |
||
768 |
} else { |
|
5 | 769 |
/** |
770 |
* Fires for each custom update action on the WordPress Updates screen. |
|
771 |
* |
|
772 |
* The dynamic portion of the hook name, `$action`, refers to the |
|
773 |
* passed update action. The hook fires in lieu of all available |
|
774 |
* default update actions. |
|
775 |
* |
|
776 |
* @since 3.2.0 |
|
777 |
*/ |
|
778 |
do_action( "update-core-custom_{$action}" ); |
|
0 | 779 |
} |