Making WordPress.org

Changeset 783


Ignore:
Timestamp:
08/12/2014 06:32:18 AM (10 years ago)
Author:
coffee2code
Message:

Code Reference: define and show custom title for site pages

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/header.php

    r781 r783  
    77 * @package wporg-developer
    88 */
     9
     10$GLOBALS['pagetitle'] = wp_title( '|', false, 'right' );
     11
    912require WPORGPATH . 'header.php';
    1013?>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/extras.php

    r781 r783  
    5050    }
    5151
    52     // Add the blog name
    53     $title .= get_bloginfo( 'name' );
     52    $post_type = get_query_var( 'post_type' );
     53
     54    // Add post type to title if it's a parsed item.
     55    if ( 0 === strpos( $post_type, 'wp-parser-' ) ) {
     56        if ( $post_type_object = get_post_type_object( $post_type ) ) {
     57            $title .= get_post_type_object( $post_type )->labels->singular_name . " $sep ";
     58        }
     59    }
     60    // Add handbook name to title if relevent
     61    elseif ( false !== strpos( $post_type, 'handbook' ) ) {
     62        if ( $post_type_object = get_post_type_object( $post_type ) ) {
     63            $label = get_post_type_object( $post_type )->labels->name . " $sep ";
     64            // Don't add the label for a page of the same name as post type name.
     65            if ( $title != $label ) {
     66                $title .= $label;
     67            }
     68        }
     69    }
    5470
    5571    // Add the blog description for the home/front page.
     
    6379        $title .= " $sep " . sprintf( __( 'Page %s', 'wporg' ), max( $paged, $page ) );
    6480    }
     81
     82    // Add the blog name
     83    $title .= get_bloginfo( 'name' );
    6584
    6685    return $title;
     
    7695function wporg_filter_archive_excerpt( $excerpt ) {
    7796    if ( ! is_single() ) {
    78         $excerpt = '<b>' . get_post_type_labels( get_post_type_object( get_post_type( get_the_ID() ) ) )->singular_name . ': </b>' . $excerpt;
     97        $excerpt = '<b>' . get_post_type_object( get_post_type( get_the_ID() ) )->labels->singular_name . ': </b>' . $excerpt;
    7998    }
    8099
     
    90109 */
    91110function wporg_filter_archive_title( $title ) {
    92     if ( ! is_single() && in_array( get_post_type(), array( 'wp-parser-function', 'wp-parser-method' ) ) ) {
     111    if ( ( ! is_single() || doing_filter( 'single_post_title' ) ) && in_array( get_post_type(), array( 'wp-parser-function', 'wp-parser-method' ) ) ) {
    93112        $title .= '()';
    94113    }
     
    97116}
    98117add_filter( 'the_title', 'wporg_filter_archive_title' );
     118add_filter( 'single_post_title', 'wporg_filter_archive_title' );
Note: See TracChangeset for help on using the changeset viewer.