Make WordPress Core


Ignore:
Timestamp:
04/13/2009 04:11:02 PM (17 years ago)
Author:
ryan
Message:

WPFS cleanups. Props DD32. fixes #9525

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-filesystem-base.php

    r10150 r10919  
    4747         */
    4848        function abspath() {
    49                 if ( defined('FTP_BASE') && strpos($this->method, 'ftp') !== false )
    50                         return FTP_BASE;
    5149                $folder = $this->find_folder(ABSPATH);
    5250                //Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
     
    6361         */
    6462        function wp_content_dir() {
    65                 if ( defined('FTP_CONTENT_DIR') && strpos($this->method, 'ftp') !== false )
    66                         return FTP_CONTENT_DIR;
    6763                return $this->find_folder(WP_CONTENT_DIR);
    6864        }
     
    7672         */
    7773        function wp_plugins_dir() {
    78                 if ( defined('FTP_PLUGIN_DIR') && strpos($this->method, 'ftp') !== false )
    79                         return FTP_PLUGIN_DIR;
    8074                return $this->find_folder(WP_PLUGIN_DIR);
    8175        }
     
    143137        function find_folder($folder) {
    144138
     139                if ( strpos($this->method, 'ftp') !== false ) {
     140                        $constant_overrides = array( 'FTP_BASE' => ABSPATH, 'FTP_CONTENT_DIR' => WP_CONTENT_DIR, 'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR );
     141                        foreach ( $constant_overrides as $constant => $dir )
     142                                if ( defined($constant) && $folder === $dir )
     143                                        return trailingslashit(constant($constant));
     144                } elseif ( 'direct' == $this->method ) {
     145                        return trailingslashit($folder);
     146                }
     147
    145148                $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows driveletter if its there.
    146149                $folder = str_replace('\\', '/', $folder); //Windows path sanitiation
     
    150153
    151154                if ( $this->exists($folder) ) { //Folder exists at that absolute path.
     155                        $folder = trailingslashit($folder);
    152156                        $this->cache[ $folder ] = $folder;
    153157                        return $folder;
     
    190194                        // If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on.
    191195                        // If it reaches the end, and still cant find it, it'll return false for the entire function.
    192                         if( isset($files[ $key ]) ){
     196                        if ( isset($files[ $key ]) ){
    193197                                //Lets try that folder:
    194198                                $newdir = trailingslashit(path_join($base, $key));
    195                                 if( $this->verbose )
     199                                if ( $this->verbose )
    196200                                        printf( __('Changing to %s') . '<br/>', $newdir );
    197                                 if( $ret = $this->search_for_folder( $folder, $newdir, $loop) )
     201                                if ( $ret = $this->search_for_folder( $folder, $newdir, $loop) )
    198202                                        return $ret;
    199203                        }
     
    201205
    202206                //Only check this as a last resort, to prevent locating the incorrect install. All above proceeedures will fail quickly if this is the right branch to take.
    203                 if(isset( $files[ $last_path ] ) ) {
    204                         if( $this->verbose )
     207                if (isset( $files[ $last_path ] ) ) {
     208                        if ( $this->verbose )
    205209                                printf( __('Found %s') . '<br/>',  $base . $last_path );
    206                         return $base . $last_path;
     210                        return trailingslashit($base . $last_path);
    207211                }
    208                 if( $loop )
     212                if ( $loop )
    209213                        return false;//Prevent tihs function looping again.
    210214                //As an extra last resort, Change back to / if the folder wasnt found. This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... mainly dedicated setups.
Note: See TracChangeset for help on using the changeset viewer.