Improve body class for page templates.

* Convert slash to dash too.
* Add sub-folder name as a separate body class.
* New classes are additional classes, old syntax will persists for BC.

With this `/page-templates/full-width.php` will produce `page-template`, `page-template-page-templates`, `page-template-full-width` and `page-template-page-templatesfull-width-php`.

props obenland, Caspie, donutz.
fixes #23470.
Built from https://develop.svn.wordpress.org/trunk@30100


git-svn-id: http://core.svn.wordpress.org/trunk@30100 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2014-10-29 22:20:23 +00:00
parent 76876654ac
commit 4df00e156d
2 changed files with 9 additions and 2 deletions

View File

@ -615,7 +615,14 @@ function get_body_class( $class = '' ) {
}
if ( is_page_template() ) {
$classes[] = 'page-template';
$classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_page_template_slug( $page_id ) ) );
$template_slug = get_page_template_slug( $page_id );
$template_parts = explode( '/', $template_slug );
foreach ( $template_parts as $part ) {
$classes[] = 'page-template-' . sanitize_html_class( str_replace( array( '.', '/' ), '-', basename( $part, '.php' ) ) );
}
$classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', $template_slug ) );
} else {
$classes[] = 'page-template-default';
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-alpha-30099';
$wp_version = '4.1-alpha-30100';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.