Ticket #943 (closed enhancement: wontfix)

Opened 3 months ago

Last modified 3 months ago

add ability to filter topic_time()'s output as well as its input time

Reported by: fel64 Assigned to:
Priority: normal Milestone:
Component: Back-end Version: 1.0-beta (trunk)
Severity: normal Keywords:
Cc:

Description

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.

Change History

09/09/08 04:38:17 changed by sambauers

I would suggest that the theme developer write their own topic_time() like function and add it to their functions.php file then apply it where required.

Something like:

function my_topic_time(args='')
{
$time = get_topic_time($args);
echo 'The time is: ' . $time;
}

I think we should expect time functions to return a string which is of a consistent group.

09/09/08 05:39:59 changed by sambauers

  • status changed from new to closed.
  • resolution set to wontfix.

I don't think there is a compelling case to change the current behaviour considering there is a workaround available.