Changeset 9664 for trunk/wp-admin/includes/plugin-install.php
- Timestamp:
- 11/13/2008 06:48:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/plugin-install.php
r9619 r9664 745 745 } 746 746 747 //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin 748 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); 749 750 if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) { 751 $wp_filesystem->delete($working_dir, true); 752 return new WP_Error('install_folder_exists', __('Folder allready exists.'), $filelist[0] ); 753 } 754 747 755 apply_filters('install_feedback', __('Installing the plugin')); 748 749 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );750 751 //find base plugin directory752 $res = update_pluginfiles_base_dir($working_dir . '/' . $filelist[0], $plugins_dir . $filelist[0]);753 754 //Create folder if not exists.755 if( ! $wp_filesystem->exists( $res['to'] ) )756 if ( ! $wp_filesystem->mkdir( $res['to'], 0755 ) )757 return new WP_Error('mkdir_failed', __('Could not create directory'), $res['to']);758 759 756 // Copy new version of plugin into place. 760 $result = copy_dir($ res['from'], $res['to']);757 $result = copy_dir($working_dir, $plugins_dir); 761 758 if ( is_wp_error($result) ) { 762 759 $wp_filesystem->delete($working_dir, true); … … 764 761 } 765 762 763 //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin 764 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); 765 766 766 // Remove working directory 767 767 $wp_filesystem->delete($working_dir, true); 768 768 769 $folder = trailingslashit(str_replace($plugins_dir, '', $res['to'])); 769 if( empty($filelist) ) 770 return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. 771 772 $folder = $filelist[0]; 770 773 $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash 771 774 $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list 772 775 773 776 //Return the plugin files name. 774 return $folder. $pluginfiles[0];777 return $folder . '/' . $pluginfiles[0]; 775 778 } 776 779 … … 837 840 } 838 841 842 //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin 843 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); 844 845 if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) { 846 $wp_filesystem->delete($working_dir, true); 847 return new WP_Error('install_folder_exists', __('Folder allready exists.'), $filelist[0] ); 848 } 849 839 850 apply_filters('install_feedback', __('Installing the plugin')); 840 841 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );842 843 //find base plugin directory844 $res = update_pluginfiles_base_dir($working_dir . '/' . $filelist[0], $plugins_dir . $filelist[0]);845 846 //Create folder if not exists.847 if( ! $wp_filesystem->exists( $res['to'] ) ) {848 if ( ! $wp_filesystem->mkdir( $res['to'], 0755 ) )849 return new WP_Error('mkdir_failed', __('Could not create directory'), $res['to']);850 }851 852 851 // Copy new version of plugin into place. 853 $result = copy_dir($ res['from'], $res['to']);852 $result = copy_dir($working_dir, $plugins_dir); 854 853 if ( is_wp_error($result) ) { 855 854 $wp_filesystem->delete($working_dir, true); … … 857 856 } 858 857 858 //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin 859 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); 860 859 861 // Remove working directory 860 862 $wp_filesystem->delete($working_dir, true); 861 863 862 $folder = trailingslashit(str_replace($plugins_dir, '', $res['to'])); 864 if( empty($filelist) ) 865 return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. 866 867 $folder = $filelist[0]; 863 868 $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash 864 869 $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list 865 870 866 871 //Return the plugin files name. 867 return $folder. $pluginfiles[0];872 return $folder . '/' . $pluginfiles[0]; 868 873 } 869 874
Note: See TracChangeset
for help on using the changeset viewer.