Make WordPress Core

Ticket #34456: 34456.4.diff

File 34456.4.diff, 2.2 KB (added by Nikschavan, 9 years ago)

I noticed this was adding title two tiles on WordPress 4.3.1, because add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 ); was also being fired along with add_theme_support( 'title-tag' ); add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 ); to compat check, will only be fired if _wp_render_title_tag does not exists.

  • src/wp-content/themes/twentythirteen/functions.php

    diff --git src/wp-content/themes/twentythirteen/functions.php src/wp-content/themes/twentythirteen/functions.php
    index e87761f..5eacb55 100644
    function twentythirteen_setup() { 
    105105
    106106        // This theme uses its own gallery styles.
    107107        add_filter( 'use_default_gallery_style', '__return_false' );
     108
     109        /*
     110         * Let WordPress manage the document title.
     111         * By adding theme support, we declare that this theme does not use a
     112         * hard-coded <title> tag in the document head, and expect WordPress to
     113         * provide it for us.
     114         */
     115        if ( function_exists( '_wp_render_title_tag' ) ) {
     116                add_theme_support( 'title-tag' );
     117        } else {               
     118                add_action( 'wp_head', 'twentythirteen_render_title' );
     119                add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 );
     120        }
     121
    108122}
    109123add_action( 'after_setup_theme', 'twentythirteen_setup' );
    110124
    function twentythirteen_scripts_styles() { 
    188202add_action( 'wp_enqueue_scripts', 'twentythirteen_scripts_styles' );
    189203
    190204/**
     205 * Provide backwords compatibility for the title-tag theme support.
     206 *
     207 * Adds <title> tags in the head of the document.
     208 *
     209 * @since Twenty Thirteen 1.7
     210 */
     211function twentythirteen_render_title() {
     212        ?>
     213        <title><?php wp_title( '|', true, 'right' ); ?></title>
     214        <?php
     215}
     216
     217/**
    191218 * Filter the page title.
    192219 *
    193220 * Creates a nicely formatted and more specific title element text for output
    function twentythirteen_wp_title( $title, $sep ) { 
    219246
    220247        return $title;
    221248}
    222 add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 );
    223249
    224250/**
    225251 * Register two widget areas.
  • src/wp-content/themes/twentythirteen/header.php

    diff --git src/wp-content/themes/twentythirteen/header.php src/wp-content/themes/twentythirteen/header.php
    index 094f74c..43d90b3 100644
     
    2121<head>
    2222        <meta charset="<?php bloginfo( 'charset' ); ?>">
    2323        <meta name="viewport" content="width=device-width">
    24         <title><?php wp_title( '|', true, 'right' ); ?></title>
    2524        <link rel="profile" href="http://gmpg.org/xfn/11">
    2625        <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    2726        <!--[if lt IE 9]>