| 664 | /* translators: 1: theme name, 2: version */ |
| 665 | $this->strings['process_success_specific'] = __('Successfully installed the theme <strong>%1$s %2$s</strong>.'); |
| 666 | $this->strings['parent_theme_search'] = __('This theme requires a parent theme, Checking if <strong>%s</strong> is installed…'); |
| 667 | /* translators: 1: theme name, 2: version */ |
| 668 | $this->strings['parent_theme_prepare_install'] = __('Preparing to install <strong>%1$s %2$s</strong>…'); |
| 669 | /* translators: 1: theme name, 2: version */ |
| 670 | $this->strings['parent_theme_currently_installed'] = __('The Parent theme, <strong>%1$s %2$s</strong>, is currently installed.'); |
| 671 | /* translators: 1: theme name, 2: version */ |
| 672 | $this->strings['parent_theme_install_success'] = __('Successfully installed the parent theme <strong>%1$s %2$s</strong>.'); |
| 673 | $this->strings['parent_theme_not_found'] = __('<strong>The parent theme could not be found, You will need to install the parent theme %s before you can use this child theme.</strong>'); |
| 676 | function check_parent_theme_filter($install_result, $hook_extra, $child_result) { |
| 677 | // Check to see if we need to install a parent theme |
| 678 | $theme_info = $this->theme_info(); |
| 679 | $theme_info['Template'] = 'the-common-blog'; //@TODO: This is a DEBUG line |
| 680 | |
| 681 | // Do we have any business here? |
| 682 | if ( empty($theme_info['Template']) ) |
| 683 | return $install_result; |
| 684 | |
| 685 | $this->skin->feedback('parent_theme_search', $theme_info['Template'] ); |
| 686 | |
| 687 | foreach ( get_themes() as $this_theme ) { |
| 688 | if ( !empty($this_theme['Stylesheet']) && $this_theme['Stylesheet'] == $theme_info['Template'] ) { |
| 689 | $this->skin->feedback('parent_theme_currently_installed', $this_theme['Name'], $this_theme['Version'] ); |
| 690 | return $install_result; // Fall through, we already have the theme |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | // 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. |
| 696 | |
| 697 | if ( ! $api || is_wp_error($api) ) { |
| 698 | $this->skin->feedback('parent_theme_not_found', $theme_info['Template']); |
| 699 | // Don't show activate or preview actions after install |
| 700 | add_filter('install_theme_complete_actions', array(&$this, 'hide_activate_preview_actions') ); |
| 701 | return $install_result; |
| 702 | } |
| 703 | |
| 704 | // Backup required data we're going to override: |
| 705 | $child_api = $this->skin->api; |
| 706 | $child_success_message = $this->strings['process_success']; |
| 707 | |
| 708 | // Override them |
| 709 | $this->skin->api = $api; |
| 710 | $this->strings['process_success_specific'] = $this->strings['parent_theme_install_success'];//, $api->name, $api->version); |
| 711 | |
| 712 | $this->skin->feedback('parent_theme_prepare_install', $api->name, $api->version); |
| 713 | |
| 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 | |
| 717 | add_filter('install_theme_complete_actions', '__return_false', 999); // Don't show any actions after installing the theme. |
| 718 | |
| 719 | // Install the parent theme |
| 720 | $parent_result = $this->run( array( |
| 721 | 'package' => $api->download_link, |
| 722 | 'destination' => WP_CONTENT_DIR . '/themes', |
| 723 | 'clear_destination' => false, //Do not overwrite files. |
| 724 | 'clear_working' => true |
| 725 | ) |
| 726 | ); |
| 727 | |
| 728 | if ( is_wp_error($parent_result) ) { |
| 729 | add_filter('install_theme_complete_actions', array(&$this, 'hide_activate_preview_actions') ); |
| 730 | } |
| 731 | |
| 732 | // Start cleaning up after the parents installation |
| 733 | remove_filter('install_theme_complete_actions', '__return_false', 999); |
| 734 | |
| 735 | // Reset child's result and data |
| 736 | $this->result = $child_result; |
| 737 | $this->skin->api = $child_api; |
| 738 | $this->strings['process_success'] = $child_success_message; |
| 739 | |
| 740 | return $install_result; |
| 741 | } |
| 742 | |
| 743 | function hide_activate_preview_actions($actions) { |
| 744 | unset($actions['activate'], $actions['preview']); |
| 745 | return $actions; |
| 746 | } |
| 747 | |