Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress Hooks

How does WordPress implement hooks internally?

like image 657
wnoveno Avatar asked Dec 01 '25 19:12

wnoveno


1 Answers

Basically, it maintains a global variable called $wp_filter to hold relevant data. Plugins can use functions like add_filter() to get themselves registered.

At various points (the hook points), wordpress examines $wp_filter to see if there are filters to run.

The easiest way to figure it out is to take a look at wp-includes/plugin.php and study the code there (or hook up a debugger and step through it, or set up firePHP and periodically dump stuff out)

I'm no expert, but I was curious, so I took a peek. If I really wanted to know more, I'd do what I just suggested.

like image 70
timdev Avatar answered Dec 04 '25 07:12

timdev