Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r18392 r19312  
    5858    }
    5959
    60     $local_package = isset( $wp_local_package )? $wp_local_package : '';
    61     $url = "http://api.wordpress.org/core/version-check/1.6/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package&blogs=$num_blogs&users={$user_count['total_users']}&multisite_enabled=$multisite_enabled";
     60    $query = array(
     61        'version'           => $wp_version,
     62        'php'               => $php_version,
     63        'locale'            => $locale,
     64        'mysql'             => $mysql_version,
     65        'local_package'     => isset( $wp_local_package ) ? $wp_local_package : '',
     66        'blogs'             => $num_blogs,
     67        'users'             => $user_count['total_users'],
     68        'multisite_enabled' => $multisite_enabled
     69    );
     70
     71    $url = 'http://api.wordpress.org/core/version-check/1.6/?' . http_build_query( $query, null, '&' );
    6272
    6373    $options = array(
     
    134144    $new_option = new stdClass;
    135145    $new_option->last_checked = time();
    136     $timeout = 'load-plugins.php' == current_filter() ? 3600 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours
     146    // Check for updated every 60 minutes if hitting update pages; else, check every 12 hours.
     147    $timeout = in_array( current_filter(), array( 'load-plugins.php', 'load-update.php', 'load-update-core.php' ) ) ? 3600 : 43200;
    137148    $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
    138149
     
    212223        $last_update = new stdClass;
    213224
    214     $timeout = 'load-themes.php' == current_filter() ? 3600 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours
     225    // Check for updated every 60 minutes if hitting update pages; else, check every 12 hours.
     226    $timeout = in_array( current_filter(), array( 'load-themes.php', 'load-update.php', 'load-update-core.php' ) ) ? 3600 : 43200;
    215227    $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked );
    216228
     
    281293}
    282294
     295/*
     296 * Collect counts and UI strings for available updates
     297 *
     298 * @since 3.3.0
     299 *
     300 * @return array
     301 */
     302function wp_get_update_data() {
     303    $counts = array( 'plugins' => 0, 'themes' => 0, 'wordpress' => 0 );
     304
     305    if ( current_user_can( 'update_plugins' ) ) {
     306        $update_plugins = get_site_transient( 'update_plugins' );
     307        if ( ! empty( $update_plugins->response ) )
     308            $counts['plugins'] = count( $update_plugins->response );
     309    }
     310
     311    if ( current_user_can( 'update_themes' ) ) {
     312        $update_themes = get_site_transient( 'update_themes' );
     313        if ( ! empty( $update_themes->response ) )
     314            $counts['themes'] = count( $update_themes->response );
     315    }
     316
     317    if ( function_exists( 'get_core_updates' ) && current_user_can( 'update_core' ) ) {
     318        $update_wordpress = get_core_updates( array('dismissed' => false) );
     319        if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') )
     320            $counts['wordpress'] = 1;
     321    }
     322
     323    $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'];
     324    $update_title = array();
     325    if ( $counts['wordpress'] )
     326        $update_title[] = sprintf(__('%d WordPress Update'), $counts['wordpress']);
     327    if ( $counts['plugins'] )
     328        $update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $counts['plugins']), $counts['plugins']);
     329    if ( $counts['themes'] )
     330        $update_title[] = sprintf(_n('%d Theme Update', '%d Theme Updates', $counts['themes']), $counts['themes']);
     331
     332    $update_title = ! empty( $update_title ) ? esc_attr( implode( ', ', $update_title ) ) : '';
     333
     334    return array( 'counts' => $counts, 'title' => $update_title );
     335}
     336
    283337function _maybe_update_core() {
    284338    include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
     
    344398}
    345399
    346 if ( ! is_main_site() )
     400if ( ! is_main_site() && ! is_network_admin() )
    347401    return;
    348402
Note: See TracChangeset for help on using the changeset viewer.