WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/20/2015 04:20:04 PM (4 years ago)
Author:
obenland
Message:

Themes: Improve document title output.

Introduces more flexibility in filtering all parts of the document title,the
separator, and a way to short-circuit title generation. Plugins can now also
check for theme support and reliably filter the entire output. See #18548.
Deprecates wp_title().

Fixes #31078.

File:
1 edited

Legend:

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

    r34230 r35294  
    9292 *
    9393 * @since 2.2.0
    94  *
    95  * @param string $sep Optional. How to separate the title. See wp_title() for more info.
    96  * @return string Error message on failure or blog title on success.
    97  */
    98 function get_wp_title_rss( $sep = '»' ) {
    99     $title = wp_title( $sep, false );
    100 
    101     if ( is_wp_error( $title ) ) {
    102         return $title->get_error_message();
    103     }
    104 
    105     if ( $title && $sep && ' ' !== substr( $title, 0, 1 ) ) {
    106         $title = " $sep " . $title;
     94 * @since 4.4.0 Deprecated argument.
     95 *
     96 * @param string $deprecated Deprecated.
     97 * @return string The document title.
     98 */
     99function get_wp_title_rss( $deprecated = '–' ) {
     100    if ( '–' !== $deprecated ) {
     101        _deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), '<code>document_title_separator</code>' ) );
    107102    }
    108103
     
    111106     *
    112107     * @since 2.2.0
    113      *
    114      * @param string $title The current blog title.
    115      * @param string $sep   Separator used by wp_title().
    116      */
    117     $title = apply_filters( 'get_wp_title_rss', $title, $sep );
    118     return $title;
     108     * @since 4.4.0 Deprecated argument.
     109     *
     110     * @param string $title      The current blog title.
     111     * @param string $deprecated Deprecated.
     112     */
     113    return apply_filters( 'get_wp_title_rss', wp_get_document_title(), $deprecated );
    119114}
    120115
     
    123118 *
    124119 * @since 2.2.0
    125  * @see wp_title() $sep parameter usage.
    126  *
    127  * @param string $sep Optional.
    128  */
    129 function wp_title_rss( $sep = '&#187;' ) {
     120 * @since 4.4.0 Deprecated argument.
     121 *
     122 * @param string $deprecated Optional.
     123 */
     124function wp_title_rss( $deprecated = '&#8211;' ) {
     125    if ( '&#8211;' !== $deprecated ) {
     126        _deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), '<code>document_title_separator</code>' ) );
     127    }
     128
    130129    /**
    131130     * Filter the blog title for display of the feed title.
    132131     *
    133132     * @since 2.2.0
     133     * @since 4.4.0 Deprecated argument.
    134134     *
    135135     * @see get_wp_title_rss()
    136136     *
    137      * @param string $wp_title The current blog title.
    138      * @param string $sep      Separator used by wp_title().
    139      */
    140     echo apply_filters( 'wp_title_rss', get_wp_title_rss( $sep ), $sep );
     137     * @param string $wp_title_rss The current blog title.
     138     * @param string $deprecated   Deprecated.
     139     */
     140    echo apply_filters( 'wp_title_rss', get_wp_title_rss(), $deprecated );
    141141}
    142142
Note: See TracChangeset for help on using the changeset viewer.