WordPress.org

Make WordPress Core

Changeset 14051


Ignore:
Timestamp:
04/10/2010 11:30:34 AM (10 years ago)
Author:
dd32
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options-permalink.php

    r13980 r14051  
    7676$iis7_permalinks = iis7_supports_permalinks();
    7777
     78$prefix = '';
     79if ( ! got_mod_rewrite() && ! $iis7_permalinks )
     80    $prefix .= '/index.php';
     81if ( is_multisite() && !is_subdomain_install() && is_main_site() )
     82    $prefix .= '/blog';
     83
    7884if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
    7985    check_admin_referer('update-permalink');
     
    8187    if ( isset( $_POST['permalink_structure'] ) ) {
    8288        $permalink_structure = $_POST['permalink_structure'];
    83         if ( ! empty( $permalink_structure ) ) {
    84             $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
    85             if ( is_multisite() && ! is_subdomain_install() && is_main_site() )
    86                 $permalink_structure = '/blog' . $permalink_structure;
    87         }
     89        if ( ! empty( $permalink_structure ) )
     90            $permalink_structure = $prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
    8891        $wp_rewrite->set_permalink_structure( $permalink_structure );
    8992    }
     
    9194    if ( isset( $_POST['category_base'] ) ) {
    9295        $category_base = $_POST['category_base'];
    93         if (! empty( $category_base ) ) {
    94             $category_base = preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
    95             if ( is_multisite() && ! is_subdomain_install() && is_main_site() )
    96                 $category_base = '/blog' . $category_base;
    97         }
     96        if ( ! empty( $category_base ) )
     97            $category_base = $prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
    9898        $wp_rewrite->set_category_base( $category_base );
    9999    }
     
    101101    if ( isset( $_POST['tag_base'] ) ) {
    102102        $tag_base = $_POST['tag_base'];
    103         if ( ! empty( $tag_base ) ) {
    104             $tag_base = preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
    105             if ( is_multisite() && ! is_subdomain_install() && is_main_site() )
    106                 $tag_base = '/blog' . $tag_base;
    107         }
     103        if ( ! empty( $tag_base ) )
     104            $tag_base = $prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
    108105        $wp_rewrite->set_tag_base( $tag_base );
    109106    }
     
    167164
    168165<?php
    169 $prefix = '';
    170 
    171166if ( ! got_mod_rewrite() && ! $iis7_permalinks )
    172     $prefix = '/index.php';
     167    $permalink_structure = preg_replace( '|^/?index\.php|', '', $permalink_structure );
     168
     169if ( is_multisite() && !is_subdomain_install() && is_main_site() ) {
     170    $permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure );
     171    $category_base = preg_replace( '|^/?blog|', '', $category_base );
     172    $tag_base = preg_replace( '|^/?blog|', '', $tag_base );
     173}
    173174
    174175$structures = array(
    175176    '',
    176     $prefix . '/%year%/%monthnum%/%day%/%postname%/',
    177     $prefix . '/%year%/%monthnum%/%postname%/',
    178     $prefix . '/archives/%post_id%'
     177    '/%year%/%monthnum%/%day%/%postname%/',
     178    '/%year%/%monthnum%/%postname%/',
     179    '/archives/%post_id%'
    179180    );
    180181?>
     
    199200    <tr>
    200201        <th>
    201             <label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog"
    202             <?php if ( !in_array($permalink_structure, $structures) ) { ?>
    203             checked="checked"
    204             <?php } ?>
    205              />
     202            <label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog" <?php checked( !in_array($permalink_structure, $structures) ); ?> />
    206203            <?php _e('Custom Structure'); ?>
    207204            </label>
    208205        </th>
    209206        <td>
    210             <?php if ( is_multisite() && !is_subdomain_install() && is_main_site() ) { echo "/blog"; $permalink_structure = preg_replace( "|^/?blog|", "", $permalink_structure ); }?>
     207            <?php echo $prefix; ?>
    211208            <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" />
    212209        </td>
     
    224221    <tr>
    225222        <th><label for="category_base"><?php /* translators: prefix for category permalinks */ _e('Category base'); ?></label></th>
    226         <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>
     223        <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>
    227224    </tr>
    228225    <tr>
    229226        <th><label for="tag_base"><?php _e('Tag base'); ?></label></th>
    230         <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>
     227        <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>
    231228    </tr>
    232229    <?php do_settings_fields('permalink', 'optional'); ?>
     
    240237  </form>
    241238<?php if ( !is_multisite() ) { ?>
    242 <?php if ($iis7_permalinks) :
     239<?php if ( $iis7_permalinks ) :
    243240    if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) :
    244241        if ( file_exists($home_path . 'web.config') ) : ?>
Note: See TracChangeset for help on using the changeset viewer.