WordPress.org

Make WordPress Core

Ticket #21995: 21995.6.diff

File 21995.6.diff, 3.1 KB (added by DrewAPicture, 5 years ago)
  • 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                $term = get_queried_object();
     821                $tax = get_taxonomy( $term->taxonomy );
     822                /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
     823                $title = sprintf( __( '%1$s Archives: %2$s' ), $tax->labels->singular_name, $before . single_term_title( '', false ) . $after );                                       
     824        } elseif ( is_author() ) {
     825                $title = sprintf( __( 'Author Archives: %s' ), $before . get_the_author() . $after );
     826        } elseif ( is_post_type_archive() ) {
     827                $title = sprintf( __( 'Archives: %s' ), $before . post_type_archive_title( '', false ) . $after );
     828        } else {
     829                $title = __( 'Archives' );
     830        }
     831
     832        $title = $prefix . $title;
     833
     834        if ( $display )
     835                echo apply_filters( 'the_archive_title', $title );
     836        else
     837                return apply_filters( 'the_archive_title', $title );
     838}
     839
     840/**
     841 * Retrieve or display tag, category or term description
     842 *
     843 * @since 3.6.0
     844 *
     845 * @uses term_description()
     846 *
     847 * @param bool $display Whether to display or return the archive description.
     848 * @return string Category, tag or term description
     849 */
     850function the_archive_description( $display = true ) {
     851        if ( is_tag() || is_category() || is_tax() ) {
     852                $term = get_queried_object();
     853                $taxonomy = $term->taxonomy;           
     854                $description = term_description( '', $taxonomy );
     855        }
     856
     857        if ( $display )
     858                echo apply_filters( 'the_archive_description', $description );
     859        else
     860                return apply_filters( 'the_archive_description', $description );
     861}
     862
     863/**
    793864 * Retrieve archive link content based on predefined or custom code.
    794865 *
    795866 * The format can be one of four styles. The 'link' for head element, 'option'