-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
render_block -> core/heading ["attrs"]["level"] only with <h1> headings #16877
Comments
Noticing this as well. I'm able to target |
Ended up implementing a regex:
This will produce: |
Clearly a bug. Makes creating a table of contents or page headings menu more difficult. This is even more strange considering that by default Gutenberg only displays h2-h4 as level options in the floating toolbar (assuming that h1 should not really be used within post content). |
I'm not able to reproduce fully what's described using the following code: function my_test_render_callback( $content, $block ) {
if ( 'core/heading' !== $block['blockName'] ) {
return $content;
}
return json_encode( $block[ 'attrs' ] );
}
add_filter( 'render_block', 'my_test_render_callback', 10, 2 ); I do indeed see that there's no This is happening because the default level is 2, and default attributes aren't applied for static blocks when trying to access them in PHP. It looks like this is tracked in #2751, I think there's a long term effort to improve this, part of which is moving all the attribute definitions to I'll close this if that's ok, as I think this is adequately tracked in #2751. |
Aaaargh. Gutenberg: making life harder in PHP, and requiring a lot more skill and hoop-jumping to access in JS. The linked issue #2751 is Closed, as well. 😢 |
When i debug the render_block filter on core/heading block, i've noticed there is an attrs array with "level" entry for only h1 headline. Then "level" has value of "1". When i change h1 to h2 or h3 the "level" entry is missing. Is this on purpose?! WordPress 5.2.2
The text was updated successfully, but these errors were encountered: