WordPress.org

Make WordPress Core

Ticket #46937: 46937-wpcs.diff

File 46937-wpcs.diff, 17.8 KB (added by afragen, 2 years ago)

includes other WPCS fixes

  • wp-admin/includes/update-core.php

    diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php
    index b0b86166ad..67cc3f3347 100644
    a b $_old_files = array( 
    254254        'wp-includes/js/jquery/interface.js',
    255255        'wp-includes/js/scriptaculous/prototype.js',
    256256        // Following file added back in 5.1 see #45645
    257         //'wp-includes/js/tinymce/wp-tinymce.js',
     257        // 'wp-includes/js/tinymce/wp-tinymce.js',
    258258        // 3.1
    259259        'wp-admin/edit-attachment-rows.php',
    260260        'wp-admin/edit-link-categories.php',
    function update_core( $from, $to ) { 
    928928        }
    929929
    930930        $wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE );
    931         require( WP_CONTENT_DIR . '/upgrade/version-current.php' );
     931        require WP_CONTENT_DIR . '/upgrade/version-current.php';
    932932        $wp_filesystem->delete( $versions_file );
    933933
    934934        $php_version       = phpversion();
    function update_core( $from, $to ) { 
    946946                $wp_filesystem->delete( $from, true );
    947947        }
    948948
     949        /* translators: %s: Update PHP page URL */
     950        $php_update_message = '<br>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
     951
     952        $annotation = wp_get_update_php_annotation();
     953
     954        if ( $annotation ) {
     955                $php_update_message .= '<br><em>' . $annotation . '</em>';
     956        }
     957
    949958        if ( ! $mysql_compat && ! $php_compat ) {
    950                 return new WP_Error( 'php_mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s 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.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) );
     959                return new WP_Error( 'php_mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s 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.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) . $php_update_message );
    951960        } elseif ( ! $php_compat ) {
    952                 return new WP_Error( 'php_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version ) );
     961                return new WP_Error( 'php_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version ) . $php_update_message );
    953962        } elseif ( ! $mysql_compat ) {
    954963                return new WP_Error( 'mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_mysql_version, $mysql_version ) );
    955964        }
    function update_core( $from, $to ) { 
    11651174                                        // If a error occurs partway through this final step, keep the error flowing through, but keep process going.
    11661175                                        if ( is_wp_error( $_result ) ) {
    11671176                                                if ( ! is_wp_error( $result ) ) {
    1168                                                         $result = new WP_Error;
     1177                                                        $result = new WP_Error();
    11691178                                                }
    11701179                                                $result->add( $_result->get_error_code() . "_$type", $_result->get_error_message(), substr( $_result->get_error_data(), strlen( $dest ) ) );
    11711180                                        }
    function update_core( $from, $to ) { 
    12531262 *
    12541263 * @param string $from     source directory
    12551264 * @param string $to       destination directory
    1256  * @param array $skip_list a list of files/folders to skip copying
     1265 * @param array  $skip_list a list of files/folders to skip copying
    12571266 * @return mixed WP_Error on failure, True on success.
    12581267 */
    12591268function _copy_dir( $from, $to, $skip_list = array() ) {
    window.location = 'about.php?updated'; 
    13501359        <?php
    13511360
    13521361        // Include admin-footer.php and exit.
    1353         include( ABSPATH . 'wp-admin/admin-footer.php' );
     1362        include ABSPATH . 'wp-admin/admin-footer.php';
    13541363        exit();
    13551364}
    13561365
  • wp-admin/install.php

    diff --git a/wp-admin/install.php b/wp-admin/install.php
    index 4a38eab1cd..3c27fafb80 100644
    a b if ( false ) { 
    3333define( 'WP_INSTALLING', true );
    3434
    3535/** Load WordPress Bootstrap */
    36 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
     36require_once dirname( dirname( __FILE__ ) ) . '/wp-load.php';
    3737
    3838/** Load WordPress Administration Upgrade API */
    39 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     39require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    4040
    4141/** Load WordPress Translation Install API */
    42 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
     42require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    4343
    4444/** Load wpdb */
    45 require_once( ABSPATH . WPINC . '/wp-db.php' );
     45require_once ABSPATH . WPINC . '/wp-db.php';
    4646
    4747nocache_headers();
    4848
    $version_url = sprintf( 
    243243        sanitize_title( $wp_version )
    244244);
    245245
     246/* translators: %s: Update PHP page URL */
     247$php_update_message = '<br>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
     248
     249$annotation = wp_get_update_php_annotation();
     250
     251if ( $annotation ) {
     252        $php_update_message .= '<br><em>' . $annotation . '</em>';
     253}
     254
    246255if ( ! $mysql_compat && ! $php_compat ) {
    247256        /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number */
    248         $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version );
     257        $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) . $php_update_message;
    249258} elseif ( ! $php_compat ) {
    250259        /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number */
    251         $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version );
     260        $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version ) . $php_update_message;
    252261} elseif ( ! $mysql_compat ) {
    253262        /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number */
    254263        $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_mysql_version, $mysql_version );
  • wp-admin/update-core.php

    diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php
    index 570703e5d8..0d8dad303a 100644
    a b  
    77 */
    88
    99/** WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
     10require_once dirname( __FILE__ ) . '/admin.php';
    1111
    1212wp_enqueue_style( 'plugin-install' );
    1313wp_enqueue_script( 'plugin-install' );
    function list_core_update( $update ) { 
    7676                                sanitize_title( $update->current )
    7777                        );
    7878
     79                        /* translators: %s: Update PHP page URL */
     80                        $php_update_message = '<br>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
     81
     82                        $annotation = wp_get_update_php_annotation();
     83
     84                        if ( $annotation ) {
     85                                $php_update_message .= '<br><em>' . $annotation . '</em>';
     86                        }
     87
    7988                        if ( ! $mysql_compat && ! $php_compat ) {
    8089                                /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number */
    81                                 $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version );
     90                                $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version ) . $php_update_message;
    8291                        } elseif ( ! $php_compat ) {
    8392                                /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number */
    84                                 $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->php_version, $php_version );
     93                                $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->php_version, $php_version ) . $php_update_message;
    8594                        } elseif ( ! $mysql_compat ) {
    8695                                /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number */
    8796                                $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->mysql_version, $mysql_version );
    function core_upgrade_preamble() { 
    183192
    184193                if ( wp_http_supports( array( 'ssl' ) ) ) {
    185194                        require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    186                         $upgrader            = new WP_Automatic_Updater;
     195                        $upgrader            = new WP_Automatic_Updater();
    187196                        $future_minor_update = (object) array(
    188197                                'current'       => $wp_version . '.1.next.minor',
    189198                                'version'       => $wp_version . '.1.next.minor',
    function core_upgrade_preamble() { 
    208217
    209218        if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
    210219                require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    211                 $upgrader = new WP_Automatic_Updater;
     220                $upgrader = new WP_Automatic_Updater();
    212221                if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) ) {
    213222                        echo '<div class="updated inline"><p>';
    214223                        echo '<strong>' . __( 'BETA TESTERS:' ) . '</strong> ' . __( 'This site is set up to install updates of future beta versions automatically.' );
    function list_plugin_updates() { 
    237246        $wp_version     = get_bloginfo( 'version' );
    238247        $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
    239248
    240         require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
     249        require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
    241250        $plugins = get_plugin_updates();
    242251        if ( empty( $plugins ) ) {
    243252                echo '<h2>' . __( 'Plugins' ) . '</h2>';
    function list_translation_updates() { 
    497506function do_core_upgrade( $reinstall = false ) {
    498507        global $wp_filesystem;
    499508
    500         include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
     509        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    501510
    502511        if ( $reinstall ) {
    503512                $url = 'update-core.php?action=do-core-reinstall';
    if ( 'upgrade-core' == $action ) { 
    655664        $force_check = ! empty( $_GET['force-check'] );
    656665        wp_version_check( array(), $force_check );
    657666
    658         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     667        require_once ABSPATH . 'wp-admin/admin-header.php';
    659668        ?>
    660669        <div class="wrap">
    661670        <h1><?php _e( 'WordPress Updates' ); ?></h1>
    if ( 'upgrade-core' == $action ) { 
    712721                )
    713722        );
    714723
    715         include( ABSPATH . 'wp-admin/admin-footer.php' );
     724        include ABSPATH . 'wp-admin/admin-footer.php';
    716725
    717726} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
    718727
    if ( 'upgrade-core' == $action ) { 
    729738                do_undismiss_core_update();
    730739        }
    731740
    732         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     741        require_once ABSPATH . 'wp-admin/admin-header.php';
    733742        if ( 'do-core-reinstall' == $action ) {
    734743                $reinstall = true;
    735744        } else {
    if ( 'upgrade-core' == $action ) { 
    748757                )
    749758        );
    750759
    751         include( ABSPATH . 'wp-admin/admin-footer.php' );
     760        include ABSPATH . 'wp-admin/admin-footer.php';
    752761
    753762} elseif ( 'do-plugin-upgrade' == $action ) {
    754763
    if ( 'upgrade-core' == $action ) { 
    772781
    773782        $title = __( 'Update Plugins' );
    774783
    775         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     784        require_once ABSPATH . 'wp-admin/admin-header.php';
    776785        echo '<div class="wrap">';
    777786        echo '<h1>' . __( 'Update Plugins' ) . '</h1>';
    778787        echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="' . esc_attr__( 'Update progress' ) . '"></iframe>';
    if ( 'upgrade-core' == $action ) { 
    786795                )
    787796        );
    788797
    789         include( ABSPATH . 'wp-admin/admin-footer.php' );
     798        include ABSPATH . 'wp-admin/admin-footer.php';
    790799
    791800} elseif ( 'do-theme-upgrade' == $action ) {
    792801
    if ( 'upgrade-core' == $action ) { 
    810819
    811820        $title = __( 'Update Themes' );
    812821
    813         require_once( ABSPATH . 'wp-admin/admin-header.php' );
     822        require_once ABSPATH . 'wp-admin/admin-header.php';
    814823        ?>
    815824        <div class="wrap">
    816825                <h1><?php _e( 'Update Themes' ); ?></h1>
    if ( 'upgrade-core' == $action ) { 
    826835                )
    827836        );
    828837
    829         include( ABSPATH . 'wp-admin/admin-footer.php' );
     838        include ABSPATH . 'wp-admin/admin-footer.php';
    830839
    831840} elseif ( 'do-translation-upgrade' == $action ) {
    832841
    if ( 'upgrade-core' == $action ) { 
    836845
    837846        check_admin_referer( 'upgrade-translations' );
    838847
    839         require_once( ABSPATH . 'wp-admin/admin-header.php' );
    840         include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
     848        require_once ABSPATH . 'wp-admin/admin-header.php';
     849        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    841850
    842851        $url     = 'update-core.php?action=do-translation-upgrade';
    843852        $nonce   = 'upgrade-translations';
    if ( 'upgrade-core' == $action ) { 
    855864                )
    856865        );
    857866
    858         require_once( ABSPATH . 'wp-admin/admin-footer.php' );
     867        require_once ABSPATH . 'wp-admin/admin-footer.php';
    859868
    860869} else {
    861870        /**
  • wp-admin/upgrade.php

    diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php
    index 330ef0fd9d..54661ddb1e 100644
    a b  
    1515define( 'WP_INSTALLING', true );
    1616
    1717/** Load WordPress Bootstrap */
    18 require( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
     18require dirname( dirname( __FILE__ ) ) . '/wp-load.php';
    1919
    2020nocache_headers();
    2121
    2222timer_start();
    23 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     23require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    2424
    2525delete_site_transient( 'update_core' );
    2626
    if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { 
    5454        $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
    5555}
    5656
     57/* translators: %s: Update PHP page URL */
     58$php_update_message = '<br>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
     59
     60$annotation = wp_get_update_php_annotation();
     61
     62if ( $annotation ) {
     63        $php_update_message .= '<br><em>' . $annotation . '</em>';
     64}
     65
    5766@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
    5867?>
    5968<!DOCTYPE html>
    elseif ( ! $php_compat || ! $mysql_compat ) : 
    8796
    8897        if ( ! $mysql_compat && ! $php_compat ) {
    8998                /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number */
    90                 $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version );
     99                $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) . $php_update_message;
    91100        } elseif ( ! $php_compat ) {
    92101                /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number */
    93                 $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version );
     102                $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version ) . $php_update_message;
    94103        } elseif ( ! $mysql_compat ) {
    95104                /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number */
    96105                $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_mysql_version, $mysql_version );