[theme-reviewers] Need A Final Call

Otto otto at ottodestruct.com
Mon Jan 21 22:43:17 UTC 2013

On Mon, Jan 21, 2013 at 4:00 PM, Chip Bennett <chip at chipbennett.net> wrote:
> By the same token: by Themes always hooking into after_setup_theme to define
> $content_width, a Plugin would always know that it is defined at that hook,
> and would not have to rely on the somewhat-more-arbitrary plugins_loaded
> (IIRC?) when functions.php executes.

No, you have the order wrong.

1. Plugins load
2. do_action( 'plugins_loaded' );
3. Theme's functions.php loads (child first, then parent)
4. do_action( 'after_setup_theme' );

After that, the only thing left as part of startup is the init action,

So if the theme hooked to after_setup_theme, and set its globals at
that time, then a plugin needing that information would need to hook
to after_setup_theme with a very high number for the priority (1000,
say), to be sure that the theme has actually done its job already.

One could reasonably argue that the plugin could hook to init to do
this, but this seems like an somewhat improper (aka, lazy) use of init
to me, from the plugin's perspective. The init action is overloaded
already for lots of things.

Also, "after_setup_theme", in it's very name, implies that it is run
*after* the theme has been setup. Having the theme do setup related
stuff on it (at least, setup related stuff that deeply affect other
parts of the system, such as global variables), strikes me as a misuse
of the hook. So I'd say that any "setup" that the theme needs to do
which really affects the whole system should actually be outside of
functions in the theme's functions.php file. For example, add_action
calls and such are often outside of functions, to hook functions into
other hooks. Setting up hooks is something that affects everything.
Similarly, globals kind of affect everything too.


More information about the theme-reviewers mailing list