Skip to content
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

Provide the widget preview iframe with a sidebar ID #33638

Open
dikiyforester opened this issue Jul 23, 2021 · 4 comments
Open

Provide the widget preview iframe with a sidebar ID #33638

dikiyforester opened this issue Jul 23, 2021 · 4 comments
Labels
[Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets [Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] Enhancement A suggestion for improvement.

Comments

@dikiyforester
Copy link

What problem does this address?

There is no way for a block/widget to identify and get data on the sidebar it’s been placed on.

Prior widget editor, we could get the sidebar id by the widget id, but in block-based widget editor it's impossible since widget id in the editor is not the actual widget id.

For example:

  1. Some would like to get the sidebar’s before_title and after_title variables from within the block itself.
  2. Some would like to add extra widget fields, depending on the sidebar.

Reported here:

  1. https://make.wordpress.org/core/2021/06/29/block-based-widgets-editor-in-wordpress-5-8/#comment-41612
  2. https://make.wordpress.org/core/2021/06/29/block-based-widgets-editor-in-wordpress-5-8/#comment-41618

What is your proposed solution?

Add the current sidebar id variable to the block/widget instance in block-based widgets editor.

@noisysocks noisysocks added [Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] Enhancement A suggestion for improvement. labels Jul 23, 2021
@noisysocks noisysocks added this to the WordPress 5.8.1 milestone Jul 23, 2021
@kevin940726
Copy link
Member

If I'm not misunderstanding this, I think it's a duplicate of #32805?

@cabrerahector
Copy link

Not really, @kevin940726. What we want is for the block to be able to access its sidebar data (id, before_widget, after_widget, before_title, after_title, etc).

The issue you're referring to requests for blocks to get assigned a widget_id on the Widgets screen which is sort of similar but not exactly the same thing.

@kevin940726
Copy link
Member

@cabrerahector See #32805 (comment), I think we ultimately want the same thing for preview iframes to have the sidebar ids. Am I missing something obvious? 🤔

@noisysocks noisysocks removed this from the WordPress 5.8.1 milestone Aug 30, 2021
@noisysocks noisysocks added [Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. labels Feb 15, 2022
@noisysocks
Copy link
Member

We can’t provide the preview iframe with a widget ID because the ID might not exist in all cases. For example, if a user creates a new Legacy Widget, the ID isn’t created until the user presses Update.

Potentially, we could pass sidebar_id as a widget argument so that plugins can access $args['sidebar_id'] in WP_Widget::widget() to work around this limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets [Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants