Skip to content

Commit 1825eff

Browse files
committed
General: use get_bloginfo( 'version' ) instead of global $wp_version in several locations - excluding those locations which reload version.php mid-flight.
See #37699. git-svn-id: https://develop.svn.wordpress.org/trunk@38459 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2078dda commit 1825eff

22 files changed

Lines changed: 51 additions & 107 deletions

src/wp-admin/about.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function _wp_override_admin_video_width_limit( $output ) {
4242

4343
$title = __( 'About' );
4444

45-
list( $display_version ) = explode( '-', $wp_version );
45+
list( $display_version ) = explode( '-', get_bloginfo( 'version' ) );
4646

4747
include( ABSPATH . 'wp-admin/admin-header.php' );
4848
?>

src/wp-admin/admin-header.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
* @global WP_Screen $current_screen
1919
* @global WP_Locale $wp_locale
2020
* @global string $pagenow
21-
* @global string $wp_version
2221
* @global string $update_title
2322
* @global int $total_update_count
2423
* @global string $parent_file
2524
*/
26-
global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version,
25+
global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow,
2726
$update_title, $total_update_count, $parent_file;
2827

2928
// Catch plugins that include admin-header.php before admin.php completes.
@@ -154,8 +153,8 @@
154153
if ( $current_screen->taxonomy )
155154
$admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
156155

157-
$admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( $wp_version ) );
158-
$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', $wp_version ) );
156+
$admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) );
157+
$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
159158
$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
160159
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
161160

src/wp-admin/credits.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
$title = __( 'Credits' );
1414

15-
list( $display_version ) = explode( '-', $wp_version );
15+
list( $display_version ) = explode( '-', get_bloginfo( 'version' ) );
1616

1717
include( ABSPATH . 'wp-admin/admin-header.php' );
1818
?>

src/wp-admin/freedoms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
$title = __( 'Freedoms' );
1313

14-
list( $display_version ) = explode( '-', $wp_version );
14+
list( $display_version ) = explode( '-', get_bloginfo( 'version' ) );
1515

1616
include( ABSPATH . 'wp-admin/admin-header.php' );
1717
?>

src/wp-admin/includes/class-wp-automatic-updater.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,8 @@ public function update( $type, $item ) {
371371
*
372372
* @since 3.7.0
373373
* @access public
374-
*
375-
* @global wpdb $wpdb
376-
* @global string $wp_version
377374
*/
378375
public function run() {
379-
global $wpdb, $wp_version;
380-
381376
if ( $this->is_disabled() )
382377
return;
383378

@@ -457,7 +452,7 @@ public function run() {
457452

458453
// Send debugging email to all development installs.
459454
if ( ! empty( $this->update_results ) ) {
460-
$development_version = false !== strpos( $wp_version, '-' );
455+
$development_version = false !== strpos( get_bloginfo( 'version' ), '-' );
461456

462457
/**
463458
* Filters whether to send a debugging email for each automatic background update.
@@ -494,12 +489,10 @@ public function run() {
494489
* @since Unknown
495490
* @access protected
496491
*
497-
* @global string $wp_version
498-
*
499492
* @param object $update_result The result of the core update. Includes the update offer and result.
500493
*/
501494
protected function after_core_update( $update_result ) {
502-
global $wp_version;
495+
$wp_version = get_bloginfo( 'version' );
503496

504497
$core_update = $update_result->item;
505498
$result = $update_result->result;
@@ -584,8 +577,6 @@ protected function after_core_update( $update_result ) {
584577
* @since 3.7.0
585578
* @access protected
586579
*
587-
* @global string $wp_version
588-
*
589580
* @param string $type The type of email to send. Can be one of 'success', 'fail', 'manual', 'critical'.
590581
* @param object $core_update The update offer that was attempted.
591582
* @param mixed $result Optional. The result for the core update. Can be WP_Error.
@@ -722,7 +713,7 @@ protected function send_email( $type, $core_update, $result = null ) {
722713

723714
if ( 'critical' == $type && is_wp_error( $result ) ) {
724715
$body .= "\n***\n\n";
725-
$body .= sprintf( __( 'Your site was running version %s.' ), $GLOBALS['wp_version'] );
716+
$body .= sprintf( __( 'Your site was running version %s.' ), get_bloginfo( 'version' ) );
726717
$body .= ' ' . __( 'We have some data that describes the error your site encountered.' );
727718
$body .= ' ' . __( 'Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:' );
728719

src/wp-admin/includes/class-wp-plugin-install-list-table.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ protected function get_installed_plugin_slugs() {
6969
* @global int $paged
7070
* @global string $type
7171
* @global string $term
72-
* @global string $wp_version
7372
*/
7473
public function prepare_items() {
7574
include( ABSPATH . 'wp-admin/includes/plugin-install.php' );
@@ -88,7 +87,7 @@ public function prepare_items() {
8887
if ( 'search' === $tab ) {
8988
$tabs['search'] = __( 'Search Results' );
9089
}
91-
if ( $tab === 'beta' || false !== strpos( $GLOBALS['wp_version'], '-' ) ) {
90+
if ( $tab === 'beta' || false !== strpos( get_bloginfo( 'version' ), '-' ) ) {
9291
$tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' );
9392
}
9493
$tabs['featured'] = _x( 'Featured', 'Plugin Installer' );
@@ -391,9 +390,6 @@ private function order_callback( $plugin_a, $plugin_b ) {
391390
}
392391
}
393392

394-
/**
395-
* @global string $wp_version
396-
*/
397393
public function display_rows() {
398394
$plugins_allowedtags = array(
399395
'a' => array( 'href' => array(),'title' => array(), 'target' => array() ),
@@ -574,9 +570,11 @@ public function display_rows() {
574570
</div>
575571
<div class="column-compatibility">
576572
<?php
577-
if ( ! empty( $plugin['tested'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) {
573+
$wp_version = get_bloginfo( 'version' );
574+
575+
if ( ! empty( $plugin['tested'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) {
578576
echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>';
579-
} elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) {
577+
} elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) {
580578
echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>';
581579
} else {
582580
echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>';

src/wp-admin/includes/class-wp-press-this.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,14 @@ public function add_category() {
267267
* @return string Source's HTML sanitized markup
268268
*/
269269
public function fetch_source_html( $url ) {
270-
global $wp_version;
271-
272270
if ( empty( $url ) ) {
273271
return new WP_Error( 'invalid-url', __( 'A valid URL was not provided.' ) );
274272
}
275273

276274
$remote_url = wp_safe_remote_get( $url, array(
277275
'timeout' => 30,
278276
// Use an explicit user-agent for Press This
279-
'user-agent' => 'Press This (WordPress/' . $wp_version . '); ' . get_bloginfo( 'url' )
277+
'user-agent' => 'Press This (WordPress/' . get_bloginfo( 'version' ) . '); ' . get_bloginfo( 'url' )
280278
) );
281279

282280
if ( is_wp_error( $remote_url ) ) {
@@ -1189,11 +1187,12 @@ public function get_suggested_content( $data ) {
11891187
* @access public
11901188
*
11911189
* @global WP_Locale $wp_locale
1192-
* @global string $wp_version
11931190
* @global bool $is_IE
11941191
*/
11951192
public function html() {
1196-
global $wp_locale, $wp_version;
1193+
global $wp_locale;
1194+
1195+
$wp_version = get_bloginfo( 'version' );
11971196

11981197
// Get data, new (POST) and old (GET).
11991198
$data = $this->merge_or_fetch_data();

src/wp-admin/includes/credits.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
/**
1111
* Retrieve the contributor credits.
1212
*
13-
* @global string $wp_version The current WordPress version.
14-
*
1513
* @since 3.2.0
1614
*
1715
* @return array|false A list of all of the contributors, or false on error.
1816
*/
1917
function wp_credits() {
20-
global $wp_version;
18+
$wp_version = get_bloginfo( 'version' );
2119
$locale = get_locale();
2220

2321
$results = get_site_transient( 'wordpress_credits_' . $locale );
@@ -26,7 +24,7 @@ function wp_credits() {
2624
|| false !== strpos( $wp_version, '-' )
2725
|| ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 )
2826
) {
29-
$response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale" );
27+
$response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}" );
3028

3129
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
3230
return false;

src/wp-admin/includes/dashboard.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,6 @@ function dashboard_browser_nag_class( $classes ) {
13931393
*
13941394
* @since 3.2.0
13951395
*
1396-
* @global string $wp_version
1397-
*
13981396
* @return array|bool False on failure, array of browser data on success.
13991397
*/
14001398
function wp_check_browser_version() {
@@ -1404,11 +1402,9 @@ function wp_check_browser_version() {
14041402
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
14051403

14061404
if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
1407-
global $wp_version;
1408-
14091405
$options = array(
14101406
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
1411-
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url()
1407+
'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url()
14121408
);
14131409

14141410
$response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', $options );

src/wp-admin/includes/plugin-install.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ function install_plugin_install_status($api, $loop = false) {
423423
* @since 2.7.0
424424
*
425425
* @global string $tab
426-
* @global string $wp_version
427426
*/
428427
function install_plugin_information() {
429428
global $tab;
@@ -630,9 +629,11 @@ function install_plugin_information() {
630629
</div>
631630
<div id="section-holder" class="wrap">
632631
<?php
633-
if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
632+
$wp_version = get_bloginfo( 'version' );
633+
634+
if ( ! empty( $api->tested ) && version_compare( substr( $wp_version, 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
634635
echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.' ) . '</p></div>';
635-
} elseif ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
636+
} elseif ( ! empty( $api->requires ) && version_compare( substr( $wp_version, 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
636637
echo '<div class="notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.' ) . '</p></div>';
637638
}
638639

0 commit comments

Comments
 (0)