Make WordPress Core

Ticket #12002: 12002.diff

File 12002.diff, 2.9 KB (added by kawauso, 14 years ago)

'ms_blog_prefix' filter

  • wp-admin/includes/ms.php

     
    603603add_action( 'network_admin_notices', 'site_admin_notice' );
    604604
    605605function avoid_blog_page_permalink_collision( $data, $postarr ) {
    606         if ( is_subdomain_install() )
     606        if ( is_subdomain_install() || ! is_main_site() || empty( $data['post_name'] ) )
    607607                return $data;
    608         if ( $data['post_type'] != 'page' )
     608
     609        $blog_prefix = apply_filters( 'ms_blog_prefix', '/blog' );
     610
     611        if ( ! empty( $blog_prefix ) )
    609612                return $data;
    610         if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
     613/*
     614        // Ignore it if the post type is not public
     615        if ( ! in_array( $data['post_type'], get_post_types( array( 'public' => true ) ) ) )
    611616                return $data;
    612         if ( !is_main_site() )
    613                 return $data;
    614617
    615618        $post_name = $data['post_name'];
    616619        $c = 0;
  • wp-admin/options-permalink.php

     
    6262$prefix = $blog_prefix = '';
    6363if ( ! got_mod_rewrite() && ! $iis7_permalinks )
    6464        $prefix = '/index.php';
    65 if ( is_multisite() && !is_subdomain_install() && is_main_site() )
    66         $blog_prefix = '/blog';
     65if ( is_multisite() && !is_subdomain_install() && is_main_site() ) {
     66        $blog_prefix = apply_filters( 'ms_blog_prefix', '/blog' );
     67        if ( ! empty( $blog_prefix ) && '/' != $blog_prefix[0] )
     68                $blog_prefix = '/' . $blog_prefix;
     69}
    6770
    6871if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
    6972        check_admin_referer('update-permalink');
     
    158161  <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>
    159162
    160163<?php
    161 if ( is_multisite() && !is_subdomain_install() && is_main_site() ) {
    162         $permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure );
    163         $category_base = preg_replace( '|^/?blog|', '', $category_base );
    164         $tag_base = preg_replace( '|^/?blog|', '', $tag_base );
     164if ( is_multisite() && !is_subdomain_install() && is_main_site() && !empty( $blog_prefix ) ) {
     165        $blog_prefix_base = '|^/?' . substr( $blog_prefix, 1 ) . '|';
     166
     167        $permalink_structure = preg_replace( $blog_prefix_base, '', $permalink_structure );
     168        $category_base = preg_replace( $blog_prefix_base, '', $category_base );
     169        $tag_base = preg_replace( $blog_prefix_base, '', $tag_base );
    165170}
    166171
    167172$structures = array(