Make WordPress Core


Ignore:
Timestamp:
11/05/2008 05:07:45 PM (16 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/update.php

    r9512 r9523  
    247247
    248248    apply_filters('update_feedback', __('Installing the latest version'));
     249
     250    $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
     251
     252    //find base plugin directory
     253    $res = update_pluginfiles_base_dir($working_dir . '/' . $filelist[0], $plugins_dir . $filelist[0]);
     254
     255    //Create folder if not exists.
     256    if( ! $wp_filesystem->exists( $res['to'] ) )
     257        if ( ! $wp_filesystem->mkdir( $res['to'] ) )
     258            return new WP_Error('mkdir_failed', __('Could not create directory'), $res['to']); 
     259
    249260    // Copy new version of plugin into place.
    250     $result = copy_dir($working_dir, $plugins_dir);
     261    $result = copy_dir($res['from'], $res['to']);
    251262    if ( is_wp_error($result) ) {
    252263        $wp_filesystem->delete($working_dir, true);
    253264        return $result;
    254265    }
    255 
    256     //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin
    257     $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
    258266
    259267    // Remove working directory
     
    263271    delete_option('update_plugins');
    264272
    265     if( empty($filelist) )
    266         return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup.
    267 
    268     $folder = $filelist[0];
     273    $folder = trailingslashit(str_replace($plugins_dir, '', $res['to']));
    269274    $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
    270275    $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
    271276
    272     return  $folder . '/' . $pluginfiles[0];
     277    //Return the plugin files name.
     278    return $folder . $pluginfiles[0];
    273279}
    274280
Note: See TracChangeset for help on using the changeset viewer.