Skip to:
Content

BuddyPress.org

Changeset 7526


Ignore:
Timestamp:
11/08/2013 04:21:15 AM (11 years ago)
Author:
johnjamesjacoby
Message:

Introduce functions for outputting notification descriptions and action links, and update template parts to use them. See #5148.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-notifications/bp-notifications-template.php

    r7524 r7526  
    512512
    513513/**
     514 * Output the timestamp of the current notification.
     515 *
     516 * @since BuddyPress (1.9.0)
     517 */
     518function bp_the_notification_time_since() {
     519    echo bp_get_the_notification_time_since();
     520}
     521    /**
     522     * Return the timestamp of the current notification.
     523     *
     524     * @since BuddyPress (1.9.0)
     525     *
     526     * @return string Timestamp of the current notification.
     527     */
     528    function bp_get_the_notification_time_since() {
     529        return apply_filters( 'bp_get_the_notification_time_since', bp_core_time_since( bp_get_the_notification_date_notified() ) );
     530    }
     531
     532/**
     533 * Output full-text description for a specific notification.
     534 *
     535 * @since BuddyPress (1.9.0)
     536 */
     537function bp_the_notification_description() {
     538    echo bp_get_the_notification_description();
     539}
     540
     541    /**
     542     * Get full-text description for a specific notification.
     543     *
     544     * @since BuddyPress (1.9.0)
     545     *
     546     * @return string
     547     */
     548    function bp_get_the_notification_description() {
     549
     550        // Setup local variables
     551        $description  = '';
     552        $bp           = buddypress();
     553        $notification = $bp->notifications->query_loop->notification;
     554
     555        // Skip inactive components
     556        if ( ! bp_is_active( $notification->component_name ) ) {
     557            return;
     558        }
     559
     560        // Callback function exists
     561        if ( isset( $bp->{ $notification->component_name }->notification_callback ) && is_callable( $bp->{ $notification->component_name }->notification_callback ) ) {
     562            $description = call_user_func( $bp->{ $notification->component_name }->notification_callback, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 );
     563
     564        // @deprecated format_notification_function - 1.5
     565        } elseif ( isset( $bp->{ $notification->component_name }->format_notification_function ) && function_exists( $bp->{ $notification->component_name }->format_notification_function ) ) {
     566            $description = call_user_func( $bp->{ $notification->component_name }->format_notification_function, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 );
     567        }
     568
     569        // Filter and return
     570        return apply_filters( 'bp_get_the_notification_description', $description );
     571    }
     572
     573/**
     574 * Output the action links for the current notification.
     575 *
     576 * @since BuddyPress (1.9.0)
     577 */
     578function bp_the_notification_action_links() {
     579    echo bp_get_the_notification_action_links();
     580}
     581    /**
     582     * Return the action links for the current notification.
     583     *
     584     * @since BuddyPress (1.9.0)
     585     *
     586     * @return string HTML links for actions to take on single notifications.
     587     */
     588    function bp_get_the_notification_action_links() {
     589
     590        // Setup the return value
     591        $retval = '';
     592
     593        // Start the output buffer
     594        ob_start();
     595
     596        // Get and empty the output buffer
     597        $retval = ob_get_clean();
     598
     599        return apply_filters( 'bp_get_the_notification_action_links', $retval );
     600    }
     601
     602/**
    514603 * Output the pagination count for the current notification loop.
    515604 *
  • trunk/bp-templates/bp-legacy/buddypress/members/single/notifications/notifications-loop.php

    r7521 r7526  
    77    <tr>
    88        <td></td>
    9         <td><?php bp_the_notification_component_action(); ?></td>
    10         <td><?php echo bp_core_get_userlink( bp_get_the_notification_item_id() ); ?></td>
    11         <td><?php echo bp_core_time_since( bp_get_the_notification_date_notified() ); ?></td>
     9        <td><?php bp_the_notification_description(); ?></td>
     10        <td><?php bp_the_notification_time_since(); ?></td>
     11        <td><?php bp_the_notification_action_links(); ?></td>
    1212    </tr>
    1313
  • trunk/bp-templates/bp-legacy/buddypress/members/single/notifications/read.php

    r7523 r7526  
    1111    </div>
    1212
    13     <table class="notification-settings">
     13    <table class="notifications">
    1414        <thead>
    1515            <tr>
    1616                <th class="icon"></th>
    1717                <th class="title"><?php _e( 'Notification', 'buddypress' ) ?></th>
    18                 <th class="title"><?php _e( 'Member',       'buddypress' ) ?></th>
    1918                <th class="date"><?php _e( 'Date Received', 'buddypress' ) ?></th>
     19                <th class="actions"><?php _e( 'Actions',    'buddypress' ); ?></th>
    2020            </tr>
    2121        </thead>
  • trunk/bp-templates/bp-legacy/buddypress/members/single/notifications/unread.php

    r7523 r7526  
    1111    </div>
    1212
    13     <table class="notification-settings">
     13    <table class="notifications">
    1414        <thead>
    1515            <tr>
    1616                <th class="icon"></th>
    17                 <th class="title"><?php _e( 'Notification', 'buddypress' ) ?></th>
    18                 <th class="title"><?php _e( 'Member',        'buddypress' ) ?></th>
    19                 <th class="date"><?php _e( 'Date Received', 'buddypress' ) ?></th>
     17                <th class="title"><?php _e( 'Notification', 'buddypress' ); ?></th>
     18                <th class="date"><?php _e( 'Date Received', 'buddypress' ); ?></th>
     19                <th class="actions"><?php _e( 'Actions',    'buddypress' ); ?></th>
    2020            </tr>
    2121        </thead>
Note: See TracChangeset for help on using the changeset viewer.