Testing your code is essential – especially if you are going to publish it somewhere like the WordPress Plugin Directory. It takes no time at all for someone to find it and politely (or not so politely) point out it’s flaws.
So how do you go about testing a plugin within a WordPress installation? Easy, install WordPress locally, copy it into the plugins folder and of you go.
Hang on, what if you want to test it in another version of WordPress? Install that version and copy the plugin into that one too. How do you now merge changes between the two versions of the plugin?
Use WinMerge, or even better, subversion or GIT .. oh but my version control files are neatly organised somewhere else…
You get the picture.
The solution is to use symbolic links. A single working copy of the plugin is used and symbolic links to it are created from the plugin directory of each WordPress install you want to test it in. The only limitation is that the files need to be on the same computer.
I use a local Debian web server for development, so the first step is get into the terminal and go to the directory where I want to create the symbolic link:
Then use the ln command to create the link to the location of the plugin files:
ln -s /var/www/wordpress-svn/dmg-text-widget/tags/1.0/ dmg-text-widget
The final part of the above command is the name of the link, which is the plugin folder name ‘dmg-text-widget’ in this case.
Then do the same in any other versions of WordPress that you need to test in, e.g:
You can also create symbolic links on a Windows host – see this article on How to Geek for more info – but I haven’t tested it on Windows.