Changeset 25082
- Timestamp:
- 08/22/2013 04:49:06 AM (11 years ago)
- Location:
- trunk/src/wp-admin/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-filesystem-base.php
r25057 r25082 80 80 * @access public 81 81 * 82 * @return string The location of the remote path. 83 */ 84 function wp_themes_dir() { 85 return $this->wp_content_dir() . 'themes/'; 82 * @param string $theme The Theme stylesheet or template for the directory 83 * @return string The location of the remote path. 84 */ 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 /** -
trunk/src/wp-admin/includes/class-wp-upgrader.php
r25048 r25082 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; … … 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, … … 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)); … … 728 731 $parent_result = $this->run( array( 729 732 'package' => $api->download_link, 730 'destination' => WP_CONTENT_DIR . '/themes',733 'destination' => get_theme_root(), 731 734 'clear_destination' => false, //Do not overwrite files. 732 735 'clear_working' => true … … 761 764 762 765 $options = array( 763 764 'destination' => WP_CONTENT_DIR . '/themes',765 766 767 766 'package' => $package, 767 'destination' => get_theme_root(), 768 'clear_destination' => false, //Do not overwrite files. 769 'clear_working' => true 770 ); 768 771 769 772 $this->run($options); … … 804 807 805 808 $options = array( 806 807 'destination' => WP_CONTENT_DIR . '/themes',808 809 810 811 812 )813 809 'package' => $r['package'], 810 'destination' => get_theme_root( $theme ), 811 'clear_destination' => true, 812 'clear_working' => true, 813 'hook_extra' => array( 814 'theme' => $theme 815 ), 816 ); 814 817 815 818 $this->run($options); … … 884 887 885 888 $options = array( 886 887 'destination' => WP_CONTENT_DIR . '/themes',888 889 890 891 892 )893 889 'package' => $r['package'], 890 'destination' => get_theme_root( $theme ), 891 'clear_destination' => true, 892 'clear_working' => true, 893 'hook_extra' => array( 894 'theme' => $theme 895 ), 896 ); 894 897 895 898 $result = $this->run($options); … … 985 988 } 986 989 987 function delete_old_theme( $removed, $local_destination, $remote_destination, $theme) {990 function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) { 988 991 global $wp_filesystem; 989 992 990 $theme = isset($theme['theme']) ? $theme['theme'] : ''; 991 992 if ( is_wp_error($removed) || empty($theme) ) 993 return $removed; //Pass errors through. 994 995 $themes_dir = $wp_filesystem->wp_themes_dir(); 996 if ( $wp_filesystem->exists( trailingslashit($themes_dir) . $theme ) ) 997 if ( ! $wp_filesystem->delete( trailingslashit($themes_dir) . $theme, true ) ) 993 if ( is_wp_error( $removed ) ) 994 return $removed; // Pass errors through. 995 996 if ( ! isset( $theme['theme'] ) ) 997 return $removed; 998 999 $theme = $theme['theme']; 1000 $themes_dir = trailingslashit( $wp_filesystem->wp_themes_dir( $theme ) ); 1001 if ( $wp_filesystem->exists( $themes_dir . $theme ) ) { 1002 if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) ) 998 1003 return false; 1004 } 1005 999 1006 return true; 1000 1007 } … … 1008 1015 return false; 1009 1016 } 1010 return wp_get_theme( $theme , WP_CONTENT_DIR . '/themes/');1017 return wp_get_theme( $theme ); 1011 1018 } 1012 1019
Note: See TracChangeset
for help on using the changeset viewer.