WordPress.org

Make WordPress Core

Ticket #21995: 21995.3.diff

File 21995.3.diff, 2.9 KB (added by DrewAPicture, 5 years ago)

Fix specifier typo in $after, allow bypassing $container

  • wp-includes/general-template.php

     
    790790}
    791791
    792792/**
     793 * Retrieve or display the archive title based on the queried object
     794 *
     795 * @since 3.6.0
     796 *
     797 * @param string $prefix Optional. What to display before the title.
     798 * @param string $container Optional. The HTML container to wrap the type of archive with.
     799 * @param bool $display Whether to display or return the archive title.
     800 * @return string Text archive title
     801 */
     802function the_archive_title( $prefix = '', $container = 'span', $display = true ) {
     803        $before = $after = '';
     804        if ( ! empty( $container ) ) {
     805                $before = sprintf( '<%s>', $container );
     806                $after = sprintf( '</%s>', $container );
     807        }
     808
     809        if ( is_day() )
     810                $title = sprintf( __( 'Daily Archives: %s' ), $before . get_the_date() . $after );
     811        elseif ( is_month() )
     812                $title = sprintf( __( 'Monthly Archives: %s' ), $before . get_the_date( _x( 'F Y', 'monthly archives date format' ) ) . $after );
     813        elseif ( is_year() )
     814                $title = sprintf( __( 'Yearly Archives: %s' ), $before . get_the_date( _x( 'Y', 'yearly archives date format' ) ) . $after );
     815        elseif ( is_tag() )
     816                $title = sprintf( __( 'Tag Archives: %s' ), $before . single_tag_title( '', false ) . $after );
     817        elseif ( is_category() )
     818                $title = sprintf( __( 'Category Archives: %s' ), $before . single_cat_title( '', false ) . $after );
     819        elseif ( is_tax() )
     820                $title = sprintf( __( 'Taxonomy Archives: %s' ), $before . single_term_title( '', false ) . $after );
     821        elseif ( is_author() )
     822                $title = sprintf( __( 'Author Archives: %s' ), $before . get_the_author() . $after );
     823        elseif ( is_post_type_archive() )
     824                $title = sprintf( __( 'Archives: %s' ), $before . post_type_archive_title( '', false ) . $after );
     825        else
     826                $title = __( 'Archives' );
     827       
     828        $title = $prefix . $title;
     829
     830        if ( $display )
     831                echo apply_filters( 'the_archive_title', $title );
     832        else
     833                return apply_filters( 'the_archive_title', $title );
     834}
     835
     836/**
     837 * Retrieve or display tag, category or term description
     838 *
     839 * @since 3.6.0
     840 *
     841 * @uses term_description()
     842 *
     843 * @param bool $display Whether to display or return the archive description.
     844 * @return string Category, tag or term description
     845 */
     846function the_archive_description( $display = true ) {
     847        if ( is_tag() || is_category() || is_tax() ) {
     848                $term = get_queried_object();
     849                $taxonomy = $term->taxonomy;           
     850                $description = term_description( '', $taxonomy );
     851        }
     852
     853        if ( $display )
     854                echo apply_filters( 'the_archive_description', $description );
     855        else
     856                return apply_filters( 'the_archive_description', $description );
     857}
     858
     859/**
    793860 * Retrieve archive link content based on predefined or custom code.
    794861 *
    795862 * The format can be one of four styles. The 'link' for head element, 'option'