Author Archives: Saurabh Shukla

Hooks API from scratch – Part 4: Action hooks in action

If you haven’t, please go through the previous post, Hooks API from scratch – Part 3: An experiential guide to action hooks. This part 4 won’t make complete sense without that.

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, stand_up(), close_your_eyes(), dance(), etc are your functions.
Continue reading

Kakapo

Hooks API from scratch – Part 3: An experiential guide to action hooks

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!

Continue reading

hooking

Hooks API from scratch – Part 2: About hooks; it’s not about the hook

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?

Continue reading

meta_id, post_id, meta_key, meta_value

Meta for Custom Objects in WordPress

Custom Objects

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.
Continue reading