Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 14 months ago

#21218 closed defect (bug) (invalid)

plugin_dir_url and plugins_url display absolute filepath within url

Reported by: chriswiegman's profile ChrisWiegman Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.1
Component: General Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

When using plugin_dir_url( __FILE__ ) or plugins_url( __FILE__ ) in a plugin with PHP 5.2.17 the absolute filepath is included in the URL string. In both cases the functions include the absolute filepath before the plugin directory name and after http://host/wp-content/plugins.

for example in PHP 5.2
http://mydomain.com/wp-content/plugins/my-plugin
would become
http://mydomain.com/wp-content/plugins/home/fileowner/public_html/wp-content/plugins/my-plugin/

in PHP 5.3 plugin_dir_url works as it should but plugins_url still displays the absolute URL within.

All has been tested using PHP 5.2.17 and PHP 5.3.13 in MAMP Pro on OSX 10.7

Change History (5)

#1 @nacin
13 years ago

Can't reproduce.

For your install, what are the values of WP_PLUGIN_DIR, ABSPATH, WP_CONTENT_DIR, __FILE__?

#2 @ChrisWiegman
13 years ago

Here is what I've got from the point at which I'm trying to call the function:

WP_PLUGIN_DIR /Users/xxx/Dropbox/MAMP/Local Sites/wordpress/public_html/content/plugins
ABSPATH /Users/xxx/Dropbox/MAMP/Local Sites/wordpress/public_html/
WP_CONTENT_DIR /Users/xxx/Dropbox/MAMP/Local Sites/wordpress/public_html/content
FILE /Users/xxx/Dropbox/MAMP/Local Sites/wordpress/public_html/content/plugins/better-wp-security/better-wp-security.php

Version 0, edited 13 years ago by ChrisWiegman (next)

#3 @nacin
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

plugins_url() takes two arguments: $path and $plugin. $plugin should be __FILE__. $path should be what path within the plugin's directory you want to generate a URL to.

#4 @ChrisWiegman
13 years ago

Thanks. I was afraid it was something I was doing....

#5 @SergeyBiryukov
13 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.