Skip to:
Content

BuddyPress.org

Changeset 9721


Ignore:
Timestamp:
04/08/2015 06:03:32 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Activity: Light clean-up to bp-activity-template.php:

  • Fix $args regression in bp_get_activity_action() from previous clean-up in r9537
  • Break up long lines of filtered content into multiple variables for easier readability
  • Pass $new_content and previous $content into bp_insert_activity_meta filter
File:
1 edited

Legend:

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

    r9698 r9721  
    17541754                global $activities_template;
    17551755
    1756                 $args = wp_parse_args( $args, array(
     1756                $r = wp_parse_args( $args, array(
    17571757                        'no_timestamp' => false,
    17581758                ) );
    17591759
    1760                 $action = $activities_template->activity->action;
    1761 
    17621760                /**
    17631761                 * Filters the activity action before the action is inserted as meta.
     
    17671765                 * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
    17681766                 */
    1769                 $action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array( $action, &$activities_template->activity, $args ) );
    1770 
     1767                $action = apply_filters_ref_array( 'bp_get_activity_action_pre_meta', array(
     1768                        $activities_template->activity->action,
     1769                        &$activities_template->activity,
     1770                        $r
     1771                ) );
     1772
     1773                // Prepend the activity action meta (link, time since, etc...)
    17711774                if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) {
    17721775                        $action = bp_insert_activity_meta( $action );
     
    17801783                 * @param array $value Array containing the current action, the current activity, and the $args array passed into the function.
    17811784                 */
    1782                 return apply_filters_ref_array( 'bp_get_activity_action', array( $action, &$activities_template->activity, $args ) );
     1785                return apply_filters_ref_array( 'bp_get_activity_action', array(
     1786                        $action,
     1787                        &$activities_template->activity,
     1788                        $r
     1789                ) );
    17831790        }
    17841791
     
    19021909 * @return string The activity content with the metadata string attached.
    19031910 */
    1904 function bp_insert_activity_meta( $content ) {
     1911function bp_insert_activity_meta( $content = '' ) {
    19051912        global $activities_template;
    19061913
    19071914        // Strip any legacy time since placeholders from BP 1.0-1.1
    1908         $content = str_replace( '<span class="time-since">%s</span>', '', $content );
     1915        $new_content = str_replace( '<span class="time-since">%s</span>', '', $content );
     1916
     1917        // Get the time since this activity was recorded
     1918        $date_recorded  = bp_core_time_since( $activities_template->activity->date_recorded );
    19091919
    19101920        /**
     
    19151925         * @param array $value Array containing the time since markup and the current activity component.
    19161926         */
    1917         $time_since = apply_filters_ref_array( 'bp_activity_time_since', array( '<span class="time-since">' . bp_core_time_since( $activities_template->activity->date_recorded ) . '</span>', &$activities_template->activity ) );
     1927        $time_since = apply_filters_ref_array( 'bp_activity_time_since', array(
     1928                '<span class="time-since">' . $date_recorded . '</span>',
     1929                &$activities_template->activity
     1930        ) );
    19181931
    19191932        // Insert the permalink
    1920         if ( !bp_is_single_activity() ) {
     1933        if ( ! bp_is_single_activity() ) {
     1934
     1935                // Setup variables for activity meta
     1936                $activity_permalink = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
     1937                $activity_meta      = sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>',
     1938                        $new_content,
     1939                        $activity_permalink,
     1940                        esc_attr__( 'View Discussion', 'buddypress' ),
     1941                        $time_since
     1942                );
    19211943
    19221944                /**
     
    19271949                 * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.
    19281950                 */
    1929                 $content = apply_filters_ref_array( 'bp_activity_permalink', array( sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ), esc_attr__( 'View Discussion', 'buddypress' ), $time_since ), &$activities_template->activity ) );
     1951                $new_content = apply_filters_ref_array( 'bp_activity_permalink', array(
     1952                        $activity_meta,
     1953                        &$activities_template->activity
     1954                ) );
    19301955        } else {
    1931                 $content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH );
     1956                $new_content .= str_pad( $time_since, strlen( $time_since ) + 2, ' ', STR_PAD_BOTH );
    19321957        }
    19331958
     
    19391964         * @param string $content Activity content with the activity metadata added.
    19401965         */
    1941         return apply_filters( 'bp_insert_activity_meta', $content );
     1966        return apply_filters( 'bp_insert_activity_meta', $new_content, $content );
    19421967}
    19431968
Note: See TracChangeset for help on using the changeset viewer.