Ticket #22501: 22501.diff
File 22501.diff, 6.0 KB (added by , 12 years ago) |
---|
-
src/wp-admin/includes/class-wp-filesystem-base.php
79 79 * @since 2.7 80 80 * @access public 81 81 * 82 * @param string $theme The Theme stylesheet or template for the directory 82 83 * @return string The location of the remote path. 83 84 */ 84 function wp_themes_dir() { 85 return $this->wp_content_dir() . 'themes/'; 85 function wp_themes_dir( $theme = false ) { 86 $theme_root = get_theme_root( $theme ); 87 88 // Account for relative theme roots 89 if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) 90 $theme_root = WP_CONTENT_DIR . $theme_root; 91 92 return $this->find_folder( $theme_root ); 86 93 } 87 94 /** 88 95 * Returns the path on the remote filesystem of WP_LANG_DIR -
src/wp-admin/includes/class-wp-upgrader.php
93 93 if ( ! $wp_filesystem->wp_plugins_dir() ) 94 94 return new WP_Error('fs_no_plugins_dir', $this->strings['fs_no_plugins_dir']); 95 95 break; 96 case WP_CONTENT_DIR . '/themes':97 if ( ! $wp_filesystem-> find_folder(WP_CONTENT_DIR . '/themes') )96 case get_theme_root(): 97 if ( ! $wp_filesystem->wp_themes_dir() ) 98 98 return new WP_Error('fs_no_themes_dir', $this->strings['fs_no_themes_dir']); 99 99 break; 100 100 default: … … 164 164 } 165 165 166 166 function install_package($args = array()) { 167 global $wp_filesystem; 167 global $wp_filesystem, $wp_theme_directories; 168 168 169 $defaults = array( 'source' => '', 'destination' => '', //Please always pass these 169 170 'clear_destination' => false, 'clear_working' => false, 170 171 'abort_if_destination_exists' => true, … … 208 209 if ( $source !== $remote_source ) 209 210 $source_files = array_keys( $wp_filesystem->dirlist($source) ); 210 211 211 //Protection against deleting files in any important base directories. 212 if ( in_array( $destination, array(ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes') ) ) { 212 // Protection against deleting files in any important base directories. 213 // Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the destination directory (WP_PLUGIN_DIR / wp-content/themes) 214 // intending to copy the directory into the directory, whilst they pass the source as the actual files to copy. 215 if ( in_array( $destination, array_merge( array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' ), $wp_theme_directories ) ) ) { 213 216 $remote_destination = trailingslashit($remote_destination) . trailingslashit(basename($source)); 214 217 $destination = trailingslashit($destination) . trailingslashit(basename($source)); 215 218 } … … 724 727 // Install the parent theme 725 728 $parent_result = $this->run( array( 726 729 'package' => $api->download_link, 727 'destination' => WP_CONTENT_DIR . '/themes',730 'destination' => get_theme_root(), 728 731 'clear_destination' => false, //Do not overwrite files. 729 732 'clear_working' => true 730 733 ) ); … … 757 760 add_filter('upgrader_post_install', array(&$this, 'check_parent_theme_filter'), 10, 3); 758 761 759 762 $options = array( 760 761 'destination' => WP_CONTENT_DIR . '/themes',762 763 764 763 'package' => $package, 764 'destination' => get_theme_root(), 765 'clear_destination' => false, //Do not overwrite files. 766 'clear_working' => true 767 ); 765 768 766 769 $this->run($options); 767 770 … … 800 803 add_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4); 801 804 802 805 $options = array( 803 804 'destination' => WP_CONTENT_DIR . '/themes',805 806 807 808 809 )810 806 'package' => $r['package'], 807 'destination' => get_theme_root( $theme ), 808 'clear_destination' => true, 809 'clear_working' => true, 810 'hook_extra' => array( 811 'theme' => $theme 812 ), 813 ); 811 814 812 815 $this->run($options); 813 816 … … 877 880 $r = $current->response[ $theme ]; 878 881 879 882 $options = array( 880 881 'destination' => WP_CONTENT_DIR . '/themes',882 883 884 885 886 )887 883 'package' => $r['package'], 884 'destination' => get_theme_root( $theme ), 885 'clear_destination' => true, 886 'clear_working' => true, 887 'hook_extra' => array( 888 'theme' => $theme 889 ), 890 ); 888 891 889 892 $result = $this->run($options); 890 893 … … 978 981 return $return; 979 982 } 980 983 981 function delete_old_theme( $removed, $local_destination, $remote_destination, $theme) {984 function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) { 982 985 global $wp_filesystem; 983 986 984 $theme = isset($theme['theme']) ? $theme['theme'] : ''; 987 if ( is_wp_error( $removed ) ) 988 return $removed; // Pass errors through. 985 989 986 if ( is_wp_error($removed) || empty($theme) )987 return $removed; //Pass errors through.990 if ( ! isset( $theme['theme'] ) ) 991 return $removed; 988 992 989 $themes_dir = $wp_filesystem->wp_themes_dir(); 990 if ( $wp_filesystem->exists( trailingslashit($themes_dir) . $theme ) ) 991 if ( ! $wp_filesystem->delete( trailingslashit($themes_dir) . $theme, true ) ) 993 $theme = $theme['theme']; 994 $themes_dir = trailingslashit( $wp_filesystem->wp_themes_dir( $theme ) ); 995 if ( $wp_filesystem->exists( $themes_dir . $theme ) ) { 996 if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) ) 992 997 return false; 998 } 999 993 1000 return true; 994 1001 } 995 1002 … … 1001 1008 else 1002 1009 return false; 1003 1010 } 1004 return wp_get_theme( $theme , WP_CONTENT_DIR . '/themes/');1011 return wp_get_theme( $theme ); 1005 1012 } 1006 1013 1007 1014 }