Ticket #12002: 12002.4.diff
File 12002.4.diff, 3.3 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/ms.php
616 616 add_action( 'network_admin_notices', 'site_admin_notice' ); 617 617 618 618 function avoid_blog_page_permalink_collision( $data, $postarr ) { 619 if ( is_subdomain_install() )619 if ( is_subdomain_install() || ! is_main_site() || empty( $data['post_name'] ) ) { 620 620 return $data; 621 if ( $data['post_type'] != 'page' ) 621 } 622 623 $blog_prefix = apply_filters( 'ms_blog_prefix', '/blog' ); 624 625 if ( ! empty( $blog_prefix ) ) { 622 626 return $data; 623 if ( !isset( $data['post_name'] ) || $data['post_name'] == '' ) 627 } 628 629 // Ignore it if the post type is not public 630 if ( ! in_array( $data['post_type'], get_post_types( array( 'public' => true ) ) ) ) { 624 631 return $data; 625 if ( !is_main_site() ) 626 return $data; 632 } 627 633 628 634 $post_name = $data['post_name']; 629 635 $c = 0; 630 while ( $c < 10 && get_id_from_blogname( $post_name ) ) {636 while ( $c < 10 && get_id_from_blogname( $post_name ) ) { 631 637 $post_name .= mt_rand( 1, 10 ); 632 638 $c ++; 633 639 } 640 634 641 if ( $post_name != $data['post_name'] ) { 635 642 $data['post_name'] = $post_name; 636 643 } 644 637 645 return $data; 638 646 } 639 647 add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 ); -
src/wp-admin/options-permalink.php
75 75 $iis7_permalinks = iis7_supports_permalinks(); 76 76 77 77 $prefix = $blog_prefix = ''; 78 if ( ! got_url_rewrite() ) 78 if ( ! got_url_rewrite() ) { 79 79 $prefix = '/index.php'; 80 if ( is_multisite() && !is_subdomain_install() && is_main_site() ) 81 $blog_prefix = '/blog'; 80 } 82 81 82 if ( is_multisite() && ! is_subdomain_install() && is_main_site() ) { 83 $blog_prefix = apply_filters( 'ms_blog_prefix', '/blog' ); 84 if ( ! empty( $blog_prefix ) && '/' !== $blog_prefix[0] ) { 85 $blog_prefix = '/' . $blog_prefix; 86 } 87 } 88 83 89 if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { 84 90 check_admin_referer('update-permalink'); 85 91 … … 179 185 <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> 180 186 181 187 <?php 182 if ( is_multisite() && !is_subdomain_install() && is_main_site() ) { 183 $permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure ); 184 $category_base = preg_replace( '|^/?blog|', '', $category_base ); 185 $tag_base = preg_replace( '|^/?blog|', '', $tag_base ); 188 if ( is_multisite() && ! is_subdomain_install() && is_main_site() && ! empty( $blog_prefix ) ) { 189 $blog_prefix_base = '|^/?' . substr( $blog_prefix, 1 ) . '|'; 190 191 $permalink_structure = preg_replace( $blog_prefix_base, '', $permalink_structure ); 192 $category_base = preg_replace( $blog_prefix_base, '', $category_base ); 193 $tag_base = preg_replace( $blog_prefix_base, '', $tag_base ); 186 194 } 187 195 188 196 $structures = array(