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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-admin/customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}


if ( wp_is_mobile() ) :
$body_class .= ' mobile';
Expand Down