WordPress.org

Making WordPress.org

Opened 4 months ago

Closed 3 months ago

#5121 closed defect (fixed)

Fix support forum dates title and datetime attributes

Reported by: TweetyThierry Owned by: dd32
Milestone: Priority: normal
Component: Support Forums Keywords: needs-patch
Cc:

Description

The title attributes for dates (example: 1 day, 2 hours ago) on the support forum are set using the post title instead of the created date (title should be in date format, not time ago). This would be specifically useful when hovering over the "time ago" date to see the actual date.

Additionally these HTML should contain datetime attribute too.

Change History (2)

#1 @TweetyThierry
4 months ago

I believe this is the template line https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-forums/bbpress/loop-single-reply.php#L39 which needs to be updated.

Since to my knowledge there isn't a core bbPress function to get the last reply date, we may have to add a helper function, something similar to bbp_get_topic_last_active_time() but returning the date or timestamp. For example:

/**
 * Return the topics last update date.
 *
 * @param int $topic_id Optional. Topic id.
 *
 * @uses bbp_get_topic_id() To get topic id
 * @uses get_post_meta() To get the topic lst active meta
 * @uses bbp_get_topic_last_reply_id() To get topic last reply id
 * @uses get_post_field() To get the post date of topic/reply
 *
 * @return string Topic last active date.
 */
function bb_base_get_topic_last_active_timestamp( $topic_id = 0 ) {
	$topic_id = bbp_get_topic_id( $topic_id );

	// Try to get the most accurate freshness time possible.
	$last_active = get_post_meta( $topic_id, '_bbp_last_active_time', true );

	if ( empty( $last_active ) ) {
		$reply_id = bbp_get_topic_last_reply_id( $topic_id );

		if ( ! empty( $reply_id ) ) {
			$last_active = get_post_field( 'post_date', $reply_id );
		} else {
			$last_active = get_post_field( 'post_date', $topic_id );
		}
	}

	return $last_active;
}
Last edited 4 months ago by TweetyThierry (previous) (diff)

#2 @dd32
3 months ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 9848:

Support Forums: Use the actual date as the title text for date links.

Fixes #5121.

Note: See TracTickets for help on using tickets.