Ticket #13774: 13774.2.diff
File 13774.2.diff, 5.1 KB (added by , 9 years ago) |
---|
-
wp-admin/includes/class-wp-upgrader.php
661 661 $this->strings['installing_package'] = __('Installing the theme…'); 662 662 $this->strings['process_failed'] = __('Theme install failed.'); 663 663 $this->strings['process_success'] = __('Theme installed successfully.'); 664 $this->strings['parent_theme_required'] = __('Preparing to install the parent theme <strong>%s</strong>…'); 664 665 } 665 666 667 function check_parent_theme_filter($res, $hook_extra, $child_result) { 668 // Check to see if we need to install a 669 $theme_info = $this->theme_info(); 670 $theme_info['Template'] = 'the-common-blog'; 671 if ( !empty($theme_info['Template']) ) { 672 673 $themes = get_themes(); 674 if ( isset($themes[ $theme_info['Template'] ]) ) 675 return $res; // Fall through, we already have the theme 676 677 foreach ( (array)$themes as $this_theme ) { 678 if ( !empty($this_theme['Stylesheet']) && $this_theme['Stylesheet'] == $theme_info['Template'] ) 679 return $res; // Fall through, we already have the theme 680 } 681 682 // We don't have the parent theme, lets install it 683 // First, We'll need to take over the information the skin is displaying.. 684 $child_api = $this->skin->api; 685 $child_success_message = $this->strings['process_success']; 686 687 $api = themes_api('theme_information', array('slug' => $theme_info['Template'], 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth. 688 $this->skin->api = $api; 689 /* translators: 1: theme name, 2: version */ 690 $this->strings['process_success'] = sprintf( __('Successfully installed the parent theme <strong>%1$s %2$s</strong>.'), $api->name, $api->version); 691 692 // Override the 693 $this->skin->feedback('parent_theme_required', $api->name . ' ' . $api->version); 694 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 670 above. 695 add_filter('install_theme_complete_actions', '__return_false'); // Don't show any actions after installing the theme. 696 697 // Install the parent theme 698 $this->run( array( 699 'package' => $api->download_link, 700 'destination' => WP_CONTENT_DIR . '/themes', 701 'clear_destination' => false, //Do not overwrite files. 702 'clear_working' => true 703 ) 704 ); 705 706 //Add error handling here for the parent installation failure. 707 $parent_result = $this->result; 708 709 // Start cleaning up after the parents installation 710 remove_filter('install_theme_complete_actions', '__return_false'); 711 712 // Reset child's result and data 713 $this->result = $child_result; 714 $this->skin->api = $child_api; 715 // $this->skin->set_result($this->result); 716 $this->strings['process_success'] = $child_success_message; 717 } 718 return $res; 719 } 720 666 721 function install($package) { 667 722 668 723 $this->init(); 669 724 $this->install_strings(); 670 725 671 726 add_filter('upgrader_source_selection', array(&$this, 'check_package') ); 727 add_filter('upgrader_post_install', array(&$this, 'check_parent_theme_filter'), 10, 3); 672 728 673 729 $options = array( 674 730 'package' => $package, … … 680 736 $this->run($options); 681 737 682 738 remove_filter('upgrader_source_selection', array(&$this, 'check_package') ); 739 remove_filter('upgrader_post_install', array(&$this, 'check_parent_theme_filter'), 10, 3); 683 740 684 741 if ( ! $this->result || is_wp_error($this->result) ) 685 742 return $this->result; … … 1419 1476 $install_actions = array( 1420 1477 'preview' => '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview “%s”'), $name)) . '">' . __('Preview') . '</a>', 1421 1478 'activate' => '<a href="' . $activate_link . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>' 1422 1479 ); 1423 1480 1424 1481 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) 1425 1482 $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . $template, 'enable-theme_' . $template ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; … … 1562 1619 1563 1620 return true; 1564 1621 } 1565 } 1622 } 1623 No newline at end of file -
wp-admin/update.php
199 199 include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api.. 200 200 201 201 check_admin_referer('install-theme_' . $theme); 202 $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false ) ) ); //Save on a bit of bandwidth.202 $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth. 203 203 204 204 if ( is_wp_error($api) ) 205 205 wp_die($api);