| 1099 | * Retrieve the archive title based on the queried object. |
| 1100 | * |
| 1101 | * @since 4.1.0 |
| 1102 | * |
| 1103 | * @return string Archive title. |
| 1104 | */ |
| 1105 | function get_archive_title() { |
| 1106 | if ( is_category() ) { |
| 1107 | $title = sprintf( esc_html__( 'Category: %s' ), single_cat_title( '', false ) ); |
| 1108 | } elseif ( is_tag() ) { |
| 1109 | $title = sprintf( esc_html__( 'Tag: %s' ), single_tag_title( '', false ) ); |
| 1110 | } elseif ( is_year() ) { |
| 1111 | $title = sprintf( esc_html__( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) ); |
| 1112 | } elseif ( is_month() ) { |
| 1113 | $title = sprintf( esc_html__( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) ); |
| 1114 | } elseif ( is_day() ) { |
| 1115 | $title = sprintf( esc_html__( 'Day: %s' ), get_the_date() ); |
| 1116 | } elseif ( is_tax() ) { |
| 1117 | $tax = get_taxonomy( get_queried_object()->taxonomy ); |
| 1118 | /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */ |
| 1119 | $title = sprintf( esc_html__( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) ); |
| 1120 | } elseif ( is_author() ) { |
| 1121 | $title = sprintf( esc_html__( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' ); |
| 1122 | } elseif ( is_post_type_archive() ) { |
| 1123 | $title = sprintf( esc_html__( 'Archives: %s' ), post_type_archive_title( '', false ) ); |
| 1124 | } elseif ( is_tax( 'post_format', 'post-format-aside' ) ) { |
| 1125 | $title = esc_html__( 'Asides' ); |
| 1126 | } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { |
| 1127 | $title = esc_html__( 'Galleries' ); |
| 1128 | } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { |
| 1129 | $title = esc_html__( 'Images' ); |
| 1130 | } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { |
| 1131 | $title = esc_html__( 'Videos' ); |
| 1132 | } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { |
| 1133 | $title = esc_html__( 'Quotes' ); |
| 1134 | } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { |
| 1135 | $title = esc_html__( 'Links' ); |
| 1136 | } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { |
| 1137 | $title = esc_html__( 'Statuses' ); |
| 1138 | } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { |
| 1139 | $title = esc_html__( 'Audios' ); |
| 1140 | } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { |
| 1141 | $title = esc_html__( 'Chats' ); |
| 1142 | } else { |
| 1143 | $title = esc_html__( 'Archives' ); |
| 1144 | } |
| 1145 | |
| 1146 | return apply_filters( 'get_archive_title', $title ); |
| 1147 | } |
| 1148 | |
| 1149 | /** |
| 1150 | * Display the archive title based on the queried object. |
| 1151 | * |
| 1152 | * @since 4.1.0 |
| 1153 | * @uses get_archive_title() |
| 1154 | * |
| 1155 | * @param string $before Optional. Content to prepend to the title. |
| 1156 | * @param string $after Optional. Content to append to the title. |
| 1157 | */ |
| 1158 | function the_archive_title( $before = '', $after = '' ) { |
| 1159 | $title = get_archive_title(); |
| 1160 | |
| 1161 | if ( ! empty( $title ) ) { |
| 1162 | echo $before . $title . $after; |
| 1163 | } |
| 1164 | } |
| 1165 | |
| 1166 | /** |
| 1167 | * Display category, tag, or term description. |
| 1168 | * |
| 1169 | * @since 4.1.0 |
| 1170 | * @uses term_description() |
| 1171 | * |
| 1172 | * @param string $before Optional. Content to prepend to the description. |
| 1173 | * @param string $after Optional. Content to append to the description. |
| 1174 | */ |
| 1175 | function the_archive_description( $before = '', $after = '' ) { |
| 1176 | $description = apply_filters( 'the_archive_description', term_description() ); |
| 1177 | |
| 1178 | if ( ! empty( $description ) ) { |
| 1179 | echo $before . $description . $after; |
| 1180 | } |
| 1181 | } |
| 1182 | |
| 1183 | /** |