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

Allow core widgets to be used in the legacy widgets block #15396

Conversation

jorgefilipecosta
Copy link
Member

The legacy widget block should not be able to allow users to use core legacy widgets for which we already have an equivalent block, but it should still load these widgets.

For example, if the user uses a calendar widget on the blocks widget screen we want to show the calendar widget inside the legacy widget, and then allow the user to convert it to the calendar block.

Currently, the legacy widget did not load the core blocks, this PR fixes this problem and makes sure the core blocks are correctly loaded, although the user can not select them when inserting a new legacy widget.

How has this been tested?

I created a new post.
I pasted the following code on the code editor:

<!-- wp:legacy-widget {"identifier":"WP_Widget_Calendar","instance":{"title":"My calendar"},"isCallbackWidget":false} /-->

<!-- wp:legacy-widget {"identifier":"WP_Widget_Calendar","instance":{"title":"My calendar"},"isCallbackWidget":false} /-->

<!-- wp:legacy-widget {"identifier":"WP_Widget_Tag_Cloud","instance":{"title":"Tags","count":0,"taxonomy":"post_tag"},"isCallbackWidget":false} /-->

<!-- wp:legacy-widget {"identifier":"WP_Widget_Archives","instance":{"title":"My archives","count":0,"dropdown":0},"isCallbackWidget":false} /-->

I switched to the visual editor and verified the legacy widgets loaded correctly and I was able to preview them.

@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended [Feature] Widgets Screen The block-based screen that replaced widgets.php. labels May 2, 2019
@jorgefilipecosta jorgefilipecosta force-pushed the update/allow-core-widgets-to-be-used-in-the-legacy-widget-block branch 3 times, most recently from 80e48d6 to 72616af Compare May 27, 2019 21:39
Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

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

I confirmed that following your testing steps works! Aside from my comment about visibleLegacyWidgets being an object, this is good to go.

Why is it that when I visit the Widgets (beta) page the legacy widgets don't render?

localhost_8888_wp-admin_admin php_page=gutenberg-widgets(Desktop)

packages/block-library/src/legacy-widget/edit/index.js Outdated Show resolved Hide resolved
packages/block-library/src/legacy-widget/edit/index.js Outdated Show resolved Hide resolved
@jorgefilipecosta jorgefilipecosta added the [Status] In Progress Tracking issues with work in progress label May 30, 2019
@jorgefilipecosta jorgefilipecosta force-pushed the update/allow-core-widgets-to-be-used-in-the-legacy-widget-block branch from 72616af to 661a13a Compare May 30, 2019 14:56
@jorgefilipecosta
Copy link
Member Author

I confirmed that following your testing steps works! Aside from my comment about visibleLegacyWidgets being an object, this is good to go.

Why is it that when I visit the Widgets (beta) page the legacy widgets don't render?

Thank you for the review @noisysocks 👍 The legacy widget does not work on the widgets page because we decided to use a reference system for the existing widgets, legacy widgets still don't support that system.
That system is implemented at #15801.

Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

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

This looks good! 👍

One minor thing I'm noticing is that when you're viewing a built-in widget, clicking the 'Change widget' button takes you to the placeholder where you can't go back. I think it makes sense to remove the 'Change widget' button for built-in widgets.

@@ -29,6 +33,51 @@ import { ServerSideRender } from '@wordpress/editor';
*/
import LegacyWidgetEditHandler from './handler';

const LegacyWidgetPlaceholder = ( {
Copy link
Member

Choose a reason for hiding this comment

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

Should we move this component to its own file ./placeholder.js?

@noisysocks
Copy link
Member

Hope you don't mind I pushed up cf265ce which removes the 'Change widget' button for built-in widgets and 7f37bbe which moves LegacyWidgetPlaceholder to its own file. Revert these commits or merge the PR—up to you! 😀

@jorgefilipecosta jorgefilipecosta removed the [Status] In Progress Tracking issues with work in progress label May 31, 2019
@jorgefilipecosta jorgefilipecosta merged commit 18983b3 into master May 31, 2019
@youknowriad youknowriad added this to the Gutenberg 5.9 milestone Jun 7, 2019
@wixaw
Copy link

wixaw commented Aug 27, 2019

Hello
I have this error now with my older block legacy-widget :

<p class="editor-warning__message block-editor-warning__message">Votre site n’inclut pas le support pour le bloc «core/legacy-widget». Vous pouvez laisser ce bloc intact ou le retirer complètement.</p>
Why did this block disappear?
Thanks

@noisysocks
Copy link
Member

@wixaw: This feature is now behind an experiment setting. Have you enabled the experiment? You can do this in WP Admin under Gutenberg > Experiments.

Screen Shot 2019-08-29 at 14 11 58

@youknowriad youknowriad deleted the update/allow-core-widgets-to-be-used-in-the-legacy-widget-block branch May 27, 2020 17:45
@wixaw
Copy link

wixaw commented Oct 12, 2020

Hello
After update 5.11 WP and Gutenberg 9.1.1 it no longer appears in Gutenberg > Experiments

I see the release note to 9.1.0 but i not understand where is now
I rollback to 9.0.0

@wixaw
Copy link

wixaw commented Nov 26, 2020

@youknowriad @noisysocks i need help please

@noisysocks
Copy link
Member

@wixaw: The setting was removed from Gutenberg → Experiments in #24685 meaning that the widgets block editor is now loaded for all users of the Gutenberg plugin. The Legacy Widget block was removed from the post editor in #24900 meaning that it is only available for use in the widgets block editor.

@wixaw
Copy link

wixaw commented Dec 7, 2020

ok thank's, it's a shame not to be able to have our homemade plugins in our pages anymore. we are going to use siteorigin as before to integrate them. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants