WordPress.org

Make WordPress Core

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

File allow-wp-content-directory-outside-of-webroot.patch, 11.5 KB (added by sambauers, 10 years ago)
  • 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 = ABSPATH . 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', ABSPATH . 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', get_option('siteurl') . "/" . WP_CONTENT_DIR . "/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( ABSPATH . WP_CONTENT_DIR . '/db.php' ) )
     1562                require_once( ABSPATH . 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( ABSPATH . WP_CONTENT_DIR . '/db-error.php' ) ) {
     1572                require_once( ABSPATH . WP_CONTENT_DIR . '/db-error.php' );
    15731573                die();
    15741574        }
    15751575
  • 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( ABSPATH . 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( ABSPATH . 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( ABSPATH . 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( ABSPATH . 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 = WP_CONTENT_DIR . '/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
  • 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') )
     103
     104if ( !defined('WP_CONTENT_DIR') )
     105        define( 'WP_CONTENT_DIR', 'wp-content' ); // no leading slash, no trailing slash, relative directories are OK
     106
     107if ( !extension_loaded('mysql') && !file_exists(ABSPATH . WP_CONTENT_DIR . '/db.php') )
    104108        die( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' );
    105109
    106110/**
     
    166170
    167171// For an advanced caching plugin to use, static because you would only want one
    168172if ( defined('WP_CACHE') )
    169         @include ABSPATH . 'wp-content/advanced-cache.php';
     173        @include ABSPATH . WP_CONTENT_DIR . '/advanced-cache.php';
    170174
    171175/**
    172176 * Stores the location of the WordPress directory of functions, classes, and core content.
     
    182186         *
    183187         * @since 2.1.0
    184188         */
    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
     189        if ( file_exists(WP_CONTENT_DIR . '/languages') && @is_dir(WP_CONTENT_DIR . '/languages') )
     190                define('LANGDIR', WP_CONTENT_DIR . '/languages'); // no leading slash, no trailing slash
    187191        else
    188192                define('LANGDIR', WPINC . '/languages'); // no leading slash, no trailing slash
    189193}
     
    197201 * @since 2.1
    198202 */
    199203if ( !defined('PLUGINDIR') )
    200         define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash
     204        define('PLUGINDIR', WP_CONTENT_DIR . '/plugins'); // no leading slash, no trailing slash
    201205
    202206require (ABSPATH . WPINC . '/compat.php');
    203207require (ABSPATH . WPINC . '/functions.php');
     
    213217if ( is_wp_error($prefix) )
    214218        wp_die('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.');
    215219
    216 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
    217         require_once (ABSPATH . 'wp-content/object-cache.php');
     220if ( file_exists(ABSPATH . WP_CONTENT_DIR . '/object-cache.php') )
     221        require_once (ABSPATH . WP_CONTENT_DIR . '/object-cache.php');
    218222else
    219223        require_once (ABSPATH . WPINC . '/cache.php');
    220224
  • 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 = ABSPATH . WP_CONTENT_DIR . '/';
    5050        if ( is_dir($temp) && is_writable($temp) )
    5151                return $temp;
    5252
  • wp-admin/includes/update.php

     
    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 = $base . WP_CONTENT_DIR . '/upgrade/' . basename($plugin, '.php');
    183183
    184184        // Clean up working directory
    185185        if ( $wp_filesystem->is_dir($working_dir) )
  • 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(ABSPATH . WP_CONTENT_DIR . '/install.php') )
     4        require (ABSPATH . WP_CONTENT_DIR . '/install.php');
    55require_once(ABSPATH . 'wp-admin/includes/admin.php');
    66require_once(ABSPATH . 'wp-admin/includes/schema.php');
    77
     
    10771077
    10781078function make_site_theme_from_oldschool($theme_name, $template) {
    10791079        $home_path = get_home_path();
    1080         $site_dir = ABSPATH . "wp-content/themes/$template";
     1080        $site_dir = ABSPATH . WP_CONTENT_DIR . "/themes/$template";
    10811081
    10821082        if (! file_exists("$home_path/index.php"))
    10831083                return false;
     
    10961096                if ($oldfile == 'index.php') { // Check to make sure it's not a new index
    10971097                        $index = implode('', file("$oldpath/$oldfile"));
    10981098                        if (strpos($index, 'WP_USE_THEMES') !== false) {
    1099                                 if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile"))
     1099                                if (! @copy(ABSPATH . WP_CONTENT_DIR . '/themes/default/index.php', "$site_dir/$newfile"))
    11001100                                        return false;
    11011101                                continue; // Don't copy anything
    11021102                                }
     
    11441144}
    11451145
    11461146function make_site_theme_from_default($theme_name, $template) {
    1147         $site_dir = ABSPATH . "wp-content/themes/$template";
    1148         $default_dir = ABSPATH . 'wp-content/themes/default';
     1147        $site_dir = ABSPATH . WP_CONTENT_DIR . "/themes/$template";
     1148        $default_dir = ABSPATH . WP_CONTENT_DIR . '/themes/default';
    11491149
    11501150        // Copy files from the default theme to the site theme.
    11511151        //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
     
    12021202        // Name the theme after the blog.
    12031203        $theme_name = __get_option('blogname');
    12041204        $template = sanitize_title($theme_name);
    1205         $site_dir = ABSPATH . "wp-content/themes/$template";
     1205        $site_dir = ABSPATH . WP_CONTENT_DIR . "/themes/$template";
    12061206
    12071207        // If the theme already exists, nothing to do.
    12081208        if ( is_dir($site_dir)) {
     
    12101210        }
    12111211
    12121212        // We must be able to write to the themes dir.
    1213         if (! is_writable(ABSPATH . "wp-content/themes")) {
     1213        if (! is_writable(ABSPATH . WP_CONTENT_DIR . "/themes")) {
    12141214                return false;
    12151215        }
    12161216
  • 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'] = ABSPATH . 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 = ABSPATH . WP_CONTENT_DIR . '/mt-export.txt';
    430430                else
    431431                        $this->file = get_attached_file($this->id);
    432432                $this->get_authors_from_post();