Make WordPress Core

Changeset 10923


Ignore:
Timestamp:
04/13/2009 04:24:37 PM (15 years ago)
Author:
ryan
Message:

Theme insall cleanups. Props DD32. fixes #9508

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/theme-install.php

    r10900 r10923  
    9898 */
    9999function install_theme_search($page) {
     100    global $theme_field_defaults;
     101
    100102    $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
    101103    $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
     
    399401<table id="availablethemes" cellspacing="0" cellpadding="0">
    400402<?php
    401     $in_column = 0;
    402403    $rows = ceil(count($themes) / 3);
    403404    $table = array();
    404     $i = 0;
    405     for ( $row = 1; $row <= $rows; $row++ ) {
    406         for ( $col = 1; $col <= 3; $col++ ) {
    407             $table[$row][$col] = $i;
    408             $i++;
    409         }
    410     }
     405    $theme_keys = array_keys($themes);
     406    for ( $row = 1; $row <= $rows; $row++ )
     407        for ( $col = 1; $col <= 3; $col++ )
     408            $table[$row][$col] = array_shift($theme_keys);
    411409
    412410    foreach ( $table as $row => $cols ) {
     
    420418        if ( $row == $rows ) $class[] = 'bottom';
    421419        if ( $col == 3 ) $class[] = 'right';
    422         $theme = $themes[$theme_index];
    423420        ?>
    424421        <td class="<?php echo join(' ', $class); ?>"><?php
    425             display_theme($theme);
     422            if ( isset($themes[$theme_index]) )
     423                display_theme($themes[$theme_index]);
    426424        ?></td>
    427425        <?php } // end foreach $cols ?>
     
    468466    }
    469467
    470     if ( version_compare($GLOBALS['wp_version'], $api->tested, '>') )
     468    if ( !empty($api->tested) && version_compare($GLOBALS['wp_version'], $api->tested, '>') )
    471469        echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This theme has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
    472     else if ( version_compare($GLOBALS['wp_version'], $api->requires, '<') )
     470    else if ( !empty($api->requires) && version_compare($GLOBALS['wp_version'], $api->requires, '<') )
    473471        echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This theme has not been marked as <strong>compatible</strong> with your version of WordPress.') . '</p></div>';
    474472
     
    477475    // Check to see if this theme is known to be installed, and has an update awaiting it.
    478476    $update_themes = get_transient('update_themes');
    479     if ( is_object($update_themes) ) {
    480         foreach ( (array)$update_themes->response as $file => $theme ) {
    481             if ( $theme->slug === $api->slug ) {
     477    if ( is_object($update_themes) && isset($update_themes->response) ) {
     478        foreach ( (array)$update_themes->response as $theme_slug => $theme_info ) {
     479            if ( $theme_slug === $api->slug ) {
    482480                $type = 'update_available';
    483                 $update_file = $file;
     481                $update_file = $theme_slug;
    484482                break;
    485483            }
  • trunk/wp-admin/themes.php

    r10915 r10923  
    9494    if ( isset($themes_update->response[ $stylesheet ]) ) {
    9595        $update = $themes_update->response[ $stylesheet ];
     96        $theme_name = is_object($theme) ? $theme->name : (is_array($theme) ? $theme['Name'] : '');
    9697        $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
    9798        $update_url = wp_nonce_url('update.php?action=upgrade-theme&amp;theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet);
    9899
    99100        if ( ! current_user_can('update_themes') )
    100             printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a>.</p>'), $ct->name, $details_url, $update['new_version']);
     101            printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a>.</p>'), $theme_name, $details_url, $update['new_version']);
    101102        else if ( empty($update->package) )
    102             printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> <em>automatic upgrade unavailable for this theme</em>.</p>'), $ct->name, $details_url, $update['new_version']);
     103            printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> <em>automatic upgrade unavailable for this theme</em>.</p>'), $theme_name, $details_url, $update['new_version']);
    103104        else
    104             printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> or <a href="%4$s">upgrade automatically</a>.</p>'), $ct->name, $details_url, $update['new_version'], $update_url );
     105            printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> or <a href="%4$s">upgrade automatically</a>.</p>'), $theme_name, $details_url, $update['new_version'], $update_url );
    105106    }
    106107}
Note: See TracChangeset for help on using the changeset viewer.