WordPress.org

Make WordPress Core

Ticket #21995: 21995.2.diff

File 21995.2.diff, 2.8 KB (added by DrewAPicture, 5 years ago)

Adds $container param, improved phpdocs

  • 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 = sprintf( '<%s>', $container );
     804        $after = sprintf( '</%x>', $container );
     805
     806        if ( is_day() )
     807                $title = sprintf( __( 'Daily Archives: %s' ), $before . get_the_date() . $after );
     808        elseif ( is_month() )
     809                $title = sprintf( __( 'Monthly Archives: %s' ), $before . get_the_date( _x( 'F Y', 'monthly archives date format' ) ) . $after );
     810        elseif ( is_year() )
     811                $title = sprintf( __( 'Yearly Archives: %s' ), $before . get_the_date( _x( 'Y', 'yearly archives date format' ) ) . $after );
     812        elseif ( is_tag() )
     813                $title = sprintf( __( 'Tag Archives: %s' ), $before . single_tag_title( '', false ) . $after );
     814        elseif ( is_category() )
     815                $title = sprintf( __( 'Category Archives: %s' ), $before . single_cat_title( '', false ) . $after );
     816        elseif ( is_tax() )
     817                $title = sprintf( __( 'Taxonomy Archives: %s' ), $before . single_term_title( '', false ) . $after );
     818        elseif ( is_author() )
     819                $title = sprintf( __( 'Author Archives: %s' ), $before . get_the_author() . $after );
     820        elseif ( is_post_type_archive() )
     821                $title = sprintf( __( 'Archives: %s' ), $before . post_type_archive_title( '', false ) . $after );
     822        else
     823                $title = __( 'Archives' );
     824       
     825        $title = $prefix . $title;
     826
     827        if ( $display )
     828                echo apply_filters( 'the_archive_title', $title );
     829        else
     830                return apply_filters( 'the_archive_title', $title );
     831}
     832
     833/**
     834 * Retrieve or display tag, category or term description
     835 *
     836 * @since 3.6.0
     837 *
     838 * @uses term_description()
     839 *
     840 * @param bool $display Whether to display or return the archive description.
     841 * @return string Category, tag or term description
     842 */
     843function the_archive_description( $display = true ) {
     844        if ( is_tag() || is_category() || is_tax() ) {
     845                $term = get_queried_object();
     846                $taxonomy = $term->taxonomy;           
     847                $description = term_description( '', $taxonomy );
     848        }
     849
     850        if ( $display )
     851                echo apply_filters( 'the_archive_description', $description );
     852        else
     853                return apply_filters( 'the_archive_description', $description );
     854}
     855
     856/**
    793857 * Retrieve archive link content based on predefined or custom code.
    794858 *
    795859 * The format can be one of four styles. The 'link' for head element, 'option'