WordPress.org

Make WordPress Core

Changeset 25810


Ignore:
Timestamp:
10/16/2013 02:33:21 PM (8 years ago)
Author:
nacin
Message:

Include translations in the update bubbles (as +1 if there are any). see #18200.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r25801 r25810  
    356356}
    357357add_action( 'admin_notices', 'maintenance_nag' );
    358 
    359 /**
    360  * Retrieves a list of all language updates available.
    361  *
    362  * @since 3.7.0
    363  */
    364 function wp_get_translation_updates() {
    365     $updates = array();
    366     $transients = array( 'update_core' => 'core', 'update_plugins' => 'plugin', 'update_themes' => 'theme' );
    367     foreach ( $transients as $transient => $type ) {
    368 
    369         $transient = get_site_transient( $transient );
    370         if ( empty( $transient->translations ) )
    371             continue;
    372 
    373         foreach ( $transient->translations as $translation ) {
    374             $updates[] = (object) $translation;
    375         }
    376     }
    377 
    378     return $updates;
    379 }
  • trunk/src/wp-includes/update.php

    r25781 r25810  
    421421}
    422422
     423/**
     424 * Retrieves a list of all language updates available.
     425 *
     426 * @since 3.7.0
     427 */
     428function wp_get_translation_updates() {
     429    $updates = array();
     430    $transients = array( 'update_core' => 'core', 'update_plugins' => 'plugin', 'update_themes' => 'theme' );
     431    foreach ( $transients as $transient => $type ) {
     432
     433        $transient = get_site_transient( $transient );
     434        if ( empty( $transient->translations ) )
     435            continue;
     436
     437        foreach ( $transient->translations as $translation ) {
     438            $updates[] = (object) $translation;
     439        }
     440    }
     441
     442    return $updates;
     443}
     444
    423445/*
    424446 * Collect counts and UI strings for available updates
     
    429451 */
    430452function wp_get_update_data() {
    431     $counts = array( 'plugins' => 0, 'themes' => 0, 'wordpress' => 0 );
    432 
    433     if ( current_user_can( 'update_plugins' ) ) {
     453    $counts = array( 'plugins' => 0, 'themes' => 0, 'wordpress' => 0, 'translations' => 0 );
     454
     455    if ( $plugins = current_user_can( 'update_plugins' ) ) {
    434456        $update_plugins = get_site_transient( 'update_plugins' );
    435457        if ( ! empty( $update_plugins->response ) )
     
    437459    }
    438460
    439     if ( current_user_can( 'update_themes' ) ) {
     461    if ( $themes = current_user_can( 'update_themes' ) ) {
    440462        $update_themes = get_site_transient( 'update_themes' );
    441463        if ( ! empty( $update_themes->response ) )
     
    443465    }
    444466
    445     if ( function_exists( 'get_core_updates' ) && current_user_can( 'update_core' ) ) {
     467    if ( ( $core = current_user_can( 'update_core' ) ) && function_exists( 'get_core_updates' ) ) {
    446468        $update_wordpress = get_core_updates( array('dismissed' => false) );
    447469        if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') )
     
    449471    }
    450472
    451     $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'];
     473    if ( ( $core || $plugins || $themes ) && wp_get_translation_updates() )
     474        $counts['translations'] = 1;
     475
     476    $counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'] + $counts['translations'];
    452477    $titles = array();
    453478    if ( $counts['wordpress'] )
     
    457482    if ( $counts['themes'] )
    458483        $titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] );
     484    if ( $counts['translations'] )
     485        $titles['translations'] = __( 'Translation Updates' );
    459486
    460487    $update_title = $titles ? esc_attr( implode( ', ', $titles ) ) : '';
Note: See TracChangeset for help on using the changeset viewer.