Changeset 17576 for trunk/wp-admin/includes/file.php
- Timestamp:
- 03/31/2011 01:28:36 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/file.php
r17555 r17576 717 717 * @param string $from source directory 718 718 * @param string $to destination directory 719 * @param array $skip_list a list of files/folders to skip copying 719 720 * @return mixed WP_Error on failure, True on success. 720 721 */ 721 function copy_dir($from, $to ) {722 function copy_dir($from, $to, $skip_list = array() ) { 722 723 global $wp_filesystem; 723 724 … … 727 728 $to = trailingslashit($to); 728 729 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 729 737 foreach ( (array) $dirlist as $filename => $fileinfo ) { 738 if ( !empty($skip_regex) ) 739 if ( preg_match($skip_regex, $from . $filename) ) 740 continue; 741 730 742 if ( 'f' == $fileinfo['type'] ) { 731 743 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { … … 740 752 return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename); 741 753 } 742 $result = copy_dir($from . $filename, $to . $filename );754 $result = copy_dir($from . $filename, $to . $filename, $skip_list); 743 755 if ( is_wp_error($result) ) 744 756 return $result;
Note: See TracChangeset
for help on using the changeset viewer.