Your function is to read
Let’s say you are a WordPress installation.
Yes, imagine you are a WordPress site!
Your job is to read the paragraph from Part 3. Since you are a WordPress website, you are created of code instead of flesh and blood. Every action of yours will be via functions. So,
dance(), etc are your functions.
Let’s perform an exercise
Read the following paragraph:
Some people wonder why WordPress wants the ‘p’ in WordPress to be capitalised. It is a little inconvenient to capitalise the ‘p’ in the middle of the word. Many agree that WordPress could easily be written as WordPress or wordpress or wordPress without any difference. Still, the WordPress team uses it this way. In fact, there is a function called, capital_P_dangit that takes any other casing and converts it into WordPress. This way, you don’t have to worry about writing WordPress the right way!
It’s not the hook
There, I’ve said it. The whole Hooks API is not about the hooks. In this whole story of hooks, bags and boxes, none of them are the hero. Who could it be then?
(Here’s our standard contemplation pause.) What could it really be about?)
To answer this question, we must answer another question:
Why do we need the hooks?
A hook and a box
Let’s say you have a hook on the wall. You have a box that you want to hang on or, in other words, add to the hook. You can’t punch a hole in the box, so what do you do?
WordPress has some default objects like posts, taxonomy, comments and users. Actually there are many more objects, but these principal ones deal with content directly.
A custom object is different from a custom post type. A custom post type is just a subtype of the post object. The difference is in just a property/attribute, i.e. post_type. Most of the times, we build custom functionality using custom post types.
At other times, we need custom objects. These are not posts, comments or users. That’s why you have to create separate tables and CRUD methods for them. This is, in fact, one of the primary reasons why a lot of developers prefer using custom post types over custom objects.
Now I realise that no one would create a theme specifically for poetry but a poet.
The story is always the same
I set out to look for some code samples while working on a couple of client projects and came across two plugins that had a notice for adoption. Then I noticed the ‘adopt-me’ tag. This then led me to the third one. (There’s one more but I’m waiting for a reply).
You have electrical power supplied to your home. It is literally an electrical current, a flow of electricity through those wires. When you need some electricity, to charge your phone, for example, what do you do?
You simply take your charger and plug it into the socket that is connected to the current.