Support installation of plugins living in a subdir in svn. Props DD32. fixes #7395

git-svn-id: https://develop.svn.wordpress.org/trunk@9523 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-11-05 17:07:45 +00:00
parent ded4fe72b8
commit 742c91322a
3 changed files with 96 additions and 40 deletions
+25 -31
View File
@@ -744,37 +744,34 @@ function wp_install_plugin($package, $feedback = '') {
return $result;
}
//Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
apply_filters('install_feedback', __('Installing the plugin'));
$filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) {
$wp_filesystem->delete($working_dir, true);
return new WP_Error('install_folder_exists', __('Folder allready exists.'), $filelist[0] );
}
//find base plugin directory
$res = update_pluginfiles_base_dir($working_dir . '/' . $filelist[0], $plugins_dir . $filelist[0]);
//Create folder if not exists.
if( ! $wp_filesystem->exists( $res['to'] ) )
if ( ! $wp_filesystem->mkdir( $res['to'] ) )
return new WP_Error('mkdir_failed', __('Could not create directory'), $res['to']);
apply_filters('install_feedback', __('Installing the plugin'));
// Copy new version of plugin into place.
$result = copy_dir($working_dir, $plugins_dir);
$result = copy_dir($res['from'], $res['to']);
if ( is_wp_error($result) ) {
$wp_filesystem->delete($working_dir, true);
return $result;
}
//Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
$filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
// Remove working directory
$wp_filesystem->delete($working_dir, true);
if( empty($filelist) )
return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
$folder = $filelist[0];
$folder = trailingslashit(str_replace($plugins_dir, '', $res['to']));
$plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
$pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
//Return the plugin files name.
return $folder . '/' . $pluginfiles[0];
return $folder . $pluginfiles[0];
}
/**
@@ -839,37 +836,34 @@ function wp_install_plugin_local_package($package, $feedback = '') {
return $result;
}
//Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
apply_filters('install_feedback', __('Installing the plugin'));
$filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
if( $wp_filesystem->exists( $plugins_dir . $filelist[0] ) ) {
$wp_filesystem->delete($working_dir, true);
return new WP_Error('install_folder_exists', __('Folder allready exists.'), $filelist[0] );
}
//find base plugin directory
$res = update_pluginfiles_base_dir($working_dir . '/' . $filelist[0], $plugins_dir . $filelist[0]);
//Create folder if not exists.
if( ! $wp_filesystem->exists( $res['to'] ) )
if ( ! $wp_filesystem->mkdir( $res['to'] ) )
return new WP_Error('mkdir_failed', __('Could not create directory'), $res['to']);
apply_filters('install_feedback', __('Installing the plugin'));
// Copy new version of plugin into place.
$result = copy_dir($working_dir, $plugins_dir);
$result = copy_dir($res['from'], $res['to']);
if ( is_wp_error($result) ) {
$wp_filesystem->delete($working_dir, true);
return $result;
}
//Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
$filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
// Remove working directory
$wp_filesystem->delete($working_dir, true);
if( empty($filelist) )
return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
$folder = $filelist[0];
$folder = trailingslashit(str_replace($plugins_dir, '', $res['to']));
$plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
$pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
//Return the plugin files name.
return $folder . '/' . $pluginfiles[0];
return $folder . $pluginfiles[0];
}
?>
?>