Chapter 2. Plugin Foundation

WHAT'S IN THIS CHAPTER?

  • Creating a solid plugin foundation

  • Determining directory and file paths

  • Using Activate and Deactivate functions

  • Understanding available plugin uninstall methods

  • Managing sanity practices and coding standards

  • Understanding proper code documentation

  • Using plugin development checklists

When developing a plugin in WordPress, it's essential to start with a solid plugin foundation. Starting with a good foundation can eliminate many headaches as you develop your new plugin. The techniques discussed in this chapter will be used throughout this book as a good example of what to do.

CREATING A PLUGIN FILE

A plugin in WordPress can be a single PHP file or a group of files inside a folder. You need to consider many things when creating a new plugin in WordPress such as the plugin name and proper folder usage.

Naming Your Plugin

When choosing a name for your plugin, it's good practice to consider a name based on what your plugin actually does. For example, if you create an SEO-focused plugin, you wouldn't want to name it Bob's Plugin. Your audience would have no idea what your plugin actually does based on the plugin name. Your plugin name should be unique to your plugin and should also be descriptive of your plugin's purpose.

It's also a good idea to search the Plugin Directory on WordPress.org (http://wordpress.org/extend/plugins/) for similar plugins to avoid confusion. If you decide to name your plugin SEO Gold, and a plugin named SEO Silver already ...

Get Professional WordPress® Plugin Development 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.