-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Hook timing of edit_form_advanced
#10929
Comments
Uh, that seems a "classic" example of doing-it-wrong? :) Edit: Ah, disregard the above. Not sure how I mixed |
According to https://wpdirectory.net/search/01CTG7DNKS5FTNBZP6VY01EB6F many plugins print some custom HTML in |
do_action( 'edit_form_advanced', $post ); is also in wp-admin/edit-form-advanced.php, where before it calls do_meta_boxes(null, 'normal', $post), and after it calls do_meta_boxes(null, 'advanced', $post), both of which output markup. So it sounds to me like gutenberg_collect_meta_box_data() should be calling some other action. |
/cc @aduth is this on your radar? |
@moorscode Was this positively or negatively impacted by #10660? |
@danielbachhuber negatively, it was not as broken before (there were strange visual glitches before). |
@moorscode Ok, thanks. I think we need to keep #10660 in, because there were more significant issues caused by the prior implementation. For this particular issue, one option to consider is: ob_start();
do_action( 'edit_form_advanced', $post );
$_edit_form_advanced_output = ob_get_clean(); We'd then write |
Sounds like a good plan. |
I'm closing this based on https://core.trac.wordpress.org/changeset/43882 . Please reopen if I'm wrongly assuming relationship. |
Hi @mtias |
Describe the bug
In Yoast SEO Premium we use the
edit_form_advanced
hook to output a hidden input field.On a Gutenberg page, this hook is being triggered at initialization.
This caused us a very strange bug, where the metabox under the content has very unwanted behaviour.
This used to only be the case for IE, but since Gutenberg 4.1, this also affects Chrome (Firefox can handle it).
The problem is that the hidden field (which is output twice, for some odd reason), is being placed before the opening
<html
tag of the document.As this behaviour is pretty obscure, I'm most certain that other plugins also use
echo
or print to the document in this hook, resulting in unwanted rending of the page.As mentioned in #1352:
To Reproduce
Add a hook implementation:
This will create an invalid HTML document structure, which results in unreliable results in different browsers.
Expected behavior
I expect this hook to be called at the location where the content div has been rendered, not before any output is sent.
Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information):
Untested
Additional context
Gutenberg 4.1-RC2
The text was updated successfully, but these errors were encountered: