From 4de28b054d805c5ce36ba87a3595724fdc8dc707 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Fri, 24 Jan 2025 10:58:24 +0000 Subject: [PATCH] Themes: Add `wp-theme-` and `wp-child-theme-` classes to `body_class`. This changeset introduces new classes to the body tag. The classes `wp-theme-` and `wp-child-theme-` (when the current theme is a child theme) are added, where `` represents the sanitized name of the active theme. Props cais, GaryJ, nacin, SergeyBiryukov, johnjamesjacoby, nirajgirixd, poena, audrasjb, rinkalpagdar. Fixes #19736. Built from https://develop.svn.wordpress.org/trunk@59698 git-svn-id: http://core.svn.wordpress.org/trunk@59040 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-header.php | 5 +++++ wp-includes/post-template.php | 5 +++++ wp-includes/version.php | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 54bcc11ca5..ea0245fdb1 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -214,6 +214,11 @@ if ( $current_screen->is_block_editor() ) { $admin_body_class .= ' block-editor-page wp-embed-responsive'; } +$admin_body_class .= ' wp-theme-' . sanitize_html_class( get_template() ); +if ( is_child_theme() ) { + $admin_body_class .= ' wp-child-theme-' . sanitize_html_class( get_stylesheet() ); +} + $error_get_last = error_get_last(); // Print a CSS class to make PHP errors visible. diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 8b84b86702..ffcca1647d 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -838,6 +838,11 @@ function get_body_class( $css_class = '' ) { } } + $classes[] = 'wp-theme-' . sanitize_html_class( get_template() ); + if ( is_child_theme() ) { + $classes[] = 'wp-child-theme-' . sanitize_html_class( get_stylesheet() ); + } + if ( ! empty( $css_class ) ) { if ( ! is_array( $css_class ) ) { $css_class = preg_split( '#\s+#', $css_class ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 8b9641deda..290c4cabdd 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59697'; +$wp_version = '6.8-alpha-59698'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.