Make WordPress Core

Changeset 25256


Ignore:
Timestamp:
09/05/2013 05:04:03 PM (11 years ago)
Author:
wonderboymusic
Message:

Remove redundant checks in some update functions. Adds some readability/coding standards cleanup.

Props miqrogroove, azaozz.
Fixes #22828.

File:
1 edited

Legend:

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

    r22618 r25256  
    1616function get_preferred_from_update_core() {
    1717    $updates = get_core_updates();
    18     if ( !is_array( $updates ) )
     18    if ( ! is_array( $updates ) )
    1919        return false;
    2020    if ( empty( $updates ) )
    21         return (object)array('response' => 'latest');
     21        return (object) array( 'response' => 'latest' );
    2222    return $updates[0];
    2323}
     
    3131 */
    3232function get_core_updates( $options = array() ) {
    33     $options = array_merge( array('available' => true, 'dismissed' => false ), $options );
     33    $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options );
    3434    $dismissed = get_site_option( 'dismissed_update_core' );
    35     if ( !is_array( $dismissed ) ) $dismissed = array();
     35
     36    if ( ! is_array( $dismissed ) )
     37        $dismissed = array();
     38
    3639    $from_api = get_site_transient( 'update_core' );
    37     if ( empty($from_api) )
    38         return false;
    39     if ( !isset( $from_api->updates ) || !is_array( $from_api->updates ) ) return false;
     40
     41    if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) )
     42        return false;
     43
    4044    $updates = $from_api->updates;
    41     if ( !is_array( $updates ) ) return false;
    4245    $result = array();
    43     foreach($updates as $update) {
    44         if ( array_key_exists( $update->current.'|'.$update->locale, $dismissed ) ) {
     46    foreach ( $updates as $update ) {
     47        if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) {
    4548            if ( $options['dismissed'] ) {
    4649                $update->dismissed = true;
    47                 $result[]= $update;
     50                $result[] = $update;
    4851            }
    4952        } else {
    5053            if ( $options['available'] ) {
    5154                $update->dismissed = false;
    52                 $result[]= $update;
     55                $result[] = $update;
    5356            }
    5457        }
     
    5962function dismiss_core_update( $update ) {
    6063    $dismissed = get_site_option( 'dismissed_update_core' );
    61     $dismissed[ $update->current.'|'.$update->locale ] = true;
     64    $dismissed[ $update->current . '|' . $update->locale ] = true;
    6265    return update_site_option( 'dismissed_update_core', $dismissed );
    6366}
     
    6568function undismiss_core_update( $version, $locale ) {
    6669    $dismissed = get_site_option( 'dismissed_update_core' );
    67     $key = $version.'|'.$locale;
    68     if ( !isset( $dismissed[$key] ) ) return false;
     70    $key = $version . '|' . $locale;
     71
     72    if ( ! isset( $dismissed[$key] ) )
     73        return false;
     74
    6975    unset( $dismissed[$key] );
    7076    return update_site_option( 'dismissed_update_core', $dismissed );
     
    7379function find_core_update( $version, $locale ) {
    7480    $from_api = get_site_transient( 'update_core' );
    75     if ( !is_array( $from_api->updates ) ) return false;
     81
     82    if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) )
     83        return false;
     84
    7685    $updates = $from_api->updates;
    77     foreach($updates as $update) {
     86    foreach ( $updates as $update ) {
    7887        if ( $update->current == $version && $update->locale == $locale )
    7988            return $update;
Note: See TracChangeset for help on using the changeset viewer.