Check the appropriate radio option on the Permalinks page for the Root blog; Display index.php prefixes properly for the root Multisite Blog. Fixes #12952

git-svn-id: http://svn.automattic.com/wordpress/trunk@14051 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-04-10 11:30:34 +00:00
parent 880b27ee2b
commit 1c688ceead
1 changed files with 27 additions and 30 deletions

View File

@ -75,36 +75,33 @@ include('admin-header.php');
$home_path = get_home_path(); $home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks(); $iis7_permalinks = iis7_supports_permalinks();
$prefix = '';
if ( ! got_mod_rewrite() && ! $iis7_permalinks )
$prefix .= '/index.php';
if ( is_multisite() && !is_subdomain_install() && is_main_site() )
$prefix .= '/blog';
if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
check_admin_referer('update-permalink'); check_admin_referer('update-permalink');
if ( isset( $_POST['permalink_structure'] ) ) { if ( isset( $_POST['permalink_structure'] ) ) {
$permalink_structure = $_POST['permalink_structure']; $permalink_structure = $_POST['permalink_structure'];
if ( ! empty( $permalink_structure ) ) { if ( ! empty( $permalink_structure ) )
$permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) ); $permalink_structure = $prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
if ( is_multisite() && ! is_subdomain_install() && is_main_site() )
$permalink_structure = '/blog' . $permalink_structure;
}
$wp_rewrite->set_permalink_structure( $permalink_structure ); $wp_rewrite->set_permalink_structure( $permalink_structure );
} }
if ( isset( $_POST['category_base'] ) ) { if ( isset( $_POST['category_base'] ) ) {
$category_base = $_POST['category_base']; $category_base = $_POST['category_base'];
if (! empty( $category_base ) ) { if ( ! empty( $category_base ) )
$category_base = preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) ); $category_base = $prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
if ( is_multisite() && ! is_subdomain_install() && is_main_site() )
$category_base = '/blog' . $category_base;
}
$wp_rewrite->set_category_base( $category_base ); $wp_rewrite->set_category_base( $category_base );
} }
if ( isset( $_POST['tag_base'] ) ) { if ( isset( $_POST['tag_base'] ) ) {
$tag_base = $_POST['tag_base']; $tag_base = $_POST['tag_base'];
if ( ! empty( $tag_base ) ) { if ( ! empty( $tag_base ) )
$tag_base = preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) ); $tag_base = $prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
if ( is_multisite() && ! is_subdomain_install() && is_main_site() )
$tag_base = '/blog' . $tag_base;
}
$wp_rewrite->set_tag_base( $tag_base ); $wp_rewrite->set_tag_base( $tag_base );
} }
} }
@ -166,16 +163,20 @@ if ( ! is_multisite() ) {
<p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p> <p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
<?php <?php
$prefix = '';
if ( ! got_mod_rewrite() && ! $iis7_permalinks ) if ( ! got_mod_rewrite() && ! $iis7_permalinks )
$prefix = '/index.php'; $permalink_structure = preg_replace( '|^/?index\.php|', '', $permalink_structure );
if ( is_multisite() && !is_subdomain_install() && is_main_site() ) {
$permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure );
$category_base = preg_replace( '|^/?blog|', '', $category_base );
$tag_base = preg_replace( '|^/?blog|', '', $tag_base );
}
$structures = array( $structures = array(
'', '',
$prefix . '/%year%/%monthnum%/%day%/%postname%/', '/%year%/%monthnum%/%day%/%postname%/',
$prefix . '/%year%/%monthnum%/%postname%/', '/%year%/%monthnum%/%postname%/',
$prefix . '/archives/%post_id%' '/archives/%post_id%'
); );
?> ?>
<h3><?php _e('Common settings'); ?></h3> <h3><?php _e('Common settings'); ?></h3>
@ -198,16 +199,12 @@ $structures = array(
</tr> </tr>
<tr> <tr>
<th> <th>
<label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog" <label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog" <?php checked( !in_array($permalink_structure, $structures) ); ?> />
<?php if ( !in_array($permalink_structure, $structures) ) { ?>
checked="checked"
<?php } ?>
/>
<?php _e('Custom Structure'); ?> <?php _e('Custom Structure'); ?>
</label> </label>
</th> </th>
<td> <td>
<?php if ( is_multisite() && !is_subdomain_install() && is_main_site() ) { echo "/blog"; $permalink_structure = preg_replace( "|^/?blog|", "", $permalink_structure ); }?> <?php echo $prefix; ?>
<input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" /> <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" />
</td> </td>
</tr> </tr>
@ -223,11 +220,11 @@ $structures = array(
<table class="form-table"> <table class="form-table">
<tr> <tr>
<th><label for="category_base"><?php /* translators: prefix for category permalinks */ _e('Category base'); ?></label></th> <th><label for="category_base"><?php /* translators: prefix for category permalinks */ _e('Category base'); ?></label></th>
<td><?php if ( is_multisite() && !is_subdomain_install() && is_main_site() ) { echo "/blog"; $category_base = preg_replace( "|^/?blog|", "", $category_base ); }?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code" /></td> <td><?php echo $prefix; ?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code" /></td>
</tr> </tr>
<tr> <tr>
<th><label for="tag_base"><?php _e('Tag base'); ?></label></th> <th><label for="tag_base"><?php _e('Tag base'); ?></label></th>
<td><?php if ( is_multisite() && !is_subdomain_install() && is_main_site() ) { echo "/blog"; $tag_base = preg_replace( "|^/?blog|", "", $tag_base ); }?> <input name="tag_base" id="tag_base" type="text" value="<?php echo esc_attr($tag_base); ?>" class="regular-text code" /></td> <td><?php echo $prefix; ?> <input name="tag_base" id="tag_base" type="text" value="<?php echo esc_attr($tag_base); ?>" class="regular-text code" /></td>
</tr> </tr>
<?php do_settings_fields('permalink', 'optional'); ?> <?php do_settings_fields('permalink', 'optional'); ?>
</table> </table>
@ -239,7 +236,7 @@ $structures = array(
</p> </p>
</form> </form>
<?php if ( !is_multisite() ) { ?> <?php if ( !is_multisite() ) { ?>
<?php if ($iis7_permalinks) : <?php if ( $iis7_permalinks ) :
if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) : if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) :
if ( file_exists($home_path . 'web.config') ) : ?> if ( file_exists($home_path . 'web.config') ) : ?>
<p><?php _e('If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code> element in <code>web.config</code> file.') ?></p> <p><?php _e('If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code> element in <code>web.config</code> file.') ?></p>