O'Reilly logo

WordPress® All-in-One For Dummies® by Michael Torbert, Andrea Rennick, Kevin Palmer, Cory Miller, Lisa Sabin-Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a Plugin Template

When you start writing WordPress plugins, you find that you spend a significant amount of time rewriting the same things. Typically, most plugins have the same basic structure and are set up the same way, meaning that they all deal with settings pages, storing options, and interacting with particular plugins, among other things. You eventually conclude that a valuable use of your time is to create a template for all the plugins to save you hours of work each time you start a new plugin.

Such a template varies from person to person, and to you, depending on programming styles, preferences, and the types of plugins the developer wants to include. For instance, if you often write plugins that use your own database tables, you should include this in your template. Similarly, if your plugins almost never require options pages, leave those out of your template.

image When making a template, keep in mind your personal plugin preferences and tendencies.

To create your own template, determine what functionality and structure your plugins usually contain. Follow these steps:

  1. Create your file structure.

    As you write more plugins, you find yourself repeating the same general filenames. If you find that you're including enough JavaScript and CSS in your plugins to necessitate their own files or directories, include these in your template. For example, if you're using a lot ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required