Skip to:
Content

BuddyPress.org

Changeset 8692


Ignore:
Timestamp:
07/25/2014 11:38:08 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Introduce functions for getting the sent-date of a specific private message, without putting it through time-since calculations. This allows for plugins and themes to perform custom calculations on message output like "37d" or "14m" or "15s", without needing to touch the global directly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-template.php

    r8674 r8692  
    17011701     */
    17021702    function bp_get_the_thread_message_time_since() {
     1703        return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s', 'buddypress' ), bp_core_time_since( bp_get_the_thread_message_date_sent() ) ) );
     1704    }
     1705
     1706/**
     1707 * Output the timestamp for the current message.
     1708 *
     1709 * @since BuddyPress (2.1.0)
     1710 */
     1711function bp_the_thread_message_date_sent() {
     1712    echo bp_get_the_thread_message_date_sent();
     1713}
     1714    /**
     1715     * Generate the 'Sent x hours ago' string for the current message.
     1716     *
     1717     * @since BuddyPress (2.1.0)
     1718     *
     1719     * @uses strtotime() To convert the message string into a usable timestamp
     1720     * @return int
     1721     */
     1722    function bp_get_the_thread_message_date_sent() {
    17031723        global $thread_template;
    17041724
    1705         return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s', 'buddypress' ), bp_core_time_since( strtotime( $thread_template->message->date_sent ) ) ) );
     1725        return apply_filters( 'bp_get_the_thread_message_date_sent', strtotime( $thread_template->message->date_sent ) );
    17061726    }
    17071727
Note: See TracChangeset for help on using the changeset viewer.