Skip to content

Update doc for legacy widget asset loading #49791

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

Closed
wants to merge 2 commits into from

Conversation

sagarnasit
Copy link

@sagarnasit sagarnasit commented Apr 13, 2023

What?

Update documentation on how to load styles and scripts within the legacy widget iframe.

Why?

Legacy widgets use an iframe to load the widget content on the editor. in the current documentation, It is not clear how to load style and script within the iFrame.

How?

PR states the suitable ways of enqueueing legacy widget styles and scripts.

issue #33584

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 13, 2023
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @sagarnasit! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@sagarnasit sagarnasit marked this pull request as draft April 13, 2023 10:05
@sagarnasit sagarnasit marked this pull request as ready for review April 14, 2023 08:16
@skorasaurus skorasaurus added the [Type] Developer Documentation Documentation for developers label Apr 18, 2023
@@ -191,3 +191,5 @@ add_action( 'enqueue_block_editor_assets', function() {
wp_add_inline_script( 'wp-widgets', 'wp.widgets.registerLegacyWidgetBlock()' );
} );
```

To load the styles and scripts on the editor for the Legacy Widget block, it's recommended to use constructore of the widget registration class or a widget method. It will ensure style and script being loaded on the iFrame as well.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this suggestion @sagarnasit.
I'm not sure if we want to make that an official recommendation. But I guess we could phrase it as:

A possible way to ensure the styles and scripts are loaded on the editor for the Legacy Widget block, is to enqueue the assents on the constructor of the widget registration class or a widget method. It will ensure style and script are loaded on the iFrame as well.

That way we still provide useful information to developers without sounding like it is an official guideline. What do you think? Thank you in advance for your thoughts/insights.

@jorgefilipecosta jorgefilipecosta added the [Status] Needs More Info Follow-up required in order to be actionable. label Oct 9, 2023
@github-actions github-actions bot added the Stale label Oct 29, 2023
@gziolo gziolo added [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. and removed Stale labels Sep 9, 2024
@Mamaduka
Copy link
Member

Mamaduka commented Aug 4, 2025

Closing this as Stale.

@Mamaduka Mamaduka closed this Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants