2017-05-30 23:21:43 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Custom Twenty Sixteen template tags
|
|
|
|
*
|
|
|
|
* Eventually, some of the functionality here could be replaced by core features.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Twenty_Sixteen
|
|
|
|
* @since Twenty Sixteen 1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ! function_exists( 'twentysixteen_entry_meta' ) ) :
|
2017-12-01 00:11:00 +01:00
|
|
|
/**
|
|
|
|
* Prints HTML with meta information for the categories, tags.
|
|
|
|
*
|
|
|
|
* Create your own twentysixteen_entry_meta() function to override in a child theme.
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 1.0
|
|
|
|
*/
|
|
|
|
function twentysixteen_entry_meta() {
|
|
|
|
if ( 'post' === get_post_type() ) {
|
|
|
|
$author_avatar_size = apply_filters( 'twentysixteen_author_avatar_size', 49 );
|
|
|
|
printf(
|
|
|
|
'<span class="byline"><span class="author vcard">%1$s<span class="screen-reader-text">%2$s </span> <a class="url fn n" href="%3$s">%4$s</a></span></span>',
|
|
|
|
get_avatar( get_the_author_meta( 'user_email' ), $author_avatar_size ),
|
|
|
|
_x( 'Author', 'Used before post author name.', 'twentysixteen' ),
|
|
|
|
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
|
|
|
|
get_the_author()
|
|
|
|
);
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2020-04-05 05:02:11 +02:00
|
|
|
if ( in_array( get_post_type(), array( 'post', 'attachment' ), true ) ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
twentysixteen_entry_date();
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$format = get_post_format();
|
|
|
|
if ( current_theme_supports( 'post-formats', $format ) ) {
|
|
|
|
printf(
|
|
|
|
'<span class="entry-format">%1$s<a href="%2$s">%3$s</a></span>',
|
|
|
|
sprintf( '<span class="screen-reader-text">%s </span>', _x( 'Format', 'Used before post format.', 'twentysixteen' ) ),
|
|
|
|
esc_url( get_post_format_link( $format ) ),
|
|
|
|
get_post_format_string( $format )
|
|
|
|
);
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( 'post' === get_post_type() ) {
|
|
|
|
twentysixteen_entry_taxonomies();
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! is_singular() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
|
|
|
echo '<span class="comments-link">';
|
2022-04-29 07:03:11 +02:00
|
|
|
/* translators: %s: Post title. Only visible to screen readers. */
|
2017-12-01 00:11:00 +01:00
|
|
|
comments_popup_link( sprintf( __( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'twentysixteen' ), get_the_title() ) );
|
|
|
|
echo '</span>';
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( ! function_exists( 'twentysixteen_entry_date' ) ) :
|
2017-12-01 00:11:00 +01:00
|
|
|
/**
|
|
|
|
* Prints HTML with date information for current post.
|
|
|
|
*
|
|
|
|
* Create your own twentysixteen_entry_date() function to override in a child theme.
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 1.0
|
|
|
|
*/
|
|
|
|
function twentysixteen_entry_date() {
|
|
|
|
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
|
|
|
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$time_string = sprintf(
|
|
|
|
$time_string,
|
|
|
|
esc_attr( get_the_date( 'c' ) ),
|
|
|
|
get_the_date(),
|
|
|
|
esc_attr( get_the_modified_date( 'c' ) ),
|
|
|
|
get_the_modified_date()
|
|
|
|
);
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
printf(
|
|
|
|
'<span class="posted-on"><span class="screen-reader-text">%1$s </span><a href="%2$s" rel="bookmark">%3$s</a></span>',
|
|
|
|
_x( 'Posted on', 'Used before publish date.', 'twentysixteen' ),
|
|
|
|
esc_url( get_permalink() ),
|
|
|
|
$time_string
|
2017-05-30 23:21:43 +02:00
|
|
|
);
|
|
|
|
}
|
2017-12-01 00:11:00 +01:00
|
|
|
endif;
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! function_exists( 'twentysixteen_entry_taxonomies' ) ) :
|
|
|
|
/**
|
|
|
|
* Prints HTML with category and tags for current post.
|
|
|
|
*
|
|
|
|
* Create your own twentysixteen_entry_taxonomies() function to override in a child theme.
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 1.0
|
|
|
|
*/
|
|
|
|
function twentysixteen_entry_taxonomies() {
|
|
|
|
$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) );
|
|
|
|
if ( $categories_list && twentysixteen_categorized_blog() ) {
|
|
|
|
printf(
|
|
|
|
'<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
|
|
|
|
_x( 'Categories', 'Used before category names.', 'twentysixteen' ),
|
|
|
|
$categories_list
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) );
|
|
|
|
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
|
|
|
|
printf(
|
|
|
|
'<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
|
|
|
|
_x( 'Tags', 'Used before tag names.', 'twentysixteen' ),
|
|
|
|
$tags_list
|
|
|
|
);
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( ! function_exists( 'twentysixteen_post_thumbnail' ) ) :
|
2017-12-01 00:11:00 +01:00
|
|
|
/**
|
|
|
|
* Displays an optional post thumbnail.
|
|
|
|
*
|
|
|
|
* Wraps the post thumbnail in an anchor element on index views, or a div
|
|
|
|
* element when on single views.
|
|
|
|
*
|
|
|
|
* Create your own twentysixteen_post_thumbnail() function to override in a child theme.
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 1.0
|
|
|
|
*/
|
|
|
|
function twentysixteen_post_thumbnail() {
|
|
|
|
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
|
|
|
|
return;
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( is_singular() ) :
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
<div class="post-thumbnail">
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php the_post_thumbnail(); ?>
|
2017-05-30 23:21:43 +02:00
|
|
|
</div><!-- .post-thumbnail -->
|
|
|
|
|
|
|
|
<?php else : ?>
|
|
|
|
|
|
|
|
<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
|
|
|
|
<?php the_post_thumbnail( 'post-thumbnail', array( 'alt' => the_title_attribute( 'echo=0' ) ) ); ?>
|
|
|
|
</a>
|
|
|
|
|
2019-01-12 07:41:52 +01:00
|
|
|
<?php
|
2020-01-29 01:45:18 +01:00
|
|
|
endif; // End is_singular().
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( ! function_exists( 'twentysixteen_excerpt' ) ) :
|
|
|
|
/**
|
|
|
|
* Displays the optional excerpt.
|
|
|
|
*
|
|
|
|
* Wraps the excerpt in a div element.
|
|
|
|
*
|
|
|
|
* Create your own twentysixteen_excerpt() function to override in a child theme.
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 1.0
|
|
|
|
*
|
Code Modernization: Rename parameters that use reserved keywords in bundled themes.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.
This commit:
* Renames the `$class` parameter to `$css_class` in:
* `twentysixteen_excerpt()`
* `twentynineteen_post_classes()`
* Renames the `$echo` parameter to `$display` in:
* `twentythirteen_entry_date()`
* `twentytwenty_generate_css()`
* `twentytwenty_site_logo()`
* `twentytwenty_site_description()`
* `twenty_twenty_one_generate_css()`
Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232].
Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.
Built from https://develop.svn.wordpress.org/trunk@53236
git-svn-id: http://core.svn.wordpress.org/trunk@52825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-20 16:24:12 +02:00
|
|
|
* @param string $css_class Optional. Class string of the div element. Defaults to 'entry-summary'.
|
2017-05-30 23:21:43 +02:00
|
|
|
*/
|
Code Modernization: Rename parameters that use reserved keywords in bundled themes.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.
This commit:
* Renames the `$class` parameter to `$css_class` in:
* `twentysixteen_excerpt()`
* `twentynineteen_post_classes()`
* Renames the `$echo` parameter to `$display` in:
* `twentythirteen_entry_date()`
* `twentytwenty_generate_css()`
* `twentytwenty_site_logo()`
* `twentytwenty_site_description()`
* `twenty_twenty_one_generate_css()`
Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232].
Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.
Built from https://develop.svn.wordpress.org/trunk@53236
git-svn-id: http://core.svn.wordpress.org/trunk@52825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-20 16:24:12 +02:00
|
|
|
function twentysixteen_excerpt( $css_class = 'entry-summary' ) {
|
|
|
|
$css_class = esc_attr( $css_class );
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( has_excerpt() || is_search() ) :
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
Code Modernization: Rename parameters that use reserved keywords in bundled themes.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.
This commit:
* Renames the `$class` parameter to `$css_class` in:
* `twentysixteen_excerpt()`
* `twentynineteen_post_classes()`
* Renames the `$echo` parameter to `$display` in:
* `twentythirteen_entry_date()`
* `twentytwenty_generate_css()`
* `twentytwenty_site_logo()`
* `twentytwenty_site_description()`
* `twenty_twenty_one_generate_css()`
Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232].
Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.
Built from https://develop.svn.wordpress.org/trunk@53236
git-svn-id: http://core.svn.wordpress.org/trunk@52825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-20 16:24:12 +02:00
|
|
|
<div class="<?php echo $css_class; ?>">
|
2017-05-30 23:21:43 +02:00
|
|
|
<?php the_excerpt(); ?>
|
Code Modernization: Rename parameters that use reserved keywords in bundled themes.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.
This commit:
* Renames the `$class` parameter to `$css_class` in:
* `twentysixteen_excerpt()`
* `twentynineteen_post_classes()`
* Renames the `$echo` parameter to `$display` in:
* `twentythirteen_entry_date()`
* `twentytwenty_generate_css()`
* `twentytwenty_site_logo()`
* `twentytwenty_site_description()`
* `twenty_twenty_one_generate_css()`
Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232].
Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.
Built from https://develop.svn.wordpress.org/trunk@53236
git-svn-id: http://core.svn.wordpress.org/trunk@52825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-20 16:24:12 +02:00
|
|
|
</div><!-- .<?php echo $css_class; ?> -->
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2017-12-01 00:11:00 +01:00
|
|
|
endif;
|
2017-05-30 23:21:43 +02:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( ! function_exists( 'twentysixteen_excerpt_more' ) && ! is_admin() ) :
|
2017-12-01 00:11:00 +01:00
|
|
|
/**
|
|
|
|
* Replaces "[...]" (appended to automatically generated excerpts) with ... and
|
|
|
|
* a 'Continue reading' link.
|
|
|
|
*
|
|
|
|
* Create your own twentysixteen_excerpt_more() function to override in a child theme.
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 1.0
|
|
|
|
*
|
|
|
|
* @return string 'Continue reading' link prepended with an ellipsis.
|
|
|
|
*/
|
|
|
|
function twentysixteen_excerpt_more() {
|
|
|
|
$link = sprintf(
|
|
|
|
'<a href="%1$s" class="more-link">%2$s</a>',
|
|
|
|
esc_url( get_permalink( get_the_ID() ) ),
|
2022-04-29 07:03:11 +02:00
|
|
|
/* translators: %s: Post title. Only visible to screen readers. */
|
2017-12-01 00:11:00 +01:00
|
|
|
sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentysixteen' ), get_the_title( get_the_ID() ) )
|
|
|
|
);
|
|
|
|
return ' … ' . $link;
|
|
|
|
}
|
|
|
|
add_filter( 'excerpt_more', 'twentysixteen_excerpt_more' );
|
2017-05-30 23:21:43 +02:00
|
|
|
endif;
|
|
|
|
|
|
|
|
if ( ! function_exists( 'twentysixteen_categorized_blog' ) ) :
|
2017-12-01 00:11:00 +01:00
|
|
|
/**
|
|
|
|
* Determines whether blog/site has more than one category.
|
|
|
|
*
|
|
|
|
* Create your own twentysixteen_categorized_blog() function to override in a child theme.
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 1.0
|
|
|
|
*
|
|
|
|
* @return bool True if there is more than one category, false otherwise.
|
|
|
|
*/
|
|
|
|
function twentysixteen_categorized_blog() {
|
2019-07-01 10:23:57 +02:00
|
|
|
$all_the_cool_cats = get_transient( 'twentysixteen_categories' );
|
|
|
|
if ( false === $all_the_cool_cats ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
// Create an array of all the categories that are attached to posts.
|
|
|
|
$all_the_cool_cats = get_categories(
|
|
|
|
array(
|
|
|
|
'fields' => 'ids',
|
|
|
|
// We only need to know if there is more than one category.
|
|
|
|
'number' => 2,
|
|
|
|
)
|
|
|
|
);
|
2017-05-30 23:21:43 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
// Count the number of categories that are attached to the posts.
|
|
|
|
$all_the_cool_cats = count( $all_the_cool_cats );
|
|
|
|
|
|
|
|
set_transient( 'twentysixteen_categories', $all_the_cool_cats );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $all_the_cool_cats > 1 || is_preview() ) {
|
2020-01-29 01:45:18 +01:00
|
|
|
// This blog has more than 1 category so twentysixteen_categorized_blog() should return true.
|
2017-12-01 00:11:00 +01:00
|
|
|
return true;
|
|
|
|
} else {
|
2020-01-29 01:45:18 +01:00
|
|
|
// This blog has only 1 category so twentysixteen_categorized_blog() should return false.
|
2017-12-01 00:11:00 +01:00
|
|
|
return false;
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flushes out the transients used in twentysixteen_categorized_blog().
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 1.0
|
|
|
|
*/
|
|
|
|
function twentysixteen_category_transient_flusher() {
|
|
|
|
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Like, beat it. Dig?
|
|
|
|
delete_transient( 'twentysixteen_categories' );
|
|
|
|
}
|
|
|
|
add_action( 'edit_category', 'twentysixteen_category_transient_flusher' );
|
2017-12-01 00:11:00 +01:00
|
|
|
add_action( 'save_post', 'twentysixteen_category_transient_flusher' );
|
2017-05-30 23:21:43 +02:00
|
|
|
|
|
|
|
if ( ! function_exists( 'twentysixteen_the_custom_logo' ) ) :
|
2017-12-01 00:11:00 +01:00
|
|
|
/**
|
|
|
|
* Displays the optional custom logo.
|
|
|
|
*
|
|
|
|
* Does nothing if the custom logo is not available.
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 1.2
|
|
|
|
*/
|
|
|
|
function twentysixteen_the_custom_logo() {
|
|
|
|
if ( function_exists( 'the_custom_logo' ) ) {
|
|
|
|
the_custom_logo();
|
|
|
|
}
|
2017-05-30 23:21:43 +02:00
|
|
|
}
|
|
|
|
endif;
|
2019-04-23 15:04:56 +02:00
|
|
|
|
|
|
|
if ( ! function_exists( 'wp_body_open' ) ) :
|
|
|
|
/**
|
|
|
|
* Fire the wp_body_open action.
|
|
|
|
*
|
2020-01-29 01:45:18 +01:00
|
|
|
* Added for backward compatibility to support pre-5.2.0 WordPress versions.
|
2019-04-23 15:04:56 +02:00
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 2.0
|
|
|
|
*/
|
|
|
|
function wp_body_open() {
|
|
|
|
/**
|
|
|
|
* Triggered after the opening <body> tag.
|
|
|
|
*
|
|
|
|
* @since Twenty Sixteen 2.0
|
|
|
|
*/
|
|
|
|
do_action( 'wp_body_open' );
|
|
|
|
}
|
|
|
|
endif;
|