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

Use blocks instead of widgets in new WordPress installations #1331

Conversation

noisysocks
Copy link
Member

@noisysocks noisysocks commented Jun 3, 2021

Modifies wp_install_defaults() so that when you install a new WordPress site you have block in your widget areas, not widgets.

Trac ticket: https://core.trac.wordpress.org/ticket/53324


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@noisysocks
Copy link
Member Author

noisysocks commented Jun 3, 2021

The Twenty Twenty-one theme will need some styling adjustments to accomodate for the different markup.

Here's how it looks with widgets:

Screen Shot 2021-06-03 at 14 54 55

Here's how it looks with blocks:

Screen Shot 2021-06-03 at 14 55 22

The headings are larger because of a missing widget-heading class. We could add this class to the Heading block but I'm not sure that's a good idea because users might miss it when adding their own headings.

The recent post titles are larger because that's how the Latest Posts block styles the list items. I'm not sure if it makes sense to override this in the theme.

I could use some guidance from someone who knows all about the default themes. @jasmussen, maybe? 🙂

@jasmussen
Copy link

I could use some guidance from someone who knows all about the default themes. @jasmussen, maybe? 🙂

I always appreciate a ping, thank you. In this case, I can only offer limited guidance:

  • A widget-heading class would probably be useful, but I imagine it might be onerous to add to the heading block just in this context, and if it's not easy, might not be worth it.
  • I think it's okay for themes to have to do a few updates here and there, and in this case I imagine there's a widget container they can target, i.e. .widgets h3 instead of h3.widget-heading, it shouldn't be a lot of work, and might be worth it for all the other changes blocks bring to widgets anyway.
  • Finally, the heading block comes with options which classic widget headings didn't. Specifically, you can choose your own heading level, which is an important accessibility consideration for some themes that might be using Widgets in a more primary fashion than others.
  • In addition to being able to set the correct heading level depending on your theme, the heading block comes with the ability to set the font size. That could potentially be a solution here, embracing one of the default smaller presets. I imagine that's why a widget-heading class existed in the first place — H2 might be the correct heading level semantically, but might have been visually too big for the design.

For some actual theme experts, you might want to ping @melchoyce and perhaps @MaggieCabrera.

Copy link
Contributor

@tellthemachines tellthemachines left a comment

Choose a reason for hiding this comment

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

Code looks good ✅ Tested with both the new and the old screens and it's working well.

1 => 'categories-2',
2 => 'meta-2',
0 => 'block-5',
1 => 'block-6',
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we still have a meta widget in here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't decide... would it be weird to have a Legacy Widget block in amongst the default blocks that you see in a new WordPress site? Is it a useful widget to have by default in 2021?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah good point about the Legacy Widget. We can leave it out for now and see if anyone notices 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to not have this legacy widget on a new install. Why? The default experience of a new install does not include the Meta widget in an active sidebar.

That said, for those who want to use its features, might be good to have a new block version of it.

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense to me. I've kept it removed.

Choose a reason for hiding this comment

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

My worry here is that we assume it's not useful. Isn't the meta widget the default front end UX path to wp-admin?

Choose a reason for hiding this comment

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

I would vote for leaving the Meta widget out but would it be possible for it to be available in the inserter and in the Legacy Widget block dropdown list until a new block version is created? (Similar to what we’re looking at doing for the Navigation Menu widget in #32431?)

Copy link
Member Author

Choose a reason for hiding this comment

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

My worry here is that we assume it's not useful. Isn't the meta widget the default front end UX path to wp-admin?

It already does not show on a new WordPress website because Twenty Twenty-one only has one widget area.

I would vote for leaving the Meta widget out but would it be possible for it to be available in the inserter and in the Legacy Widget block dropdown list until a new block version is created? (Similar to what we’re looking at doing for the Navigation Menu widget in #32431?)

Yes absolutely. Would you mind creating an issue in the Gutenberg repo about adding a block equivalent of Meta? I looked but couldn't find one.

Choose a reason for hiding this comment

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

No prob, made an issue for the block version here: WordPress/gutenberg#32551

src/wp-includes/block-editor.php Outdated Show resolved Hide resolved
@noisysocks
Copy link
Member Author

Thanks for your useful comment, @jasmussen!

A widget-heading class would probably be useful, but I imagine it might be onerous to add to the heading block just in this context, and if it's not easy, might not be worth it.

Yeah. I think adding the widget-heading class is not the way to go. It will be confusing to users who insert a new Heading block in their widget area as the new Heading block that they add won't have the class and so will appear bigger.

Finally, the heading block comes with options which classic widget headings didn't. Specifically, you can choose your own heading level, which is an important accessibility consideration for some themes that might be using Widgets in a more primary fashion than others.

Great point! 🌈

In addition to being able to set the correct heading level depending on your theme, the heading block comes with the ability to set the font size. That could potentially be a solution here, embracing one of the default smaller presets. I imagine that's why a widget-heading class existed in the first place — H2 might be the correct heading level semantically, but might have been visually too big for the design.

This is a really good idea and not one I'd thought of. I tried it, but it doesn't work fully because we also want the heading to appear bold. We could do this by adding <strong> to the Heading block but I fear that at this point we're having the default blocks assume too much about what everything should look like when really this is the theme's job.

I think it's okay for themes to have to do a few updates here and there, and in this case I imagine there's a widget container they can target, i.e. .widgets h3 instead of h3.widget-heading, it shouldn't be a lot of work, and might be worth it for all the other changes blocks bring to widgets anyway.

I think this is what we have to do! I've adjust the Twenty Twenty-one styles in 249e2d6. Happy to hear thoughts from everyone.

@noisysocks noisysocks force-pushed the fix/default-widgets-in-new-installations branch from 249e2d6 to e29f086 Compare June 4, 2021 05:27
@noisysocks
Copy link
Member Author

Unfortunately this breaks just about every unit test we have 😛. I'll start fixing them on Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants