Changeset 36168
- Timestamp:
- 01/04/2016 05:15:31 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r36107 r36168 857 857 $title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() ); 858 858 859 // If on the home orfront page, use the site title.860 } elseif ( is_ home() && is_front_page() ) {859 // If on the front page, use the site title. 860 } elseif ( is_front_page() ) { 861 861 $title['title'] = get_bloginfo( 'name', 'display' ); 862 862 … … 870 870 871 871 /* 872 * If we're on the blog page and that page is not the homepage or a single 873 * page that is designated as the homepage, use the container page's title. 874 */ 875 } elseif ( ( is_home() && ! is_front_page() ) || ( ! is_home() && is_front_page() ) ) { 876 $title['title'] = single_post_title( '', false ); 877 878 // If on a single post of any post type, use the post title. 879 } elseif ( is_singular() ) { 872 * If we're on the blog page that is not the homepage or 873 * a single post of any post type, use the post title. 874 */ 875 } elseif ( is_home() || is_singular() ) { 880 876 $title['title'] = single_post_title( '', false ); 881 877 … … 905 901 906 902 // Append the description or site title to give context. 907 if ( is_ home() && is_front_page() ) {903 if ( is_front_page() ) { 908 904 $title['tagline'] = get_bloginfo( 'description', 'display' ); 909 905 } else { -
trunk/tests/phpunit/tests/general/document-title.php
r35334 r36168 80 80 function test_front_page_title() { 81 81 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 82 update_option( 'page_on_front', $this->factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) ); 84 85 $this->go_to( '/' ); 86 87 $this->assertEquals( sprintf( ' front-page – %s', $this->blog_name ), wp_get_document_title() );83 add_filter( 'document_title_parts', array( $this, '_front_page_title_parts' ) ); 84 85 $this->go_to( '/' ); 86 $this->assertEquals( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); 88 87 89 88 update_option( 'show_on_front', 'posts' ); 90 } 91 92 function test_home_title() { 93 $this->go_to( '/' ); 94 95 add_filter( 'document_title_parts', array( $this, '_home_title_parts' ) ); 96 89 90 $this->go_to( '/' ); 97 91 $this->assertEquals( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); 98 92 } 99 93 100 function _ home_title_parts( $parts ) {94 function _front_page_title_parts( $parts ) { 101 95 $this->assertArrayHasKey( 'title', $parts ); 102 96 $this->assertArrayHasKey( 'tagline', $parts ); … … 104 98 105 99 return $parts; 100 } 101 102 function test_home_title() { 103 $blog_page_id = $this->factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ); 104 update_option( 'show_on_front', 'page' ); 105 update_option( 'page_for_posts', $blog_page_id ); 106 107 // Show page name on home page if it's not the front page. 108 $this->go_to( get_permalink( $blog_page_id ) ); 109 $this->assertEquals( sprintf( 'blog-page – %s', $this->blog_name ), wp_get_document_title() ); 106 110 } 107 111
Note: See TracChangeset
for help on using the changeset viewer.