WordPress.org

Make WordPress Core

Ticket #21995: 21995.5.diff

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