如何在 BuddyPress 中自定义消息中的最后回复时间戳? [英] How do I customise the last reply timestamp in messages in BuddyPress?
问题描述
目前,收件箱或已发送标签中thread_id
的最后回复时间戳格式如下:August 21, 2017 at 5:06 am
Currently, the last reply timestamp of thread_id
in the inbox or sent tab is formatted like this: August 21, 2017 at 5:06 am
我正在使用 bp_message_thread_last_post_date()
来显示时间戳.
I am using bp_message_thread_last_post_date()
to display the timestamp.
如何更改此设置,使其以 2 days, 11 hours ago
格式显示最后一条回复?
How do I change this so it displays the last reply in the format 2 days, 11 hours ago
?
推荐答案
在您调用的 buddypress 函数中,它回显来自应用过滤器的类似命名函数的值.您应该创建自己的名为bp_message_thread_last_post_date"的过滤器,以根据需要更改日期格式.
In the buddypress function you are calling, it echos the value from a similarily named function that applies a filter. You should create your own filter named 'bp_message_thread_last_post_date' to change the format of the date as you wish.
在您的functions.php文件中,添加如下内容:
In your functions.php file, add something like the following:
add_filter( 'bp_message_thread_last_post_date', 'fluffyKittenDate', 10, 1 );
function fluffyKittenDate($oldformat) {
// reformat date contained in oldformat here and return the new value
}
确保将 add_filter 方法的优先级设置得足够高,以确保您的过滤器最后运行.
Be sure and make the priority of add_filter method high enough to ensure your filter runs last.
这篇关于如何在 BuddyPress 中自定义消息中的最后回复时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!