Search Results for 'bbp_get_time_since'
-
AuthorSearch Results
-
May 28, 2023 at 12:36 pm #235956
In reply to: change post time to time ago
Robin WModeratoradd_filter( 'bbp_get_reply_post_date', 'rew_show_time_since' , 10 , 6) ; add_filter( 'bbp_get_topic_post_date', 'rew_show_time_since' , 10 , 6) ; function rew_show_time_since ($result, $reply_id, $humanize, $gmt, $date, $time ){ $gmt_s = ! empty( $gmt ) ? 'G' : 'U'; $date = get_post_time( $gmt_s, $gmt, $reply_id ); $result = bbp_get_time_since( $date ); return $result ; }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
April 9, 2023 at 5:53 am #235238In reply to: Customizing lead topic
Robin WModeratorso is this with this function installed?
add_filter ('bbp_get_topic_post_date' , 'rew_change_to_freshness', 10 , 6) ; add_filter ('bbp_get_reply_post_date' , 'rew_change_to_freshness', 10 , 6) ; function rew_change_to_freshness ($result, $topic_id, $humanize, $gmt, $date, $time) { $result = bbp_get_time_since( bbp_convert_date( $time ) ) ; return $result ; }
March 28, 2023 at 12:47 pm #235036In reply to: Customizing lead topic
Robin WModeratoryou can leave the template for time unchanged.
add_filter ('bbp_get_topic_post_date' , 'rew_change_to_freshness', 10 , 6) ; add_filter ('bbp_get_reply_post_date' , 'rew_change_to_freshness', 10 , 6) ; function rew_change_to_freshness ($result, $topic_id, $humanize, $gmt, $date, $time) { $result = bbp_get_time_since( bbp_convert_date( $time ) ) ; return $result ; }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
April 4, 2022 at 12:56 pm #228449In reply to: Missing Date on Started by
Robin WModeratoruntested, but this should work
add_filter( 'bbp_get_topic_post_date', 'rew_date_only' , 20, 6) ; function rew_date_only ($result, $topic_id, $humanize, $gmt, $date, $time ){ $topic_id = bbp_get_topic_id( $topic_id ); // 4 days, 4 hours ago if ( ! empty( $humanize ) ) { $gmt_s = ! empty( $gmt ) ? 'G' : 'U'; $date = get_post_time( $gmt_s, $gmt, $topic_id ); $time = false; // For filter below $result = bbp_get_time_since( $date ); // August 4, 2012 at 2:37 pm } else { $date = get_post_time( get_option( 'date_format' ), $gmt, $topic_id, true ); $result = $date; } // Filter & return return apply_filters( 'rew_date_only', $result, $topic_id, $humanize, $gmt, $date, $time ); } }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
June 14, 2021 at 5:46 am #221208In reply to: how can I change x “days” ago
Robin WModeratorok, try this
add_filter ('bbp_get_time_since' , 'rew_time_since_translate' ) ; function rew_time_since_translate ($output) { $output = preg_replace('/years/', 'new word', $output); $output = preg_replace('/year/', 'new word', $output); $output = preg_replace('/days/', 'new word', $output); $output = preg_replace('/day/', 'new word', $output); return $output ; }
so change ‘new word’ in each case for what you want to show
you can add as many lines as you need, but always do the plural first so ‘years’ followed by ‘year’
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
February 9, 2021 at 9:28 am #218228In reply to: Reply-Post-Date needs a space after the word On
LongbowParticipantI’m digging through php and can’t locate where the word “On” gets inserted.
bbpress/includes/replies/template/php
lines 660-680
function bbp_get_reply_post_date( $reply_id = 0, $humanize = false, $gmt = false ) { $reply_id = bbp_get_reply_id( $reply_id ); // 4 days, 4 hours ago if ( ! empty( $humanize ) ) { $gmt_s = ! empty( $gmt ) ? 'G' : 'U'; $date = get_post_time( $gmt_s, $gmt, $reply_id ); $time = false; // For filter below $result = bbp_get_time_since( $date ); // August 4, 2012 at 2:37 pm } else { $date = get_post_time( get_option( 'date_format' ), $gmt, $reply_id, true ); $time = get_post_time( get_option( 'time_format' ), $gmt, $reply_id, true ); $result = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbpress' ), $date, $time ); } // Filter & return return apply_filters( 'bbp_get_reply_post_date', $result, $reply_id, $humanize, $gmt, $date, $time ); }
November 18, 2020 at 9:59 am #215994wpturkParticipantYou can remove everything between comma “,” and “ago” this way: (put in functions.php)
function short_time ($output) { $output = preg_replace( '/, .*[^ago]/', ' ', $output ); echo $output; } add_action ('bbp_get_time_since', 'short_time') ;
November 8, 2019 at 11:47 am #205379In reply to: Change forum date output
Robin WModeratorok, the existing function is
function bbp_get_topic_post_date( $topic_id = 0, $humanize = false, $gmt = false ) { $topic_id = bbp_get_topic_id( $topic_id ); // 4 days, 4 hours ago if ( !empty( $humanize ) ) { $gmt_s = !empty( $gmt ) ? 'U' : 'G'; $date = get_post_time( $gmt_s, $gmt, $topic_id ); $time = false; // For filter below $result = bbp_get_time_since( $date ); // August 4, 2012 at 2:37 pm } else { $date = get_post_time( get_option( 'date_format' ), $gmt, $topic_id, true ); $time = get_post_time( get_option( 'time_format' ), $gmt, $topic_id, true ); $result = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbpress' ), $date, $time ); } return apply_filters( 'bbp_get_topic_post_date', $result, $topic_id, $humanize, $gmt, $date, $time ); }
so we can filter this as follows :
add_filter ('bbp_get_topic_post_date' , 'rew_date' , 10 , 6) ; function rew_date ($result, $topic_id, $humanize, $gmt, $date, $time) { $result = 'hello' ; return $result ; }
This should then say ‘hello’ so all we want to do is change $result to read whatever you want – so what do you want it to say ?
September 5, 2018 at 9:51 am #194668Topic: bbp_get_time_since issue
in forum TroubleshootingsiparkerParticipantHi,
The function
bbp_get_time_since
inincludes/common/formatting.php
always returns “right now”.bbPress Version: 2.6 release candidate 6
June 3, 2016 at 10:44 pm #175383In reply to: How to hide the word “ago” from freshness…
lflierParticipantHere is a straightforward approach to abbreviating the time. Just put it in your functions.php file. You can modify the abbreviations as you wish:
add_filter( 'bbp_get_time_since', 'abbreviate_time' ); function abbreviate_time ( $output ) { $output = str_replace( 'minutes', 'min', $output ); $output = str_replace( 'minute', 'min', $output ); $output = str_replace( 'hours', 'hr', $output ); $output = str_replace( 'hour', 'hr', $output ); $output = str_replace( 'weeks', 'wk', $output ); $output = str_replace( 'week', 'wk', $output ); $output = str_replace( 'months', 'mo', $output ); $output = str_replace( 'month', 'mo', $output ); $output = str_replace( 'years', 'yr', $output ); $output = str_replace( 'year', 'yr', $output ); return $output; }
March 17, 2016 at 8:20 am #173024In reply to: How to change `bp_topic_last_active_time` format
Pascal CasierModerator2 tips:
– Install my bbP Toolkit
– Use the code below:// Change freshness time by removing the last part, so '1 month, 3 days ago' becomes '1 month ago' function casiepa_shorten_freshness_time($return) { $return = preg_replace( '/, .*[^ago]/', ' ', $return ); return $return; } add_filter( 'bbp_get_time_since', 'casiepa_shorten_freshness_time' ); add_filter( 'bp_core_time_since', 'casiepa_shorten_freshness_time');
PS. Ben je niet op https://wpnl.slack.com ?
November 9, 2015 at 9:22 am #168775In reply to: how to change the freshness timing type?
Pascal CasierModeratorWell, for your specific case, you would probably go with:
function bbptoolkitpc_shorten_freshness_time($return) { $return = str_replace( "hour", "hr", $return ); $return = str_replace( "minutes", "min", $return ); return $return; } add_filter( 'bbp_get_time_since', 'bbptoolkitpc_shorten_freshness_time' ); add_filter( 'bp_core_time_since', 'bbptoolkitpc_shorten_freshness_time');
Pascal.
November 9, 2015 at 4:18 am #168768In reply to: how to change the freshness timing type?
Pascal CasierModeratorHi,
The section is fine 🙂You will have to change the regular expression inside, but the basic function would look like this:
function bbptoolkitpc_shorten_freshness_time($return) { $bbptoolkit_short_fresh = get_option('bbptoolkit-short-fresh', false); if ($bbptoolkit_short_fresh) { $return = preg_replace( '/, .*[^ago]/', ' ', $return ); } return $return; } add_filter( 'bbp_get_time_since', 'bbptoolkitpc_shorten_freshness_time' ); add_filter( 'bp_core_time_since', 'bbptoolkitpc_shorten_freshness_time');
Pascal.
May 29, 2014 at 9:44 am #147133In reply to: Hello from Japan! How to remove the anchor tag…
Robin WModeratorok, so
//function to remove the comma
function change_comma_time($output) {
$output = preg_replace( ‘/[,]/’ , ‘ ‘ , $output );
return $output;
}
add_filter( ‘bbp_get_time_since’, ‘change_comma_time’ );
add_filter(‘bp_core_time_since’, ‘change_comma_time’);will take out the commas. You need to add this to your functions file and
‘function custom_get_forum_freshness_link() {
$time_since = bbp_get_forum_last_active_time( $forum_id );
$anchor = $time_since ;
return $anchor ;
}add_filter( ‘bbp_get_forum_freshness_link’, ‘custom_get_forum_freshness_link’ );’
will take out the link
You will need to add these to your functions file.
Come back if you need further help
February 14, 2014 at 4:39 am #142480In reply to: Change of date for freshness
Robin WModeratorso the answer is
function short_freshness_time( $output) { $output = preg_replace( '/, .*[^ago]/', ' ', $output ); return $output; } add_filter( 'bbp_get_time_since', 'short_freshness_time' ); add_filter('bp_core_time_since', 'short_freshness_time');
Drop this into your functions file
February 13, 2014 at 10:10 pm #142470In reply to: Change of date for freshness
Stephen EdgarKeymasterFebruary 13, 2014 at 3:42 pm #142464In reply to: Change of date for freshness
virusek89Participantbbp_get_time_since
I found it in these files
bbpress\includes\topics\template-tags.php
bbpress\includes\replies\template-tags.php
bbpress\includes\forums\template-tags.php
bbpress\includes\common\widgets.php
bbpress\includes\common\functions.phpNow what I need to edit to remove the rest of the decimal?
I want to ask because I am a beginner in php
February 13, 2014 at 2:19 pm #142460In reply to: Change of date for freshness
John James JacobyKeymasterYou’ll want to filter the output of
bbp_get_time_since
; it’s the function responsible for humanizing timestamps. You’ll probably want to perform a string replacement starting at the comma, and append your own ‘ago’ at the end.February 10, 2014 at 11:43 pm #142324MajijibooParticipantWhich bbpress file should I add the below filter to to get that feature? Thanks.
function short_freshness_time( $output) { $output = preg_replace( '/, .*[^ago]/', ' ', $output ); return $output; } add_filter( 'bbp_get_time_since', 'short_freshness_time' ); add_filter('bp_core_time_since', 'short_freshness_time');
January 21, 2014 at 10:12 am #141648koendbParticipantJanuary 20, 2014 at 2:23 pm #141624koendbParticipantThanks Shmoo!
I added this filter, don’t remember where I found it:function short_freshness_time( $output) { $output = preg_replace( '/, .*[^ago]/', ' ', $output ); return $output; } add_filter( 'bbp_get_time_since', 'short_freshness_time' ); add_filter('bp_core_time_since', 'short_freshness_time');
Shall we leave this thread to Mycelus now? Feel free to PM me or open your own.
July 24, 2013 at 4:01 pm #135580In reply to: Shorter Freshness Titles
blg002Participant@thesnowjunkies @johnjamesjacoby @undyingearth @olivier-lettinga So here’s what I did, it looks to work but I haven’t fully put it through its paces. I’m also kind of a n00b with this PHP WordPress thing so hopefully this isn’t a terrible idea. I basically used an add filter on bbp_get_time_since and did a regex string replacement on the output removing anything from the first comma up to ‘ago’.
function short_freshness_time( $output, $older_date, $newer_date ) { $output = preg_replace( '/, .*[^ago]/', ' ', $output ); return $output; } add_filter( 'bbp_get_time_since', 'short_freshness_time' );
May 13, 2013 at 5:08 pm #134256Topic: Edit topic freshness to just 1 time chunk, not 2
in forum ThemesgingerngoParticipantHi,
I’m wondering how I can create a function that will allow me to output just 1 time chunk in the freshness column instead of 2.
So instead of “3 months, 1 hour” it will just be “3 months” and “4 hours, 23 minutes” will just be “4 hours.”
I found the bbp_get_time_since() function, but I’d like to create a separate function so I don’t edit the plugin files. Is this possible?
February 12, 2013 at 5:27 am #126282In reply to: Shorter Freshness Titles
undyingearthParticipantI’ve almost got this working, but my PHP-fu skills are not quite strong enough. @johnjamesjacoby and @thesnowjunkies pointed me in the right direction, but I feel like I must be making a basic mistake in the implementation.
I found the function bbp_get_time_since in /plugins/bbpress/includes/common/functions.php
I managed to achieve the desired effect by deleting the following:
`
// Step two: the second chunk
if ( $i + 2 $since ) {
$output = $unknown_text;// We only want to output two chunks of time here, eg:
// x years, xx months
// x days, xx hours
// so there’s only two bits of calculation below:
} else {// Step one: the first chunk
for ( $i = 0, $j = count( $chunks ); $i < $j; ++$i ) {
$seconds = $chunks[$i][0];// Finding the biggest chunk (if the chunk fits, break)
$count = floor( $since / $seconds );
if ( 0 != $count ) {
break;
}
}// If $i iterates all the way to $j, then the event happened 0 seconds ago
if ( !isset( $chunks[$i] ) ) {
$output = $right_now_text;} else {
// Set output var
$output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2];// Step two: the second chunk
if ( $i + 2 < $j ) {
$seconds2 = $chunks[$i + 1][0];
$name2 = $chunks[$i + 1][1];
$count2 = floor( ( $since – ( $seconds * $count ) ) / $seconds2 );// Add to output var
if ( 0 != $count2 ) {
$output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'bbpress' ) . ' 1 '. $name2 : _x( ',', 'Separator in time since', 'bbpress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
}
}// No output, so happened right now
if ( ! (int) trim( $output ) ) {
$output = $right_now_text;
}
}
}// Append 'ago' to the end of time-since if not 'right now'
if ( $output != $right_now_text ) {
$output = sprintf( $ago_text, $output );
}return apply_filters( 'bbp_get_time_short', $output, $older_date, $newer_date );
}`
This almost works. It cuts off the extra chunk. The problem is, it also returns a freshness value that is several years off. Instead of saying "10 minutes ago", it gives me "12 years ago"!
Any ideas what I'm doing wrong? I can achieve what I want by editing the core plugin, but I'd really like to update-proof this.
Thanks!
J.S.
November 15, 2012 at 10:38 pm #119989In reply to: Shorter Freshness Titles
John James JacobyKeymasterSearch for: ‘function bbp_get_time_since(‘
-
AuthorSearch Results