{"id":11296752,"date":"2019-03-11T00:03:24","date_gmt":"2019-03-11T00:03:24","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/does-a-theme-really-need-to-hook-after_setup_theme-in-functions-php\/"},"modified":"2019-03-11T00:03:24","modified_gmt":"2019-03-11T00:03:24","slug":"does-a-theme-really-need-to-hook-after_setup_theme-in-functions-php","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/does-a-theme-really-need-to-hook-after_setup_theme-in-functions-php\/","title":{"rendered":"Does a theme really need to hook after_setup_theme in functions.php?"},"content":{"rendered":"<p>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).<\/p>\n<p>Please note that this is not a problem report&#8230;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&#8230;see <a href=\"https:\/\/gitlab.com\/BackStopThemes\/ThemeCoreV2\/wikis\/development-history\/\">history<\/a> if interested) has been in use on 100+ sites for over ten years.<\/p>\n<p>This is more a theme design question than an issue.<\/p>\n<p>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 <code>add_theme_support( &#039;title-tag&#039; );<\/code> 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.<\/p>\n<p>It is my understanding that the actions in an after_setup_theme hooked callback function will be executed after the theme&#8217;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.<\/p>\n<p>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?<\/p>\n<p>NOTE: One designer stated that this approach enabled flexibility for child themes that needed to override the parent theme&#8230;but then the child theme could hook after_setup_theme to do so. Why would a parent theme need to hook after_setup_theme?<\/p>\n<p>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&#8230;I needed to know why \ud83d\ude42<\/p>\n","protected":false},"template":"","class_list":["post-11296752","topic","type-topic","status-publish","hentry","topic-tag-after_setup_theme","topic-tag-theme-design"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11296752","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11296752\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=11296752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}