I am in an ongoing process of modernising a legacy abandoned premium theme suite. As part of that upgrade process I am looking to ensure the theme suite conforms to the WordPress theme design requirements and design best practice (WordPress+PHPCS, ThemeCheck plug-in, ThemeSniffer plug-in, namespacing, hooking, filtering, etc).
Please note that this is not a problem report…the theme suite has been upgraded to support WordPress 5.2 and PHP7.3 and operates without problems. The theme suite in question (MysiteMyWay forked as BackStop Themes…see history if interested) has been in use on 100+ sites for over ten years.
This is more a theme design question than an issue.
This theme suite has never hooked after_setup_theme. Having said that, most respected themes (WordPress themes, reputable starter themes) tend to perform some functions such as
add_theme_support( 'title-tag' );within a callback function hooked to the after_setup_theme hook. But nowhere is it documented how to choose what to action from within the functions.php and what to action within an after_setup_theme hooked callback function or why.
It is my understanding that the actions in an after_setup_theme hooked callback function will be executed after the theme’s functions.php completes execution. So in that sense, putting actions at the end of functions.php in an unhooked state would be equivalent to putting them in an after_setup_theme hooked callback function.
Is there something that happens between the completion of the functions.php code processing and the start of the after_setup_theme hooked callback function processing that is significant?
NOTE: One designer stated that this approach enabled flexibility for child themes that needed to override the parent theme…but then the child theme could hook after_setup_theme to do so. Why would a parent theme need to hook after_setup_theme?
Thanks in advance for your words of wisdom. I could have just added in the after_setup_theme hooked callback function and moved on but I had an intellectual itch I needed to scratch…I needed to know why 🙂
- The topic ‘Does a theme really need to hook after_setup_theme in functions.php?’ is closed to new replies.