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

Filtering Content

Now that you know how a plugin is created, it's time to have some fun and create a WordPress plugin that actually does something, and in the process, discover more basics of WordPress plugin development.

A powerful feature of WordPress is its numerous filters. By latching code to a filter, you can modify information as it flows through WordPress, and therefore modify the information WordPress displays or stores.

Imagine that you have a habit of using contractions far too often. Your readership mocks you and your penchant for the commoner practice of merging words together. At night, you worry about whether you missed an instance of it's, we're, or I'll.

It is causing you to lose sleep. You tried listening to the self-help tapes, you review every word and you have been to therapy to find the deep-seated cause of your craving for contractions. Despite your best efforts and the constant ridicule, you cannot help but sound like an etiquette contrarian.

Fortunately, there is a cure. With a simple filter and a bit of code, your grammatical ailment can be disguised easily with a simple WordPress plugin that you create in the next section of this chapter.

Setting up the plugin structure

The plugin we create in this section is Example: Contraction Compulsion Correction that will reside in a directory called /example-contraction-compulsion-correction with a main plugin file named init.php. Apply the same steps to create the directory and main plugin file as you did in the ...

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