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

Building a Settings Page

Many plugins offer a settings page that allows the user to customize plugin options. The options offered by a settings page varies from a few check boxes, drop downs, or text inputs to multiple advanced editors that allow the user to build data sets, set up forums, or do advanced content management. Although this section focuses on building a simple settings page, you can expand the concept to fill any type of need that your plugin has.

When reduced to a bare minimum, a basic settings page consists of code that displays the page, stores the settings, and adds the page to the WordPress admin menu. The plugin created in this section will give you a solid foundation that you can use to build your own plugin settings pages.

Setting up the plugin structure

The plugin you create in this section is Example: Settings Page. To get started with this plugin, create a new plugins directory named /example-settings-page. All the files for this plugin go in this new directory. That's right, files. We're going to change up the structure a little bit in this plugin by adding multiple plugin files to the plugin directory.

As plugins get larger, having everything in one file quickly becomes hard to manage. A good practice is to separate different functionality into separate files. Similar to the way the init.php file is named because it initializes the plugin, the other files used by the plugin should be named so the purpose of each file is easy to discern when looking at ...

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