-
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
New Widgets Screen does wp_footer action below each Widget #33580
Comments
This is working fine on development version 5.9-alpha-51272-src with theme (Twenty Twenty-One). |
Similarly |
Sharing my notes from trac here too:
|
We could simply hide in a div any output? |
Hiding the output in a div only accounts for some of the cases. I agree that there doesn't appear to be a great solution here, but of all the proposed ones, I'd probably have gone with this one: "Remove the front-end actions and use new wp_widget_preview_* in their place -- this will require all themes to enqueue default styles especially for the widget previews" However, the approach feels especially "not great" now that the Widgets screen has already launched without this approach. While I'm slightly surprised to not see more people raising this issue, my assumption is that so many people are using Classic Widgets (or just haven't tried to update their Widgets since 5.8) that it will be popping up more and more for folks over the next several months/year. |
Yes, it was a very raw idea 👍🏻
It's also likely that themes don't output content with this action. By the time we reach the closing In the trac copy of this issue a patch is evolving which proposes some interesting ideas. |
See this comment on Trac for the reason why the possible solution I'd posted that @draganescu referenced above won't be suitable for all cases, as well as a proposal to remove legacy widget previews (instead showing only the form for the legacy widget) until such time as we reach a better solution. |
Testing ReportTL;DR
Env
Steps to Test
add_action( 'wp_footer', 'wp_footer_proof_of_concept' );
function wp_footer_proof_of_concept() {
echo 'Why is this being output on the Widgets screen?';
}
Results (without patch)
Results (with patch applied)
NotesThe patch updates In CI, this file is picked up by This triggers a failure on |
I've just tested this following the steps here, and I can confirm the patch correctly removes the content outputted by Testing environment
|
Now that this issue has two test reports that show the patch successfully prevents the content from being visible to the user, how do we progress it to the next/final stage? |
I'm still see footer everywhere in admin->widgets management & customizer->widgets management pages. Testing with WordPress 5.9-RC2-52567 If I copy those patch to wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php then it seems to be fixed. |
Seeing as this patch doesn't look like it's made it into Wordpress core, what is the recommended method for preventing the issue for plugin developers? I have come up with this ... ?
Please confirm. Oliver |
@webd-uk searching for the patch in core reveals it at line 105 in
|
Oh. I assumed the patch would prevent Legacy Widgets from firing |
The patch certainly doesn't fix the issue for me, either. On 6.1.1, when I use a Legacy Widget, I still get the output from wp_footer rendering on my widgets screen. |
OK, glad I'm not going mad :) |
Confirm problem still exists with legacy widget on admin > Appearance > Widgets page. Tested with WordPress 6.2-alpha-55027 |
Yes the patch is a CSS based one, the thing fires but the content is hidden. Definitely not bullet proof. But it did fix a lot of common situations. @MadtownLems could you open a new issue or add here as a comment more details about:
Thank you! |
@draganescu OK, but as for my suggestion for plugin developers so that the problem can be sorted from that angle at the same time, do you concur that it's a good solution? If so I'll start rolling it out wherever we use |
On 6.1.1, wp_footer output is still being shown for Legacy Widgets (fresh 6.1.1 multisite, twenty twenty-one theme), but not for most blocks. `<?php
add_action( 'wp_footer', 'wp_footer_proof_of_concept_53801' ); function wp_footer_proof_of_concept_53801() { |
Yes, this ticket needs to be re-opened I think. We are actively migrating legacy widgets on client sites to Block Widgets or installing the "Classic Widgets" plugin for widgets that cannot be converted. For plugins we develop that make use of the
Oliver |
Description
do_action( 'wp_footer') is apparently called after every widget on the new block-based Widgets screen
Step-by-step reproduction instructions
Use any code that outputs during wp_footer and you'll see that output after each widget on the new widgets screen. (example in code snippet section)
Expected behaviour
Nothing is output on the widgets screen
Actual behaviour
"Why is this being output on the Widgets screen?" is being output after every widget on the widget screen.
Screenshots or screen recording (optional)
Code snippet (optional)
add_action( 'wp_footer', 'wp_footer_proof_of_concept' );
function wp_footer_proof_of_concept() {
echo "Why is this being output on the Widgets screen?";
}
WordPress information
Device information
The text was updated successfully, but these errors were encountered: