Creating Your First Plugin

When developing something new, taking very small steps is usually best. This way, if something breaks, the problem is clear. Doing a large number of new things at one time makes finding where something went wrong difficult.

Sticking with this concept, the first plugin we help you create in this chapter is a plugin that can be activated and deactivated but doesn't do anything. In other words, a fully functional plugin shell that's ready for code to be added.

Because this plugin is an example and won't really do anything, we named it Example: Do Nothing.

Setting up the plugin files

For this plugin, all that you need is a main plugin file. Following the best practices from earlier in this chapter, this file is placed in its own directory by following these quick steps:

  1. Connect to your Web server via FTP.

    Check out Book II, Chapter 2 for a refresher on using FTP.

  2. Browse to the /wp-content/plugins directory in your WordPress installation directory.

    If you're unsure where your WordPress installation directory is located, flip to Book II, Chapter 4 where we cover installing WordPress on your Web server.

  3. Create a new directory within /wp-content/plugins called /example-do-nothing.

    Most FTP programs allow you to right-click with your mouse and choose Add New Folder or Add New Directory.

  4. Create an empty .php file with the filename init.php.

    Use your favorite text editor, such as Notepad for PC or TextMate for Mac, to open a new file and then save it with the filename ...

Get WordPress® All-in-One For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.