Make WordPress Core

Ticket #18548: 18548.6.diff

File 18548.6.diff, 3.2 KB (added by obenland, 10 years ago)
  • src/wp-includes/default-filters.php

     
    196196add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 );
    197197
    198198// Actions
     199add_action( 'wp_head',             '_wp_render_title_tag',            1     );
    199200add_action( 'wp_head',             'wp_enqueue_scripts',              1     );
    200201add_action( 'wp_head',             'feed_links',                      2     );
    201202add_action( 'wp_head',             'feed_links_extra',                3     );
  • src/wp-includes/general-template.php

     
    731731}
    732732
    733733/**
     734 * Display <title> tag with contents.
     735 *
     736 * @since 4.1.0
     737 * @access private
     738 */
     739function _wp_render_title_tag() {
     740        if ( ! current_theme_supports( 'title-tag' ) ) {
     741                return;
     742        }
     743
     744        // This can only work internally on wp_head.
     745        if ( ! did_action( 'wp_head' ) && ! doing_action( 'wp_head' ) ) {
     746                return;
     747        }
     748
     749        echo "<title>" . wp_title( '|', false, 'right' ) . "</title>\n";
     750}
     751
     752/**
    734753 * Display or retrieve page title for all areas of blog.
    735754 *
    736755 * By default, the page title will display the separator before the page title,
     
    853872                $title = $prefix . implode( " $sep ", $title_array );
    854873        }
    855874
     875        if ( current_theme_supports( 'title-tag' ) && ! is_feed() ) {
     876                global $page, $paged;
     877
     878                $title .= get_bloginfo( 'name', 'display' );
     879
     880                $site_description = get_bloginfo( 'description', 'display' );
     881                if ( $site_description && ( is_home() || is_front_page() ) ) {
     882                        $title .= " $sep $site_description";
     883                }
     884
     885                if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
     886                        $title .= " $sep " . sprintf( __( 'Page %s' ), max( $paged, $page ) );
     887                }
     888        }
     889
    856890        /**
    857891         * Filter the text of the page title.
    858892         *
  • src/wp-includes/theme.php

     
    16111611                                define( 'BACKGROUND_IMAGE', $args[0]['default-image'] );
    16121612
    16131613                        break;
     1614
     1615                // Ensure that 'title-tag' is accessible in the admin.
     1616                case 'title-tag' :
     1617                        // Can be called in functions.php but must happen before wp_loaded, i.e. not in header.php.
     1618                        if ( did_action( 'wp_loaded' ) ) {
     1619                                _doing_it_wrong( "add_theme_support( 'title-tag' )", sprintf( _x( 'You need to add theme support before %s.', 'action name' ), '<code>wp_loaded</code>' ), '4.1.0' );
     1620
     1621                                return false;
     1622                        }
    16141623        }
    16151624
    16161625        $_wp_theme_features[ $feature ] = $args;
     
    17631772        if ( !isset( $_wp_theme_features[$feature] ) )
    17641773                return false;
    17651774
     1775        if ( 'title-tag' == $feature ) {
     1776                // Don't confirm support unless called internally.
     1777                $trace = debug_backtrace();
     1778                if ( ! in_array( $trace[1]['function'], array( '_wp_render_title_tag', 'wp_title' ) ) ) {
     1779                        return false;
     1780                }
     1781        }
     1782
    17661783        // If no args passed then no extra checks need be performed
    17671784        if ( func_num_args() <= 1 )
    17681785                return true;