From f69396c2298e0b979902c9bbc0f48104124fb39d Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Thu, 1 Oct 2015 20:39:24 +0000 Subject: [PATCH] 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 --- wp-admin/options-permalink.php | 14 +++++++++++--- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index f77684129a..98a871d241 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -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() ) {

URLs 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 number of tags are available, and here are some examples to get you started.'); ?>