From ad2d18200f90bc762c10a557f0e510cd9a2d99d1 Mon Sep 17 00:00:00 2001 From: David Allsop <50546855+medavidallsop@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:21:33 +0100 Subject: [PATCH] Add additional body class for the account dashboard (#30050) (#51147) Co-authored-by: github-actions Co-authored-by: Nestor Soriano --- plugins/woocommerce/changelog/51147-30050 | 4 ++++ plugins/woocommerce/includes/wc-template-functions.php | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 plugins/woocommerce/changelog/51147-30050 diff --git a/plugins/woocommerce/changelog/51147-30050 b/plugins/woocommerce/changelog/51147-30050 new file mode 100644 index 00000000000..1c94e59a7c8 --- /dev/null +++ b/plugins/woocommerce/changelog/51147-30050 @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Add additional body class for the account dashboard \ No newline at end of file diff --git a/plugins/woocommerce/includes/wc-template-functions.php b/plugins/woocommerce/includes/wc-template-functions.php index 5b804e25533..10a4ebdc563 100644 --- a/plugins/woocommerce/includes/wc-template-functions.php +++ b/plugins/woocommerce/includes/wc-template-functions.php @@ -299,6 +299,9 @@ function wc_generator_tag( $gen, $type ) { * @return array */ function wc_body_class( $classes ) { + + global $wp; + $classes = (array) $classes; if ( is_shop() ) { @@ -327,6 +330,11 @@ function wc_body_class( $classes ) { $classes[] = 'woocommerce-account'; $classes[] = 'woocommerce-page'; + $account_page_id = get_option( 'woocommerce_myaccount_page_id' ); + + if ( ! empty( $account_page_id ) && ( get_post_field( 'post_name', $account_page_id ) === basename( $wp->request ) && is_user_logged_in() ) ) { + $classes[] = 'woocommerce-dashboard'; + } } if ( is_store_notice_showing() ) {