Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In the function.php file of the twentyeleven the setup function checks to see whether it exists before running it:

if (!function_exists('twentyelevent_setup')):
function twentyelevent_setup() {
... Setup code ...
}

add_action( 'after_setup_theme', 'twentyeleven_setup' );

However, in twentytwelve, it is not set up like this (it does not check if the function exists). My question is: what is the point of this design pattern? Does function_exists just check whether the function has been defined (which it is on the next line?) or does it do something else? Why does the new theme not include it?

share|improve this question

1 Answer 1

That twentyeleven_setup function, and others like it, are pluggable - meaning that they can be overridden by a child theme. The child theme's version of a function with that same name will be parsed first, so the parent theme's version will not be run at all.

In TwentyTwelve some functions are not pluggable, but instead are attached to hooks. By attaching alternative functions to those same hooks in a child theme, you can override the parent theme function's internal logic, without rebuilding the whole function.

share|improve this answer
3  
you can also use remove_action - codex.wordpress.org/Function_Reference/remove_action –  Q Studio Apr 9 '13 at 20:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.