Skip to content

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

Closed
walbo wants to merge 1 commit intoWordPress:masterfrom
walbo:53609
Closed

Add wp-embed-responsive body class to customizer#1476
walbo wants to merge 1 commit intoWordPress:masterfrom
walbo:53609

Conversation

@walbo
Copy link
Copy Markdown
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.

_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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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