Skip to:
Content

BuddyPress.org

Changeset 8807


Ignore:
Timestamp:
08/12/2014 12:27:49 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Clean up xprofile_record_activity():

  • Use bp_parse_args()
  • Remove explode() usage
File:
1 edited

Legend:

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

    r8806 r8807  
    116116 * it will show in the users activity stream (if installed)
    117117 *
     118 * @since BuddyPress (1.0.0)0
     119 *
    118120 * @package BuddyPress
    119121 * @subpackage XProfileActivity
    120122 * @param string $args String containing all variables used after extract() call
    121  * @global $bp The global BuddyPress settings variable created in bp_core_current_times()
    122123 * @uses bp_activity_add() Adds an entry to the activity component tables for a specific activity
    123124 */
    124125function xprofile_record_activity( $args = '' ) {
    125126
    126         if ( !bp_is_active( 'activity' ) )
    127                 return false;
    128 
    129         global $bp;
    130 
    131         $defaults = array (
     127        // Bail if activity component is not active
     128        if ( ! bp_is_active( 'activity' ) ) {
     129                return false;
     130        }
     131
     132        // Parse the arguments
     133        $r = bp_parse_args( $args, array(
    132134                'user_id'           => bp_loggedin_user_id(),
    133135                'action'            => '',
    134136                'content'           => '',
    135137                'primary_link'      => '',
    136                 'component'         => $bp->profile->id,
     138                'component'         => buddypress()->profile->id,
    137139                'type'              => false,
    138140                'item_id'           => false,
    … …  
    140142                'recorded_time'     => bp_core_current_time(),
    141143                'hide_sitewide'     => false
    142         );
    143 
    144         $r = wp_parse_args( $args, $defaults );
    145         extract( $r, EXTR_SKIP );
    146 
    147         return bp_activity_add( array(
    148                 'user_id'           => $user_id,
    149                 'action'            => $action,
    150                 'content'           => $content,
    151                 'primary_link'      => $primary_link,
    152                 'component'         => $component,
    153                 'type'              => $type,
    154                 'item_id'           => $item_id,
    155                 'secondary_item_id' => $secondary_item_id,
    156                 'recorded_time'     => $recorded_time,
    157                 'hide_sitewide'     => $hide_sitewide
    158144        ) );
     145
     146        return bp_activity_add( $r );
    159147}
    160148
Note: See TracChangeset for help on using the changeset viewer.