Make WordPress Core

Ticket #13774: 13774.diff

File 13774.diff, 3.4 KB (added by Otto42, 13 years ago)

First stab at a patch for this

  • includes/class-wp-upgrader.php

     
    13131313                parent::__construct($args);
    13141314        }
    13151315
     1316        function header() {
     1317                if ( $this->done_header )
     1318                        return;
     1319                $this->done_header = true;
     1320                echo '<div class="wrap">';
     1321                if ( !isset( $this->api->template ) ) echo screen_icon();
     1322                echo '<h2>' . $this->options['title'] . '</h2>';
     1323        }
     1324       
    13161325        function before() {
    13171326                if ( !empty($this->api) ) {
    13181327                        /* translators: 1: theme name, 2: version */
     
    13371346                $install_actions = array(
    13381347                        'preview' => '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name)) . '">' . __('Preview') . '</a>',
    13391348                        'activate' => '<a href="' . $activate_link .  '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>'
    1340                                                         );
    1341 
     1349                        );
     1350                       
    13421351                if ( $this->type == 'web' )
    13431352                        $install_actions['themes_page'] = '<a href="' . self_admin_url('theme-install.php') . '" title="' . esc_attr__('Return to Theme Installer') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
    13441353                else
     
    13461355
    13471356                if ( ! $this->result || is_wp_error($this->result) || is_network_admin() )
    13481357                        unset( $install_actions['activate'], $install_actions['preview'] );
     1358                       
     1359                if ( isset($this->api->child) )
     1360                        unset( $install_actions['activate'], $install_actions['preview'], $install_actions['themes_page'] );
    13491361
    13501362                $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
    13511363                if ( ! empty($install_actions) )
  • update.php

     
    208208                $submenu_file = 'themes.php';
    209209                require_once(ABSPATH . 'wp-admin/admin-header.php');
    210210
     211                if (isset($api->template) && !empty($api->template)) {
     212
     213                        // look for the parent theme in the existing themes             
     214                        $found = false;
     215                        $themes = get_themes();
     216                        if ( ! $themes[$api->template] ) {
     217                                foreach ( $themes as $this_theme ) {
     218                                        if ( is_array($this_theme) && $this_theme['Stylesheet'] == $api->template ) {
     219                                                $found = true;
     220                                                break;
     221                                        }
     222                                }
     223                        }
     224
     225                        // if we didn't find it, install it first                       
     226                        if (!$found) {         
     227                                $child_api = $api;
     228                                $api = themes_api('theme_information', array('slug' => $api->template, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
     229                                $api->child = $theme; // set the flag showing the installer that this is a parent theme install
     230
     231                                $title = sprintf( __('Installing Parent Theme: %s'), $api->name . ' ' . $api->version );
     232                                $nonce = 'install-theme_' . $api->template;
     233                                $url = 'update.php?action=install-theme&theme=' . $api->template;
     234                                $type = 'web'; //Install theme type, From Web or an Upload.
     235
     236                                $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
     237                                $upgrader->install($api->download_link);
     238
     239                                $api=$child_api;
     240                        }
     241                }
     242
    211243                $title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version );
    212244                $nonce = 'install-theme_' . $theme;
    213245                $url = 'update.php?action=install-theme&theme=' . $theme;