Make WordPress Core

Changeset 20268


Ignore:
Timestamp:
03/23/2012 10:20:26 AM (14 years ago)
Author:
nacin
Message:

Leverage WP_Theme in the upgrader. Remove debug line from [20267]. Stop using get_theme_data() as it will be deprecated. see #13774. see #20103.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-upgrader.php

    r20267 r20268  
    679679                $theme_info = $this->theme_info();
    680680
    681                 // Do we have any business here?
    682                 if ( empty($theme_info['Template']) )
     681                if ( ! $theme_info->parent() )
    683682                        return $install_result;
    684683
    685                 $this->skin->feedback('parent_theme_search', $theme_info['Template'] );
    686 
    687                 $parent_theme = wp_get_theme( $theme_info['Template'] );
    688                 if ( ! $parent_theme->errors() ) {
    689                         $this->skin->feedback( 'parent_theme_currently_installed', $parent_theme['Name'], $parent_theme['Version'] );
     684                $this->skin->feedback( 'parent_theme_search' );
     685
     686                if ( ! $theme_info->parent()->errors() ) {
     687                        $this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display('Name'), $theme_info->parent()->display('Version') );
    690688                        // We already have the theme, fall through.
    691689                        return $install_result;
     
    693691
    694692                // We don't have the parent theme, lets install it
    695                 $api = themes_api('theme_information', array('slug' => $theme_info['Template'], 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
     693                $api = themes_api('theme_information', array('slug' => $theme_info->get('Template'), 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
    696694
    697695                if ( ! $api || is_wp_error($api) ) {
    698                         $this->skin->feedback('parent_theme_not_found', $theme_info['Template']);
     696                        $this->skin->feedback( 'parent_theme_not_found', $theme_info->get('Template') );
    699697                        // Don't show activate or preview actions after install
    700698                        add_filter('install_theme_complete_actions', array(&$this, 'hide_activate_preview_actions') );
     
    712710                $this->skin->feedback('parent_theme_prepare_install', $api->name, $api->version);
    713711               
    714                 //@TODO: This is a DEBUG line! Only needed with the-common-blog line above.
    715                 remove_filter('upgrader_post_install', array(&$this, 'check_parent_theme_filter'), 10, 3); // This is only needed when we're forcing a template on line 676 above.
    716 
    717712                add_filter('install_theme_complete_actions', '__return_false', 999); // Don't show any actions after installing the theme.
    718713
     
    917912                        return $source;
    918913
    919                 if ( ! file_exists( $working_directory . 'style.css' ) ) // A proper archive should have a style.css file in the single subdirectory
     914                // A proper archive should have a style.css file in the single subdirectory
     915                if ( ! file_exists( $working_directory . 'style.css' ) )
    920916                        return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __('The theme is missing the <code>style.css</code> stylesheet.') );
    921917
    922                 $info = get_theme_data( $working_directory . 'style.css' );
    923                 if ( empty($info['Name']) )
     918                $info = get_file_data( $working_directory . 'style.css', array( 'Name' => 'Theme Name', 'Template' => 'Template' ) );
     919
     920                if ( empty( $info['Name'] ) )
    924921                        return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __("The <code>style.css</code> stylesheet doesn't contain a valid theme header.") );
    925922
    926                 if ( empty($info['Template']) && ! file_exists( $working_directory . 'index.php' ) ) // If no template is set, it must have at least an index.php to be legit.
     923                // If it's not a child theme, it must have at least an index.php to be legit.
     924                if ( empty( $info['Template'] ) && ! file_exists( $working_directory . 'index.php' ) )
    927925                        return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __('The theme is missing the <code>index.php</code> file.') );
    928926
     
    952950                $theme = isset($theme['theme']) ? $theme['theme'] : '';
    953951
    954                 if ( $theme != get_stylesheet() ) //If not current
     952                if ( $theme != get_stylesheet() ) // If not current
    955953                        return $return;
    956954
    957                 //Ensure stylesheet name hasnt changed after the upgrade:
     955                // Ensure stylesheet name hasnt changed after the upgrade:
    958956                // @TODO: Note, This doesn't handle the Template changing, or the Template name changing.
    959957                if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
    960958                        $theme_info = $this->theme_info();
    961959                        $stylesheet = $this->result['destination_name'];
    962                         $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;
     960                        $template = $theme_info->get_template();
    963961                        switch_theme($template, $stylesheet, true);
    964962                }
     
    993991                                return false;
    994992                }
    995                 return get_theme_data(WP_CONTENT_DIR . '/themes/' . $theme . '/style.css');
     993                return wp_get_theme( $theme, WP_CONTENT_DIR . '/themes/' );
    996994        }
    997995
     
    13721370
    13731371        function before() {
    1374                 parent::before($this->theme_info['Name']);
     1372                parent::before( $this->theme_info->display('Name') );
    13751373        }
    13761374
    13771375        function after() {
    1378                 parent::after($this->theme_info['Name']);
    1379         }
     1376                parent::after( $this->theme_info->display('Name') );
     1377        }
     1378
    13801379        function bulk_footer() {
    13811380                parent::bulk_footer();
     
    13851384                );
    13861385
    1387                 $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info);
     1386                $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
    13881387                if ( ! empty($update_actions) )
    13891388                        $this->feedback(implode(' | ', (array)$update_actions));
     
    14891488                if ( empty($theme_info) )
    14901489                        return;
    1491                 $name = $theme_info['Name'];
     1490                $name = $theme_info->display('Name');
    14921491                $stylesheet = $this->upgrader->result['destination_name'];
    1493                 $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;
     1492                $template = $theme_info->get_template();
    14941493
    14951494                $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => 1, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) );
     
    15421541
    15431542                $update_actions = array();
    1544                 if ( !empty($this->upgrader->result['destination_name']) &&
    1545                         ($theme_info = $this->upgrader->theme_info()) &&
    1546                         !empty($theme_info) ) {
    1547 
    1548                         $name = $theme_info['Name'];
     1543                if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
     1544                        $name = $theme_info->display('Name');
    15491545                        $stylesheet = $this->upgrader->result['destination_name'];
    1550                         $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;
     1546                        $template = $theme_info->get_template();
    15511547
    15521548                        $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) );
Note: See TracChangeset for help on using the changeset viewer.