Skip to Content
Smashing WordPress: Beyond The Blog
book

Smashing WordPress: Beyond The Blog

by Thord Daniel Hedengren
February 2010
Beginner to intermediate
322 pages
8h 40m
English
Wiley
Content preview from Smashing WordPress: Beyond The Blog

Chapter 7. ANATOMY OF A WORDPRESS PLUGIN

It goes without saying that plugins are different from themes, but a lot of things concerning them share the same ground. If you simplify things, you could say that when you're adding functionality to your theme by adding code to the functions.php template file, you're actually writing a plugin.

But there is a huge difference. Themes are there to display the WordPress site, using the tools available. Plugins, on the other hand, are used when you need to extend the WordPress functionality with additional features. You should remember that, because bloating your theme's functions.php with features sometimes isn't the way to go.

In this chapter we'll look at plugins from a slightly different standpoint than we did with the themes chapters previously. The reason for this is simple: your plugin can do anything. It is basically a way for you to add whatever feature you want; compare that to doing funky stuff with a select few template tags, and you see the difference.

With plugins, it is not a matter of what you can do, it is more a question of why. So that's where we'll start.

Plugin Basics

A plugin's essentials don't differ too much from a theme's essentials. Instead of the necessary style.css stylesheet file with its theme-identifying top header, you have an aptly named PHP file with a similar header. Then you can expand by adding even more functionality outside of the main plugin PHP file if you want, just like you add template files to the child ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Smashing WordPress: Beyond the Blog, 3rd Edition

Smashing WordPress: Beyond the Blog, 3rd Edition

Thord Daniel Hedengren
Expert PHP and MySQL®

Expert PHP and MySQL®

Andrew Curioso, Ronald Bradford, Patrick Galbraith

Publisher Resources

ISBN: 9780470684153Purchase book