-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WP_Theme::is_block_theme()
: Add more methods of identifying a block theme.
#2240
base: trunk
Are you sure you want to change the base?
Conversation
2795b2a
to
63d43cd
Compare
63d43cd
to
69a8e70
Compare
continue; | ||
} | ||
|
||
$blocks = parse_blocks( trim( $content ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without trim()
, parse_blocks()
will interpret an empty last line as a block with blockName => NULL
, which could lead to a false negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
questions (non-blocking): Is there a reason we're parsing the blocks? The str_contains
should be enough to check the existence of the blocks.
The has_blocks
uses a similar check as well - https://developer.wordpress.org/reference/functions/has_blocks/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hybrid themes may use mixed HTML (block and non-block markup). The thinking here is that parsing the blocks is a way to determine whether this is a "pure" block template or not.
The str_contains()
is a quick way for us to determine if there are any blocks. If there are no blocks, we can return false
and save the resources required to parse the contents more thoroughly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice job on the unit tests.
33058c0
to
2265889
Compare
Removed the fix for |
Based on the paths outlined by @anton-vlasenko. Includes unit tests. Ready for review.
Trac ticket: https://core.trac.wordpress.org/ticket/54910