Make WordPress Core

Ticket #23470: 23470.2.diff

File 23470.2.diff, 1.1 KB (added by obenland, 11 years ago)
  • src/wp-includes/post-template.php

     
    592592                        $classes[] = 'parent-pageid-' . $post->post_parent;
    593593                }
    594594                if ( is_page_template() ) {
     595                        $template_slug  = get_page_template_slug( $page_id );
     596                        $template_parts = explode( '/', $template_slug );
     597                        $template_dir   = array_shift( $template_parts );
     598
    595599                        $classes[] = 'page-template';
    596                         $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_page_template_slug( $page_id ) ) );
     600
     601                        if ( ! empty( $template_dir ) ) {
     602                                $classes[] = 'page-template-' . sanitize_html_class( str_replace( array( '.', '/' ), '-', $template_dir ) );
     603                        }
     604
     605                        $classes[] = 'page-template-' . sanitize_html_class( str_replace( array( '.', '/' ), '-', $template_slug ) );
     606                        $classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', $template_slug ) );
    597607                } else {
    598608                        $classes[] = 'page-template-default';
    599609                }