Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: upgrader_source_selection

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
191
192           //Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
193           if ( 1 == count($source_files) && $wp_filesystem->is_dir( trailingslashit($source) . $source_files[0] . '/') ) //Only one folder? Then we want its contents.
194                $source = trailingslashit($source) . trailingslashit($source_files[0]);
195           elseif ( count($source_files) == 0 )
196                return new WP_Error('bad_package', $this->strings['bad_package']); //There are no files?
197           //else //Its only a single file, The upgrader will use the foldername of this file as the destination folder. foldername is based on zip filename.
198
199           //Hook ability to change the source file location..
200           $source = apply_filters('upgrader_source_selection', $source, $remote_source, $this);
201           if ( is_wp_error($source) )
202                return $source;
203
204           //Has the source location changed? If so, we need a new source_files list.
205           if ( $source !== $remote_source )
206                $source_files = array_keys( $wp_filesystem->dirlist($source) );
207
208           //Protection against deleting files in any important base directories.
209           if ( in_array( $destination, array(ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes') ) ) {