Making WordPress.org

Changeset 2042


Ignore:
Timestamp:
11/05/2015 06:50:05 PM (9 years ago)
Author:
coffee2code
Message:

apps.wordpress.org: Filter 'document_title_parts' instead of the deprecated 'wp_title' to customize document title. See #1353.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-apps/inc/extras.php

    r843 r2042  
    3737
    3838/**
    39  * Filters wp_title to print a neat <title> tag based on what is being viewed.
     39 * Filters document title to add context based on what is being viewed.
    4040 *
    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.
    4443 */
    45 function wpmobileapps_wp_title( $title, $sep ) {
     44function wpmobileapps_document_title( $parts ) {
    4645    if ( is_feed() ) {
    47         return $title;
     46        return $parts;
    4847    }
    4948
    5049    global $page, $paged;
    5150
    52     // Add the blog name
    53     $title .= get_bloginfo( 'name', 'display' );
     51    $title = $parts['title'];
     52    $sep = '|';
    5453
    5554    // Add the blog description for the home/front page.
    5655    $site_description = get_bloginfo( 'description', 'display' );
    5756    if ( $site_description && ( is_home() || is_front_page() ) ) {
    58         $title .= " $sep $site_description";
     57        $title = $site_description;
    5958    }
    6059
    6160    // Add a page number if necessary:
    62     if ( $paged >= 2 || $page >= 2 ) {
    63         $title .= " $sep " . sprintf( __( 'Page %s', 'wpmobileapps' ), max( $paged, $page ) );
     61    if ( isset( $parts['page'] ) && $parts['page'] >= 2 ) {
     62        $title .= " $sep " . sprintf( __( 'Page %s', 'wpmobileapps' ), $parts['page'] );
    6463    }
    6564
    66     return $title;
     65    $parts['title'] = $title;
     66    return $parts;
    6767}
    68 add_filter( 'wp_title', 'wpmobileapps_wp_title', 10, 2 );
     68add_filter( 'document_title_parts', 'wpmobileapps_document_title' );
    6969
    7070/**
Note: See TracChangeset for help on using the changeset viewer.