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 , 17 years ago) |
---|
-
wp-includes/plugin.php
434 434 /** 435 435 * plugin_basename() - Gets the basename of a plugin. 436 436 * 437 * This method extract the name of a plugin from its filename.437 * This method extracts the name of a plugin from its filename. 438 438 * 439 439 * @package WordPress 440 440 * @subpackage Plugin … … 444 444 * 445 445 * @param string $file The filename of plugin. 446 446 * @return string The name of a plugin. 447 * @uses WP_PLUGIN_DIR 447 448 */ 448 449 function plugin_basename($file) { 449 450 $file = str_replace('\\','/',$file); // sanitize for Win32 installs 450 451 $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 452 455 return $file; 453 456 } 454 457 -
wp-includes/js/tinymce/tiny_mce_config.php
206 206 } 207 207 208 208 // 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'; 210 210 if ( $disk_cache && ! is_dir($cache_path) ) 211 211 $disk_cache = wp_mkdir_p($cache_path); 212 212 -
wp-includes/theme.php
333 333 } 334 334 335 335 function get_theme_root() { 336 return apply_filters('theme_root', ABSPATH . "wp-content/themes");336 return apply_filters('theme_root', WP_CONTENT_DIR . "/themes"); 337 337 } 338 338 339 339 function 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')); 341 341 } 342 342 343 343 function get_query_template($type) { -
wp-includes/functions.php
1080 1080 $siteurl = get_option( 'siteurl' ); 1081 1081 $upload_path = get_option( 'upload_path' ); 1082 1082 if ( trim($upload_path) === '' ) 1083 $upload_path = 'wp-content/uploads';1083 $upload_path = WP_CONTENT_DIR . '/uploads'; 1084 1084 $dir = $upload_path; 1085 1085 1086 1086 // $dir is absolute, $path is (maybe) relative to ABSPATH … … 1558 1558 */ 1559 1559 function require_wp_db() { 1560 1560 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' ); 1563 1563 else 1564 1564 require_once( ABSPATH . WPINC . '/wp-db.php' ); 1565 1565 } … … 1568 1568 global $wpdb; 1569 1569 1570 1570 // 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' ); 1573 1573 die(); 1574 1574 } 1575 1575 -
wp-includes/l10n.php
278 278 * 279 279 * The plugin may place all of the .mo files in another folder and set 280 280 * the $path based on the relative location from ABSPATH constant. The 281 * plugin may use the constant PLUGINDIR and/or plugin_basename() to281 * plugin may use the constant WP_PLUGIN_DIR and/or plugin_basename() to 282 282 * get path of the plugin and then add the folder which holds the .mo 283 283 * files. 284 284 * … … 291 291 $locale = get_locale(); 292 292 293 293 if ( false === $path ) 294 $path = PLUGINDIR;294 $path = WP_PLUGIN_DIR; 295 295 296 $mofile = ABSPATH . "$path/$domain-$locale.mo";296 $mofile = $path . '/'. $domain . '-' . $locale . '.mo'; 297 297 load_textdomain($domain, $mofile); 298 298 } 299 299 -
wp-includes/comment-template.php
665 665 if ( file_exists( $include ) ) 666 666 require( $include ); 667 667 else 668 require( ABSPATH . 'wp-content/themes/default/comments.php');668 require( WP_CONTENT_DIR . '/themes/default/comments.php'); 669 669 } 670 670 671 671 /** -
wp-includes/general-template.php
7 7 if ( file_exists( TEMPLATEPATH . '/header.php') ) 8 8 load_template( TEMPLATEPATH . '/header.php'); 9 9 else 10 load_template( ABSPATH . 'wp-content/themes/default/header.php');10 load_template( WP_CONTENT_DIR . '/themes/default/header.php'); 11 11 } 12 12 13 13 … … 16 16 if ( file_exists( TEMPLATEPATH . '/footer.php') ) 17 17 load_template( TEMPLATEPATH . '/footer.php'); 18 18 else 19 load_template( ABSPATH . 'wp-content/themes/default/footer.php');19 load_template( WP_CONTENT_DIR . '/themes/default/footer.php'); 20 20 } 21 21 22 22 … … 27 27 elseif ( file_exists( TEMPLATEPATH . '/sidebar.php') ) 28 28 load_template( TEMPLATEPATH . '/sidebar.php'); 29 29 else 30 load_template( ABSPATH . 'wp-content/themes/default/sidebar.php');30 load_template( WP_CONTENT_DIR . '/themes/default/sidebar.php'); 31 31 } 32 32 33 33 -
wp-includes/rss.php
651 651 } 652 652 653 653 class RSSCache { 654 var $BASE_CACHE = 'wp-content/cache'; // where the cache files are stored654 var $BASE_CACHE; // where the cache files are stored 655 655 var $MAX_AGE = 43200; // when are files stale, default twelve hours 656 656 var $ERROR = ''; // accumulate error messages 657 657 658 658 function RSSCache ($base='', $age='') { 659 $this->BASE_CACHE = WP_CONTENT_DIR . '/cache'; 659 660 if ( $base ) { 660 661 $this->BASE_CACHE = $base; 661 662 } -
wp-settings.php
100 100 die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.3.' ); 101 101 } 102 102 103 if ( !extension_loaded('mysql') && !file_exists(ABSPATH . 'wp-content/db.php') ) 103 if ( !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 106 if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') ) 104 107 die( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ); 105 108 106 109 /** … … 166 169 167 170 // For an advanced caching plugin to use, static because you would only want one 168 171 if ( defined('WP_CACHE') ) 169 @include ABSPATH . 'wp-content/advanced-cache.php';172 @include WP_CONTENT_DIR . '/advanced-cache.php'; 170 173 171 174 /** 172 175 * Stores the location of the WordPress directory of functions, classes, and core content. … … 175 178 */ 176 179 define('WPINC', 'wp-includes'); 177 180 178 if ( !defined(' LANGDIR') ) {181 if ( !defined('WP_LANG_DIR') ) { 179 182 /** 180 * Stores the location of the language directory. First looks for language folder in wp-content183 * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR 181 184 * and uses that folder if it exists. Or it uses the "languages" folder in WPINC. 182 185 * 183 186 * @since 2.1.0 184 187 */ 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 } 189 201 } 190 202 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.1198 */199 if ( !defined('PLUGINDIR') )200 define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash201 202 203 require (ABSPATH . WPINC . '/compat.php'); 203 204 require (ABSPATH . WPINC . '/functions.php'); 204 205 require (ABSPATH . WPINC . '/classes.php'); … … 213 214 if ( is_wp_error($prefix) ) 214 215 wp_die('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'); 215 216 216 if ( file_exists( ABSPATH . 'wp-content/object-cache.php') )217 require_once ( ABSPATH . 'wp-content/object-cache.php');217 if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) 218 require_once (WP_CONTENT_DIR . '/object-cache.php'); 218 219 else 219 220 require_once (ABSPATH . WPINC . '/cache.php'); 220 221 … … 272 273 require (ABSPATH . WPINC . '/shortcodes.php'); 273 274 require (ABSPATH . WPINC . '/media.php'); 274 275 276 if ( !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 */ 284 if ( !defined('WP_PLUGIN_DIR') ) 285 define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash 286 if ( !defined('WP_PLUGIN_URL') ) 287 define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash 288 if ( !defined('PLUGINDIR') ) 289 define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat. 290 275 291 if ( ! defined('WP_INSTALLING') ) { 276 292 // Used to guarantee unique hash cookies 277 293 $cookiehash = md5(get_option('siteurl')); … … 357 373 $current_plugins = get_option('active_plugins'); 358 374 if ( is_array($current_plugins) ) { 359 375 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); 362 378 } 363 379 } 364 380 } … … 451 467 * @since 1.5.0 452 468 */ 453 469 $locale = get_locale(); 454 $locale_file = ABSPATH . LANGDIR . "/$locale.php";470 $locale_file = WP_LANG_DIR . "/$locale.php"; 455 471 if ( is_readable($locale_file) ) 456 472 require_once($locale_file); 457 473 -
wp-admin/menu-header.php
19 19 if ( !empty($submenu[$item[2]]) ) { 20 20 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 21 21 $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)) 23 23 echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 24 24 else 25 25 echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 26 26 } else if ( current_user_can($item[1]) ) { 27 27 $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) ) 29 29 echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; 30 30 else 31 31 echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; … … 49 49 if ( !empty($submenu[$item[2]]) ) { 50 50 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 51 51 $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)) 53 53 echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 54 54 else 55 55 echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 56 56 } else if ( current_user_can($item[1]) ) { 57 57 $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) ) 59 59 echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; 60 60 else 61 61 echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; … … 74 74 if ( !empty($submenu[$item[2]]) ) { 75 75 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 76 76 $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)) 78 78 echo "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 79 79 else 80 80 echo "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a></li>"; 81 81 } else if ( current_user_can($item[1]) ) { 82 82 $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) ) 84 84 echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; 85 85 else 86 86 echo "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a></li>"; … … 106 106 if ( !empty($submenu[$item[2]]) ) { 107 107 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 108 108 $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)) 110 110 $side_items[] = "\n\t<li><a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; 111 111 else 112 112 $side_items[] = "\n\t<li><a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; 113 113 } else if ( current_user_can($item[1]) ) { 114 114 $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) ) 116 116 $side_items[] = "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a>"; 117 117 else 118 118 $side_items[] = "\n\t<li><a href='{$item[2]}'$class>{$item[0]}</a>"; … … 143 143 144 144 $menu_hook = get_plugin_page_hook($item[2], $parent_file); 145 145 146 if (file_exists( ABSPATH . PLUGINDIR . "/{$item[2]}") || ! empty($menu_hook)) {146 if (file_exists(WP_PLUGIN_DIR . "/{$item[2]}") || ! empty($menu_hook)) { 147 147 if ( 'admin.php' == $pagenow ) 148 148 echo "\n\t<li><a href='admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; 149 149 else -
wp-admin/includes/class-wp-filesystem-ftpsockets.php
86 86 $this->permission = $perm; 87 87 } 88 88 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 90 93 //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 driveletter93 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]; 95 98 } 96 99 97 100 //Set up the base directory (Which unless specified, is the current one) … … 99 102 $base = trailingslashit($base); 100 103 101 104 //Can we see the Current directory as part of the ABSPATH? 102 $location = strpos($ abspath, $base);105 $location = strpos($path, $base); 103 106 if( false !== $location ) { 104 $newbase = path_join($base, substr($ abspath, $location + strlen($base)));107 $newbase = path_join($base, substr($path, $location + strlen($base))); 105 108 106 109 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. 107 110 if($echo) printf( __('Changing to %s') . '<br/>', $newbase ); … … 118 121 //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture. 119 122 $files = $this->dirlist($base); 120 123 121 $arrPath = explode('/', $ abspath);124 $arrPath = explode('/', $path); 122 125 foreach($arrPath as $key){ 123 126 //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, 124 127 // If its found, change into it and follow through looking for it. … … 128 131 //Lets try that folder: 129 132 $folder = path_join($base, $key); 130 133 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); 132 135 if( $ret ) 133 136 return $ret; 134 137 } … … 141 144 if( $loop ) 142 145 return false;//Prevent tihs function looping again. 143 146 //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); 145 148 } 146 149 147 function get_base_dir($ base = '.', $echo = false){150 function get_base_dir($path = false, $base = '.', $echo = false){ 148 151 if( defined('FTP_BASE') ) 149 152 $this->wp_base = FTP_BASE; 150 153 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); 152 155 return $this->wp_base; 153 156 } 154 157 -
wp-admin/includes/plugin.php
39 39 } 40 40 41 41 $wp_plugins = array (); 42 $plugin_root = ABSPATH . PLUGINDIR;42 $plugin_root = WP_PLUGIN_DIR; 43 43 if( !empty($plugin_folder) ) 44 44 $plugin_root .= $plugin_folder; 45 45 … … 104 104 if ( !empty($redirect) ) 105 105 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 106 106 ob_start(); 107 @include( ABSPATH . PLUGINDIR . '/' . $plugin);107 @include(WP_PLUGIN_DIR . '/' . $plugin); 108 108 $current[] = $plugin; 109 109 sort($current); 110 110 update_option('active_plugins', $current); … … 179 179 // If a plugin file does not exist, remove it from the list of active 180 180 // plugins. 181 181 foreach ( $check_plugins as $check_plugin ) { 182 if ( !file_exists( ABSPATH . PLUGINDIR . '/' . $check_plugin) ) {182 if ( !file_exists(WP_PLUGIN_DIR . '/' . $check_plugin) ) { 183 183 $current = get_option('active_plugins'); 184 184 $key = array_search($check_plugin, $current); 185 185 if ( false !== $key && NULL !== $key ) { … … 193 193 function validate_plugin($plugin) { 194 194 if ( validate_file($plugin) ) 195 195 return new WP_Error('plugin_invalid', __('Invalid plugin.')); 196 if ( ! file_exists( ABSPATH . PLUGINDIR . '/' . $plugin) )196 if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) ) 197 197 return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); 198 198 199 199 return 0; -
wp-admin/includes/schema.php
226 226 if ( ini_get('safe_mode') ) { 227 227 // Safe mode screws up mkdir(), so we must use a flat structure. 228 228 add_option('uploads_use_yearmonth_folders', 0); 229 add_option('upload_path', 'wp-content');229 add_option('upload_path', WP_CONTENT_DIR); 230 230 } else { 231 231 add_option('uploads_use_yearmonth_folders', 1); 232 add_option('upload_path', 'wp-content/uploads');232 add_option('upload_path', WP_CONTENT_DIR . '/uploads'); 233 233 } 234 234 235 235 // 2.0.3 -
wp-admin/includes/file.php
46 46 if ( defined('WP_TEMP_DIR') ) 47 47 return trailingslashit(WP_TEMP_DIR); 48 48 49 $temp = ABSPATH . 'wp-content/';49 $temp = WP_CONTENT_DIR . '/'; 50 50 if ( is_dir($temp) && is_writable($temp) ) 51 51 return $temp; 52 52 -
wp-admin/includes/update.php
159 159 if ( $wp_filesystem->errors->get_error_code() ) 160 160 return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); 161 161 162 //Get the Basefolder163 $base = $wp_filesystem->get_base_dir( );162 //Get the base plugin folder 163 $base = $wp_filesystem->get_base_dir(WP_PLUGIN_DIR); 164 164 165 165 if ( empty($base) ) 166 166 return new WP_Error('fs_nowordpress', __('Unable to locate WordPress directory.')); … … 179 179 if ( is_wp_error($file) ) 180 180 return new WP_Error('download_failed', __('Download failed.'), $file->get_error_message()); 181 181 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'); 183 183 184 184 // Clean up working directory 185 185 if ( $wp_filesystem->is_dir($working_dir) ) … … 205 205 206 206 // Remove the existing plugin. 207 207 apply_filters('update_feedback', __('Removing the old version of the plugin')); 208 $plugin_dir = dirname($base . PLUGINDIR ."/$plugin");208 $plugin_dir = dirname($base . "/$plugin"); 209 209 $plugin_dir = trailingslashit($plugin_dir); 210 210 211 211 // 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 folder212 if ( strpos($plugin, '/') && $plugin_dir != $base . '/' ) //base check on if plugin includes directory seperator AND that its not the root plugin folder 213 213 $deleted = $wp_filesystem->delete($plugin_dir, true); 214 214 else 215 $deleted = $wp_filesystem->delete($base . PLUGINDIR . "/$plugin");215 $deleted = $wp_filesystem->delete($base . '/' . $plugin); 216 216 217 217 if ( !$deleted ) { 218 218 $wp_filesystem->delete($working_dir, true); … … 221 221 222 222 apply_filters('update_feedback', __('Installing the latest version')); 223 223 // Copy new version of plugin into place. 224 if ( !copy_dir($working_dir, $base . PLUGINDIR) ) {224 if ( !copy_dir($working_dir, $base) ) { 225 225 //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails. 226 226 return new WP_Error('install_failed', __('Installation failed')); 227 227 } -
wp-admin/includes/class-wp-filesystem-ftpext.php
84 84 $this->permission = $perm; 85 85 } 86 86 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 88 91 //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 driveletter91 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]; 93 96 } 94 97 95 98 //Set up the base directory (Which unless specified, is the current one) … … 97 100 $base = trailingslashit($base); 98 101 99 102 //Can we see the Current directory as part of the ABSPATH? 100 $location = strpos($ abspath, $base);103 $location = strpos($path, $base); 101 104 if( false !== $location ) { 102 $newbase = path_join($base, substr($ abspath, $location + strlen($base)));105 $newbase = path_join($base, substr($path, $location + strlen($base))); 103 106 104 107 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. 105 108 if($echo) printf( __('Changing to %s') . '<br/>', $newbase ); … … 116 119 //Get a list of the files in the current directory, See if we can locate where we are in the folder stucture. 117 120 $files = $this->dirlist($base); 118 121 119 $arrPath = explode('/', $ abspath);122 $arrPath = explode('/', $path); 120 123 foreach($arrPath as $key){ 121 124 //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder, 122 125 // If its found, change into it and follow through looking for it. … … 126 129 //Lets try that folder: 127 130 $folder = path_join($base, $key); 128 131 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); 130 133 if( $ret ) 131 134 return $ret; 132 135 } … … 139 142 if( $loop ) 140 143 return false;//Prevent tihs function looping again. 141 144 //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); 143 146 } 144 147 145 function get_base_dir($ base = '.', $echo = false){148 function get_base_dir($path = false, $base = '.', $echo = false){ 146 149 if( defined('FTP_BASE') ) 147 150 $this->wp_base = FTP_BASE; 148 151 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); 150 153 return $this->wp_base; 151 154 } 152 155 function get_contents($file,$type='',$resumepos=0){ -
wp-admin/includes/class-wp-filesystem-direct.php
13 13 function setDefaultPermissions($perm){ 14 14 $this->permission = $perm; 15 15 } 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); 18 20 } 19 function get_base_dir($ base = '.', $echo = false){21 function get_base_dir($path = false, $base = '.', $echo = false){ 20 22 return $this->find_base_dir($base, $echo); 21 23 } 22 24 function get_contents($file){ -
wp-admin/includes/upgrade.php
1 1 <?php 2 2 3 if ( file_exists( ABSPATH . 'wp-content/install.php') )4 require ( ABSPATH . 'wp-content/install.php');3 if ( file_exists(WP_CONTENT_DIR . '/install.php') ) 4 require (WP_CONTENT_DIR . '/install.php'); 5 5 require_once(ABSPATH . 'wp-admin/includes/admin.php'); 6 6 require_once(ABSPATH . 'wp-admin/includes/schema.php'); 7 7 … … 1086 1086 1087 1087 function make_site_theme_from_oldschool($theme_name, $template) { 1088 1088 $home_path = get_home_path(); 1089 $site_dir = ABSPATH . "wp-content/themes/$template";1089 $site_dir = WP_CONTENT_DIR . "/themes/$template"; 1090 1090 1091 1091 if (! file_exists("$home_path/index.php")) 1092 1092 return false; … … 1105 1105 if ($oldfile == 'index.php') { // Check to make sure it's not a new index 1106 1106 $index = implode('', file("$oldpath/$oldfile")); 1107 1107 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")) 1109 1109 return false; 1110 1110 continue; // Don't copy anything 1111 1111 } … … 1153 1153 } 1154 1154 1155 1155 function 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'; 1158 1158 1159 1159 // Copy files from the default theme to the site theme. 1160 1160 //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css'); … … 1211 1211 // Name the theme after the blog. 1212 1212 $theme_name = __get_option('blogname'); 1213 1213 $template = sanitize_title($theme_name); 1214 $site_dir = ABSPATH . "wp-content/themes/$template";1214 $site_dir = WP_CONTENT_DIR . "/themes/$template"; 1215 1215 1216 1216 // If the theme already exists, nothing to do. 1217 1217 if ( is_dir($site_dir)) { … … 1219 1219 } 1220 1220 1221 1221 // 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")) { 1223 1223 return false; 1224 1224 } 1225 1225 -
wp-admin/update.php
117 117 if ( is_wp_error($result) ) { 118 118 show_message($result); 119 119 } else { 120 //Result is the new plugin file relative to PLUGINDIR120 //Result is the new plugin file relative to WP_PLUGIN_DIR 121 121 show_message(__('Plugin upgraded successfully')); 122 122 if( $result && $was_activated ){ 123 123 show_message(__('Attempting reactivation of the plugin')); … … 164 164 echo '<p>' . __('Plugin failed to reactivate due to a fatal error.') . '</p>'; 165 165 error_reporting( E_ALL ^ E_NOTICE ); 166 166 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. 167 include( ABSPATH . PLUGINDIR . '/' . $plugin);167 include(WP_PLUGIN_DIR . '/' . $plugin); 168 168 } 169 169 echo "</body></html>"; 170 170 } -
wp-admin/admin.php
58 58 wp_die(__('Invalid plugin page')); 59 59 } 60 60 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") ) ) 62 62 wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); 63 63 64 64 do_action('load-' . $plugin_page); … … 66 66 if (! isset($_GET['noheader'])) 67 67 require_once(ABSPATH . 'wp-admin/admin-header.php'); 68 68 69 include( ABSPATH . PLUGINDIR . "/$plugin_page");69 include(WP_PLUGIN_DIR . "/$plugin_page"); 70 70 } 71 71 72 72 include(ABSPATH . 'wp-admin/admin-footer.php'); -
wp-admin/import/mt.php
179 179 180 180 function select_authors() { 181 181 if ( $_POST['upload_type'] === 'ftp' ) { 182 $file['file'] = ABSPATH . 'wp-content/mt-export.txt';182 $file['file'] = WP_CONTENT_DIR . '/mt-export.txt'; 183 183 if ( !file_exists($file['file']) ) 184 184 $file['error'] = __('<code>mt-export.txt</code> does not exist'); 185 185 } else { … … 426 426 function import() { 427 427 $this->id = (int) $_GET['id']; 428 428 if ( $this->id == 0 ) 429 $this->file = ABSPATH . 'wp-content/mt-export.txt';429 $this->file = WP_CONTENT_DIR . '/mt-export.txt'; 430 430 else 431 431 $this->file = get_attached_file($this->id); 432 432 $this->get_authors_from_post(); -
wp-admin/plugins.php
18 18 wp_die($valid); 19 19 error_reporting( E_ALL ^ E_NOTICE ); 20 20 @ini_set('display_errors', true); //Ensure that Fatal errors are displayed. 21 include( ABSPATH . PLUGINDIR . '/' . $plugin);21 include(WP_PLUGIN_DIR . '/' . $plugin); 22 22 } elseif ( 'deactivate' == $_GET['action'] ) { 23 23 check_admin_referer('deactivate-plugin_' . $_GET['plugin']); 24 24 deactivate_plugins($_GET['plugin']); … … 123 123 } else { 124 124 $action_links[] = "<a href='" . wp_nonce_url("plugins.php?action=activate&plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>"; 125 125 } 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) ) 127 127 $action_links[] = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>"; 128 128 129 129 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); … … 166 166 } 167 167 ?> 168 168 169 <p><?php printf(__('If something goes wrong with a plugin and you can’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’t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), WP_PLUGIN_DIR); ?></p> 170 170 171 171 <h2><?php _e('Get More Plugins'); ?></h2> 172 172 <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> 174 174 175 175 </div> 176 176 -
wp-admin/plugin-editor.php
15 15 $file = $plugin_files[0]; 16 16 17 17 $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; 19 19 20 20 switch($action) { 21 21 … … 68 68 69 69 require_once('admin-header.php'); 70 70 71 update_recently_edited( PLUGINDIR . "/$file");71 update_recently_edited(WP_PLUGIN_DIR . '/' . $file); 72 72 73 73 if ( ! is_file($real_file) ) 74 74 $error = 1;