Make WordPress Core

Ticket #9508: 9508.2.diff

File 9508.2.diff, 5.4 KB (added by DD32, 16 years ago)
  • wp-admin/includes/theme-install.php

     
    9797 * @param string $page
    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'] ) : '';
    102104
     
    398400?>
    399401<table id="availablethemes" cellspacing="0" cellpadding="0">
    400402<?php
    401         $in_column = 0;
     403
    402404        $rows = ceil(count($themes) / 3);
    403405        $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         }
     406        $theme_keys = array_keys($themes);
     407        for ( $row = 1; $row <= $rows; $row++ )
     408                for ( $col = 1; $col <= 3; $col++ )
     409                        $table[$row][$col] = array_shift($theme_keys);
    411410
    412411        foreach ( $table as $row => $cols ) {
    413412        ?>
    414413        <tr>
    415414        <?php
    416415
    417416        foreach ( $cols as $col => $theme_index ) {
    418417                $class = array('available-theme');
    419418                if ( $row == 1 ) $class[] = 'top';
    420419                if ( $col == 1 ) $class[] = 'left';
    421420                if ( $row == $rows ) $class[] = 'bottom';
    422421                if ( $col == 3 ) $class[] = 'right';
    423                 $theme = $themes[$theme_index];
    424422                ?>
    425423                <td class="<?php echo join(' ', $class); ?>"><?php
    426                         display_theme($theme);
     424                        if ( isset($themes[$theme_index]) )
     425                                display_theme($themes[$theme_index]);
    427426                ?></td>
    428427                <?php } // end foreach $cols ?>
    429428        </tr>
     
    467467                exit;
    468468        }
    469469
    470         if ( version_compare($GLOBALS['wp_version'], $api->tested, '>') )
     470        if ( !empty($api->tested) && version_compare($GLOBALS['wp_version'], $api->tested, '>') )
    471471                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, '<') )
     472        else if ( !empty($api->requires) && version_compare($GLOBALS['wp_version'], $api->requires, '<') )
    473473                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>';
    474474
    475475        // Default to a "new" theme
     
    477477        // Check to see if this theme is known to be installed, and has an update awaiting it.
    478478        $update_themes = get_transient('update_themes');
    479479        if ( is_object($update_themes) ) {
    480                 foreach ( (array)$update_themes->response as $file => $theme ) {
    481                         if ( $theme->slug === $api->slug ) {
     480                foreach ( (array)$update_themes->response as $theme_slug => $theme_info ) {
     481                        if ( $theme_slug === $api->slug ) {
    482482                                $type = 'update_available';
    483                                 $update_file = $file;
     483                                $update_file = $theme_slug;
    484484                                break;
    485485                        }
    486486                }
  • wp-admin/themes.php

     
    8484        if ( !isset($themes_update) )
    8585                $themes_update = get_transient('update_themes');
    8686
     87        //Note: Current theme is object, with lower case keys, Others are arrays, with Camal Case keys
    8788        if ( is_object($theme) && isset($theme->stylesheet) )
    8889                $stylesheet = $theme->stylesheet;
    8990        elseif ( is_array($theme) && isset($theme['Stylesheet']) )
     
    9394
    9495        if ( isset($themes_update->response[ $stylesheet ]) ) {
    9596                $update = $themes_update->response[ $stylesheet ];
     97                $theme_name = is_object($theme) ? $theme->name : (is_array($theme) ? $theme['Name'] : '');
     98               
    9699                $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.
    97100                $update_url = wp_nonce_url('update.php?action=upgrade-theme&amp;theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet);
    98101
    99102                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']);
     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>.</p>'), $theme_name, $details_url, $update['new_version']);
    101104                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']);
     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> <em>automatic upgrade unavailable for this theme</em>.</p>'), $theme_name, $details_url, $update['new_version']);
    103106                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 );
     107                        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 );
    105108        }
    106109}
    107110