WordPress.org

Make WordPress Core

Ticket #19736: body-class-defaults.patch

File body-class-defaults.patch, 1.7 KB (added by cais, 4 years ago)
  • wp-includes/post-template.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    536536                        $classes[] = 'post-type-paged-' . $page; 
    537537        } 
    538538 
     539    /** Add child-theme-<Name> to default body classes */ 
     540    if ( is_child_theme() ) { 
     541        $active_theme_css_url = get_stylesheet_directory() . '/style.css'; 
     542        $active_theme_data = get_theme_data( $active_theme_css_url ); 
     543        // set Name to lower case 
     544        $active_theme_slug = esc_attr( strtolower( $active_theme_data['Name'] ) ); 
     545        // concatenate multiple word names by replacing spaces with hyphens 
     546        $active_theme_slug = preg_replace( '/\s\s+/', ' ', $active_theme_slug ); 
     547        $active_theme_slug = preg_replace( '/\\040/', '-', $active_theme_slug ); 
     548        $classes[] = 'child-theme-' . $active_theme_slug; 
     549    } 
     550 
     551    /** Add theme-<Name> to default body classes */ 
     552    $parent_theme_css_url = get_template_directory() . '/style.css'; 
     553    $parent_theme_data = get_theme_data( $parent_theme_css_url ); 
     554    // set Name to lower case 
     555    $parent_theme_slug = esc_attr( strtolower( $parent_theme_data['Name'] ) ); 
     556    // concatenate multiple word names by replacing spaces with hyphens 
     557    $parent_theme_slug = preg_replace( '/\s\s+/', ' ', $parent_theme_slug ); 
     558    $parent_theme_slug = preg_replace( '/\\040/', '-', $parent_theme_slug ); 
     559    $classes[] = 'theme-' . $parent_theme_slug; 
     560 
    539561        if ( ! empty( $class ) ) { 
    540562                if ( !is_array( $class ) ) 
    541563                        $class = preg_split( '#\s+#', $class );