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

Add wp-embed-responsive body class to customizer #1476

Closed
wants to merge 1 commit into from
Closed

Add wp-embed-responsive body class to customizer #1476

wants to merge 1 commit into from

Conversation

walbo
Copy link
Member

@walbo walbo commented Jul 6, 2021

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


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.

@@ -128,7 +128,7 @@
wp_user_settings();
_wp_admin_html_begin();

$body_class = 'wp-core-ui wp-customizer js';
$body_class = 'wp-core-ui wp-customizer wp-embed-responsive js';
Copy link
Member

@kevin940726 kevin940726 Jul 7, 2021

Choose a reason for hiding this comment

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

I'm not sure if we should add this regardlessly. It seems like we only add this if the theme supports responsive embeds in the post editor:

if ( current_theme_supports( 'responsive-embeds' ) ) {
$classes[] = 'wp-embed-responsive';
}

We can add this if statement here as well. WDYT?

No wait, seems like it's being added here instead.

if ( $current_screen->is_block_editor() ) {
$admin_body_class .= ' block-editor-page wp-embed-responsive';
}

Since that every block editor will have this class in <body>, the fix seems reasonable.

However, I don't think the editor should be relying on class names on <body> to work. Probably worth to fix it in gutenberg instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

current_theme_supports( 'responsive-embeds' ) only applies frontend in the body_class().

Seems the class is added backend if the current screen is an block editor.

if ( $current_screen->is_block_editor() ) {
$admin_body_class .= ' block-editor-page wp-embed-responsive';
}

--
Did a quick test adding the conditional and removed responsive-embeds support. In the post editor the embeds work but in the cusomtizer they didn't.

Copy link
Member

Choose a reason for hiding this comment

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

How about we add the class conditionally based on whether or not the block editor is being used in the Customizer?

if ( wp_use_widgets_block_editor() ) {
	$body_class .= ' wp-embed-responsive';
}

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.

3 participants