Ticket #19235: 19235.diff
File 19235.diff, 13.8 KB (added by , 12 years ago) |
---|
-
wp-includes/functions.php
1436 1436 $siteurl = get_option( 'siteurl' ); 1437 1437 $upload_path = get_option( 'upload_path' ); 1438 1438 $upload_path = trim($upload_path); 1439 $main_override = is_multisite() && defined( 'MULTISITE' ) && is_main_site();1440 1439 if ( empty($upload_path) ) { 1441 1440 $dir = WP_CONTENT_DIR . '/uploads'; 1442 1441 } else { … … 1456 1455 $url = trailingslashit( $siteurl ) . $upload_path; 1457 1456 } 1458 1457 1459 if ( defined( 'UPLOADS') && !$main_override && ( !isset( $switched ) || $switched === false) ) {1458 if ( defined( 'UPLOADS' ) ) { 1460 1459 $dir = ABSPATH . UPLOADS; 1461 1460 $url = trailingslashit( $siteurl ) . UPLOADS; 1462 }1463 1461 1464 if ( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) { 1465 if ( defined( 'BLOGUPLOADDIR' ) ) 1466 $dir = untrailingslashit(BLOGUPLOADDIR); 1467 $url = str_replace( UPLOADS, 'files', $url ); 1462 // If multisite, we're not switched, and we're not on the main site (for post-MU networks), append sites/ID 1463 if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) && empty( $switched ) ) { 1464 $dir .= '/sites/' . $blog_id; 1465 $url .= '/sites/' . $blog_id; 1466 } 1468 1467 } 1469 1468 1470 1469 $bdir = $dir; -
wp-includes/ms-default-constants.php
12 12 * 13 13 * @since 3.0.0 14 14 */ 15 function ms_upload_constants( ) { 16 global $wpdb; 15 function ms_upload_constants() {} 17 16 18 /** @since 3.0.0 */19 // Base uploads dir relative to ABSPATH20 if ( !defined( 'UPLOADBLOGSDIR' ) )21 define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );22 23 /** @since 3.0.0 */24 if ( !defined( 'UPLOADS' ) ) {25 // Uploads dir relative to ABSPATH26 define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );27 if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR )28 define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );29 }30 }31 32 17 /** 33 18 * Defines Multisite cookie constants. 34 19 * -
wp-includes/ms-functions.php
1154 1154 // fix url. 1155 1155 update_option('siteurl', $url); 1156 1156 update_option('home', $url); 1157 update_option('fileupload_url', $url . "/files" ); 1158 update_option('upload_path', UPLOADBLOGSDIR . "/$blog_id/files");1157 1158 update_option('upload_path', "wp-content/uploads/sites/$blog_id"); // Don't know how this should be calculated. 1159 1159 update_option('blogname', stripslashes( $blog_title ) ); 1160 1160 update_option('admin_email', ''); 1161 1161 $wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') ); -
wp-admin/network.php
15 15 /** WordPress Administration Bootstrap */ 16 16 require_once( './admin.php' ); 17 17 18 function ms_files_rewriting_enabled() { return false; } 19 18 20 if ( ! is_super_admin() ) 19 21 wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); 20 22 … … 106 108 $network_help = '<p>' . __('This screen allows you to configure a network as having subdomains (<code>site1.example.com</code>) or subdirectories (<code>example.com/site1</code>). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '</p>' . 107 109 '<p>' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '</p>' . 108 110 '<p>' . __('The next screen for Network Setup will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '</p>' . 109 '<p>' . __('Add a <code>blogs.dir</code> directory under <code>/wp-content</code> and addthe designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .111 '<p>' . __('Add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' . 110 112 '<p>' . __('Once you add this code and refresh your browser, multisite should be enabled. This screen, now in the Network Admin navigation menu, will keep an archive of the added code. You can toggle between Network Admin and Site Admin by clicking on the Network Admin or an individual site name under the My Sites dropdown in the Toolbar.') . '</p>' . 111 113 '<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with “/blog/” from the main site. This disabling will be addressed in a future version.') . '</p>' . 112 114 '<p><strong>' . __('For more information:') . '</strong></p>' . … … 360 362 } 361 363 ?> 362 364 <ol> 363 <li><p><?php 364 printf( __( 'Create a <code>blogs.dir</code> directory at <code>%s/blogs.dir</code>. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); 365 if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' ) 366 echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong>'; 367 ?></p></li> 365 <?php 366 if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' ) 367 echo '<li><p><strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p></li>'; 368 ?> 368 369 <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That’s all, stop editing! Happy blogging. */</code>:' ), ABSPATH ); ?></p> 369 370 <textarea class="code" readonly="readonly" cols="100" rows="7"> 370 371 define('MULTISITE', true); … … 415 416 <rule name="WordPress Rule 1" stopProcessing="true"> 416 417 <match url="^index\.php$" ignoreCase="false" /> 417 418 <action type="None" /> 418 </rule> 419 <rule name="WordPress Rule 2" stopProcessing="true"> 419 </rule>'; 420 if ( ms_files_rewriting_enabled() ) { 421 $web_config_file .= ' 422 <rule name="WordPress Rule for Files" stopProcessing="true"> 420 423 <match url="^files/(.+)" ignoreCase="false" /> 421 424 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" /> 422 </rule> 423 <rule name="WordPress Rule 3" stopProcessing="true"> 425 </rule>'; 426 } 427 $web_config_file .= ' 428 <rule name="WordPress Rule 2" stopProcessing="true"> 424 429 <match url="^" ignoreCase="false" /> 425 430 <conditions logicalGrouping="MatchAny"> 426 431 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> … … 428 433 </conditions> 429 434 <action type="None" /> 430 435 </rule> 431 <rule name="WordPress Rule 4" stopProcessing="true">436 <rule name="WordPress Rule 3" stopProcessing="true"> 432 437 <match url="." ignoreCase="false" /> 433 438 <action type="Rewrite" url="index.php" /> 434 439 </rule> … … 446 451 <rule name="WordPress Rule 1" stopProcessing="true"> 447 452 <match url="^index\.php$" ignoreCase="false" /> 448 453 <action type="None" /> 449 </rule> 454 </rule>'; 455 if ( ms_files_rewriting_enabled() ) { 456 $web_config_file .= ' 457 <rule name="WordPress Rule for Files" stopProcessing="true"> 458 <match url="^files/(.+)" ignoreCase="false" /> 459 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" /> 460 </rule>'; 461 } 462 $web_config_file .= ' 450 463 <rule name="WordPress Rule 2" stopProcessing="true"> 451 <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />452 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />453 </rule>454 <rule name="WordPress Rule 3" stopProcessing="true">455 464 <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" /> 456 465 <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" /> 457 466 </rule> 458 <rule name="WordPress Rule 4" stopProcessing="true">467 <rule name="WordPress Rule 3" stopProcessing="true"> 459 468 <match url="^" ignoreCase="false" /> 460 469 <conditions logicalGrouping="MatchAny"> 461 470 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> … … 463 472 </conditions> 464 473 <action type="None" /> 465 474 </rule> 466 <rule name="WordPress Rule 5" stopProcessing="true">475 <rule name="WordPress Rule 4" stopProcessing="true"> 467 476 <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" /> 468 477 <action type="Rewrite" url="{R:1}" /> 469 478 </rule> 470 <rule name="WordPress Rule 6" stopProcessing="true">479 <rule name="WordPress Rule 5" stopProcessing="true"> 471 480 <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> 472 481 <action type="Rewrite" url="{R:2}" /> 473 482 </rule> 474 <rule name="WordPress Rule 7" stopProcessing="true">483 <rule name="WordPress Rule 6" stopProcessing="true"> 475 484 <match url="." ignoreCase="false" /> 476 485 <action type="Rewrite" url="index.php" /> 477 486 </rule> … … 491 500 492 501 $htaccess_file = 'RewriteEngine On 493 502 RewriteBase ' . $base . ' 494 RewriteRule ^index\.php$ - [L] 503 RewriteRule ^index\.php$ - [L]' . "\n"; 495 504 496 # uploaded files 497 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n"; 505 if ( ms_files_rewriting_enabled() ) { 506 $htaccess_file .= "\n\n# uploaded files\nRewriteRule ^"; 507 $htaccess_file .= ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n"; 508 } 498 509 499 510 if ( ! $subdomain_install ) 500 511 $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n"; … … 511 522 512 523 ?> 513 524 <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p> 514 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">525 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>"> 515 526 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li> 516 527 </ol> 517 528 -
wp-admin/includes/schema.php
932 932 $upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads'; 933 933 update_option( 'upload_path', $upload_path ); 934 934 } 935 update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );936 935 } 937 936 938 937 if ( $subdomain_install ) -
wp-admin/includes/ms.php
90 90 91 91 $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) ); 92 92 93 $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id ); 93 $uploads = wp_upload_dir(); 94 $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id ); 94 95 $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); 95 96 $top_dir = $dir; 96 97 $stack = array($dir); … … 347 348 function get_space_used() { 348 349 // Allow for an alternative way of tracking storage space used 349 350 $space_used = apply_filters( 'pre_get_space_used', false ); 350 if ( false === $space_used ) 351 $space_used = get_dirsize( BLOGUPLOADDIR ); 351 if ( false === $space_used ) { 352 $upload_dir = wp_upload_dir(); 353 $space_used = get_dirsize( $upload_dir['basedir'] ); 354 } 352 355 353 356 return $space_used; 354 357 } … … 665 668 <?php 666 669 } 667 670 668 function ms_deprecated_blogs_file() {669 if ( ! is_super_admin() )670 return;671 if ( ! file_exists( WP_CONTENT_DIR . '/blogs.php' ) )672 return;673 echo '<div class="update-nag">' . sprintf( __( 'The <code>%1$s</code> file is deprecated. Please remove it and update your server rewrite rules to use <code>%2$s</code> instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '</div>';674 }675 add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' );676 677 671 /** 678 672 * Grants super admin privileges. 679 673 *