Make WordPress Core

Changeset 59159


Ignore:
Timestamp:
10/03/2024 12:23:53 AM (2 years ago)
Author:
peterwilsoncc
Message:

General: Expand use of wp_get_wp_version().

Expands the use of wp_get_wp_version() to get an unmodified value of the current WordPress version in various locations in which it would be unhelpful if a plugin has modified the global $wp_version.

This includes:

  • Theme and plugin compatibility tests
  • During the upgrade process of WP Core
  • Debug and site health data reports of the current version
  • Version number display in the dashboard
  • Block theme export and caching utilities
  • The WPDB class

Props peterwilsoncc, hellofromtonya.
See #61627.

Location:
trunk/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-core-upgrader.php

    r58319 r59159  
    392392         * @since 3.7.0
    393393         *
    394          * @global string $wp_version       The WordPress version string.
    395394         * @global string $wp_local_package Locale code of the package.
    396395         *
    … …  
    398397         */
    399398        public function check_files() {
    400                 global $wp_version, $wp_local_package;
     399                global $wp_local_package;
     400                $wp_version = wp_get_wp_version();
    401401
    402402                $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
  • trunk/src/wp-admin/includes/class-plugin-installer-skin.php

    r58082 r59159  
    285285                                /* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */
    286286                                __( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ),
    287                                 get_bloginfo( 'version' ),
     287                                esc_html( wp_get_wp_version() ),
    288288                                $requires_wp
    289289                        );
  • trunk/src/wp-admin/includes/class-plugin-upgrader.php

    r57658 r59159  
    275275         * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional.
    276276         *
    277          * @global string $wp_version The WordPress version string.
    278          *
    279277         * @param string[] $plugins Array of paths to plugin files relative to the plugins directory.
    280278         * @param array    $args {
    … …  
    286284         */
    287285        public function bulk_upgrade( $plugins, $args = array() ) {
    288                 global $wp_version;
     286                $wp_version = wp_get_wp_version();
    289287
    290288                $defaults    = array(
    … …  
    458456         *
    459457         * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
    460          * @global string             $wp_version    The WordPress version string.
    461458         *
    462459         * @param string $source The path to the downloaded package source.
    … …  
    464461         */
    465462        public function check_package( $source ) {
    466                 global $wp_filesystem, $wp_version;
    467 
     463                global $wp_filesystem;
     464
     465                $wp_version            = wp_get_wp_version();
    468466                $this->new_plugin_data = array();
    469467
  • trunk/src/wp-admin/includes/class-theme-installer-skin.php

    r58082 r59159  
    320320                                /* translators: 1: Current WordPress version, 2: Version required by the uploaded theme. */
    321321                                __( 'Your WordPress version is %1$s, however the uploaded theme requires %2$s.' ),
    322                                 get_bloginfo( 'version' ),
     322                                esc_html( wp_get_wp_version() ),
    323323                                $requires_wp
    324324                        );
  • trunk/src/wp-admin/includes/class-theme-upgrader.php

    r57252 r59159  
    372372         * @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional.
    373373         *
    374          * @global string $wp_version The WordPress version string.
    375          *
    376374         * @param string[] $themes Array of the theme slugs.
    377375         * @param array    $args {
    … …  
    384382         */
    385383        public function bulk_upgrade( $themes, $args = array() ) {
    386                 global $wp_version;
    387 
     384                $wp_version  = wp_get_wp_version();
    388385                $defaults    = array(
    389386                        'clear_update_cache' => true,
    … …  
    559556         *
    560557         * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
    561          * @global string             $wp_version    The WordPress version string.
    562558         *
    563559         * @param string $source The path to the downloaded package source.
    … …  
    565561         */
    566562        public function check_package( $source ) {
    567                 global $wp_filesystem, $wp_version;
    568 
     563                global $wp_filesystem;
     564
     565                $wp_version           = wp_get_wp_version();
    569566                $this->new_theme_data = array();
    570567
  • trunk/src/wp-admin/includes/class-wp-automatic-updater.php

    r58436 r59159  
    753753                // Send debugging email to admin for all development installations.
    754754                if ( ! empty( $this->update_results ) ) {
    755                         $development_version = str_contains( get_bloginfo( 'version' ), '-' );
     755                        $development_version = str_contains( wp_get_wp_version(), '-' );
    756756
    757757                        /**
    … …  
    796796         */
    797797        protected function after_core_update( $update_result ) {
    798                 $wp_version = get_bloginfo( 'version' );
     798                $wp_version = wp_get_wp_version();
    799799
    800800                $core_update = $update_result->item;
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r59155 r59159  
    4747                $default_comment_status = get_option( 'default_comment_status' );
    4848                $environment_type       = wp_get_environment_type();
    49                 $core_version           = get_bloginfo( 'version' );
     49                $core_version           = wp_get_wp_version();
    5050                $core_updates           = get_core_updates();
    5151                $core_update_needed     = '';
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r59120 r59159  
    265265                );
    266266
    267                 $core_current_version = get_bloginfo( 'version' );
     267                $core_current_version = wp_get_wp_version();
    268268                $core_updates         = get_core_updates();
    269269
  • trunk/src/wp-admin/includes/dashboard.php

    r59120 r59159  
    20572057 */
    20582058function wp_welcome_panel() {
    2059         list( $display_version ) = explode( '-', get_bloginfo( 'version' ) );
     2059        list( $display_version ) = explode( '-', wp_get_wp_version() );
    20602060        $can_customize           = current_user_can( 'customize' );
    20612061        $is_block_theme          = wp_is_block_theme();
    … …  
    20712071                        <?php
    20722072                                /* translators: %s: Current WordPress version. */
    2073                                 printf( __( 'Learn more about the %s version.' ), $display_version );
     2073                                printf( __( 'Learn more about the %s version.' ), esc_html( $display_version ) );
    20742074                        ?>
    20752075                        </a>
  • trunk/src/wp-admin/includes/update-core.php

    r59150 r59159  
    15401540 * @global array              $_old_requests_files Requests files to be preloaded.
    15411541 * @global WP_Filesystem_Base $wp_filesystem       WordPress filesystem subclass.
    1542  * @global string             $wp_version          The WordPress version string.
    15431542 *
    15441543 * @param string $to Path to old WordPress installation.
    15451544 */
    15461545function _preload_old_requests_classes_and_interfaces( $to ) {
    1547         global $_old_requests_files, $wp_filesystem, $wp_version;
     1546        global $_old_requests_files, $wp_filesystem;
     1547        $wp_version = wp_get_wp_version();
    15481548
    15491549        /*
    … …  
    15881588 * @since 3.3.0
    15891589 *
    1590  * @global string $wp_version The WordPress version string.
    1591  * @global string $pagenow    The filename of the current screen.
     1590 * @global string $pagenow The filename of the current screen.
    15921591 * @global string $action
    15931592 *
    … …  
    15951594 */
    15961595function _redirect_to_about_wordpress( $new_version ) {
    1597         global $wp_version, $pagenow, $action;
     1596        global $pagenow, $action;
     1597        $wp_version = wp_get_wp_version();
    15981598
    15991599        if ( version_compare( $wp_version, '3.4-RC1', '>=' ) ) {
  • trunk/src/wp-admin/update-core.php

    r59064 r59159  
    3838        static $first_pass = true;
    3939
    40         $wp_version     = get_bloginfo( 'version' );
     40        $wp_version     = wp_get_wp_version();
    4141        $version_string = sprintf( '%s&ndash;%s', $update->current, get_locale() );
    4242
    … …  
    394394
    395395        if ( $upgrade_major ) {
    396                 $wp_version = get_bloginfo( 'version' );
     396                $wp_version = wp_get_wp_version();
    397397                $updates    = get_core_updates();
    398398
    … …  
    461461 */
    462462function list_plugin_updates() {
    463         $wp_version     = get_bloginfo( 'version' );
     463        $wp_version     = wp_get_wp_version();
    464464        $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
    465465
    … …  
    11021102        echo '<h2 class="wp-current-version">';
    11031103        /* translators: Current version of WordPress. */
    1104         printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) );
     1104        printf( __( 'Current version: %s' ), esc_html( wp_get_wp_version() ) );
    11051105        echo '</h2>';
    11061106
  • trunk/src/wp-includes/block-template-utils.php

    r59101 r59159  
    14051405 * @since 6.0.0 Adds the whole theme to the export archive.
    14061406 *
    1407  * @global string $wp_version The WordPress version string.
    1408  *
    14091407 * @return WP_Error|string Path of the ZIP file or error on failure.
    14101408 */
    14111409function wp_generate_block_templates_export_file() {
    1412         global $wp_version;
     1410        $wp_version = wp_get_wp_version();
    14131411
    14141412        if ( ! class_exists( 'ZipArchive' ) ) {
  • trunk/src/wp-includes/blocks/index.php

    r59132 r59159  
    2626 *
    2727 * @since 6.3.0
    28  *
    29  * @global string $wp_version The WordPress version string.
    3028 */
    3129function register_core_block_style_handles() {
    32         global $wp_version;
     30        $wp_version = wp_get_wp_version();
    3331
    3432        if ( ! wp_should_load_separate_core_block_assets() ) {
  • trunk/src/wp-includes/class-wpdb.php

    r59069 r59159  
    39843984         * @since 2.5.0
    39853985         *
    3986          * @global string $wp_version             The WordPress version string.
    39873986         * @global string $required_mysql_version The required MySQL version string.
    39883987         * @return void|WP_Error
    39893988         */
    39903989        public function check_database_version() {
    3991                 global $wp_version, $required_mysql_version;
     3990                global $required_mysql_version;
     3991                $wp_version = wp_get_wp_version();
     3992
    39923993                // Make sure the server has the required MySQL version.
    39933994                if ( version_compare( $this->db_version(), $required_mysql_version, '<' ) ) {
Note: See TracChangeset for help on using the changeset viewer.