MS: Provide better UI when a main site's /blog prefix is changed.

The main site on a new network is forced by default into using `/blog` as the prefix for its permalink structure. This can be changed easily through the network admin, though the `options-permalink.php` screen is then unusable to make further changes to the structure.

Now, if `/blog/` is not at the beginning of the `permalink_structure` option, we do not force `/blog` as a prefix in the UI.

Fixes #12002.

Built from https://develop.svn.wordpress.org/trunk@34749


git-svn-id: http://core.svn.wordpress.org/trunk@34714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2015-10-01 20:39:24 +00:00
parent 113a9d4517
commit f69396c229
2 changed files with 12 additions and 4 deletions

View File

@ -50,12 +50,21 @@ add_filter('admin_head', 'options_permalink_add_js');
$home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks();
$permalink_structure = get_option( 'permalink_structure' );
$prefix = $blog_prefix = '';
if ( ! got_url_rewrite() )
$prefix = '/index.php';
if ( is_multisite() && !is_subdomain_install() && is_main_site() )
/**
* In a subdirectory configuration of multisite, the `/blog` prefix is used by
* default on the main site to avoid collisions with other sites created on that
* network. If the `permalink_structure` option has been changed to remove this
* base prefix, WordPress core can no longer account for the possible collision.
*/
if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos( $permalink_structure, '/blog/' ) ) {
$blog_prefix = '/blog';
}
if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
check_admin_referer('update-permalink');
@ -94,7 +103,6 @@ if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
exit;
}
$permalink_structure = get_option( 'permalink_structure' );
$category_base = get_option( 'category_base' );
$tag_base = get_option( 'tag_base' );
$update_required = false;
@ -162,7 +170,7 @@ 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="https://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
<?php
if ( is_multisite() && !is_subdomain_install() && is_main_site() ) {
if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos( $permalink_structure, '/blog/' ) ) {
$permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure );
$category_base = preg_replace( '|^/?blog|', '', $category_base );
$tag_base = preg_replace( '|^/?blog|', '', $tag_base );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34748';
$wp_version = '4.4-alpha-34749';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.