WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/28/2014 09:11:11 PM (7 years ago)
Author:
johnbillion
Message:

Introduce a new means of outputting a <title> tag in the theme head. Requires a theme to add support by calling add_theme_support( 'title-tag' ). This is the first step in adding a more robust means of generating and outputting the title tag.

See #18548.
Props obenland, chrisbliss18, joostdevalk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r30055 r30074  
    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
     
    17631772    if ( !isset( $_wp_theme_features[$feature] ) )
    17641773        return false;
     1774
     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    }
    17651782
    17661783    // If no args passed then no extra checks need be performed
Note: See TracChangeset for help on using the changeset viewer.