WordPress.org

Make WordPress Core

Ticket #14897: 14897.7.diff

File 14897.7.diff, 3.0 KB (added by PeteMall, 9 years ago)

Add theme updates to network themes panel.

  • wp-admin/includes/update.php

     
    241241        return $upgrader->upgrade($theme);
    242242}
    243243
     244function wp_theme_update_rows() {
     245        if ( !current_user_can('update_themes' ) )
     246                return;
    244247
     248        $themes = get_site_transient( 'update_themes' );
     249        if ( isset($themes->response) && is_array($themes->response) ) {
     250                $themes = array_keys( $themes->response );
     251
     252                foreach( $themes as $theme ) {
     253                        add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 );
     254                }
     255        }
     256}
     257add_action( 'admin_init', 'wp_theme_update_rows' );
     258
     259function wp_theme_update_row( $theme_key, $theme ) {
     260        $current = get_site_transient( 'update_themes' );
     261        if ( !isset( $current->response[ $theme_key ] ) )
     262                return false;
     263        $r = $current->response[ $theme_key ];
     264        $themes_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
     265        $theme_name = wp_kses( $theme['Name'], $themes_allowedtags );
     266
     267        $details_url = self_admin_url("theme-install.php?tab=theme-information&theme=$theme_key&TB_iframe=true&width=600&height=400");
     268
     269        echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message">';
     270        if ( ! current_user_can('update_themes') )
     271                printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version );
     272        else if ( empty( $r['package'] ) )
     273                printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic upgrade is unavailable for this plugin.</em>'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] );
     274        else
     275                printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">upgrade automatically</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) );
     276
     277        do_action( "in_theme_update_message-$theme_key", $theme, $r );
     278
     279        echo '</div></td></tr>';
     280}
     281
    245282function wp_update_core($current, $feedback = '') {
    246283        if ( !empty($feedback) )
    247284                add_filter('update_feedback', $feedback);
  • wp-admin/network/themes.php

     
    6464}
    6565
    6666$wp_list_table->prepare_items();
     67add_thickbox();
    6768
    6869add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' ), 'default' => 999) );
    6970