Make WordPress Core


Ignore:
Timestamp:
11/05/2008 05:07:45 PM (18 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/plugin-install.php

    r9521 r9523  
    745745        }
    746746
    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
     747        apply_filters('install_feedback', __('Installing the plugin'));
     748       
    748749        $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
    749750
    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 
    755         apply_filters('install_feedback', __('Installing the plugin'));
     751        //find base plugin directory
     752        $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'] ) )
     757                        return new WP_Error('mkdir_failed', __('Could not create directory'), $res['to']);     
     758
    756759        // Copy new version of plugin into place.
    757         $result = copy_dir($working_dir, $plugins_dir);
     760        $result = copy_dir($res['from'], $res['to']);
    758761        if ( is_wp_error($result) ) {
    759762                $wp_filesystem->delete($working_dir, true);
     
    761764        }
    762765
    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 
    766766        // Remove working directory
    767767        $wp_filesystem->delete($working_dir, true);
    768768
    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];
     769        $folder = trailingslashit(str_replace($plugins_dir, '', $res['to']));
    773770        $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
    774771        $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
    775772
    776773        //Return the plugin files name.
    777         return  $folder . '/' . $pluginfiles[0];
     774        return $folder . $pluginfiles[0];
    778775}
    779776
     
    840837        }
    841838
    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
     839        apply_filters('install_feedback', __('Installing the plugin'));
     840       
    843841        $filelist = array_keys( $wp_filesystem->dirlist($working_dir) );
    844842
    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 
    850         apply_filters('install_feedback', __('Installing the plugin'));
     843        //find base plugin directory
     844        $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'] ) )
     849                        return new WP_Error('mkdir_failed', __('Could not create directory'), $res['to']);     
     850
    851851        // Copy new version of plugin into place.
    852         $result = copy_dir($working_dir, $plugins_dir);
     852        $result = copy_dir($res['from'], $res['to']);
    853853        if ( is_wp_error($result) ) {
    854854                $wp_filesystem->delete($working_dir, true);
     
    856856        }
    857857
    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 
    861858        // Remove working directory
    862859        $wp_filesystem->delete($working_dir, true);
    863860
    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];
     861        $folder = trailingslashit(str_replace($plugins_dir, '', $res['to']));
    868862        $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash
    869863        $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
    870864
    871865        //Return the plugin files name.
    872         return  $folder . '/' . $pluginfiles[0];
     866        return $folder . $pluginfiles[0];
    873867}
    874868
Note: See TracChangeset for help on using the changeset viewer.