Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (4 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/upgrade.php

    r41200 r42343  
    1313require_once( ABSPATH . WPINC . '/http.php' );
    1414
    15 $title = __( 'Upgrade Network' );
     15$title       = __( 'Upgrade Network' );
    1616$parent_file = 'upgrade.php';
    1717
    18 get_current_screen()->add_help_tab( array(
    19     'id'      => 'overview',
    20     'title'   => __('Overview'),
    21     'content' =>
    22         '<p>' . __('Only use this screen once you have updated to a new version of WordPress through Updates/Available Updates (via the Network Administration navigation menu or the Toolbar). Clicking the Upgrade Network button will step through each site in the network, five at a time, and make sure any database updates are applied.') . '</p>' .
    23         '<p>' . __('If a version update to core has not happened, clicking this button won&#8217;t affect anything.') . '</p>' .
    24         '<p>' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '</p>'
    25 ) );
     18get_current_screen()->add_help_tab(
     19    array(
     20        'id'      => 'overview',
     21        'title'   => __( 'Overview' ),
     22        'content' =>
     23            '<p>' . __( 'Only use this screen once you have updated to a new version of WordPress through Updates/Available Updates (via the Network Administration navigation menu or the Toolbar). Clicking the Upgrade Network button will step through each site in the network, five at a time, and make sure any database updates are applied.' ) . '</p>' .
     24            '<p>' . __( 'If a version update to core has not happened, clicking this button won&#8217;t affect anything.' ) . '</p>' .
     25            '<p>' . __( 'If this process fails for any reason, users logging in to their sites will force the same update.' ) . '</p>',
     26    )
     27);
    2628
    2729get_current_screen()->set_help_sidebar(
    28     '<p><strong>' . __('For more information:') . '</strong></p>' .
    29     '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Updates_Screen">Documentation on Upgrade Network</a>') . '</p>' .
    30     '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
     30    '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
     31    '<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Updates_Screen">Documentation on Upgrade Network</a>' ) . '</p>' .
     32    '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    3133);
    3234
     
    4042echo '<h1>' . __( 'Upgrade Network' ) . '</h1>';
    4143
    42 $action = isset($_GET['action']) ? $_GET['action'] : 'show';
     44$action = isset( $_GET['action'] ) ? $_GET['action'] : 'show';
    4345
    4446switch ( $action ) {
    45     case "upgrade":
    46         $n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0;
     47    case 'upgrade':
     48        $n = ( isset( $_GET['n'] ) ) ? intval( $_GET['n'] ) : 0;
    4749
    4850        if ( $n < 5 ) {
     
    5456        }
    5557
    56         $site_ids = get_sites( array(
    57             'spam'       => 0,
    58             'deleted'    => 0,
    59             'archived'   => 0,
    60             'network_id' => get_current_network_id(),
    61             'number'     => 5,
    62             'offset'     => $n,
    63             'fields'     => 'ids',
    64             'order'      => 'DESC',
    65             'orderby'    => 'id',
    66         ) );
     58        $site_ids = get_sites(
     59            array(
     60                'spam'       => 0,
     61                'deleted'    => 0,
     62                'archived'   => 0,
     63                'network_id' => get_current_network_id(),
     64                'number'     => 5,
     65                'offset'     => $n,
     66                'fields'     => 'ids',
     67                'order'      => 'DESC',
     68                'orderby'    => 'id',
     69            )
     70        );
    6771        if ( empty( $site_ids ) ) {
    6872            echo '<p>' . __( 'All done!' ) . '</p>';
    6973            break;
    7074        }
    71         echo "<ul>";
     75        echo '<ul>';
    7276        foreach ( (array) $site_ids as $site_id ) {
    7377            switch_to_blog( $site_id );
    74             $siteurl = site_url();
     78            $siteurl     = site_url();
    7579            $upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
    7680            restore_current_blog();
     
    7882            echo "<li>$siteurl</li>";
    7983
    80             $response = wp_remote_get( $upgrade_url, array(
    81                 'timeout'     => 120,
    82                 'httpversion' => '1.1',
    83                 'sslverify'   => false,
    84             ) );
     84            $response = wp_remote_get(
     85                $upgrade_url, array(
     86                    'timeout'     => 120,
     87                    'httpversion' => '1.1',
     88                    'sslverify'   => false,
     89                )
     90            );
    8591            if ( is_wp_error( $response ) ) {
    86                 wp_die( sprintf(
    87                     /* translators: 1: site url, 2: server error message */
    88                     __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s' ),
    89                     $siteurl,
    90                     '<em>' . $response->get_error_message() . '</em>'
    91                 ) );
     92                wp_die(
     93                    sprintf(
     94                        /* translators: 1: site url, 2: server error message */
     95                        __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s' ),
     96                        $siteurl,
     97                        '<em>' . $response->get_error_message() . '</em>'
     98                    )
     99                );
    92100            }
    93101
     
    109117            do_action( 'wpmu_upgrade_site', $site_id );
    110118        }
    111         echo "</ul>";
    112         ?><p><?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this link:' ); ?> <a class="button" href="upgrade.php?action=upgrade&amp;n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p>
     119        echo '</ul>';
     120        ?><p><?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this link:' ); ?> <a class="button" href="upgrade.php?action=upgrade&amp;n=<?php echo ( $n + 5 ); ?>"><?php _e( 'Next Sites' ); ?></a></p>
    113121        <script type="text/javascript">
    114122        <!--
    115123        function nextpage() {
    116             location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>";
     124            location.href = "upgrade.php?action=upgrade&n=<?php echo ( $n + 5 ); ?>";
    117125        }
    118126        setTimeout( "nextpage()", 250 );
    119127        //-->
    120         </script><?php
    121     break;
     128        </script>
     129        <?php
     130        break;
    122131    case 'show':
    123132    default:
     
    137146         */
    138147        do_action( 'wpmu_upgrade_page' );
    139     break;
     148        break;
    140149}
    141150?>
Note: See TracChangeset for help on using the changeset viewer.