Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#14774 closed defect (bug) (invalid)

Incorrect sub-directory multisite URL constants

Reported by: jfarthing84's profile jfarthing84 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.1
Component: Multisite Keywords:
Focuses: Cc:

Description

I noticed when using the multisite feature that the constants WP_CONTENT_URL, WP_PLUGIN_URL, WPMU_PLUGIN_URL and PLUGINS_COOKIE_PATH are all incorrect when on a sub-blog. They reflect the sub-blog "directory", which of course, doesn't exist. This also affects, of course, plugins_url(), content_url(), etc.

Example:
Right: WP_CONTENT_URL = mysite.com/wp-content
Wrong: WP_CONTENT_URL = mysite.com/sub-blog/wp-content

Change History (4)

#1 @jfarthing84
15 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Stupid me. I suppose those links get rewrote and work as expected huh? Something was giving me a 500 error on my server, but I seem to have fixed it.

#2 @ocean90
15 years ago

  • Keywords dev-feedback removed
  • Milestone Awaiting Review deleted
  • Severity changed from major to normal

#3 @ev3rywh3re
14 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Summary changed from Incorrect multisite URL constants to Incorrect sub-directory multisite URL constants

I thought I would reopen this ticket rather than making a new one since the summary is correct. Since the WP_CONTENT_URI defined in wp_plugin_directory_constants() in default-constants.php uses get_option('siteurl'), everything that uses WP_CONTENT_URI will produce bad URIs for multisite sub-directory installations.

To reproduce create a multisite installation, create a sub-blog and use some of the *_uri functions.

examples:

get_stylesheet_directory_uri() - http://site.com/sub-blog/wp-content/themes/stylesheet
get_template_directory_uri() - http://site.com/sub-blog/wp-content/themes/template

I've just realized this as I started working to make some themes more portable for some of my sub-directory projects. I was planning to start using the *_uri functions because I already knew WP_CONTENT_URI was defined like that. I might use the filters for those functions since this might be a little sticky. In the past I've been using something like:

define( CUSTOM_WP_CONTENT_URI,'http://' . $current_site->domain . $current_site->path . 'wp-content');

#4 @nacin
14 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

This is expected behavior. These links are rewritten properly, i.e. http://example.com/some-site/wp-content/ would then be rewritten to http://example.com/wp-content/ via htaccess (if using Apache).

If you want the actual path, then use WP_CONTENT_DIR. If you want to remove some-site from the URL, then filter it or define the constant on your own.

Note: See TracTickets for help on using tickets.