Make WordPress Core

Changeset 55874


Ignore:
Timestamp:
06/01/2023 03:12:16 PM (16 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in wp-admin/includes/update.php.

Includes minor code layout fixes for better readability.

Follow-up to [9441], [25540].

Props aristath, poena, afercia, SergeyBiryukov.
See #57839.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/update.php

    r55624 r55874  
    1616function get_preferred_from_update_core() {
    1717    $updates = get_core_updates();
     18
    1819    if ( ! is_array( $updates ) ) {
    1920        return false;
    2021    }
     22
    2123    if ( empty( $updates ) ) {
    2224        return (object) array( 'response' => 'latest' );
    2325    }
     26
    2427    return $updates[0];
    2528}
     
    3538 */
    3639function get_core_updates( $options = array() ) {
    37     $options   = array_merge(
     40    $options = array_merge(
    3841        array(
    3942            'available' => true,
     
    4245        $options
    4346    );
     47
    4448    $dismissed = get_site_option( 'dismissed_update_core' );
    4549
     
    5660    $updates = $from_api->updates;
    5761    $result  = array();
     62
    5863    foreach ( $updates as $update ) {
    5964        if ( 'autoupdate' === $update->response ) {
     
    7378        }
    7479    }
     80
    7581    return $result;
    7682}
     
    8793function find_core_auto_update() {
    8894    $updates = get_site_transient( 'update_core' );
     95
    8996    if ( ! $updates || empty( $updates->updates ) ) {
    9097        return false;
     
    95102    $auto_update = false;
    96103    $upgrader    = new WP_Automatic_Updater();
     104
    97105    foreach ( $updates->updates as $update ) {
    98106        if ( 'autoupdate' !== $update->response ) {
     
    108116        }
    109117    }
     118
    110119    return $auto_update;
    111120}
     
    125134
    126135    $ssl = wp_http_supports( array( 'ssl' ) );
     136
    127137    if ( $ssl ) {
    128138        $url = set_url_scheme( $url, 'https' );
     
    134144
    135145    $response = wp_remote_get( $url, $options );
     146
    136147    if ( $ssl && is_wp_error( $response ) ) {
    137148        trigger_error(
     
    143154            headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
    144155        );
     156
    145157        $response = wp_remote_get( $http_url, $options );
    146158    }
    147159
    148     if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
     160    if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
    149161        return false;
    150162    }
     
    171183    $dismissed = get_site_option( 'dismissed_update_core' );
    172184    $dismissed[ $update->current . '|' . $update->locale ] = true;
     185
    173186    return update_site_option( 'dismissed_update_core', $dismissed );
    174187}
     
    192205
    193206    unset( $dismissed[ $key ] );
     207
    194208    return update_site_option( 'dismissed_update_core', $dismissed );
    195209}
     
    212226
    213227    $updates = $from_api->updates;
     228
    214229    foreach ( $updates as $update ) {
    215         if ( $update->current == $version && $update->locale == $locale ) {
     230        if ( $update->current === $version && $update->locale === $locale ) {
    216231            return $update;
    217232        }
    218233    }
     234
    219235    return false;
    220236}
     
    235251
    236252    $cur = get_preferred_from_update_core();
     253
    237254    if ( ! is_object( $cur ) ) {
    238255        $cur = new stdClass();
     
    336353function update_right_now_message() {
    337354    $theme_name = wp_get_theme();
     355
    338356    if ( current_user_can( 'switch_themes' ) ) {
    339357        $theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name );
     
    385403    $upgrade_plugins = array();
    386404    $current         = get_site_transient( 'update_plugins' );
     405
    387406    foreach ( (array) $all_plugins as $plugin_file => $plugin_data ) {
    388407        if ( isset( $current->response[ $plugin_file ] ) ) {
     
    406425
    407426    $plugins = get_site_transient( 'update_plugins' );
     427
    408428    if ( isset( $plugins->response ) && is_array( $plugins->response ) ) {
    409429        $plugins = array_keys( $plugins->response );
     430
    410431        foreach ( $plugins as $plugin_file ) {
    411432            add_action( "after_plugin_row_{$plugin_file}", 'wp_plugin_update_row', 10, 2 );
     
    425446function wp_plugin_update_row( $file, $plugin_data ) {
    426447    $current = get_site_transient( 'update_plugins' );
     448
    427449    if ( ! isset( $current->response[ $file ] ) ) {
    428450        return false;
     
    608630
    609631    $update_themes = array();
     632
    610633    foreach ( $current->response as $stylesheet => $data ) {
    611634        $update_themes[ $stylesheet ]         = wp_get_theme( $stylesheet );
     
    627650
    628651    $themes = get_site_transient( 'update_themes' );
     652
    629653    if ( isset( $themes->response ) && is_array( $themes->response ) ) {
    630654        $themes = array_keys( $themes->response );
     
    819843 *
    820844 * @global int $upgrading
     845 *
    821846 * @return void|false
    822847 */
     
    825850    require ABSPATH . WPINC . '/version.php';
    826851    global $upgrading;
     852
    827853    $nag = isset( $upgrading );
     854
    828855    if ( ! $nag ) {
    829856        $failed = get_site_option( 'auto_core_update_failed' );
Note: See TracChangeset for help on using the changeset viewer.