[Bb-trac] [bbPress] #943: add ability to filter topic_time()'s
output as well as its input time
bbPress
bb-trac at lists.bbpress.org
Sat Aug 23 16:20:09 GMT 2008
#943: add ability to filter topic_time()'s output as well as its input time
-------------------------+--------------------------------------------------
Reporter: fel64 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Back-end | Version: 1.0-beta (trunk)
Severity: normal | Keywords:
-------------------------+--------------------------------------------------
The code for `topic_time()`, used in topic listings, is here:
{{{
function topic_time( $args = '' ) {
$args = _bb_parse_time_function_args( $args );
$time = apply_filters( 'topic_time', get_topic_time(
array('format' => 'mysql') + $args), $args );
echo _bb_time_function_return( $time, $args );
}
}}}
You can see that the filter `topic_time` filters the actual time, which is
then passed to `_bb_time_function_return()`, which does a little
processing and then passes it to `bb_gmdate_i18n()` which then returns
something. A filter is not applied again (as far as I can tell - the time
functions are not very easy to read).
If someone wishes to change how the time is displayed, they have to change
the functions in their template files. In my opinion this would be better
done with a plugin; it increases theme maintanability (since less theme
files have to be changed, thus more of them can come from the up-to-date
kakumei).
A plugin could be used or, equally, the change could be made using plugin-
like code in the theme's functions.php. It may be a design decision, but I
think it's best implemented using code, and for that bbPress needs to
filter topic_time()'s output. The filter should also pass the time as an
argument.
Additional filter names could be `echo_topic_time` and, for
`get_topic_time()`, `return_topic_time`.
--
Ticket URL: <http://trac.bbpress.org/ticket/943>
bbPress <http://bbpress.org/>
Innovative forum development
More information about the Bb-trac
mailing list