Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #57422


Ignore:
Timestamp:
01/05/2023 02:32:28 PM (2 years ago)
Author:
sabernhardt
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #57422

    • Property Keywords changes-requested removed
    • Property Component changed from General to Posts, Post Types
  • Ticket #57422 – Description

    initial v1  
    1 When is_singular() and is_page_template() and the template file is inside a directory within the theme folder, get_body_class() adds a class with a missing hyphen between the template directory and the template file name.
     1When `is_singular()` and `is_page_template()` and the template file is inside a directory within the theme folder, `get_body_class()` adds a class with a missing hyphen between the template directory and the template file name.
    22
    3 post-template.php line 677;
     3`post-template.php` line 677;
    44
    5 $classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( '.', '-', $template_slug ) );
     5`$classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( '.', '-', $template_slug ) );`
    66
    7 Example: post_type is page and template file is, "page-templates/my-template-file.php"
     7Example: `post_type` is page and template file is, `page-templates/my-template-file.php`
    88
    9 Result: .page-template-page-templatesmy-template-file-php
     9Result: `.page-template-page-templatesmy-template-file-php`
    1010
    11 Suggested change to post-template.php line 677;
     11Suggested change to `post-template.php` line 677;
    1212
    13 $classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( array( '.', '/' ), '-', $template_slug ) );
     13`$classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( array( '.', '/' ), '-', $template_slug ) );`