How wordpress actions and hooks work?

In wordpress execution of each and every page is executed in the form of an array.What is does it creates a global $wp_filter array and each array element contains a function reference.

for eg.We all must have used wp_footer action……so internally wordpress treat it like this

[wp_footer] => Array
        (
            [10] => Array
                (
                    [wp_print_footer_scripts] => Array
                        (
                            [function] => wp_print_footer_scripts
                            [accepted_args] => 1
                        )

                )

        )

So when we do add_action()……………It basically adds one more element in the global array and when we do do_action………..a function call is triggered.

So add_action is to add more and more elements in global array and do_action is to execute that function.Filters also work in the same way.

Advertisements

About Kapil Chugh

In love with PHP and tweaking WordPress. Hungry for Open Source and new technologies. Honest. God-fearing. Happiest when solving problems.
This entry was posted in WordPress and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s