Easier Plugin Development by Moving Plugin Directory

If you're a experienced programmer you're testing your programs not only with the latest version of WordPress but also with some older versions since there are many dated installations. So you have several versions installed on your development server and want to test your newly created code with every single version.

You could copy your plugin files to all installed version's plugin directory manually every time you change the code... but you're a programmer, so this is no option, is it?
If your dev server works under a *nix system you probably have tried to use symbolic links but it didn't work. This is not a bug of WordPress but of PHP. So this does not work either.

Fortunately WordPress defines two constants which can help you to simplify things nonetheless: WP_PLUGIN_DIR and WP_PLUGIN_URL. These constants point to the plugin directory of the respective WordPress installation. They are defined since WordPress 2.6 and supporting older versions is most likely unnecessary
To make your plugins accessible to all your installed WordPress versions you simply move them to a central directory and define the constants accordingly:

define( 'WP_PLUGIN_DIR', '/var/www/plugins' ); // or with XAMPP C:/xampp/htdocs/plugins
define( 'WP_PLUGIN_URL', 'http://localhost/plugins' );

In this example the plugins reside in the directory 'plugins' in the root directory of the webserver. If you now define the above constants in every WordPress installation you have easy access to them to test your code with every version.

(Thanks to John Blackbourn on the wp-hackers list for having the idea.)

Hint for Multisite-Users

Also usable for WordPress Multisite

define( 'WPMU_PLUGIN_DIR', '/var/www/multisite-plugins' );
define( 'WPMU_PLUGIN_URL', 'http://localhost/multisite-plugins' );

Comments are closed.


  1. Dominik

    And if you want, you can do the same with WPMU_PLUGIN_DIR and WPMU_PLUGIN_URL.

  2. Mike Schinkel

    Nice! I didn't know about those.

  3. Frank

    @Dominik: yes, use this also; now i have add an small hint; thanks

  4. Jens Törnell

    Can this be done with themes as well? What define is there for themes folder?

  5. Frank

    @Jens: not the same clearly constant, but you can use the constant for wp-content and move this to an other place.
    see: http://wpengineer.com/2382/wordpress-constants-overview/#paths

  6. Andreas Nurbo

    Jens: If you don't use __FILE__ (which you shouldn't) You can easily just symlink the folders. Thats how I do it.
    If WordPress used once and only in wp-config __FILE__ you would be able to symlink WP as well.

  7. Tushar

    Is there any way to modify the default plugin directory to our CDN server .. Like if i have domain abc.com and want to use a CDN - cdn.abc.com then how can i shift my all plugins files to cdn?

  8. Frank

    @Tushar: yes, you can also change this: see my post about this; sorry only in german language; but the code is readable for all readers 😉

One pingback

  1. Adventskalender am 19. Dezember « F-LOG-GE