WordPress.org

Make WordPress Core

Ticket #38766: 38766.3.diff

File 38766.3.diff, 4.7 KB (added by peterwilsoncc, 4 years ago)
  • src/wp-includes/class-wp-theme.php

    diff --git src/wp-includes/class-wp-theme.php src/wp-includes/class-wp-theme.php
    index 8b3661a..f161a63 100644
    final class WP_Theme implements ArrayAccess { 
    10381038                                }
    10391039
    10401040                                foreach ( $types as $type ) {
    1041                                         $type = trim( $type );
     1041                                        $type = sanitize_key( $type );
    10421042                                        if ( ! isset( $post_templates[ $type ] ) ) {
    10431043                                                $post_templates[ $type ] = array();
    10441044                                        }
  • new file tests/phpunit/data/themedir1/page-templates/38766/no-trailing-period-post-types.php

    diff --git tests/phpunit/data/themedir1/page-templates/38766/no-trailing-period-post-types.php tests/phpunit/data/themedir1/page-templates/38766/no-trailing-period-post-types.php
    new file mode 100644
    index 0000000..2b68671
    - +  
     1<?php
     2/*
     3   Template Name: No Trailing Period
     4   Template Post Type: period, full-stop
     5 */
  • new file tests/phpunit/data/themedir1/page-templates/38766/tilde-post-types.php

    diff --git tests/phpunit/data/themedir1/page-templates/38766/tilde-post-types.php tests/phpunit/data/themedir1/page-templates/38766/tilde-post-types.php
    new file mode 100644
    index 0000000..fd1a8ec
    - +  
     1<?php
     2/*
     3   Template Name: Tilde in Post Type.
     4   Template Post Type: period, full~stop
     5
     6   This template should be applied to the `period` post type and ignored by the `full-stop` post type.
     7 */
  • new file tests/phpunit/data/themedir1/page-templates/38766/trailing-comma-post-types.php

    diff --git tests/phpunit/data/themedir1/page-templates/38766/trailing-comma-post-types.php tests/phpunit/data/themedir1/page-templates/38766/trailing-comma-post-types.php
    new file mode 100644
    index 0000000..9069f54
    - +  
     1<?php
     2/*
     3   Template Name: Trailing Comma,
     4   Template Post Type: period, full-stop,
     5 */
  • new file tests/phpunit/data/themedir1/page-templates/38766/trailing-period-post-types.php

    diff --git tests/phpunit/data/themedir1/page-templates/38766/trailing-period-post-types.php tests/phpunit/data/themedir1/page-templates/38766/trailing-period-post-types.php
    new file mode 100644
    index 0000000..4c703bb
    - +  
     1<?php
     2/*
     3   Template Name: Trailing Period.
     4   Template Post Type: period, full-stop.
     5 */
  • new file tests/phpunit/data/themedir1/page-templates/38766/trailing-period-whitespace-post-types.php

    diff --git tests/phpunit/data/themedir1/page-templates/38766/trailing-period-whitespace-post-types.php tests/phpunit/data/themedir1/page-templates/38766/trailing-period-whitespace-post-types.php
    new file mode 100644
    index 0000000..aeb6688
    - +  
     1<?php
     2/*
     3   Template Name: Trailing Period, White Space.
     4   Template Post Type: period, full-stop.       
     5 */
  • new file tests/phpunit/data/themedir1/page-templates/38766/trailing-whitespace-period-post-types.php

    diff --git tests/phpunit/data/themedir1/page-templates/38766/trailing-whitespace-period-post-types.php tests/phpunit/data/themedir1/page-templates/38766/trailing-whitespace-period-post-types.php
    new file mode 100644
    index 0000000..2b123fa
    - +  
     1<?php
     2/*
     3   Template Name: Trailing White Space, Period.
     4   Template Post Type: period, full-stop         .
     5 */
  • tests/phpunit/tests/admin/includesTheme.php

    diff --git tests/phpunit/tests/admin/includesTheme.php tests/phpunit/tests/admin/includesTheme.php
    index 5319006..522615c 100644
    class Tests_Admin_includesTheme extends WP_UnitTestCase { 
    8787        }
    8888
    8989        /**
     90         * @ticket 38766
     91         */
     92        function test_page_templates_for_post_types_with_trailing_periods() {
     93                $theme = wp_get_theme( 'page-templates' );
     94                $this->assertNotEmpty( $theme );
     95
     96                switch_theme( $theme['Template'], $theme['Stylesheet'] );
     97
     98                $this->assertEqualSetsWithIndex( array(
     99                        'No Trailing Period' => '38766/no-trailing-period-post-types.php',
     100                        'Trailing Period.' => '38766/trailing-period-post-types.php',
     101                        'Trailing Comma,' => '38766/trailing-comma-post-types.php',
     102                        'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
     103                        'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
     104                        'Tilde in Post Type.' => '38766/tilde-post-types.php',
     105                ), get_page_templates( null, 'period' ) );
     106                $this->assertEqualSetsWithIndex( array(
     107                        'No Trailing Period' => '38766/no-trailing-period-post-types.php',
     108                        'Trailing Period.' => '38766/trailing-period-post-types.php',
     109                        'Trailing Comma,' => '38766/trailing-comma-post-types.php',
     110                        'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
     111                        'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
     112                ), get_page_templates( null, 'full-stop' ) );
     113        }
     114
     115        /**
    90116         * @ticket 38696
    91117         */
    92118        function test_page_templates_child_theme() {