In WordPress, this is done:
add_action( 'after_setup_theme', 'theme_setup' );
function theme_setup() {
...
}
How does WordPress access the function theme_setup() given the string theme_setup?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Firstly, the function add_action is called with all the parameters. Code of this function is listed below. This function in not interesting, it is just a wrapper for add_filter function, which is more interesting.
Function add_filter saves the data provided to a function to a global variable. Code is follows:
Now you have everything you need saved in global variable and you can start to call function names from function do_action, which is pretty long. But the most interesting part is on it’s end:
Function call_user_func_array is the magic. You can read more about it in PHP manual