Skip to content

Commit

Permalink
Add filter to hide meta post updated time
Browse files Browse the repository at this point in the history
  • Loading branch information
crftwrk committed Apr 16, 2024
1 parent 47ed899 commit d9d5d0b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Eventually, some of the functionality here could be replaced by core features.
*
* @package Bootscore
* @version 5.3.3
* @version 6.0.0
*/


Expand Down Expand Up @@ -60,13 +60,23 @@ function bootscore_category() {
* Date
*/
if (!function_exists('bootscore_date')) :

/**
* Prints HTML with meta information for the current post-date/time.
*/
function bootscore_date() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';

// Check if modified time is different from the published time
if (get_the_time('U') !== get_the_modified_time('U')) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time> <span class="time-updated-separator">/</span> <time class="updated" datetime="%3$s">%4$s</time>';
$show_updated_time = apply_filters('bootscore/time/updated', true);

// If filter returns false, don't display modified time
if (!$show_updated_time) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
} else {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time> <span class="time-updated-separator">/</span> <time class="updated" datetime="%3$s">%4$s</time>';
}
}

$time_string = sprintf(
Expand All @@ -78,7 +88,7 @@ function bootscore_date() {
);

$posted_on = sprintf(
/* translators: %s: post date. */
/* translators: %s: post date. */
'%s',
'<span rel="bookmark">' . $time_string . '</span>'
);
Expand Down

0 comments on commit d9d5d0b

Please sign in to comment.