Symbolic Links on dev box with plugins and stylesheets

I’m using mac os x 10.6 with xampp.

http://wp3.1/ is the url to where I have WordPress installed.

The physical path is /Users/myUserName/Sites/wp3.1/

I do not install plugins or themes in the “natural” way. I have created a directory named “git” which is located in /Users/myUserName/git/. This is where all my git repositories live. When I want to install a plugin, I just create a symbolic link in /Users/myUserName/Sites/wp3.1/wp-content/plugins/. This works great for simple plugins, but if the plugin enqueue’s a style sheet or script, the url displays as:

http://wp3.1/wp-content/plugins/Users/myUserName/git/options-framework-plugin/css/colorpicker.css?ver=3.1.1

How do I fix this?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Symbolic links are … risky in WordPress. It is easier to use a separate domain for plugins per wp-config.php:

define( 'WP_PLUGIN_DIR', '/local/path/to/plugin/directory' );
define( 'WP_PLUGIN_URL', 'http://plugins.dev');

See Strategy On Building Plugin Using Eclipse as an example for IDE configuration with such a setup.

Method 2

As you can see, the plugin URL is correct except for the real path stuck in the middle. We can filter the function responsible for generating plugin URLs and remove this.

The following code should be installed as a Must Use Plugin:

add_filter( 'plugins_url', function( $url ) {
    return str_replace( '/Users/myUserName/git/', '', $url );
});


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x