Make WordPress Core

Ticket #6938: allow-wp-content-directory-outside-of-webroot-2.patch

File allow-wp-content-directory-outside-of-webroot-2.patch, 35.7 KB (added by sambauers, 17 years ago)
  • wp-includes/plugin.php

     
    434434/**
    435435 * plugin_basename() - Gets the basename of a plugin.
    436436 *
    437  * This method extract the name of a plugin from its filename.
     437 * This method extracts the name of a plugin from its filename.
    438438 *
    439439 * @package WordPress
    440440 * @subpackage Plugin
     
    444444 *
    445445 * @param string $file The filename of plugin.
    446446 * @return string The name of a plugin.
     447 * @uses WP_PLUGIN_DIR
    447448 */
    448449function plugin_basename($file) {
    449450        $file = str_replace('\\','/',$file); // sanitize for Win32 installs
    450451        $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
    451         $file = preg_replace('|^.*/' . PLUGINDIR . '/|','',$file); // get relative path from plugins dir
     452        $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
     453        $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
     454        $file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir
    452455        return $file;
    453456}
    454457
  • wp-includes/js/tinymce/tiny_mce_config.php

     
    206206}
    207207
    208208// Cache path, this is where the .gz files will be stored
    209 $cache_path = ABSPATH . 'wp-content/uploads/js_cache';
     209$cache_path = WP_CONTENT_DIR . '/uploads/js_cache';
    210210if ( $disk_cache && ! is_dir($cache_path) )
    211211        $disk_cache = wp_mkdir_p($cache_path);
    212212
  • wp-includes/theme.php

     
    333333}
    334334
    335335function get_theme_root() {
    336         return apply_filters('theme_root', ABSPATH . "wp-content/themes");
     336        return apply_filters('theme_root', WP_CONTENT_DIR . "/themes");
    337337}
    338338
    339339function get_theme_root_uri() {
    340         return apply_filters('theme_root_uri', get_option('siteurl') . "/wp-content/themes", get_option('siteurl'));
     340        return apply_filters('theme_root_uri', WP_CONTENT_URL . "/themes", get_option('siteurl'));
    341341}
    342342
    343343function get_query_template($type) {
  • wp-includes/functions.php

     
    10801080        $siteurl = get_option( 'siteurl' );
    10811081        $upload_path = get_option( 'upload_path' );
    10821082        if ( trim($upload_path) === '' )
    1083                 $upload_path = 'wp-content/uploads';
     1083                $upload_path = WP_CONTENT_DIR . '/uploads';
    10841084        $dir = $upload_path;
    10851085
    10861086        // $dir is absolute, $path is (maybe) relative to ABSPATH
     
    15581558 */
    15591559function require_wp_db() {
    15601560        global $wpdb;
    1561         if ( file_exists( ABSPATH . 'wp-content/db.php' ) )
    1562                 require_once( ABSPATH . 'wp-content/db.php' );
     1561        if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
     1562                require_once( WP_CONTENT_DIR . '/db.php' );
    15631563        else
    15641564                require_once( ABSPATH . WPINC . '/wp-db.php' );
    15651565}
     
    15681568        global $wpdb;
    15691569
    15701570        // Load custom DB error template, if present.
    1571         if ( file_exists( ABSPATH . 'wp-content/db-error.php' ) ) {
    1572                 require_once( ABSPATH . 'wp-content/db-error.php' );
     1571        if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
     1572                require_once( WP_CONTENT_DIR . '/db-error.php' );
    15731573                die();
    15741574        }
    15751575
  • wp-includes/l10n.php

     
    278278 *
    279279 * The plugin may place all of the .mo files in another folder and set
    280280 * the $path based on the relative location from ABSPATH constant. The
    281  * plugin may use the constant PLUGINDIR and/or plugin_basename() to
     281 * plugin may use the constant WP_PLUGIN_DIR and/or plugin_basename() to
    282282 * get path of the plugin and then add the folder which holds the .mo
    283283 * files.
    284284 *
     
    291291        $locale = get_locale();
    292292
    293293        if ( false === $path )
    294                 $path = PLUGINDIR;
     294                $path = WP_PLUGIN_DIR;
    295295
    296         $mofile = ABSPATH . "$path/$domain-$locale.mo";
     296        $mofile = $path . '/'. $domain . '-' . $locale . '.mo';
    297297        load_textdomain($domain, $mofile);
    298298}
    299299
  • wp-includes/comment-template.php

     
    665665        if ( file_exists( $include ) )
    666666                require( $include );
    667667        else
    668                 require( ABSPATH . 'wp-content/themes/default/comments.php');
     668                require( WP_CONTENT_DIR . '/themes/default/comments.php');
    669669}
    670670
    671671/**
  • wp-includes/general-template.php

     
    77        if ( file_exists( TEMPLATEPATH . '/header.php') )
    88                load_template( TEMPLATEPATH . '/header.php');
    99        else
    10                 load_template( ABSPATH . 'wp-content/themes/default/header.php');
     10                load_template( WP_CONTENT_DIR . '/themes/default/header.php');
    1111}
    1212
    1313
     
    1616        if ( file_exists( TEMPLATEPATH . '/footer.php') )
    1717                load_template( TEMPLATEPATH . '/footer.php');
    1818        else
    19                 load_template( ABSPATH . 'wp-content/themes/default/footer.php');
     19                load_template( WP_CONTENT_DIR . '/themes/default/footer.php');
    2020}
    2121
    2222
     
    2727        elseif ( file_exists( TEMPLATEPATH . '/sidebar.php') )
    2828                load_template( TEMPLATEPATH . '/sidebar.php');
    2929        else
    30                 load_template( ABSPATH . 'wp-content/themes/default/sidebar.php');
     30                load_template( WP_CONTENT_DIR . '/themes/default/sidebar.php');
    3131}
    3232
    3333
  • wp-includes/rss.php

     
    651651}
    652652
    653653class RSSCache {
    654         var $BASE_CACHE = 'wp-content/cache';   // where the cache files are stored
     654        var $BASE_CACHE;        // where the cache files are stored
    655655        var $MAX_AGE    = 43200;                // when are files stale, default twelve hours
    656656        var $ERROR              = '';                   // accumulate error messages
    657657
    658658        function RSSCache ($base='', $age='') {
     659                $this->BASE_CACHE = WP_CONTENT_DIR . '/cache';
    659660                if ( $base ) {
    660661                        $this->BASE_CACHE = $base;
    661662                }
  • wp-settings.php

     
    100100        die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.3.' );
    101101}
    102102
    103 if ( !extension_loaded('mysql') && !file_exists(ABSPATH . 'wp-content/db.php') )
     103if ( !defined('WP_CONTENT_DIR') )
     104        define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
     105
     106if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') )
    104107        die( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' );
    105108
    106109/**
     
    166169
    167170// For an advanced caching plugin to use, static because you would only want one
    168171if ( defined('WP_CACHE') )
    169         @include ABSPATH . 'wp-content/advanced-cache.php';
     172        @include WP_CONTENT_DIR . '/advanced-cache.php';
    170173
    171174/**
    172175 * Stores the location of the WordPress directory of functions, classes, and core content.
     
    175178 */
    176179define('WPINC', 'wp-includes');
    177180
    178 if ( !defined('LANGDIR') ) {
     181if ( !defined('WP_LANG_DIR') ) {
    179182        /**
    180          * Stores the location of the language directory. First looks for language folder in wp-content
     183         * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR
    181184         * and uses that folder if it exists. Or it uses the "languages" folder in WPINC.
    182185         *
    183186         * @since 2.1.0
    184187         */
    185         if ( file_exists(ABSPATH . 'wp-content/languages') && @is_dir(ABSPATH . 'wp-content/languages') )
    186                 define('LANGDIR', 'wp-content/languages'); // no leading slash, no trailing slash
    187         else
    188                 define('LANGDIR', WPINC . '/languages'); // no leading slash, no trailing slash
     188        if ( file_exists(WP_CONTENT_DIR . '/languages') && @is_dir(WP_CONTENT_DIR . '/languages') ) {
     189                define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
     190                if (!defined('LANGDIR')) {
     191                        // Old static relative path maintained for limited backwards compatibility - won't work in some cases
     192                        define('LANGDIR', 'wp-content/languages');
     193                }
     194        } else {
     195                define('WP_LANG_DIR', ABSPATH . WPINC . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
     196                if (!defined('LANGDIR')) {
     197                        // Old relative path maintained for backwards compatibility
     198                        define('LANGDIR', WPINC . '/languages');
     199                }
     200        }
    189201}
    190202
    191 /**
    192  * Allows for the plugins directory to be moved from the default location.
    193  *
    194  * This isn't used everywhere. Constant is not used in plugin_basename()
    195  * which might cause conflicts with changing this.
    196  *
    197  * @since 2.1
    198  */
    199 if ( !defined('PLUGINDIR') )
    200         define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash
    201 
    202203require (ABSPATH . WPINC . '/compat.php');
    203204require (ABSPATH . WPINC . '/functions.php');
    204205require (ABSPATH . WPINC . '/classes.php');
     
    213214if ( is_wp_error($prefix) )
    214215        wp_die('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.');
    215216
    216 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
    217         require_once (ABSPATH . 'wp-content/object-cache.php');
     217if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') )
     218        require_once (WP_CONTENT_DIR . '/object-cache.php');
    218219else
    219220        require_once (ABSPATH . WPINC . '/cache.php');
    220221
     
    272273require (ABSPATH . WPINC . '/shortcodes.php');
    273274require (ABSPATH . WPINC . '/media.php');
    274275
     276if ( !defined('WP_CONTENT_URL') )
     277        define( 'WP_CONTENT_URL', get_option('home') . 'wp-content'); // full url - WP_CONTENT_DIR is defined further up
     278
     279/**
     280 * Allows for the plugins directory to be moved from the default location.
     281 *
     282 * @since 2.6
     283 */
     284if ( !defined('WP_PLUGIN_DIR') )
     285        define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
     286if ( !defined('WP_PLUGIN_URL') )
     287        define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
     288if ( !defined('PLUGINDIR') )
     289        define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH.  For back compat.
     290
    275291if ( ! defined('WP_INSTALLING') ) {
    276292        // Used to guarantee unique hash cookies
    277293        $cookiehash = md5(get_option('siteurl'));
     
    357373        $current_plugins = get_option('active_plugins');
    358374        if ( is_array($current_plugins) ) {
    359375                foreach ($current_plugins as $plugin) {
    360                         if ('' != $plugin && file_exists(ABSPATH . PLUGINDIR . '/' . $plugin))
    361                                 include_once(ABSPATH . PLUGINDIR . '/' . $plugin);
     376                        if ('' != $plugin && file_exists(WP_PLUGIN_DIR . '/' . $plugin))
     377                                include_once(WP_PLUGIN_DIR . '/' . $plugin);
    362378                }
    363379        }
    364380}
     
    451467 * @since 1.5.0
    452468 */
    453469$locale = get_locale();
    454 $locale_file = ABSPATH . LANGDIR . "/$locale.php";
     470$locale_file = WP_LANG_DIR . "/$locale.php";
    455471if ( is_readable($locale_file) )
    456472        require_once($locale_file);
    457473
  • wp-admin/menu-header.php

     
    1919        if ( !empty($submenu[$item[2]]) ) {
    2020                $submenu[$item[2]] = array_values($submenu[$item[2]]);  // Re-index.
    2121                $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
    22                 if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
     22                if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
    2323                        echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
    2424                else
    2525                        echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
    2626        } else if ( current_user_can($item[1]) ) {
    2727                $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
    28                 if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) )
     28                if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
    2929                        echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
    3030                else
    3131                        echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
     
    4949        if ( !empty($submenu[$item[2]]) ) {
    5050                $submenu[$item[2]] = array_values($submenu[$item[2]]);  // Re-index.
    5151                $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
    52                 if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
     52                if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
    5353                        echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
    5454                else
    5555                        echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
    5656        } else if ( current_user_can($item[1]) ) {
    5757                $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
    58                 if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) )
     58                if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
    5959                        echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
    6060                else
    6161                        echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
     
    7474        if ( !empty($submenu[$item[2]]) ) {
    7575                $submenu[$item[2]] = array_values($submenu[$item[2]]);  // Re-index.
    7676                $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
    77                 if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
     77                if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
    7878                        echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
    7979                else
    8080                        echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
    8181        } else if ( current_user_can($item[1]) ) {
    8282                $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
    83                 if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) )
     83                if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
    8484                        echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
    8585                else
    8686                        echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
     
    106106        if ( !empty($submenu[$item[2]]) ) {
    107107                $submenu[$item[2]] = array_values($submenu[$item[2]]);  // Re-index.
    108108                $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
    109                 if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
     109                if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
    110110                        $side_items[] = "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
    111111                else
    112112                        $side_items[] = "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
    113113        } else if ( current_user_can($item[1]) ) {
    114114                $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
    115                 if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) )
     115                if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
    116116                        $side_items[] = "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a>";
    117117                else
    118118                        $side_items[] = "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a>";
     
    143143
    144144$menu_hook = get_plugin_page_hook($item[2], $parent_file);
    145145
    146 if (file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || ! empty($menu_hook)) {
     146if (file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || ! empty($menu_hook)) {
    147147        if ( 'admin.php' == $pagenow )
    148148                echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
    149149        else
  • wp-admin/includes/class-wp-filesystem-ftpsockets.php

     
    8686                $this->permission = $perm;
    8787        }
    8888
    89         function find_base_dir($base = '.',$echo = false, $loop = false) {
     89        function find_base_dir($path = false, $base = '.',$echo = false, $loop = false) {
     90                if (!$path)
     91                        $path = ABSPATH;
     92               
    9093                //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output.
    91                 $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..
    92                 if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter
    93                         if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) )
    94                                 $abspath = $mat[1];
     94                $path = str_replace('\\','/',$path); //windows: Straighten up the paths..
     95                if( strpos($path, ':') ){ //Windows, Strip out the driveletter
     96                        if( preg_match("|.{1}\:(.+)|i", $path, $mat) )
     97                                $path = $mat[1];
    9598                }
    9699       
    97100                //Set up the base directory (Which unless specified, is the current one)
     
    99102                $base = trailingslashit($base);
    100103
    101104                //Can we see the Current directory as part of the ABSPATH?
    102                 $location = strpos($abspath, $base);
     105                $location = strpos($path, $base);
    103106                if( false !== $location ) {
    104                         $newbase = path_join($base, substr($abspath, $location + strlen($base)));
     107                        $newbase = path_join($base, substr($path, $location + strlen($base)));
    105108
    106109                        if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly.
    107110                                if($echo) printf( __('Changing to %s') . '<br/>', $newbase );
     
    118121                //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture.
    119122                $files = $this->dirlist($base);
    120123               
    121                 $arrPath = explode('/', $abspath);
     124                $arrPath = explode('/', $path);
    122125                foreach($arrPath as $key){
    123126                        //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
    124127                        // If its found, change into it and follow through looking for it.
     
    128131                                //Lets try that folder:
    129132                                $folder = path_join($base, $key);
    130133                                if($echo) printf( __('Changing to %s') . '<br/>', $folder );
    131                                 $ret = $this->find_base_dir( $folder, $echo, $loop);
     134                                $ret = $this->find_base_dir($path, $folder, $echo, $loop);
    132135                                if( $ret )
    133136                                        return $ret;
    134137                        }
     
    141144                if( $loop )
    142145                        return false;//Prevent tihs function looping again.
    143146                //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.
    144                 return $this->find_base_dir('/', $echo, true);
     147                return $this->find_base_dir($path, '/', $echo, true);
    145148        }
    146149
    147         function get_base_dir($base = '.', $echo = false){
     150        function get_base_dir($path = false, $base = '.', $echo = false){
    148151                if( defined('FTP_BASE') )
    149152                        $this->wp_base = FTP_BASE;
    150153                if( empty($this->wp_base) )
    151                         $this->wp_base = $this->find_base_dir($base, $echo);
     154                        $this->wp_base = $this->find_base_dir($path, $base, $echo);
    152155                return $this->wp_base;
    153156        }
    154157
  • wp-admin/includes/plugin.php

     
    3939        }
    4040
    4141        $wp_plugins = array ();
    42         $plugin_root = ABSPATH . PLUGINDIR;
     42        $plugin_root = WP_PLUGIN_DIR;
    4343        if( !empty($plugin_folder) )
    4444                $plugin_root .= $plugin_folder;
    4545
     
    104104                        if ( !empty($redirect) )
    105105                                wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
    106106                        ob_start();
    107                         @include(ABSPATH . PLUGINDIR . '/' . $plugin);
     107                        @include(WP_PLUGIN_DIR . '/' . $plugin);
    108108                        $current[] = $plugin;
    109109                        sort($current);
    110110                        update_option('active_plugins', $current);
     
    179179        // If a plugin file does not exist, remove it from the list of active
    180180        // plugins.
    181181        foreach ( $check_plugins as $check_plugin ) {
    182                 if ( !file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin) ) {
     182                if ( !file_exists(WP_PLUGIN_DIR . '/' . $check_plugin) ) {
    183183                        $current = get_option('active_plugins');
    184184                        $key = array_search($check_plugin, $current);
    185185                        if ( false !== $key && NULL !== $key ) {
     
    193193function validate_plugin($plugin) {
    194194        if ( validate_file($plugin) )
    195195                return new WP_Error('plugin_invalid', __('Invalid plugin.'));
    196         if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
     196        if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) )
    197197                return new WP_Error('plugin_not_found', __('Plugin file does not exist.'));
    198198
    199199        return 0;
  • wp-admin/includes/schema.php

     
    226226        if ( ini_get('safe_mode') ) {
    227227                // Safe mode screws up mkdir(), so we must use a flat structure.
    228228                add_option('uploads_use_yearmonth_folders', 0);
    229                 add_option('upload_path', 'wp-content');
     229                add_option('upload_path', WP_CONTENT_DIR);
    230230        } else {
    231231                add_option('uploads_use_yearmonth_folders', 1);
    232                 add_option('upload_path', 'wp-content/uploads');
     232                add_option('upload_path', WP_CONTENT_DIR . '/uploads');
    233233        }
    234234
    235235        // 2.0.3
  • wp-admin/includes/file.php

     
    4646        if ( defined('WP_TEMP_DIR') )
    4747                return trailingslashit(WP_TEMP_DIR);
    4848
    49         $temp = ABSPATH . 'wp-content/';
     49        $temp = WP_CONTENT_DIR . '/';
    5050        if ( is_dir($temp) && is_writable($temp) )
    5151                return $temp;
    5252
  • wp-admin/includes/update.php

     
    159159        if ( $wp_filesystem->errors->get_error_code() )
    160160                return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
    161161
    162         //Get the Base folder
    163         $base = $wp_filesystem->get_base_dir();
     162        //Get the base plugin folder
     163        $base = $wp_filesystem->get_base_dir(WP_PLUGIN_DIR);
    164164       
    165165        if ( empty($base) )
    166166                return new WP_Error('fs_nowordpress', __('Unable to locate WordPress directory.'));
     
    179179        if ( is_wp_error($file) )
    180180                return new WP_Error('download_failed', __('Download failed.'), $file->get_error_message());
    181181
    182         $working_dir = $base . 'wp-content/upgrade/' . basename($plugin, '.php');
     182        $working_dir = $wp_filesystem->get_base_dir(WP_CONTENT_DIR) . '/upgrade/' . basename($plugin, '.php');
    183183
    184184        // Clean up working directory
    185185        if ( $wp_filesystem->is_dir($working_dir) )
     
    205205
    206206        // Remove the existing plugin.
    207207        apply_filters('update_feedback', __('Removing the old version of the plugin'));
    208         $plugin_dir = dirname($base . PLUGINDIR . "/$plugin");
     208        $plugin_dir = dirname($base . "/$plugin");
    209209        $plugin_dir = trailingslashit($plugin_dir);
    210210       
    211211        // If plugin is in its own directory, recursively delete the directory.
    212         if ( strpos($plugin, '/') && $plugin_dir != $base . PLUGINDIR . '/' ) //base check on if plugin includes directory seperator AND that its not the root plugin folder
     212        if ( strpos($plugin, '/') && $plugin_dir != $base . '/' ) //base check on if plugin includes directory seperator AND that its not the root plugin folder
    213213                $deleted = $wp_filesystem->delete($plugin_dir, true);
    214214        else
    215                 $deleted = $wp_filesystem->delete($base . PLUGINDIR . "/$plugin");
     215                $deleted = $wp_filesystem->delete($base . '/' . $plugin);
    216216
    217217        if ( !$deleted ) {
    218218                $wp_filesystem->delete($working_dir, true);
     
    221221
    222222        apply_filters('update_feedback', __('Installing the latest version'));
    223223        // Copy new version of plugin into place.
    224         if ( !copy_dir($working_dir, $base . PLUGINDIR) ) {
     224        if ( !copy_dir($working_dir, $base) ) {
    225225                //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails.
    226226                return new WP_Error('install_failed', __('Installation failed'));
    227227        }
  • wp-admin/includes/class-wp-filesystem-ftpext.php

     
    8484                $this->permission = $perm;
    8585        }
    8686
    87         function find_base_dir($base = '.',$echo = false, $loop = false) {
     87        function find_base_dir($path = false, $base = '.',$echo = false, $loop = false) {
     88                if (!$path)
     89                        $path = ABSPATH;
     90               
    8891                //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output.
    89                 $abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..
    90                 if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter
    91                         if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) )
    92                                 $abspath = $mat[1];
     92                $path = str_replace('\\','/',$path); //windows: Straighten up the paths..
     93                if( strpos($path, ':') ){ //Windows, Strip out the driveletter
     94                        if( preg_match("|.{1}\:(.+)|i", $path, $mat) )
     95                                $path = $mat[1];
    9396                }
    9497       
    9598                //Set up the base directory (Which unless specified, is the current one)
     
    97100                $base = trailingslashit($base);
    98101
    99102                //Can we see the Current directory as part of the ABSPATH?
    100                 $location = strpos($abspath, $base);
     103                $location = strpos($path, $base);
    101104                if( false !== $location ) {
    102                         $newbase = path_join($base, substr($abspath, $location + strlen($base)));
     105                        $newbase = path_join($base, substr($path, $location + strlen($base)));
    103106
    104107                        if( false !== $this->chdir($newbase) ){ //chdir sometimes returns null under certain circumstances, even when its changed correctly, FALSE will be returned if it doesnt change correctly.
    105108                                if($echo) printf( __('Changing to %s') . '<br/>', $newbase );
     
    116119                //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture.
    117120                $files = $this->dirlist($base);
    118121               
    119                 $arrPath = explode('/', $abspath);
     122                $arrPath = explode('/', $path);
    120123                foreach($arrPath as $key){
    121124                        //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
    122125                        // If its found, change into it and follow through looking for it.
     
    126129                                //Lets try that folder:
    127130                                $folder = path_join($base, $key);
    128131                                if($echo) printf( __('Changing to %s') . '<br/>', $folder );
    129                                 $ret = $this->find_base_dir( $folder, $echo, $loop);
     132                                $ret = $this->find_base_dir( $path, $folder, $echo, $loop);
    130133                                if( $ret )
    131134                                        return $ret;
    132135                        }
     
    139142                if( $loop )
    140143                        return false;//Prevent tihs function looping again.
    141144                //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.
    142                 return $this->find_base_dir('/', $echo, true);
     145                return $this->find_base_dir($path, '/', $echo, true);
    143146        }
    144147
    145         function get_base_dir($base = '.', $echo = false){
     148        function get_base_dir($path = false, $base = '.', $echo = false){
    146149                if( defined('FTP_BASE') )
    147150                        $this->wp_base = FTP_BASE;
    148151                if( empty($this->wp_base) )
    149                         $this->wp_base = $this->find_base_dir($base,$echo);
     152                        $this->wp_base = $this->find_base_dir($path, $base, $echo);
    150153                return $this->wp_base;
    151154        }
    152155        function get_contents($file,$type='',$resumepos=0){
  • wp-admin/includes/class-wp-filesystem-direct.php

     
    1313        function setDefaultPermissions($perm){
    1414                $this->permission = $perm;
    1515        }
    16         function find_base_dir($base = '.', $echo = false){
    17                 return str_replace('\\','/',ABSPATH);
     16        function find_base_dir($path = false, $base = '.', $echo = false){
     17                if (!$path)
     18                        $path = ABSPATH;
     19                return str_replace('\\','/',$path);
    1820        }
    19         function get_base_dir($base = '.', $echo = false){
     21        function get_base_dir($path = false, $base = '.', $echo = false){
    2022                return $this->find_base_dir($base, $echo);
    2123        }
    2224        function get_contents($file){
  • wp-admin/includes/upgrade.php

     
    11<?php
    22
    3 if ( file_exists(ABSPATH . 'wp-content/install.php') )
    4         require (ABSPATH . 'wp-content/install.php');
     3if ( file_exists(WP_CONTENT_DIR . '/install.php') )
     4        require (WP_CONTENT_DIR . '/install.php');
    55require_once(ABSPATH . 'wp-admin/includes/admin.php');
    66require_once(ABSPATH . 'wp-admin/includes/schema.php');
    77
     
    10861086
    10871087function make_site_theme_from_oldschool($theme_name, $template) {
    10881088        $home_path = get_home_path();
    1089         $site_dir = ABSPATH . "wp-content/themes/$template";
     1089        $site_dir = WP_CONTENT_DIR . "/themes/$template";
    10901090
    10911091        if (! file_exists("$home_path/index.php"))
    10921092                return false;
     
    11051105                if ($oldfile == 'index.php') { // Check to make sure it's not a new index
    11061106                        $index = implode('', file("$oldpath/$oldfile"));
    11071107                        if (strpos($index, 'WP_USE_THEMES') !== false) {
    1108                                 if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile"))
     1108                                if (! @copy(WP_CONTENT_DIR . '/themes/default/index.php', "$site_dir/$newfile"))
    11091109                                        return false;
    11101110                                continue; // Don't copy anything
    11111111                                }
     
    11531153}
    11541154
    11551155function make_site_theme_from_default($theme_name, $template) {
    1156         $site_dir = ABSPATH . "wp-content/themes/$template";
    1157         $default_dir = ABSPATH . 'wp-content/themes/default';
     1156        $site_dir = WP_CONTENT_DIR . "/themes/$template";
     1157        $default_dir = WP_CONTENT_DIR . '/themes/default';
    11581158
    11591159        // Copy files from the default theme to the site theme.
    11601160        //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
     
    12111211        // Name the theme after the blog.
    12121212        $theme_name = __get_option('blogname');
    12131213        $template = sanitize_title($theme_name);
    1214         $site_dir = ABSPATH . "wp-content/themes/$template";
     1214        $site_dir = WP_CONTENT_DIR . "/themes/$template";
    12151215
    12161216        // If the theme already exists, nothing to do.
    12171217        if ( is_dir($site_dir)) {
     
    12191219        }
    12201220
    12211221        // We must be able to write to the themes dir.
    1222         if (! is_writable(ABSPATH . "wp-content/themes")) {
     1222        if (! is_writable(WP_CONTENT_DIR . "/themes")) {
    12231223                return false;
    12241224        }
    12251225
  • wp-admin/update.php

     
    117117        if ( is_wp_error($result) ) {
    118118                show_message($result);
    119119        } else {
    120                 //Result is the new plugin file relative to PLUGINDIR
     120                //Result is the new plugin file relative to WP_PLUGIN_DIR
    121121                show_message(__('Plugin upgraded successfully'));       
    122122                if( $result && $was_activated ){
    123123                        show_message(__('Attempting reactivation of the plugin'));
     
    164164                        echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>';
    165165                        error_reporting( E_ALL ^ E_NOTICE );
    166166                        @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
    167                         include(ABSPATH . PLUGINDIR . '/' . $plugin);
     167                        include(WP_PLUGIN_DIR . '/' . $plugin);
    168168                }
    169169                echo "</body></html>";
    170170        }
  • wp-admin/admin.php

     
    5858                        wp_die(__('Invalid plugin page'));
    5959                }
    6060
    61                 if (! ( file_exists(ABSPATH . PLUGINDIR . "/$plugin_page") && is_file( ABSPATH . PLUGINDIR . "/$plugin_page") ) )
     61                if (! ( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) )
    6262                        wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
    6363
    6464                do_action('load-' . $plugin_page);
     
    6666                if (! isset($_GET['noheader']))
    6767                        require_once(ABSPATH . 'wp-admin/admin-header.php');
    6868
    69                 include(ABSPATH . PLUGINDIR . "/$plugin_page");
     69                include(WP_PLUGIN_DIR . "/$plugin_page");
    7070        }
    7171
    7272        include(ABSPATH . 'wp-admin/admin-footer.php');
  • wp-admin/import/mt.php

     
    179179
    180180        function select_authors() {
    181181                if ( $_POST['upload_type'] === 'ftp' ) {
    182                         $file['file'] = ABSPATH . 'wp-content/mt-export.txt';
     182                        $file['file'] = WP_CONTENT_DIR . '/mt-export.txt';
    183183                        if ( !file_exists($file['file']) )
    184184                                $file['error'] = __('<code>mt-export.txt</code> does not exist');
    185185                } else {
     
    426426        function import() {
    427427                $this->id = (int) $_GET['id'];
    428428                if ( $this->id == 0 )
    429                         $this->file = ABSPATH . 'wp-content/mt-export.txt';
     429                        $this->file = WP_CONTENT_DIR . '/mt-export.txt';
    430430                else
    431431                        $this->file = get_attached_file($this->id);
    432432                $this->get_authors_from_post();
  • wp-admin/plugins.php

     
    1818                        wp_die($valid);
    1919                error_reporting( E_ALL ^ E_NOTICE );
    2020                @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
    21                 include(ABSPATH . PLUGINDIR . '/' . $plugin);
     21                include(WP_PLUGIN_DIR . '/' . $plugin);
    2222        } elseif ( 'deactivate' == $_GET['action'] ) {
    2323                check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
    2424                deactivate_plugins($_GET['plugin']);
     
    123123                } else {
    124124                        $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=activate&amp;plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
    125125                }
    126                 if ( current_user_can('edit_plugins') && is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) )
     126                if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
    127127                        $action_links[] = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
    128128
    129129                $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
     
    166166}
    167167?>
    168168
    169 <p><?php printf(__('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), PLUGINDIR); ?></p>
     169<p><?php printf(__('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), WP_PLUGIN_DIR); ?></p>
    170170
    171171<h2><?php _e('Get More Plugins'); ?></h2>
    172172<p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>.'); ?></p>
    173 <p><?php printf(__('To install a plugin you generally just need to upload the plugin file into your <code>%s</code> directory. Once a plugin is uploaded, you may activate it here.'), PLUGINDIR); ?></p>
     173<p><?php printf(__('To install a plugin you generally just need to upload the plugin file into your <code>%s</code> directory. Once a plugin is uploaded, you may activate it here.'), WP_PLUGIN_DIR); ?></p>
    174174
    175175</div>
    176176
  • wp-admin/plugin-editor.php

     
    1515        $file = $plugin_files[0];
    1616
    1717$file = validate_file_to_edit($file, $plugin_files);
    18 $real_file = get_real_file_to_edit( PLUGINDIR . "/$file");
     18$real_file = WP_PLUGIN_DIR . '/' . $file;
    1919
    2020switch($action) {
    2121
     
    6868
    6969        require_once('admin-header.php');
    7070
    71         update_recently_edited(PLUGINDIR . "/$file");
     71        update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
    7272
    7373        if ( ! is_file($real_file) )
    7474                $error = 1;