Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 4 months ago

#16199 closed defect (bug) (worksforme)

plugin_dir_url - wrong directory for symlinks

Reported by: iworks's profile iworks Owned by:
Milestone: Priority: normal
Severity: trivial Version: 3.0.4
Component: Plugins Keywords:
Focuses: Cc:


If plugin dir is a symlink, plugin_dir_url generate wrong url, getting physical not logical path.

I have symlink in wp-content/plugins

ln -s /home/user/svn/wordpress/plugins/plugin_dir/trunk plugin_dir





Change History (3)

#1 @garyc40
13 years ago

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

plugin_dir_url() lets you specify a $file parameter. If you pass in __FILE__, the symlink will always be resolved.

Instead of passing in __FILE__, you can use $_SERVER["SCRIPT_FILENAME"], which will let the symlink alone.

See this StackOverflow Q/A.

Also, you can even move your wp-content folder somewhere else, although this is not completely compatible with multisite enabled (works fine for single site). In your wp-config.php file, you can define these constants:

define( 'WP_CONTENT_DIR', '/absolute/path/to/your/wp-content' );
define( 'WP_CONTENT_URL', '' );

I'm closing this as worksforme.

#2 @dd32
13 years ago

  • Keywords plugin_dir_url removed
  • Milestone Awaiting Review deleted

SCRIPT_FILENAME resolves to the current executing script, not the plugins filename.

Really, A Duplicate of: #13550

Note: See TracTickets for help on using tickets.