admin管理员组文章数量:1022997
I'm trying to find how to edit format of bbp_forum_freshness_link()
function in bbpress plugin. E.g. currently it displays how many days ago there was last activity and I would like to display date. So if someone would like to share some thoughts or code snippets, that would be great.
I'm trying to find how to edit format of bbp_forum_freshness_link()
function in bbpress plugin. E.g. currently it displays how many days ago there was last activity and I would like to display date. So if someone would like to share some thoughts or code snippets, that would be great.
2 Answers
Reset to default 2I cannot test it right now, but it should work like this:
add_filter( 'bbp_get_forum_freshness_link', 'wpse_77441_change_time_format', 10, 2 );
function wpse_77441_change_time_format( $anchor, $forum_id )
{
$last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true );
if ( empty( $last_active ) ) {
$reply_id = bbp_get_forum_last_reply_id( $forum_id );
if ( !empty( $reply_id ) ) {
$last_active = get_post_field( 'post_date', $reply_id );
} else {
$topic_id = bbp_get_forum_last_topic_id( $forum_id );
if ( !empty( $topic_id ) ) {
$last_active = bbp_get_topic_last_active_time( $topic_id );
}
}
}
$date = bbp_convert_date( $last_active );
$time_since = bbp_get_forum_last_active_time( $forum_id );
return str_replace( "$time_since</a>", "$date</a>", $anchor );
}
function wpse_77441_change_time_format( $anchor, $forum_id )
{
$last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true );
if ( empty( $last_active ) ) {
$reply_id = bbp_get_forum_last_reply_id( $forum_id );
if ( !empty( $reply_id ) ) {
$last_active = get_post_field( 'post_date', $reply_id );
} else {
$topic_id = bbp_get_forum_last_topic_id( $forum_id );
if ( !empty( $topic_id ) ) {
$last_active = bbp_get_topic_last_active_time( $topic_id );
}
}
}
$date = get_post_time( get_option( 'date_format' ), $gmt, $reply_id, true );
$time = get_post_time( get_option( 'time_format' ), $gmt, $reply_id, true );
$dt = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbpress' ), $date, $time );
$time_since = bbp_get_forum_last_active_time( $forum_id );
return str_replace( "$time_since</a>", "$dt</a>", $anchor );
}
add_filter( 'bbp_get_forum_freshness_link', 'wpse_77441_change_time_format', 10, 2 );
I'm trying to find how to edit format of bbp_forum_freshness_link()
function in bbpress plugin. E.g. currently it displays how many days ago there was last activity and I would like to display date. So if someone would like to share some thoughts or code snippets, that would be great.
I'm trying to find how to edit format of bbp_forum_freshness_link()
function in bbpress plugin. E.g. currently it displays how many days ago there was last activity and I would like to display date. So if someone would like to share some thoughts or code snippets, that would be great.
2 Answers
Reset to default 2I cannot test it right now, but it should work like this:
add_filter( 'bbp_get_forum_freshness_link', 'wpse_77441_change_time_format', 10, 2 );
function wpse_77441_change_time_format( $anchor, $forum_id )
{
$last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true );
if ( empty( $last_active ) ) {
$reply_id = bbp_get_forum_last_reply_id( $forum_id );
if ( !empty( $reply_id ) ) {
$last_active = get_post_field( 'post_date', $reply_id );
} else {
$topic_id = bbp_get_forum_last_topic_id( $forum_id );
if ( !empty( $topic_id ) ) {
$last_active = bbp_get_topic_last_active_time( $topic_id );
}
}
}
$date = bbp_convert_date( $last_active );
$time_since = bbp_get_forum_last_active_time( $forum_id );
return str_replace( "$time_since</a>", "$date</a>", $anchor );
}
function wpse_77441_change_time_format( $anchor, $forum_id )
{
$last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true );
if ( empty( $last_active ) ) {
$reply_id = bbp_get_forum_last_reply_id( $forum_id );
if ( !empty( $reply_id ) ) {
$last_active = get_post_field( 'post_date', $reply_id );
} else {
$topic_id = bbp_get_forum_last_topic_id( $forum_id );
if ( !empty( $topic_id ) ) {
$last_active = bbp_get_topic_last_active_time( $topic_id );
}
}
}
$date = get_post_time( get_option( 'date_format' ), $gmt, $reply_id, true );
$time = get_post_time( get_option( 'time_format' ), $gmt, $reply_id, true );
$dt = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbpress' ), $date, $time );
$time_since = bbp_get_forum_last_active_time( $forum_id );
return str_replace( "$time_since</a>", "$dt</a>", $anchor );
}
add_filter( 'bbp_get_forum_freshness_link', 'wpse_77441_change_time_format', 10, 2 );
本文标签: bbpresshow to edit bbpforumfreshnesslink() format
版权声明:本文标题:bbpress - how to edit bbp_forum_freshness_link() format 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745530890a2154745.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论