Make WordPress Core


Ignore:
Timestamp:
03/31/2011 01:28:36 PM (14 years ago)
Author:
dd32
Message:

Be a party-pooper; No more Akismet Dancing upon upgrade; Respect custom WP_CONTENT_DIR for bundled plugins/theme installation; Respect custom WP_CONTENT_DIR/WP_LANG_DIR for Language files when upgrading; Standardise WP_Filesystem path method returns (They're trailing slash'd). Adds an exclusion list to copy_dir() as well as WP_Filesystem_Base::wp_lang_dir(). See #14484 See #11495

File:
1 edited

Legend:

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

    r17555 r17576  
    717717 * @param string $from source directory
    718718 * @param string $to destination directory
     719 * @param array $skip_list a list of files/folders to skip copying
    719720 * @return mixed WP_Error on failure, True on success.
    720721 */
    721 function copy_dir($from, $to) {
     722function copy_dir($from, $to, $skip_list = array() ) {
    722723    global $wp_filesystem;
    723724
     
    727728    $to = trailingslashit($to);
    728729
     730    $skip_regex = '';
     731    foreach ( (array)$skip_list as $key => $skip_file )
     732        $skip_regex .= preg_quote($skip_file, '!') . '|';
     733
     734    if ( !empty($skip_regex) )
     735        $skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';
     736
    729737    foreach ( (array) $dirlist as $filename => $fileinfo ) {
     738        if ( !empty($skip_regex) )
     739            if ( preg_match($skip_regex, $from . $filename) )
     740                continue;
     741
    730742        if ( 'f' == $fileinfo['type'] ) {
    731743            if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
     
    740752                    return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);
    741753            }
    742             $result = copy_dir($from . $filename, $to . $filename);
     754            $result = copy_dir($from . $filename, $to . $filename, $skip_list);
    743755            if ( is_wp_error($result) )
    744756                return $result;
Note: See TracChangeset for help on using the changeset viewer.