[wp-trac] [WordPress Trac] #26969: Incorrect WP path set when creating a new site with wp in a subfolder

WordPress Trac noreply at wordpress.org
Mon Feb 10 12:41:20 UTC 2014


#26969: Incorrect WP path set when creating a new site with wp in a subfolder
-------------------------------+------------------------------
 Reporter:  Denis-de-Bernardy  |       Owner:
     Type:  defect (bug)       |      Status:  reopened
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Upgrade/Install    |     Version:  trunk
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------

Comment (by Denis-de-Bernardy):

 Replying to [comment:7 nacin]:
 > get_included_files() would probably be more efficient/sane than a
 backtrace. If we wanted to go that route.

 The following, from my bug fixes plugin, actually *tries* the subfolder:

 {{{
     /**
      * Sets the home url when WP is installed in its own folder
      **/
     protected function fixHomeUrl()
     {
         $home_url = get_option('home');
         $site_url = get_option('siteurl');
         $home_dir = basename($home_url);
         $site_dir = basename($site_url);
         $phys_dir = basename(ABSPATH);

         # Bail if $phys_dir is not in any url
         if ($home_dir != $phys_dir || $site_dir != $phys_dir) return;

         # Bail if the parent url isn't loading this WP install
         $maybe_home_url = dirname($home_url);
         $response = wp_remote_head($maybe_home_url, array('timeout' => 5,
 'httpversion' => '1.1'));
         if (is_wp_error($response) || 200 !=
 wp_remote_retrieve_response_code($response)) return;
         $pingback_url = wp_remote_retrieve_header($response,
 'x-pingback');
         if (!$pingback_url || $pingback_url !=
 get_bloginfo('pingback_url')) return;

         # Override the home url found by WP
         update_option('home', $maybe_home_url);
     }

 }}}

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


More information about the wp-trac mailing list