WordPress.org

Make WordPress Core

Ticket #34962: 34962.diff

File 34962.diff, 2.2 KB (added by peterwilsoncc, 5 years ago)
  • src/wp-includes/general-template.php

    diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
    index c7498ab..6950fdf 100644
    a b function wp_get_document_title() { 
    857857                $title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() );
    858858
    859859        // If on the home or front page, use the site title.
    860         } elseif ( is_home() && is_front_page() ) {
     860        } elseif ( is_front_page() ) {
    861861                $title['title'] = get_bloginfo( 'name', 'display' );
    862862
    863863        // If on a post type archive, use the post type archive title.
    function wp_get_document_title() { 
    904904        }
    905905
    906906        // Append the description or site title to give context.
    907         if ( is_home() && is_front_page() ) {
     907        if ( is_front_page() ) {
    908908                $title['tagline'] = get_bloginfo( 'description', 'display' );
    909909        } else {
    910910                $title['site'] = get_bloginfo( 'name', 'display' );
  • tests/phpunit/tests/general/document-title.php

    diff --git a/tests/phpunit/tests/general/document-title.php b/tests/phpunit/tests/general/document-title.php
    index 19886a5..8e52978 100644
    a b class Tests_General_DocumentTitle extends WP_UnitTestCase { 
    7878        }
    7979
    8080        function test_front_page_title() {
     81                $blog_page_id = $this->factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) );
    8182                update_option( 'show_on_front', 'page' );
    82                 update_option( 'page_for_posts', $this->factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );
     83                update_option( 'page_for_posts', $blog_page_id );
    8384                update_option( 'page_on_front', $this->factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );
    8485
    8586                $this->go_to( '/' );
    8687
    87                 $this->assertEquals( sprintf( 'front-page – %s', $this->blog_name ), wp_get_document_title() );
     88                $this->assertEquals( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() );
     89
     90                $this->go_to( get_permalink( $blog_page_id ) );
     91
     92                $this->assertEquals( sprintf( 'blog-page – %s', $this->blog_name ), wp_get_document_title() );
    8893
    8994                update_option( 'show_on_front', 'posts' );
    9095        }