[wp-trac] [WordPress Trac] #27287: siteurl is missing WordPress path when creating a new site

WordPress Trac noreply at wordpress.org
Wed Jan 27 17:19:12 UTC 2016


#27287: siteurl is missing WordPress path when creating a new site
------------------------------------------+-----------------------------
 Reporter:  danielbachhuber               |       Owner:
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  Future Release
Component:  Networks and Sites            |     Version:
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:  multisite
------------------------------------------+-----------------------------

Comment (by flixos90):

 I use the following to ensure that all home / site URLs work properly
 (given my WordPress directory is called `core`, but a constant could
 obviously be used as well):

 {{{#!php
 <?php
 class URLFixer {
         public function run() {
                 add_filter( 'option_home', array( $this, 'fix_home_url' )
 );
                 add_filter( 'sanitize_option_home', array( $this,
 'fix_home_url' ) );

                 add_filter( 'option_siteurl', array( $this, 'fix_site_url'
 ) );
                 add_filter( 'sanitize_option_siteurl', array( $this,
 'fix_site_url' ) );
         }

         public function fix_home_url( $value ) {
                 if ( '/core' === substr( $value, -5 ) ) {
                         $value = substr( $value, 0, -5 );
                 }
                 return $value;
         }

         public function fix_site_url( $value ) {
                 if ( '/core' !== substr( $value, -5 ) ) {
                         $value .= '/core';
                 }
                 return $value;
         }
 }
 }}}

 There are still quite a few areas on multisite which assume that `home`
 and `siteurl` have the same value or that show one of the two values in
 the wrong context (see #35632). I wonder if we should create a centralized
 ticket for these issues.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27287#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list