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-theme-<name> and wp-child-theme-<name> classes to body tag #7038

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions src/wp-admin/admin-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@
$admin_body_class .= ' block-editor-page wp-embed-responsive';
}

// Append the active theme's name as a CSS class to the body class.
$admin_body_class .= ' wp-theme-' . sanitize_html_class( get_option( 'template' ) );
nirajgiriXD marked this conversation as resolved.
Show resolved Hide resolved

// If a child theme is active, append the child theme's name as an additional CSS class.
if ( is_child_theme() ) {
$admin_body_class .= ' wp-child-theme-' . sanitize_html_class( get_option( 'stylesheet' ) );
nirajgiriXD marked this conversation as resolved.
Show resolved Hide resolved
}

$error_get_last = error_get_last();

// Print a CSS class to make PHP errors visible.
Expand Down
8 changes: 8 additions & 0 deletions src/wp-includes/post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,14 @@ function get_body_class( $css_class = '' ) {
}
}

// Add the active theme's name as a CSS class to the body classes array.
$classes[] = 'wp-theme-' . sanitize_html_class( get_option( 'template' ) );
nirajgiriXD marked this conversation as resolved.
Show resolved Hide resolved

// If a child theme is active, add the child theme's name as an additional CSS class to the body classes array.
if ( is_child_theme() ) {
$classes[] = 'wp-child-theme-' . sanitize_html_class( get_option( 'stylesheet' ) );
nirajgiriXD marked this conversation as resolved.
Show resolved Hide resolved
}

if ( ! empty( $css_class ) ) {
if ( ! is_array( $css_class ) ) {
$css_class = preg_split( '#\s+#', $css_class );
Expand Down
Loading