19 return (object) array( 'response' => 'latest' ); |
19 return (object) array( 'response' => 'latest' ); |
20 return $updates[0]; |
20 return $updates[0]; |
21 } |
21 } |
22 |
22 |
23 /** |
23 /** |
24 * Get available core updates |
24 * Get available core updates. |
25 * |
25 * |
26 * @param array $options Set $options['dismissed'] to true to show dismissed upgrades too, |
26 * @param array $options Set $options['dismissed'] to true to show dismissed upgrades too, |
27 * set $options['available'] to false to skip not-dismissed updates. |
27 * set $options['available'] to false to skip not-dismissed updates. |
28 * @return array Array of the update objects |
28 * @return bool|array Array of the update objects on success, false on failure. |
29 */ |
29 */ |
30 function get_core_updates( $options = array() ) { |
30 function get_core_updates( $options = array() ) { |
31 $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options ); |
31 $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options ); |
32 $dismissed = get_site_option( 'dismissed_update_core' ); |
32 $dismissed = get_site_option( 'dismissed_update_core' ); |
33 |
33 |
99 * @param string $version Version string to query. |
99 * @param string $version Version string to query. |
100 * @param string $locale Locale to query. |
100 * @param string $locale Locale to query. |
101 * @return bool|array False on failure. An array of checksums on success. |
101 * @return bool|array False on failure. An array of checksums on success. |
102 */ |
102 */ |
103 function get_core_checksums( $version, $locale ) { |
103 function get_core_checksums( $version, $locale ) { |
104 $return = array(); |
|
105 |
|
106 $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); |
104 $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); |
107 |
105 |
108 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
106 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
109 $url = set_url_scheme( $url, 'https' ); |
107 $url = set_url_scheme( $url, 'https' ); |
110 |
108 |
112 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
110 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
113 ); |
111 ); |
114 |
112 |
115 $response = wp_remote_get( $url, $options ); |
113 $response = wp_remote_get( $url, $options ); |
116 if ( $ssl && is_wp_error( $response ) ) { |
114 if ( $ssl && is_wp_error( $response ) ) { |
117 trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="http://wordpress.org/support/">support forums</a>.' ) . ' ' . '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)', headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
115 trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
118 $response = wp_remote_get( $http_url, $options ); |
116 $response = wp_remote_get( $http_url, $options ); |
119 } |
117 } |
120 |
118 |
121 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
119 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
122 return false; |
120 return false; |
179 $cur->response = ''; |
177 $cur->response = ''; |
180 |
178 |
181 switch ( $cur->response ) { |
179 switch ( $cur->response ) { |
182 case 'development' : |
180 case 'development' : |
183 return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
181 return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
184 break; |
|
185 |
182 |
186 case 'upgrade' : |
183 case 'upgrade' : |
187 return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', network_admin_url( 'update-core.php' ), $cur->current); |
184 return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', network_admin_url( 'update-core.php' ), $cur->current); |
188 break; |
|
189 |
185 |
190 case 'latest' : |
186 case 'latest' : |
191 default : |
187 default : |
192 return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
188 return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
193 break; |
|
194 } |
189 } |
195 } |
190 } |
196 add_filter( 'update_footer', 'core_update_footer' ); |
191 add_filter( 'update_footer', 'core_update_footer' ); |
197 |
192 |
198 function update_nag() { |
193 function update_nag() { |
208 |
203 |
209 if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) |
204 if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) |
210 return false; |
205 return false; |
211 |
206 |
212 if ( current_user_can('update_core') ) { |
207 if ( current_user_can('update_core') ) { |
213 $msg = sprintf( __('<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url( 'update-core.php' ) ); |
208 $msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url( 'update-core.php' ) ); |
214 } else { |
209 } else { |
215 $msg = sprintf( __('<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current ); |
210 $msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current ); |
216 } |
211 } |
217 echo "<div class='update-nag'>$msg</div>"; |
212 echo "<div class='update-nag'>$msg</div>"; |
218 } |
213 } |
219 add_action( 'admin_notices', 'update_nag', 3 ); |
214 add_action( 'admin_notices', 'update_nag', 3 ); |
220 add_action( 'network_admin_notices', 'update_nag', 3 ); |
215 add_action( 'network_admin_notices', 'update_nag', 3 ); |
221 |
216 |
222 // Called directly from dashboard |
217 // Called directly from dashboard |
223 function update_right_now_message() { |
218 function update_right_now_message() { |
224 $msg = sprintf( __( 'You are using <span class="b">WordPress %s</span>.' ), get_bloginfo( 'version', 'display' ) ); |
219 $theme_name = wp_get_theme(); |
|
220 if ( current_user_can( 'switch_themes' ) ) { |
|
221 $theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name ); |
|
222 } |
|
223 |
|
224 $msg = ''; |
225 |
225 |
226 if ( current_user_can('update_core') ) { |
226 if ( current_user_can('update_core') ) { |
227 $cur = get_preferred_from_update_core(); |
227 $cur = get_preferred_from_update_core(); |
228 |
228 |
229 if ( isset( $cur->response ) && $cur->response == 'upgrade' ) |
229 if ( isset( $cur->response ) && $cur->response == 'upgrade' ) |
230 $msg .= " <a href='" . network_admin_url( 'update-core.php' ) . "' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>'; |
230 $msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> '; |
231 } |
231 } |
232 |
232 |
233 echo "<span id='wp-version-message'>$msg</span>"; |
233 $msg .= sprintf( '<span id="wp-version">' . __( 'WordPress %1$s running %2$s theme.' ) . '</span>', get_bloginfo( 'version', 'display' ), $theme_name ); |
|
234 |
|
235 echo "<p id='wp-version-message'>$msg</p>"; |
234 } |
236 } |
235 |
237 |
236 function get_plugin_updates() { |
238 function get_plugin_updates() { |
237 $all_plugins = get_plugins(); |
239 $all_plugins = get_plugins(); |
238 $upgrade_plugins = array(); |
240 $upgrade_plugins = array(); |
274 $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '§ion=changelog&TB_iframe=true&width=600&height=800'); |
276 $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '§ion=changelog&TB_iframe=true&width=600&height=800'); |
275 |
277 |
276 $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
278 $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
277 |
279 |
278 if ( is_network_admin() || !is_multisite() ) { |
280 if ( is_network_admin() || !is_multisite() ) { |
279 echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
281 $active_class = ( is_plugin_active( $plugin_data['plugin'] ) ) ? ' active' : ''; |
280 |
282 echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $r->slug . '-update' ) . '" data-slug="' . esc_attr( $r->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">'; |
281 if ( ! current_user_can('update_plugins') ) |
283 |
|
284 if ( ! current_user_can( 'update_plugins' ) ) { |
282 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); |
285 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); |
283 else if ( empty($r->package) ) |
286 } elseif ( empty($r->package) ) { |
284 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); |
287 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version ); |
285 else |
288 } else { |
286 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) ); |
289 printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link">update now</a>.' ), $plugin_name, esc_url( $details_url ), esc_attr( $plugin_name ), $r->new_version, wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ) ); |
287 |
290 } |
288 do_action( "in_plugin_update_message-$file", $plugin_data, $r ); |
291 /** |
|
292 * Fires at the end of the update message container in each |
|
293 * row of the plugins list table. |
|
294 * |
|
295 * The dynamic portion of the hook name, `$file`, refers to the path |
|
296 * of the plugin's primary file relative to the plugins directory. |
|
297 * |
|
298 * @since 2.8.0 |
|
299 * |
|
300 * @param array $plugin_data { |
|
301 * An array of plugin metadata. |
|
302 * |
|
303 * @type string $name The human-readable name of the plugin. |
|
304 * @type string $plugin_uri Plugin URI. |
|
305 * @type string $version Plugin version. |
|
306 * @type string $description Plugin description. |
|
307 * @type string $author Plugin author. |
|
308 * @type string $author_uri Plugin author URI. |
|
309 * @type string $text_domain Plugin text domain. |
|
310 * @type string $domain_path Relative path to the plugin's .mo file(s). |
|
311 * @type bool $network Whether the plugin can only be activated network wide. |
|
312 * @type string $title The human-readable title of the plugin. |
|
313 * @type string $author_name Plugin author's name. |
|
314 * @type bool $update Whether there's an available update. Default null. |
|
315 * } |
|
316 * @param array $r { |
|
317 * An array of metadata about the available plugin update. |
|
318 * |
|
319 * @type int $id Plugin ID. |
|
320 * @type string $slug Plugin slug. |
|
321 * @type string $new_version New plugin version. |
|
322 * @type string $url Plugin URL. |
|
323 * @type string $package Plugin update package URL. |
|
324 * } |
|
325 */ |
|
326 do_action( "in_plugin_update_message-{$file}", $plugin_data, $r ); |
289 |
327 |
290 echo '</div></td></tr>'; |
328 echo '</div></td></tr>'; |
291 } |
329 } |
292 } |
330 } |
293 |
331 |
294 function get_theme_updates() { |
332 function get_theme_updates() { |
295 $themes = wp_get_themes(); |
|
296 $current = get_site_transient('update_themes'); |
333 $current = get_site_transient('update_themes'); |
297 |
334 |
298 if ( ! isset( $current->response ) ) |
335 if ( ! isset( $current->response ) ) |
299 return array(); |
336 return array(); |
300 |
337 |
325 function wp_theme_update_row( $theme_key, $theme ) { |
362 function wp_theme_update_row( $theme_key, $theme ) { |
326 $current = get_site_transient( 'update_themes' ); |
363 $current = get_site_transient( 'update_themes' ); |
327 if ( !isset( $current->response[ $theme_key ] ) ) |
364 if ( !isset( $current->response[ $theme_key ] ) ) |
328 return false; |
365 return false; |
329 $r = $current->response[ $theme_key ]; |
366 $r = $current->response[ $theme_key ]; |
330 $themes_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); |
|
331 $theme_name = wp_kses( $theme['Name'], $themes_allowedtags ); |
|
332 |
367 |
333 $details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] ); |
368 $details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] ); |
334 |
369 |
335 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); |
370 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); |
336 |
371 |
337 echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
372 echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
338 if ( ! current_user_can('update_themes') ) |
373 if ( ! current_user_can('update_themes') ) { |
339 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version ); |
374 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version ); |
340 else if ( empty( $r['package'] ) ) |
375 } elseif ( empty( $r['package'] ) ) { |
341 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] ); |
376 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] ); |
342 else |
377 } else { |
343 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) ); |
378 printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) ); |
344 |
379 } |
345 do_action( "in_theme_update_message-$theme_key", $theme, $r ); |
380 /** |
|
381 * Fires at the end of the update message container in each |
|
382 * row of the themes list table. |
|
383 * |
|
384 * The dynamic portion of the hook name, `$theme_key`, refers to |
|
385 * the theme slug as found in the WordPress.org themes repository. |
|
386 * |
|
387 * @since 3.1.0 |
|
388 * |
|
389 * @param WP_Theme $theme The WP_Theme object. |
|
390 * @param array $r { |
|
391 * An array of metadata about the available theme update. |
|
392 * |
|
393 * @type string $new_version New theme version. |
|
394 * @type string $url Theme URL. |
|
395 * @type string $package Theme update package URL. |
|
396 * } |
|
397 */ |
|
398 do_action( "in_theme_update_message-{$theme_key}", $theme, $r ); |
346 |
399 |
347 echo '</div></td></tr>'; |
400 echo '</div></td></tr>'; |
348 } |
401 } |
349 |
402 |
350 function maintenance_nag() { |
403 function maintenance_nag() { |
351 include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version |
404 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
352 global $upgrading; |
405 global $upgrading; |
353 $nag = isset( $upgrading ); |
406 $nag = isset( $upgrading ); |
354 if ( ! $nag ) { |
407 if ( ! $nag ) { |
355 $failed = get_site_option( 'auto_core_update_failed' ); |
408 $failed = get_site_option( 'auto_core_update_failed' ); |
356 /* |
409 /* |