[wp-trac] [WordPress Trac] #55023: get_header() notice: Theme without header.php is deprecated
WordPress Trac
noreply at wordpress.org
Sun Sep 4 01:41:45 UTC 2022
#55023: get_header() notice: Theme without header.php is deprecated
--------------------------+------------------------
Reporter: kpdaa | Owner: audrasjb
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 6.1
Component: Themes | Version: 5.9
Severity: normal | Resolution:
Keywords: has-patch | Focuses: multisite
--------------------------+------------------------
Comment (by manfcarlo):
Replying to [comment:22 lgedeon]:
> If block themes do not require header.php and footer.php, then they must
have an alternative. If that alternative is in place then the
compatibility files will never be reached and so they are still
deprecated.
>
> The solution of only showing the deprecation for classic themes misses
the point that these files should not be used for either block or classic
themes. They contain hard-coded <hr /> tags and other content that does
not make sense for block themes.
>
> These files should never be loaded. Deprecation is correct, but it needs
to be expanded with an explanation of how block themes can avoid these
files being loaded.
Agreed. The patch essentially un-deprecates these files for block themes,
which was probably not the intention.
I previously suggested to use `block_header_area` and `block_footer_area`
and a few other people suggested the same, but after a closer look, I have
changed my mind about this.
The issue is that `header.php` is expected to include `<!DOCTYPE html>`,
`<html>`, `wp_head();`, `<body>` and also typically includes the opening
tag of a max-width container, while `footer.php` will close all of these
tags and also call `wp_footer();`. Block headers and footers do not and
can not do any of these things, because it is not possible to open and
close the same block in two different template parts.
In other words, using `block_header_area` and `block_footer_area` in this
context will not only put browsers into quirks mode, but will also fail to
apply any max-width containers to the signup form, which will leave the
page looking rather ugly.
The code that is really needed here is located in
https://core.trac.wordpress.org/browser/tags/6.0/src/wp-includes/template-
canvas.php and one suggestion is to move this code directly into the
`get_header` and `get_footer` functions for block themes and also call
those functions from the template canvas file.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55023#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list