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

View File

@ -75,36 +75,33 @@ include('admin-header.php');
$home_path = get_home_path();
$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']) ) {
check_admin_referer('update-permalink');
if ( isset( $_POST['permalink_structure'] ) ) {
$permalink_structure = $_POST['permalink_structure'];
if ( ! empty( $permalink_structure ) ) {
$permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
if ( is_multisite() && ! is_subdomain_install() && is_main_site() )
$permalink_structure = '/blog' . $permalink_structure;
}
if ( ! empty( $permalink_structure ) )
$permalink_structure = $prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
$wp_rewrite->set_permalink_structure( $permalink_structure );
}
if ( isset( $_POST['category_base'] ) ) {
$category_base = $_POST['category_base'];
if (! empty( $category_base ) ) {
$category_base = preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
if ( is_multisite() && ! is_subdomain_install() && is_main_site() )
$category_base = '/blog' . $category_base;
}
if ( ! empty( $category_base ) )
$category_base = $prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
$wp_rewrite->set_category_base( $category_base );
}
if ( isset( $_POST['tag_base'] ) ) {
$tag_base = $_POST['tag_base'];
if ( ! empty( $tag_base ) ) {
$tag_base = preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
if ( is_multisite() && ! is_subdomain_install() && is_main_site() )
$tag_base = '/blog' . $tag_base;
}
if ( ! empty( $tag_base ) )
$tag_base = $prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $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>
<?php
$prefix = '';
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(
'',
$prefix . '/%year%/%monthnum%/%day%/%postname%/',
$prefix . '/%year%/%monthnum%/%postname%/',
$prefix . '/archives/%post_id%'
'/%year%/%monthnum%/%day%/%postname%/',
'/%year%/%monthnum%/%postname%/',
'/archives/%post_id%'
);
?>
<h3><?php _e('Common settings'); ?></h3>
@ -198,16 +199,12 @@ $structures = array(
</tr>
<tr>
<th>
<label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog"
<?php if ( !in_array($permalink_structure, $structures) ) { ?>
checked="checked"
<?php } ?>
/>
<label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog" <?php checked( !in_array($permalink_structure, $structures) ); ?> />
<?php _e('Custom Structure'); ?>
</label>
</th>
<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" />
</td>
</tr>
@ -223,11 +220,11 @@ $structures = array(
<table class="form-table">
<tr>
<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>
<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>
<?php do_settings_fields('permalink', 'optional'); ?>
</table>
@ -239,7 +236,7 @@ $structures = array(
</p>
</form>
<?php if ( !is_multisite() ) { ?>
<?php if ($iis7_permalinks) :
<?php if ( $iis7_permalinks ) :
if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) :
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>