Added 'hybrid_get_time_since' to the utilities functions. #12

Closed
wants to merge 8 commits into
from

Conversation

Projects
None yet
3 participants

dronix commented Dec 25, 2012

Adds the 'hybrid_get_time_since' function taken from bbpress to allow users to return human readable time. Also added one extra attribute of 'human_time' to '[entry-published]' shortcode and added attributes to the '[comment-published]' shortcode.

dronix added some commits Dec 20, 2012

@dronix dronix Set the correct suffix to the main stylesheet
The suffix is already defined to be style.min.css if SCRIPT_DEBUG is turned off. We just needed to add this conditional suffix to the name of the stylesheet itself.
864a0c5
@dronix dronix Merge branch '1.5' of https://github.com/justintadlock/hybrid-core in…
…to 1.5
453b3a8
@dronix dronix Merge branch '1.5' of https://github.com/justintadlock/hybrid-core in…
…to 1.5
11c010b
@dronix dronix Merge branch '1.5' of https://github.com/justintadlock/hybrid-core in…
…to 1.5
99990ab
@dronix dronix Added 'hybrid_get_time_since' to the utilities functions.
Adds the 'hybrid_get_time_since' function taken from bbpress to allow users to return human readable time. Also added one extra attribute of 'human_time' to '[entry-published]' shortcode and added attributes to the '[comment-published]' shortcode.
953c889
@dronix dronix Fixed a misspelling in 'hybrid_comment_published_shortcode'
Fixed a misspelling in 'hybrid_comment_published_shortcode' in 'functions/shortcodes.php'.
fb61eb0
Contributor

Rarst commented Dec 25, 2012

Hm... Rather than including custom implementation maybe it would make more sense to use native human_time_diff() and filter it to allow for more elaborate custom processing.

dronix commented Dec 25, 2012

Yes this is meant to replace human_time_diff as it is does not provide any filters.

Contributor

Rarst commented Dec 25, 2012

Yes, my point is that Hybrid Core can wrap it in a filter (as it often does with core WordPress functions). Introducing custom re-implementation of function is not a light move - stuck maintaining it forever. :)

dronix commented Dec 25, 2012

Ah I see what you mean. I'm not sure how I would go about extending human_time_diff.

Contributor

Rarst commented Dec 25, 2012

$human_time_diff = apply_filters( 'human_time_diff', human_time_diff(... and stuff. :) Then people who need more fancy implementation than that of WP can replace it.

dronix commented Dec 25, 2012

I'm sorry but I still fail to see what you mean. You're essentially suggesting to do the same thing we've done but instead of creating hybrid_get_time_since you've replaced the WordPress human_time_diff. The hybrid_get_time_since function is filterable.

Contributor

Rarst commented Dec 25, 2012

Yes, then you can use your custom function in that filter (without including it in Hybrid Core), someone else can customize it with something else and everyone who doesn't care to customize will get native WordPress functionality.

It's up to @justintadlock of course if he sees a place for such function in Hybrid Core, just sharing my opinion on it.

dronix commented Dec 25, 2012

I appreciate it Rarst. I'm also unclear whether it should go into Hybrid Core or not. I've just been using it in a few themes and thought I would give it a go and see what @justintadlock says.

Owner

justintadlock commented Dec 27, 2012

Basically, if adding this, I'd probably add it to just the shortcodes. The [entry-published] shortcode would use something like:

$attr = shortcode_atts( array( 'before' => '', 'after' => '', 'format' => get_option( 'date_format' ), 'human_time' => '' ), $attr );
if ( !empty( $attr['human_time'] ) )
    /* Use human time diff. */

One might put in something like:

[entry-published human_time="%s ago"]

Since this is a shortcode, it's probably best not to use a boolean and stick to strings.

This is an idea I'll visit in 1.6. It's actually already been on my to-do list.

Owner

justintadlock commented May 26, 2013

It looks like this ticket is making it into WP 3.6: http://core.trac.wordpress.org/ticket/9272 If you need an additional filter hook, I highly recommend hopping over to Trac.

I've added the ability to use the human time to the entry-published and comment-published shortcodes in 0125918

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment