Allow wp-content to exist outside of webroot. Props sambauers. see #6938

git-svn-id: http://svn.automattic.com/wordpress/trunk@7999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-05-27 17:55:24 +00:00
parent 9771ec5110
commit 6c8d35de32
23 changed files with 140 additions and 112 deletions

View File

@ -58,7 +58,7 @@ if (isset($plugin_page)) {
wp_die(__('Invalid plugin page')); wp_die(__('Invalid plugin page'));
} }
if (! ( file_exists(ABSPATH . PLUGINDIR . "/$plugin_page") && is_file( ABSPATH . PLUGINDIR . "/$plugin_page") ) ) if (! ( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) )
wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
do_action('load-' . $plugin_page); do_action('load-' . $plugin_page);
@ -66,7 +66,7 @@ if (isset($plugin_page)) {
if (! isset($_GET['noheader'])) if (! isset($_GET['noheader']))
require_once(ABSPATH . 'wp-admin/admin-header.php'); require_once(ABSPATH . 'wp-admin/admin-header.php');
include(ABSPATH . PLUGINDIR . "/$plugin_page"); include(WP_PLUGIN_DIR . "/$plugin_page");
} }
include(ABSPATH . 'wp-admin/admin-footer.php'); include(ABSPATH . 'wp-admin/admin-footer.php');

View File

@ -179,7 +179,7 @@ class MT_Import {
function select_authors() { function select_authors() {
if ( $_POST['upload_type'] === 'ftp' ) { if ( $_POST['upload_type'] === 'ftp' ) {
$file['file'] = ABSPATH . 'wp-content/mt-export.txt'; $file['file'] = WP_CONTENT_DIR . '/mt-export.txt';
if ( !file_exists($file['file']) ) if ( !file_exists($file['file']) )
$file['error'] = __('<code>mt-export.txt</code> does not exist'); $file['error'] = __('<code>mt-export.txt</code> does not exist');
} else { } else {
@ -426,7 +426,7 @@ class MT_Import {
function import() { function import() {
$this->id = (int) $_GET['id']; $this->id = (int) $_GET['id'];
if ( $this->id == 0 ) if ( $this->id == 0 )
$this->file = ABSPATH . 'wp-content/mt-export.txt'; $this->file = WP_CONTENT_DIR . '/mt-export.txt';
else else
$this->file = get_attached_file($this->id); $this->file = get_attached_file($this->id);
$this->get_authors_from_post(); $this->get_authors_from_post();

View File

@ -13,10 +13,12 @@ class WP_Filesystem_Direct{
function setDefaultPermissions($perm){ function setDefaultPermissions($perm){
$this->permission = $perm; $this->permission = $perm;
} }
function find_base_dir($base = '.', $echo = false){ function find_base_dir($path = false, $base = '.', $echo = false){
return str_replace('\\','/',ABSPATH); if (!$path)
$path = ABSPATH;
return str_replace('\\','/',$path);
} }
function get_base_dir($base = '.', $echo = false){ function get_base_dir($path = false, $base = '.', $echo = false){
return $this->find_base_dir($base, $echo); return $this->find_base_dir($base, $echo);
} }
function get_contents($file){ function get_contents($file){

View File

@ -84,12 +84,15 @@ class WP_Filesystem_FTPext{
$this->permission = $perm; $this->permission = $perm;
} }
function find_base_dir($base = '.',$echo = false, $loop = false) { function find_base_dir($path = false, $base = '.',$echo = false, $loop = false) {
if (!$path)
$path = ABSPATH;
//Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output. //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output.
$abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. $path = str_replace('\\','/',$path); //windows: Straighten up the paths..
if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter if( strpos($path, ':') ){ //Windows, Strip out the driveletter
if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) if( preg_match("|.{1}\:(.+)|i", $path, $mat) )
$abspath = $mat[1]; $path = $mat[1];
} }
//Set up the base directory (Which unless specified, is the current one) //Set up the base directory (Which unless specified, is the current one)
@ -97,9 +100,9 @@ class WP_Filesystem_FTPext{
$base = trailingslashit($base); $base = trailingslashit($base);
//Can we see the Current directory as part of the ABSPATH? //Can we see the Current directory as part of the ABSPATH?
$location = strpos($abspath, $base); $location = strpos($path, $base);
if( false !== $location ) { if( false !== $location ) {
$newbase = path_join($base, substr($abspath, $location + strlen($base))); $newbase = path_join($base, substr($path, $location + strlen($base)));
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. 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.
if($echo) printf( __('Changing to %s') . '<br/>', $newbase ); if($echo) printf( __('Changing to %s') . '<br/>', $newbase );
@ -116,7 +119,7 @@ class WP_Filesystem_FTPext{
//Get a list of the files in the current directory, See if we can locate where we are in the folder stucture. //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture.
$files = $this->dirlist($base); $files = $this->dirlist($base);
$arrPath = explode('/', $abspath); $arrPath = explode('/', $path);
foreach($arrPath as $key){ foreach($arrPath as $key){
//Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
// If its found, change into it and follow through looking for it. // If its found, change into it and follow through looking for it.
@ -126,7 +129,7 @@ class WP_Filesystem_FTPext{
//Lets try that folder: //Lets try that folder:
$folder = path_join($base, $key); $folder = path_join($base, $key);
if($echo) printf( __('Changing to %s') . '<br/>', $folder ); if($echo) printf( __('Changing to %s') . '<br/>', $folder );
$ret = $this->find_base_dir( $folder, $echo, $loop); $ret = $this->find_base_dir( $path, $folder, $echo, $loop);
if( $ret ) if( $ret )
return $ret; return $ret;
} }
@ -139,14 +142,14 @@ class WP_Filesystem_FTPext{
if( $loop ) if( $loop )
return false;//Prevent tihs function looping again. return false;//Prevent tihs function looping again.
//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. //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.
return $this->find_base_dir('/', $echo, true); return $this->find_base_dir($path, '/', $echo, true);
} }
function get_base_dir($base = '.', $echo = false){ function get_base_dir($path = false, $base = '.', $echo = false){
if( defined('FTP_BASE') ) if( defined('FTP_BASE') )
$this->wp_base = FTP_BASE; $this->wp_base = FTP_BASE;
if( empty($this->wp_base) ) if( empty($this->wp_base) )
$this->wp_base = $this->find_base_dir($base,$echo); $this->wp_base = $this->find_base_dir($path, $base, $echo);
return $this->wp_base; return $this->wp_base;
} }
function get_contents($file,$type='',$resumepos=0){ function get_contents($file,$type='',$resumepos=0){

View File

@ -86,12 +86,15 @@ class WP_Filesystem_ftpsockets{
$this->permission = $perm; $this->permission = $perm;
} }
function find_base_dir($base = '.',$echo = false, $loop = false) { function find_base_dir($path = false, $base = '.',$echo = false, $loop = false) {
if (!$path)
$path = ABSPATH;
//Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output. //Sanitize the Windows path formats, This allows easier conparison and aligns it to FTP output.
$abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths.. $path = str_replace('\\','/',$path); //windows: Straighten up the paths..
if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter if( strpos($path, ':') ){ //Windows, Strip out the driveletter
if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) ) if( preg_match("|.{1}\:(.+)|i", $path, $mat) )
$abspath = $mat[1]; $path = $mat[1];
} }
//Set up the base directory (Which unless specified, is the current one) //Set up the base directory (Which unless specified, is the current one)
@ -99,9 +102,9 @@ class WP_Filesystem_ftpsockets{
$base = trailingslashit($base); $base = trailingslashit($base);
//Can we see the Current directory as part of the ABSPATH? //Can we see the Current directory as part of the ABSPATH?
$location = strpos($abspath, $base); $location = strpos($path, $base);
if( false !== $location ) { if( false !== $location ) {
$newbase = path_join($base, substr($abspath, $location + strlen($base))); $newbase = path_join($base, substr($path, $location + strlen($base)));
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. 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.
if($echo) printf( __('Changing to %s') . '<br/>', $newbase ); if($echo) printf( __('Changing to %s') . '<br/>', $newbase );
@ -118,7 +121,7 @@ class WP_Filesystem_ftpsockets{
//Get a list of the files in the current directory, See if we can locate where we are in the folder stucture. //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture.
$files = $this->dirlist($base); $files = $this->dirlist($base);
$arrPath = explode('/', $abspath); $arrPath = explode('/', $path);
foreach($arrPath as $key){ foreach($arrPath as $key){
//Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
// If its found, change into it and follow through looking for it. // If its found, change into it and follow through looking for it.
@ -128,7 +131,7 @@ class WP_Filesystem_ftpsockets{
//Lets try that folder: //Lets try that folder:
$folder = path_join($base, $key); $folder = path_join($base, $key);
if($echo) printf( __('Changing to %s') . '<br/>', $folder ); if($echo) printf( __('Changing to %s') . '<br/>', $folder );
$ret = $this->find_base_dir( $folder, $echo, $loop); $ret = $this->find_base_dir($path, $folder, $echo, $loop);
if( $ret ) if( $ret )
return $ret; return $ret;
} }
@ -141,14 +144,14 @@ class WP_Filesystem_ftpsockets{
if( $loop ) if( $loop )
return false;//Prevent tihs function looping again. return false;//Prevent tihs function looping again.
//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. //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.
return $this->find_base_dir('/', $echo, true); return $this->find_base_dir($path, '/', $echo, true);
} }
function get_base_dir($base = '.', $echo = false){ function get_base_dir($path = false, $base = '.', $echo = false){
if( defined('FTP_BASE') ) if( defined('FTP_BASE') )
$this->wp_base = FTP_BASE; $this->wp_base = FTP_BASE;
if( empty($this->wp_base) ) if( empty($this->wp_base) )
$this->wp_base = $this->find_base_dir($base, $echo); $this->wp_base = $this->find_base_dir($path, $base, $echo);
return $this->wp_base; return $this->wp_base;
} }

View File

@ -46,7 +46,7 @@ function get_temp_dir() {
if ( defined('WP_TEMP_DIR') ) if ( defined('WP_TEMP_DIR') )
return trailingslashit(WP_TEMP_DIR); return trailingslashit(WP_TEMP_DIR);
$temp = ABSPATH . 'wp-content/'; $temp = WP_CONTENT_DIR . '/';
if ( is_dir($temp) && is_writable($temp) ) if ( is_dir($temp) && is_writable($temp) )
return $temp; return $temp;

View File

@ -39,7 +39,7 @@ function get_plugins($plugin_folder = '') {
} }
$wp_plugins = array (); $wp_plugins = array ();
$plugin_root = ABSPATH . PLUGINDIR; $plugin_root = WP_PLUGIN_DIR;
if( !empty($plugin_folder) ) if( !empty($plugin_folder) )
$plugin_root .= $plugin_folder; $plugin_root .= $plugin_folder;
@ -104,7 +104,7 @@ function activate_plugin($plugin, $redirect = '') {
if ( !empty($redirect) ) if ( !empty($redirect) )
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 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
ob_start(); ob_start();
@include(ABSPATH . PLUGINDIR . '/' . $plugin); @include(WP_PLUGIN_DIR . '/' . $plugin);
$current[] = $plugin; $current[] = $plugin;
sort($current); sort($current);
update_option('active_plugins', $current); update_option('active_plugins', $current);
@ -179,7 +179,7 @@ function validate_active_plugins() {
// If a plugin file does not exist, remove it from the list of active // If a plugin file does not exist, remove it from the list of active
// plugins. // plugins.
foreach ( $check_plugins as $check_plugin ) { foreach ( $check_plugins as $check_plugin ) {
if ( !file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin) ) { if ( !file_exists(WP_PLUGIN_DIR . '/' . $check_plugin) ) {
$current = get_option('active_plugins'); $current = get_option('active_plugins');
$key = array_search($check_plugin, $current); $key = array_search($check_plugin, $current);
if ( false !== $key && NULL !== $key ) { if ( false !== $key && NULL !== $key ) {
@ -193,7 +193,7 @@ function validate_active_plugins() {
function validate_plugin($plugin) { function validate_plugin($plugin) {
if ( validate_file($plugin) ) if ( validate_file($plugin) )
return new WP_Error('plugin_invalid', __('Invalid plugin.')); return new WP_Error('plugin_invalid', __('Invalid plugin.'));
if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) )
return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); return new WP_Error('plugin_not_found', __('Plugin file does not exist.'));
return 0; return 0;

View File

@ -226,10 +226,10 @@ function populate_options() {
if ( ini_get('safe_mode') ) { if ( ini_get('safe_mode') ) {
// Safe mode screws up mkdir(), so we must use a flat structure. // Safe mode screws up mkdir(), so we must use a flat structure.
add_option('uploads_use_yearmonth_folders', 0); add_option('uploads_use_yearmonth_folders', 0);
add_option('upload_path', 'wp-content'); add_option('upload_path', WP_CONTENT_DIR);
} else { } else {
add_option('uploads_use_yearmonth_folders', 1); add_option('uploads_use_yearmonth_folders', 1);
add_option('upload_path', 'wp-content/uploads'); add_option('upload_path', WP_CONTENT_DIR . '/uploads');
} }
// 2.0.3 // 2.0.3

View File

@ -159,8 +159,8 @@ function wp_update_plugin($plugin, $feedback = '') {
if ( $wp_filesystem->errors->get_error_code() ) if ( $wp_filesystem->errors->get_error_code() )
return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
//Get the Base folder //Get the base plugin folder
$base = $wp_filesystem->get_base_dir(); $base = $wp_filesystem->get_base_dir(WP_PLUGIN_DIR);
if ( empty($base) ) if ( empty($base) )
return new WP_Error('fs_nowordpress', __('Unable to locate WordPress directory.')); return new WP_Error('fs_nowordpress', __('Unable to locate WordPress directory.'));
@ -179,7 +179,7 @@ function wp_update_plugin($plugin, $feedback = '') {
if ( is_wp_error($file) ) if ( is_wp_error($file) )
return new WP_Error('download_failed', __('Download failed.'), $file->get_error_message()); return new WP_Error('download_failed', __('Download failed.'), $file->get_error_message());
$working_dir = $base . 'wp-content/upgrade/' . basename($plugin, '.php'); $working_dir = $wp_filesystem->get_base_dir(WP_CONTENT_DIR) . '/upgrade/' . basename($plugin, '.php');
// Clean up working directory // Clean up working directory
if ( $wp_filesystem->is_dir($working_dir) ) if ( $wp_filesystem->is_dir($working_dir) )
@ -205,14 +205,14 @@ function wp_update_plugin($plugin, $feedback = '') {
// Remove the existing plugin. // Remove the existing plugin.
apply_filters('update_feedback', __('Removing the old version of the plugin')); apply_filters('update_feedback', __('Removing the old version of the plugin'));
$plugin_dir = dirname($base . PLUGINDIR . "/$plugin"); $plugin_dir = dirname($base . "/$plugin");
$plugin_dir = trailingslashit($plugin_dir); $plugin_dir = trailingslashit($plugin_dir);
// If plugin is in its own directory, recursively delete the directory. // If plugin is in its own directory, recursively delete the directory.
if ( strpos($plugin, '/') && $plugin_dir != $base . PLUGINDIR . '/' ) //base check on if plugin includes directory seperator AND that its not the root plugin folder if ( strpos($plugin, '/') && $plugin_dir != $base . '/' ) //base check on if plugin includes directory seperator AND that its not the root plugin folder
$deleted = $wp_filesystem->delete($plugin_dir, true); $deleted = $wp_filesystem->delete($plugin_dir, true);
else else
$deleted = $wp_filesystem->delete($base . PLUGINDIR . "/$plugin"); $deleted = $wp_filesystem->delete($base . '/' . $plugin);
if ( !$deleted ) { if ( !$deleted ) {
$wp_filesystem->delete($working_dir, true); $wp_filesystem->delete($working_dir, true);
@ -221,7 +221,7 @@ function wp_update_plugin($plugin, $feedback = '') {
apply_filters('update_feedback', __('Installing the latest version')); apply_filters('update_feedback', __('Installing the latest version'));
// Copy new version of plugin into place. // Copy new version of plugin into place.
if ( !copy_dir($working_dir, $base . PLUGINDIR) ) { if ( !copy_dir($working_dir, $base) ) {
//$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails. //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails.
return new WP_Error('install_failed', __('Installation failed')); return new WP_Error('install_failed', __('Installation failed'));
} }

View File

@ -1,7 +1,7 @@
<?php <?php
if ( file_exists(ABSPATH . 'wp-content/install.php') ) if ( file_exists(WP_CONTENT_DIR . '/install.php') )
require (ABSPATH . 'wp-content/install.php'); require (WP_CONTENT_DIR . '/install.php');
require_once(ABSPATH . 'wp-admin/includes/admin.php'); require_once(ABSPATH . 'wp-admin/includes/admin.php');
require_once(ABSPATH . 'wp-admin/includes/schema.php'); require_once(ABSPATH . 'wp-admin/includes/schema.php');
@ -1086,7 +1086,7 @@ function make_db_current_silent() {
function make_site_theme_from_oldschool($theme_name, $template) { function make_site_theme_from_oldschool($theme_name, $template) {
$home_path = get_home_path(); $home_path = get_home_path();
$site_dir = ABSPATH . "wp-content/themes/$template"; $site_dir = WP_CONTENT_DIR . "/themes/$template";
if (! file_exists("$home_path/index.php")) if (! file_exists("$home_path/index.php"))
return false; return false;
@ -1105,7 +1105,7 @@ function make_site_theme_from_oldschool($theme_name, $template) {
if ($oldfile == 'index.php') { // Check to make sure it's not a new index if ($oldfile == 'index.php') { // Check to make sure it's not a new index
$index = implode('', file("$oldpath/$oldfile")); $index = implode('', file("$oldpath/$oldfile"));
if (strpos($index, 'WP_USE_THEMES') !== false) { if (strpos($index, 'WP_USE_THEMES') !== false) {
if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile")) if (! @copy(WP_CONTENT_DIR . '/themes/default/index.php', "$site_dir/$newfile"))
return false; return false;
continue; // Don't copy anything continue; // Don't copy anything
} }
@ -1153,8 +1153,8 @@ function make_site_theme_from_oldschool($theme_name, $template) {
} }
function make_site_theme_from_default($theme_name, $template) { function make_site_theme_from_default($theme_name, $template) {
$site_dir = ABSPATH . "wp-content/themes/$template"; $site_dir = WP_CONTENT_DIR . "/themes/$template";
$default_dir = ABSPATH . 'wp-content/themes/default'; $default_dir = WP_CONTENT_DIR . '/themes/default';
// Copy files from the default theme to the site theme. // Copy files from the default theme to the site theme.
//$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css'); //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
@ -1211,7 +1211,7 @@ function make_site_theme() {
// Name the theme after the blog. // Name the theme after the blog.
$theme_name = __get_option('blogname'); $theme_name = __get_option('blogname');
$template = sanitize_title($theme_name); $template = sanitize_title($theme_name);
$site_dir = ABSPATH . "wp-content/themes/$template"; $site_dir = WP_CONTENT_DIR . "/themes/$template";
// If the theme already exists, nothing to do. // If the theme already exists, nothing to do.
if ( is_dir($site_dir)) { if ( is_dir($site_dir)) {
@ -1219,7 +1219,7 @@ function make_site_theme() {
} }
// We must be able to write to the themes dir. // We must be able to write to the themes dir.
if (! is_writable(ABSPATH . "wp-content/themes")) { if (! is_writable(WP_CONTENT_DIR . "/themes")) {
return false; return false;
} }

View File

@ -19,13 +19,13 @@ foreach ( $menu as $key => $item ) {
if ( !empty($submenu[$item[2]]) ) { if ( !empty($submenu[$item[2]]) ) {
$submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
$menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
else else
echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
} else if ( current_user_can($item[1]) ) { } else if ( current_user_can($item[1]) ) {
$menu_hook = get_plugin_page_hook($item[2], 'admin.php'); $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) ) if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
else else
echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
@ -49,13 +49,13 @@ foreach ( $menu as $key => $item ) {
if ( !empty($submenu[$item[2]]) ) { if ( !empty($submenu[$item[2]]) ) {
$submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
$menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
else else
echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
} else if ( current_user_can($item[1]) ) { } else if ( current_user_can($item[1]) ) {
$menu_hook = get_plugin_page_hook($item[2], 'admin.php'); $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) ) if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
else else
echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
@ -74,13 +74,13 @@ foreach ( $menu as $key => $item ) {
if ( !empty($submenu[$item[2]]) ) { if ( !empty($submenu[$item[2]]) ) {
$submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
$menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
else else
echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>";
} else if ( current_user_can($item[1]) ) { } else if ( current_user_can($item[1]) ) {
$menu_hook = get_plugin_page_hook($item[2], 'admin.php'); $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) ) if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
else else
echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>";
@ -106,13 +106,13 @@ foreach ( $menu as $key => $item ) {
if ( !empty($submenu[$item[2]]) ) { if ( !empty($submenu[$item[2]]) ) {
$submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
$menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
$side_items[] = "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; $side_items[] = "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
else else
$side_items[] = "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; $side_items[] = "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
} else if ( current_user_can($item[1]) ) { } else if ( current_user_can($item[1]) ) {
$menu_hook = get_plugin_page_hook($item[2], 'admin.php'); $menu_hook = get_plugin_page_hook($item[2], 'admin.php');
if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || !empty($menu_hook) ) if ( file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || !empty($menu_hook) )
$side_items[] = "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a>"; $side_items[] = "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a>";
else else
$side_items[] = "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a>"; $side_items[] = "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a>";
@ -143,7 +143,7 @@ else $class = '';
$menu_hook = get_plugin_page_hook($item[2], $parent_file); $menu_hook = get_plugin_page_hook($item[2], $parent_file);
if (file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || ! empty($menu_hook)) { if (file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || ! empty($menu_hook)) {
if ( 'admin.php' == $pagenow ) if ( 'admin.php' == $pagenow )
echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
else else

View File

@ -15,7 +15,7 @@ if (empty($file))
$file = $plugin_files[0]; $file = $plugin_files[0];
$file = validate_file_to_edit($file, $plugin_files); $file = validate_file_to_edit($file, $plugin_files);
$real_file = get_real_file_to_edit( PLUGINDIR . "/$file"); $real_file = WP_PLUGIN_DIR . '/' . $file;
switch($action) { switch($action) {
@ -68,7 +68,7 @@ default:
require_once('admin-header.php'); require_once('admin-header.php');
update_recently_edited(PLUGINDIR . "/$file"); update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
if ( ! is_file($real_file) ) if ( ! is_file($real_file) )
$error = 1; $error = 1;

View File

@ -18,7 +18,7 @@ if ( isset($_GET['action']) ) {
wp_die($valid); wp_die($valid);
error_reporting( E_ALL ^ E_NOTICE ); error_reporting( E_ALL ^ E_NOTICE );
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed. @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
include(ABSPATH . PLUGINDIR . '/' . $plugin); include(WP_PLUGIN_DIR . '/' . $plugin);
} elseif ( 'deactivate' == $_GET['action'] ) { } elseif ( 'deactivate' == $_GET['action'] ) {
check_admin_referer('deactivate-plugin_' . $_GET['plugin']); check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
deactivate_plugins($_GET['plugin']); deactivate_plugins($_GET['plugin']);
@ -123,7 +123,7 @@ if (empty($plugins)) {
} else { } else {
$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>"; $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>";
} }
if ( current_user_can('edit_plugins') && is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) ) if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
$action_links[] = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>"; $action_links[] = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
$plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
@ -166,11 +166,11 @@ if (empty($plugins)) {
} }
?> ?>
<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> <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>
<h2><?php _e('Get More Plugins'); ?></h2> <h2><?php _e('Get More Plugins'); ?></h2>
<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> <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>
<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> <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>
</div> </div>

View File

@ -117,7 +117,7 @@ function do_plugin_upgrade($plugin) {
if ( is_wp_error($result) ) { if ( is_wp_error($result) ) {
show_message($result); show_message($result);
} else { } else {
//Result is the new plugin file relative to PLUGINDIR //Result is the new plugin file relative to WP_PLUGIN_DIR
show_message(__('Plugin upgraded successfully')); show_message(__('Plugin upgraded successfully'));
if( $result && $was_activated ){ if( $result && $was_activated ){
show_message(__('Attempting reactivation of the plugin')); show_message(__('Attempting reactivation of the plugin'));
@ -164,7 +164,7 @@ wp_admin_css( 'colors', true );
echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>'; echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>';
error_reporting( E_ALL ^ E_NOTICE ); error_reporting( E_ALL ^ E_NOTICE );
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed. @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
include(ABSPATH . PLUGINDIR . '/' . $plugin); include(WP_PLUGIN_DIR . '/' . $plugin);
} }
echo "</body></html>"; echo "</body></html>";
} }

View File

@ -665,7 +665,7 @@ function comments_template( $file = '/comments.php' ) {
if ( file_exists( $include ) ) if ( file_exists( $include ) )
require( $include ); require( $include );
else else
require( ABSPATH . 'wp-content/themes/default/comments.php'); require( WP_CONTENT_DIR . '/themes/default/comments.php');
} }
/** /**

View File

@ -1080,7 +1080,7 @@ function wp_upload_dir( $time = NULL ) {
$siteurl = get_option( 'siteurl' ); $siteurl = get_option( 'siteurl' );
$upload_path = get_option( 'upload_path' ); $upload_path = get_option( 'upload_path' );
if ( trim($upload_path) === '' ) if ( trim($upload_path) === '' )
$upload_path = 'wp-content/uploads'; $upload_path = WP_CONTENT_DIR . '/uploads';
$dir = $upload_path; $dir = $upload_path;
// $dir is absolute, $path is (maybe) relative to ABSPATH // $dir is absolute, $path is (maybe) relative to ABSPATH
@ -1558,8 +1558,8 @@ function wp_ob_end_flush_all() {
*/ */
function require_wp_db() { function require_wp_db() {
global $wpdb; global $wpdb;
if ( file_exists( ABSPATH . 'wp-content/db.php' ) ) if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
require_once( ABSPATH . 'wp-content/db.php' ); require_once( WP_CONTENT_DIR . '/db.php' );
else else
require_once( ABSPATH . WPINC . '/wp-db.php' ); require_once( ABSPATH . WPINC . '/wp-db.php' );
} }
@ -1568,8 +1568,8 @@ function dead_db() {
global $wpdb; global $wpdb;
// Load custom DB error template, if present. // Load custom DB error template, if present.
if ( file_exists( ABSPATH . 'wp-content/db-error.php' ) ) { if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
require_once( ABSPATH . 'wp-content/db-error.php' ); require_once( WP_CONTENT_DIR . '/db-error.php' );
die(); die();
} }

View File

@ -7,7 +7,7 @@ function get_header() {
if ( file_exists( TEMPLATEPATH . '/header.php') ) if ( file_exists( TEMPLATEPATH . '/header.php') )
load_template( TEMPLATEPATH . '/header.php'); load_template( TEMPLATEPATH . '/header.php');
else else
load_template( ABSPATH . 'wp-content/themes/default/header.php'); load_template( WP_CONTENT_DIR . '/themes/default/header.php');
} }
@ -16,7 +16,7 @@ function get_footer() {
if ( file_exists( TEMPLATEPATH . '/footer.php') ) if ( file_exists( TEMPLATEPATH . '/footer.php') )
load_template( TEMPLATEPATH . '/footer.php'); load_template( TEMPLATEPATH . '/footer.php');
else else
load_template( ABSPATH . 'wp-content/themes/default/footer.php'); load_template( WP_CONTENT_DIR . '/themes/default/footer.php');
} }
@ -27,7 +27,7 @@ function get_sidebar( $name = null ) {
elseif ( file_exists( TEMPLATEPATH . '/sidebar.php') ) elseif ( file_exists( TEMPLATEPATH . '/sidebar.php') )
load_template( TEMPLATEPATH . '/sidebar.php'); load_template( TEMPLATEPATH . '/sidebar.php');
else else
load_template( ABSPATH . 'wp-content/themes/default/sidebar.php'); load_template( WP_CONTENT_DIR . '/themes/default/sidebar.php');
} }

View File

@ -206,7 +206,7 @@ if ( $msie = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) {
} }
// Cache path, this is where the .gz files will be stored // Cache path, this is where the .gz files will be stored
$cache_path = ABSPATH . 'wp-content/uploads/js_cache'; $cache_path = WP_CONTENT_DIR . '/uploads/js_cache';
if ( $disk_cache && ! is_dir($cache_path) ) if ( $disk_cache && ! is_dir($cache_path) )
$disk_cache = wp_mkdir_p($cache_path); $disk_cache = wp_mkdir_p($cache_path);

View File

@ -278,7 +278,7 @@ function load_default_textdomain() {
* *
* The plugin may place all of the .mo files in another folder and set * The plugin may place all of the .mo files in another folder and set
* the $path based on the relative location from ABSPATH constant. The * the $path based on the relative location from ABSPATH constant. The
* plugin may use the constant PLUGINDIR and/or plugin_basename() to * plugin may use the constant WP_PLUGIN_DIR and/or plugin_basename() to
* get path of the plugin and then add the folder which holds the .mo * get path of the plugin and then add the folder which holds the .mo
* files. * files.
* *
@ -291,9 +291,9 @@ function load_plugin_textdomain($domain, $path = false) {
$locale = get_locale(); $locale = get_locale();
if ( false === $path ) if ( false === $path )
$path = PLUGINDIR; $path = WP_PLUGIN_DIR;
$mofile = ABSPATH . "$path/$domain-$locale.mo"; $mofile = $path . '/'. $domain . '-' . $locale . '.mo';
load_textdomain($domain, $mofile); load_textdomain($domain, $mofile);
} }

View File

@ -434,7 +434,7 @@ function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args
/** /**
* plugin_basename() - Gets the basename of a plugin. * plugin_basename() - Gets the basename of a plugin.
* *
* This method extract the name of a plugin from its filename. * This method extracts the name of a plugin from its filename.
* *
* @package WordPress * @package WordPress
* @subpackage Plugin * @subpackage Plugin
@ -444,11 +444,14 @@ function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args
* *
* @param string $file The filename of plugin. * @param string $file The filename of plugin.
* @return string The name of a plugin. * @return string The name of a plugin.
* @uses WP_PLUGIN_DIR
*/ */
function plugin_basename($file) { function plugin_basename($file) {
$file = str_replace('\\','/',$file); // sanitize for Win32 installs $file = str_replace('\\','/',$file); // sanitize for Win32 installs
$file = preg_replace('|/+|','/', $file); // remove any duplicate slash $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
$file = preg_replace('|^.*/' . PLUGINDIR . '/|','',$file); // get relative path from plugins dir $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
$plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
$file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir
return $file; return $file;
} }

View File

@ -651,11 +651,12 @@ function is_server_error ($sc) {
} }
class RSSCache { class RSSCache {
var $BASE_CACHE = 'wp-content/cache'; // where the cache files are stored var $BASE_CACHE; // where the cache files are stored
var $MAX_AGE = 43200; // when are files stale, default twelve hours var $MAX_AGE = 43200; // when are files stale, default twelve hours
var $ERROR = ''; // accumulate error messages var $ERROR = ''; // accumulate error messages
function RSSCache ($base='', $age='') { function RSSCache ($base='', $age='') {
$this->BASE_CACHE = WP_CONTENT_DIR . '/cache';
if ( $base ) { if ( $base ) {
$this->BASE_CACHE = $base; $this->BASE_CACHE = $base;
} }

View File

@ -333,11 +333,11 @@ function get_current_theme() {
} }
function get_theme_root() { function get_theme_root() {
return apply_filters('theme_root', ABSPATH . "wp-content/themes"); return apply_filters('theme_root', WP_CONTENT_DIR . "/themes");
} }
function get_theme_root_uri() { function get_theme_root_uri() {
return apply_filters('theme_root_uri', get_option('siteurl') . "/wp-content/themes", get_option('siteurl')); return apply_filters('theme_root_uri', WP_CONTENT_URL . "/themes", get_option('siteurl'));
} }
function get_query_template($type) { function get_query_template($type) {

View File

@ -100,7 +100,10 @@ if ( version_compare( '4.3', phpversion(), '>' ) ) {
die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.3.' ); die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.3.' );
} }
if ( !extension_loaded('mysql') && !file_exists(ABSPATH . 'wp-content/db.php') ) if ( !defined('WP_CONTENT_DIR') )
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') )
die( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ); die( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' );
/** /**
@ -166,7 +169,7 @@ if (defined('WP_DEBUG') and WP_DEBUG == true) {
// For an advanced caching plugin to use, static because you would only want one // For an advanced caching plugin to use, static because you would only want one
if ( defined('WP_CACHE') ) if ( defined('WP_CACHE') )
@include ABSPATH . 'wp-content/advanced-cache.php'; @include WP_CONTENT_DIR . '/advanced-cache.php';
/** /**
* Stores the location of the WordPress directory of functions, classes, and core content. * Stores the location of the WordPress directory of functions, classes, and core content.
@ -175,30 +178,28 @@ if ( defined('WP_CACHE') )
*/ */
define('WPINC', 'wp-includes'); define('WPINC', 'wp-includes');
if ( !defined('LANGDIR') ) { if ( !defined('WP_LANG_DIR') ) {
/** /**
* Stores the location of the language directory. First looks for language folder in wp-content * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR
* and uses that folder if it exists. Or it uses the "languages" folder in WPINC. * and uses that folder if it exists. Or it uses the "languages" folder in WPINC.
* *
* @since 2.1.0 * @since 2.1.0
*/ */
if ( file_exists(ABSPATH . 'wp-content/languages') && @is_dir(ABSPATH . 'wp-content/languages') ) if ( file_exists(WP_CONTENT_DIR . '/languages') && @is_dir(WP_CONTENT_DIR . '/languages') ) {
define('LANGDIR', 'wp-content/languages'); // no leading slash, no trailing slash define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
else if (!defined('LANGDIR')) {
define('LANGDIR', WPINC . '/languages'); // no leading slash, no trailing slash // Old static relative path maintained for limited backwards compatibility - won't work in some cases
define('LANGDIR', 'wp-content/languages');
}
} else {
define('WP_LANG_DIR', ABSPATH . WPINC . '/languages'); // no leading slash, no trailing slash, full path, not relative to ABSPATH
if (!defined('LANGDIR')) {
// Old relative path maintained for backwards compatibility
define('LANGDIR', WPINC . '/languages');
}
}
} }
/**
* Allows for the plugins directory to be moved from the default location.
*
* This isn't used everywhere. Constant is not used in plugin_basename()
* which might cause conflicts with changing this.
*
* @since 2.1
*/
if ( !defined('PLUGINDIR') )
define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash
require (ABSPATH . WPINC . '/compat.php'); require (ABSPATH . WPINC . '/compat.php');
require (ABSPATH . WPINC . '/functions.php'); require (ABSPATH . WPINC . '/functions.php');
require (ABSPATH . WPINC . '/classes.php'); require (ABSPATH . WPINC . '/classes.php');
@ -213,8 +214,8 @@ $prefix = $wpdb->set_prefix($table_prefix);
if ( is_wp_error($prefix) ) if ( is_wp_error($prefix) )
wp_die('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'); wp_die('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.');
if ( file_exists(ABSPATH . 'wp-content/object-cache.php') ) if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') )
require_once (ABSPATH . 'wp-content/object-cache.php'); require_once (WP_CONTENT_DIR . '/object-cache.php');
else else
require_once (ABSPATH . WPINC . '/cache.php'); require_once (ABSPATH . WPINC . '/cache.php');
@ -272,6 +273,21 @@ require (ABSPATH . WPINC . '/canonical.php');
require (ABSPATH . WPINC . '/shortcodes.php'); require (ABSPATH . WPINC . '/shortcodes.php');
require (ABSPATH . WPINC . '/media.php'); require (ABSPATH . WPINC . '/media.php');
if ( !defined('WP_CONTENT_URL') )
define( 'WP_CONTENT_URL', get_option('home') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
/**
* Allows for the plugins directory to be moved from the default location.
*
* @since 2.6
*/
if ( !defined('WP_PLUGIN_DIR') )
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
if ( !defined('WP_PLUGIN_URL') )
define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
if ( !defined('PLUGINDIR') )
define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
if ( ! defined('WP_INSTALLING') ) { if ( ! defined('WP_INSTALLING') ) {
// Used to guarantee unique hash cookies // Used to guarantee unique hash cookies
$cookiehash = md5(get_option('siteurl')); $cookiehash = md5(get_option('siteurl'));
@ -364,8 +380,8 @@ if ( get_option('active_plugins') ) {
$current_plugins = get_option('active_plugins'); $current_plugins = get_option('active_plugins');
if ( is_array($current_plugins) ) { if ( is_array($current_plugins) ) {
foreach ($current_plugins as $plugin) { foreach ($current_plugins as $plugin) {
if ('' != $plugin && file_exists(ABSPATH . PLUGINDIR . '/' . $plugin)) if ('' != $plugin && file_exists(WP_PLUGIN_DIR . '/' . $plugin))
include_once(ABSPATH . PLUGINDIR . '/' . $plugin); include_once(WP_PLUGIN_DIR . '/' . $plugin);
} }
} }
} }
@ -458,7 +474,7 @@ load_default_textdomain();
* @since 1.5.0 * @since 1.5.0
*/ */
$locale = get_locale(); $locale = get_locale();
$locale_file = ABSPATH . LANGDIR . "/$locale.php"; $locale_file = WP_LANG_DIR . "/$locale.php";
if ( is_readable($locale_file) ) if ( is_readable($locale_file) )
require_once($locale_file); require_once($locale_file);