Changeset 2010 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php
- Timestamp:
- 10/26/2015 07:41:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php
r1475 r2010 39 39 * Filters wp_title to print a neat <title> tag based on what is being viewed. 40 40 * 41 * @param string $title Default title text for current view. 42 * @param string $sep Optional separator. 43 * @return string The filtered title. 41 * @param array $parts The document title parts. 42 * @return array The document title parts. 44 43 */ 45 function wporg_developer_wp_title( $ title, $sep) {44 function wporg_developer_wp_title( $parts ) { 46 45 global $page, $paged; 47 46 48 47 if ( is_feed() ) { 49 return $ title;48 return $parts; 50 49 } 50 51 $title = $parts['title']; 52 $sep = '|'; 51 53 52 54 $post_type = get_query_var( 'post_type' ); 53 55 56 // Omit 'Home' from the home page. 57 if ( 'Home' === $title ) { 58 $title = ''; 59 } 54 60 // Add post type to title if it's a parsed item. 55 if ( is_singular() && \DevHub\is_parsed_post_type( $post_type ) ) {61 elseif ( is_singular() && \DevHub\is_parsed_post_type( $post_type ) ) { 56 62 if ( $post_type_object = get_post_type_object( $post_type ) ) { 57 $title .= get_post_type_object( $post_type )->labels->singular_name . " $sep ";63 $title .= " $sep " . get_post_type_object( $post_type )->labels->singular_name; 58 64 } 59 65 } … … 61 67 elseif ( is_singular() && false !== strpos( $post_type, 'handbook' ) ) { 62 68 if ( $post_type_object = get_post_type_object( $post_type ) ) { 63 $handbook_label = get_post_type_object( $post_type )->labels->name . " $sep ";64 $handbook_name = \WPorg_Handbook::get_name( $post_type ) . " Handbook $sep";69 $handbook_label = " $sep " . get_post_type_object( $post_type )->labels->name; 70 $handbook_name = " $sep " . \WPorg_Handbook::get_name( $post_type ) . " Handbook"; 65 71 66 72 // Replace title with handbook name if this is landing page for the handbook … … 75 81 76 82 // Add a page number if necessary: 77 if ( $paged >= 2 || $page>= 2 ) {78 $title .= sprintf( __( 'Page %s', 'wporg' ), max( $paged, $page ) ) . " $sep ";83 if ( isset( $parts['page'] ) && $parts['page'] >= 2 ) { 84 $title .= " $sep " . sprintf( __( 'Page %s', 'wporg' ), $parts['page'] ); 79 85 } 80 86 81 // Add the blog name 82 $title .= get_bloginfo( 'name' ); 83 84 return $title; 87 $parts['title'] = $title; 88 return $parts; 85 89 } 86 add_filter( ' wp_title', 'wporg_developer_wp_title', 10, 2);90 add_filter( 'document_title_parts', 'wporg_developer_wp_title' ); 87 91 88 92 /**
Note: See TracChangeset
for help on using the changeset viewer.