Skip to:
Content

BuddyPress.org

Changeset 8710


Ignore:
Timestamp:
07/29/2014 01:24:17 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Clean up code formatting in bp-activity-functions.php.

  • Brackets
  • Indentation
  • Fix incorrect phpdoc
  • Add inline doc
  • Move some variable assignments outside of comparisons
  • Remove some trailing whitespace
  • Use bp_parse_args()
  • Remove some one-time use variables
  • Replace $bp global usages with buddypress() calls
File:
1 edited

Legend:

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

    r8530 r8710  
    6464 */
    6565function bp_activity_find_mentions( $content ) {
     66
    6667    $pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
    6768    preg_match_all( $pattern, $content, $usernames );
    6869
    6970    // Make sure there's only one instance of each username
    70     if ( !$usernames = array_unique( $usernames[1] ) )
    71         return false;
     71    $usernames = array_unique( $usernames[1] );
     72
     73    // Bail if no usernames
     74    if ( empty( $usernames ) ) {
     75        return false;
     76    }
    7277
    7378    $mentioned_users = array();
     
    8388    }
    8489
    85     if ( empty( $mentioned_users ) )
    86         return false;
     90    if ( empty( $mentioned_users ) ) {
     91        return false;
     92    }
    8793
    8894    return $mentioned_users;
     
    100106function bp_activity_clear_new_mentions( $user_id ) {
    101107    bp_delete_user_meta( $user_id, 'bp_new_mention_count' );
    102     bp_delete_user_meta( $user_id, 'bp_new_mentions' );
     108    bp_delete_user_meta( $user_id, 'bp_new_mentions'      );
    103109}
    104110
     
    120126 */
    121127function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
    122     if ( empty( $activity_id ) )
    123         return false;
     128
     129    // Bail if no activity ID passed
     130    if ( empty( $activity_id ) ) {
     131        return false;
     132    }
    124133
    125134    // Get activity object
    126     $activity = new BP_Activity_Activity( (int) $activity_id );
     135    $activity  = new BP_Activity_Activity( (int) $activity_id );
    127136
    128137    // Try to find mentions
     
    130139
    131140    // Still empty? Stop now
    132     if ( empty( $usernames ) )
    133         return false;
     141    if ( empty( $usernames ) ) {
     142        return false;
     143    }
    134144
    135145    // Increment mention count foreach mentioned user
     
    156166 */
    157167function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) {
    158     if ( empty( $user_id ) || empty( $activity_id ) )
    159         return false;
     168
     169    if ( empty( $user_id ) || empty( $activity_id ) ) {
     170        return false;
     171    }
    160172
    161173    // Adjust the mention list and count for the member
    162174    $new_mention_count = (int) bp_get_user_meta( $user_id, 'bp_new_mention_count', true );
    163     if ( !$new_mentions = bp_get_user_meta( $user_id, 'bp_new_mentions', true ) )
     175    $new_mentions      =       bp_get_user_meta( $user_id, 'bp_new_mentions',      true );
     176
     177    // Make sure new mentions is an array
     178    if ( empty( $new_mentions ) ) {
    164179        $new_mentions = array();
     180    }
    165181
    166182    switch ( $action ) {
     
    322338 * @since BuddyPress (1.1.0)
    323339 *
    324  * @global object $bp BuddyPress global settings.
    325340 * @uses apply_filters() To call the 'bp_activity_get_action' hook.
    326341 *
     
    330345 */
    331346function bp_activity_get_action( $component_id, $key ) {
    332     global $bp;
    333347
    334348    // Return false if any of the above values are not set
    335     if ( empty( $component_id ) || empty( $key ) )
    336         return false;
    337 
    338     return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
     349    if ( empty( $component_id ) || empty( $key ) ) {
     350        return false;
     351    }
     352
     353    $bp     = buddypress();
     354    $retval = isset( $bp->activity->actions->{$component_id}->{$key} )
     355        ? $bp->activity->actions->{$component_id}->{$key}
     356        : false;
     357
     358    return apply_filters( 'bp_activity_get_action', $retval, $component_id, $key );
    339359}
    340360
     
    353373        $action = array_values( (array) $action );
    354374
    355         for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
     375        for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
    356376            $actions[ $action[$i]['key'] ] = $action[$i]['value'];
     377        }
    357378    }
    358379
     
    379400
    380401    // Fallback to logged in user if no user_id is passed
    381     if ( empty( $user_id ) )
     402    if ( empty( $user_id ) ) {
    382403        $user_id = bp_displayed_user_id();
     404    }
    383405
    384406    // Get favorites for user
     
    408430
    409431    // Favorite activity stream items are for logged in users only
    410     if ( !is_user_logged_in() )
    411         return false;
     432    if ( ! is_user_logged_in() ) {
     433        return false;
     434    }
    412435
    413436    // Fallback to logged in user if no user_id is passed
    414     if ( empty( $user_id ) )
     437    if ( empty( $user_id ) ) {
    415438        $user_id = bp_loggedin_user_id();
     439    }
    416440
    417441    $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
     
    472496
    473497    // Favorite activity stream items are for logged in users only
    474     if ( !is_user_logged_in() )
    475         return false;
     498    if ( ! is_user_logged_in() ) {
     499        return false;
     500    }
    476501
    477502    // Fallback to logged in user if no user_id is passed
    478     if ( empty( $user_id ) )
     503    if ( empty( $user_id ) ) {
    479504        $user_id = bp_loggedin_user_id();
     505    }
    480506
    481507    $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
     
    492518
    493519    // Update the total number of users who have favorited this activity
    494     if ( $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' ) ) {
     520    $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
     521    if ( ! empty( $fav_count ) ) {
    495522
    496523        // Deduct from total favorites
     
    564591
    565592    // Fallback on displayed user, and then logged in user
    566     if ( empty( $user_id ) )
     593    if ( empty( $user_id ) ) {
    567594        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
     595    }
    568596
    569597    return BP_Activity_Activity::total_favorite_count( $user_id );
     
    593621 */
    594622function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
    595     global $wpdb, $bp;
    596623
    597624    // Legacy - if no meta_key is passed, delete all for the item
     
    674701 * @param string $meta_key Metadata key.
    675702 * @param mixed $meta_value Metadata value.
    676  * @param bool $unique. Optional. Whether to enforce a single metadata value
     703 * @param bool $unique Optional. Whether to enforce a single metadata value
    677704 *        for the given key. If true, and the object already has a value for
    678705 *        the key, no change will be made. Default: false.
     
    705732
    706733    // Do not delete user data unless a logged in user says so
    707     if ( empty( $user_id ) || !is_user_logged_in() )
    708         return false;
     734    if ( empty( $user_id ) || ! is_user_logged_in() ) {
     735        return false;
     736    }
    709737
    710738    // Clear the user's activity from the sitewide stream and clear their activity tables
     
    712740
    713741    // Remove any usermeta
    714     bp_delete_user_meta( $user_id, 'bp_latest_update' );
     742    bp_delete_user_meta( $user_id, 'bp_latest_update'       );
    715743    bp_delete_user_meta( $user_id, 'bp_favorite_activities' );
    716744
     
    735763 */
    736764function bp_activity_spam_all_user_data( $user_id = 0 ) {
    737     global $bp, $wpdb;
     765    global $wpdb;
    738766
    739767    // Do not delete user data unless a logged in user says so
    740     if ( empty( $user_id ) || ! is_user_logged_in() )
    741         return false;
     768    if ( empty( $user_id ) || ! is_user_logged_in() ) {
     769        return false;
     770    }
    742771
    743772    // Get all the user's activities.
    744     $activities = bp_activity_get( array( 'display_comments' => 'stream', 'filter' => array( 'user_id' => $user_id ), 'show_hidden' => true, ) );
     773    $activities = bp_activity_get( array(
     774        'display_comments' => 'stream',
     775        'filter'           => array( 'user_id' => $user_id ),
     776        'show_hidden'      => true
     777    ) );
     778
     779    $bp = buddypress();
    745780
    746781    // Mark each as spam
     
    749784        // Create an activity object
    750785        $activity_obj = new BP_Activity_Activity;
    751         foreach ( $activity as $k => $v )
     786        foreach ( $activity as $k => $v ) {
    752787            $activity_obj->$k = $v;
     788        }
    753789
    754790        // Mark as spam
     
    762798         * we need to update manually.
    763799         */
    764         if ( ! empty( $bp->activity->akismet ) )
     800        if ( ! empty( $bp->activity->akismet ) ) {
    765801            $bp->activity->akismet->update_activity_spam_meta( $activity_obj );
     802        }
    766803
    767804        // Tidy up
     
    788825 */
    789826function bp_activity_ham_all_user_data( $user_id = 0 ) {
    790     global $bp, $wpdb;
     827    global $wpdb;
    791828
    792829    // Do not delete user data unless a logged in user says so
    793     if ( empty( $user_id ) || ! is_user_logged_in() )
    794         return false;
     830    if ( empty( $user_id ) || ! is_user_logged_in() ) {
     831        return false;
     832    }
    795833
    796834    // Get all the user's activities.
    797     $activities = bp_activity_get( array( 'display_comments' => 'stream', 'filter' => array( 'user_id' => $user_id ), 'show_hidden' => true, 'spam' => 'all', ) );
     835    $activities = bp_activity_get( array(
     836        'display_comments' => 'stream',
     837        'filter'           => array( 'user_id' => $user_id ),
     838        'show_hidden'      => true,
     839        'spam'             => 'all'
     840    ) );
     841
     842    $bp = buddypress();
    798843
    799844    // Mark each as not spam
     
    802847        // Create an activity object
    803848        $activity_obj = new BP_Activity_Activity;
    804         foreach ( $activity as $k => $v )
     849        foreach ( $activity as $k => $v ) {
    805850            $activity_obj->$k = $v;
     851        }
    806852
    807853        // Mark as not spam
     
    815861         * we need to update manually.
    816862         */
    817         if ( ! empty( $bp->activity->akismet ) )
     863        if ( ! empty( $bp->activity->akismet ) ) {
    818864            $bp->activity->akismet->update_activity_ham_meta( $activity_obj );
     865        }
    819866
    820867        // Tidy up
     
    834881 *
    835882 * @since BuddyPress (1.6.0)
    836  *
    837  * @global object $bp BuddyPress global settings.
    838883 */
    839884function bp_activity_register_activity_actions() {
    840     global $bp;
     885    $bp = buddypress();
    841886
    842887    bp_activity_set_action(
     
    872917 */
    873918function bp_activity_generate_action_string( $activity ) {
     919
    874920    // Check for valid input
    875921    if ( empty( $activity->component ) || empty( $activity->type ) ) {
     
    952998 */
    953999function bp_activity_get( $args = '' ) {
    954     $defaults = array(
     1000
     1001    $r = bp_parse_args( $args, array(
    9551002        'max'               => false,        // Maximum number of results to return
    9561003        'page'              => 1,            // page 1 without a per_page will result in no pagination.
     
    9791026         */
    9801027        'filter' => array()
    981     );
    982     $r = wp_parse_args( $args, $defaults );
     1028    ) );
    9831029
    9841030    // Attempt to return a cached copy of the first page of sitewide activity.
    985     if ( 1 == (int) $r['page'] && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && 'DESC' == $r['sort'] && empty( $r['exclude'] ) && 'ham_only' == $r['spam'] ) {
    986         if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) {
    987             $args = array(
     1031    if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) {
     1032
     1033        $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' );
     1034        if ( false === $activity ) {
     1035
     1036            $activity = BP_Activity_Activity::get( array(
    9881037                'page'              => $r['page'],
    9891038                'per_page'          => $r['per_page'],
     
    9981047                'update_meta_cache' => $r['update_meta_cache'],
    9991048                'count_total'       => $r['count_total'],
    1000             );
    1001             $activity = BP_Activity_Activity::get( $args );
     1049            ) );
     1050
    10021051            wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );
    10031052        }
    10041053
    10051054    } else {
    1006         $args = array(
     1055        $activity = BP_Activity_Activity::get( array(
    10071056            'page'             => $r['page'],
    10081057            'per_page'         => $r['per_page'],
     
    10181067            'spam'             => $r['spam'],
    10191068            'count_total'      => $r['count_total'],
    1020         );
    1021         $activity = BP_Activity_Activity::get( $args );
     1069        ) );
    10221070    }
    10231071
     
    10441092 */
    10451093function bp_activity_get_specific( $args = '' ) {
    1046     $defaults = array(
    1047         'activity_ids'      => false,       // A single activity_id or array of IDs.
    1048         'display_comments'  => false,       // true or false to display threaded comments for these specific activity items
    1049         'max'               => false,       // Maximum number of results to return
    1050         'page'              => 1,           // page 1 without a per_page will result in no pagination.
    1051         'per_page'          => false,       // results per page
    1052         'show_hidden'       => true,        // When fetching specific items, show all
    1053         'sort'              => 'DESC',      // sort ASC or DESC
    1054         'spam'              => 'ham_only',  // Retrieve items marked as spam
     1094
     1095    $r = bp_parse_args( $args, array(
     1096        'activity_ids'      => false,      // A single activity_id or array of IDs.
     1097        'display_comments'  => false,      // true or false to display threaded comments for these specific activity items
     1098        'max'               => false,      // Maximum number of results to return
     1099        'page'              => 1,          // page 1 without a per_page will result in no pagination.
     1100        'per_page'          => false,      // results per page
     1101        'show_hidden'       => true,       // When fetching specific items, show all
     1102        'sort'              => 'DESC',     // sort ASC or DESC
     1103        'spam'              => 'ham_only', // Retrieve items marked as spam
    10551104        'update_meta_cache' => true,
    1056     );
    1057     $r = wp_parse_args( $args, $defaults );
     1105    ) );
    10581106
    10591107    $get_args = array(
     1108        'display_comments'  => $r['display_comments'],
     1109        'in'                => $r['activity_ids'],
     1110        'max'               => $r['max'],
    10601111        'page'              => $r['page'],
    10611112        'per_page'          => $r['per_page'],
    1062         'max'               => $r['max'],
     1113        'show_hidden'       => $r['show_hidden'],
    10631114        'sort'              => $r['sort'],
    1064         'display_comments'  => $r['display_comments'],
    1065         'show_hidden'       => $r['show_hidden'],
    1066         'in'                => $r['activity_ids'],
    10671115        'spam'              => $r['spam'],
    10681116        'update_meta_cache' => $r['update_meta_cache'],
    10691117    );
     1118
    10701119    return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );
    10711120}
     
    11171166function bp_activity_add( $args = '' ) {
    11181167
    1119     $defaults = array(
    1120         'id'                => false, // Pass an existing activity ID to update an existing entry.
    1121 
    1122         'action'            => '',    // The activity action - e.g. "Jon Doe posted an update"
    1123         'content'           => '',    // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
    1124 
    1125         'component'         => false, // The name/ID of the component e.g. groups, profile, mycomponent
    1126         'type'              => false, // The activity type e.g. activity_update, profile_updated
    1127         'primary_link'      => '',    // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
    1128 
    1129         'user_id'           => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user.
    1130         'item_id'           => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
    1131         'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
     1168    $r = bp_parse_args( $args, array(
     1169        'id'                => false,                  // Pass an existing activity ID to update an existing entry.
     1170        'action'            => '',                     // The activity action - e.g. "Jon Doe posted an update"
     1171        'content'           => '',                     // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
     1172        'component'         => false,                  // The name/ID of the component e.g. groups, profile, mycomponent
     1173        'type'              => false,                  // The activity type e.g. activity_update, profile_updated
     1174        'primary_link'      => '',                     // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
     1175        'user_id'           => bp_loggedin_user_id(),  // Optional: The user to record the activity for, can be false if this activity is not for a user.
     1176        'item_id'           => false,                  // Optional: The ID of the specific item being recorded, e.g. a blog_id
     1177        'secondary_item_id' => false,                  // Optional: A second ID used to further filter e.g. a comment_id
    11321178        'recorded_time'     => bp_core_current_time(), // The GMT time that this activity was recorded
    1133         'hide_sitewide'     => false, // Should this be hidden on the sitewide activity stream?
    1134         'is_spam'           => false, // Is this activity item to be marked as spam?
    1135     );
    1136     $r = wp_parse_args( $args, $defaults );
     1179        'hide_sitewide'     => false,                  // Should this be hidden on the sitewide activity stream?
     1180        'is_spam'           => false,                  // Is this activity item to be marked as spam?
     1181    ) );
    11371182
    11381183    // Make sure we are backwards compatible
    1139     if ( empty( $r['component'] ) && !empty( $r['component_name'] ) )
     1184    if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
    11401185        $r['component'] = $r['component_name'];
    1141 
    1142     if ( empty( $r['type'] ) && !empty( $r['component_action'] ) )
     1186    }
     1187
     1188    if ( empty( $r['type'] ) && !empty( $r['component_action'] ) ) {
    11431189        $r['type'] = $r['component_action'];
     1190    }
    11441191
    11451192    // Setup activity to be added
     
    11611208
    11621209    // If this is an activity comment, rebuild the tree
    1163     if ( 'activity_comment' == $activity->type )
     1210    if ( 'activity_comment' == $activity->type ) {
    11641211        BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
     1212    }
    11651213
    11661214    wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
     
    11751223 * @since BuddyPress (1.2.0)
    11761224 *
    1177  * @global object $bp BuddyPress global settings.
    11781225 * @uses wp_parse_args()
    11791226 * @uses bp_is_user_inactive()
     
    11941241 */
    11951242function bp_activity_post_update( $args = '' ) {
    1196     global $bp;
    1197 
    1198     $defaults = array(
     1243
     1244    $r = wp_parse_args( $args, array(
    11991245        'content' => false,
    12001246        'user_id' => bp_loggedin_user_id()
    1201     );
    1202     $r = wp_parse_args( $args, $defaults );
    1203 
    1204     if ( empty( $r['content'] ) || !strlen( trim( $r['content'] ) ) )
    1205         return false;
    1206 
    1207     if ( bp_is_user_inactive( $r['user_id'] ) )
    1208         return false;
     1247    ) );
     1248
     1249    if ( empty( $r['content'] ) || !strlen( trim( $r['content'] ) ) ) {
     1250        return false;
     1251    }
     1252
     1253    if ( bp_is_user_inactive( $r['user_id'] ) ) {
     1254        return false;
     1255    }
    12091256
    12101257    // Record this on the user's profile
    1211     $from_user_link   = bp_core_get_userlink( $r['user_id'] );
    12121258    $activity_content = $r['content'];
    12131259    $primary_link     = bp_core_get_userlink( $r['user_id'], false, true );
     
    12181264        'content'      => apply_filters( 'bp_activity_new_update_content', $activity_content ),
    12191265        'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
    1220         'component'    => $bp->activity->id,
     1266        'component'    => buddypress()->activity->id,
    12211267        'type'         => 'activity_update',
    12221268    ) );
     
    12251271
    12261272    // Add this update to the "latest update" usermeta so it can be fetched anywhere.
    1227     bp_update_user_meta( bp_loggedin_user_id(), 'bp_latest_update', array( 'id' => $activity_id, 'content' => $activity_content ) );
     1273    bp_update_user_meta( bp_loggedin_user_id(), 'bp_latest_update', array(
     1274        'id'      => $activity_id,
     1275        'content' => $activity_content
     1276    ) );
    12281277
    12291278    do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id );
     
    13281377 */
    13291378function bp_activity_get_activity_id( $args = '' ) {
    1330     $defaults = array(
     1379
     1380    $r = bp_parse_args( $args, array(
    13311381        'user_id'           => false,
    13321382        'component'         => false,
     
    13371387        'content'           => false,
    13381388        'date_recorded'     => false,
    1339     );
    1340 
    1341     $r = wp_parse_args( $args, $defaults );
    1342 
    1343     return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $r['user_id'], $r['component'], $r['type'], $r['item_id'], $r['secondary_item_id'], $r['action'], $r['content'], $r['date_recorded'] ) );
     1389    ) );
     1390
     1391    return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id(
     1392        $r['user_id'],
     1393        $r['component'],
     1394        $r['type'],
     1395        $r['item_id'],
     1396        $r['secondary_item_id'],
     1397        $r['action'],
     1398        $r['content'],
     1399        $r['date_recorded']
     1400    ) );
    13441401}
    13451402
     
    13791436
    13801437    // Pass one or more the of following variables to delete by those variables
    1381     $defaults = array(
     1438    $args = bp_parse_args( $args, array(
    13821439        'id'                => false,
    13831440        'action'            => false,
     
    13911448        'date_recorded'     => false,
    13921449        'hide_sitewide'     => false
    1393     );
    1394 
    1395     $args = wp_parse_args( $args, $defaults );
     1450    ) );
    13961451
    13971452    do_action( 'bp_before_activity_delete', $args );
     
    14001455    bp_activity_adjust_mention_count( $args['id'], 'delete' );
    14011456
    1402     if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) )
    1403         return false;
     1457    $activity_ids_deleted = BP_Activity_Activity::delete( $args );
     1458    if ( empty( $activity_ids_deleted ) ) {
     1459        return false;
     1460    }
    14041461
    14051462    // Check if the user's latest update has been deleted
    1406     if ( empty( $args['user_id'] ) )
    1407         $user_id = bp_loggedin_user_id();
    1408     else
    1409         $user_id = $args['user_id'];
     1463    $user_id = empty( $args['user_id'] )
     1464        ? bp_loggedin_user_id()
     1465        : $args['user_id'];
    14101466
    14111467    $latest_update = bp_get_user_meta( $user_id, 'bp_latest_update', true );
     
    14421498    function bp_activity_delete_by_item_id( $args = '' ) {
    14431499
    1444         $defaults = array(
     1500        $r = bp_parse_args( $args, array(
    14451501            'item_id'           => false,
    14461502            'component'         => false,
     
    14481504            'user_id'           => false,
    14491505            'secondary_item_id' => false
    1450         );
    1451         $r = wp_parse_args( $args, $defaults );
    1452 
    1453         return bp_activity_delete( array( 'item_id' => $r['item_id'], 'component' => $r['component'], 'type' => $r['type'], 'user_id' => $r['user_id'], 'secondary_item_id' => $r['secondary_item_id'] ) );
     1506        ) );
     1507
     1508        return bp_activity_delete( $r );
    14541509    }
    14551510
     
    14851540     */
    14861541    function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
    1487         return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) );
     1542        return bp_activity_delete( array(
     1543            'user_id'   => $user_id,
     1544            'content'   => $content,
     1545            'component' => $component,
     1546            'type'      => $type
     1547        ) );
    14881548    }
    14891549
     
    15031563     */
    15041564    function bp_activity_delete_for_user_by_component( $user_id, $component ) {
    1505         return bp_activity_delete( array( 'user_id' => $user_id, 'component' => $component ) );
     1565        return bp_activity_delete( array(
     1566            'user_id'   => $user_id,
     1567            'component' => $component
     1568        ) );
    15061569    }
    15071570
     
    15311594     * handle the deletion of child comments differently. Make sure you return false.
    15321595     */
    1533     if ( !apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) )
    1534         return false;
     1596    if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) {
     1597        return false;
     1598    }
    15351599
    15361600    // Delete any children of this comment.
     
    15381602
    15391603    // Delete the actual comment
    1540     if ( !bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) )
    1541         return false;
     1604    if ( ! bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) ) {
     1605        return false;
     1606    }
    15421607
    15431608    // Recalculate the comment tree
     
    15921657function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
    15931658
    1594     if ( empty( $activity_obj ) )
     1659    if ( empty( $activity_obj ) ) {
    15951660        $activity_obj = new BP_Activity_Activity( $activity_id );
     1661    }
    15961662
    15971663    if ( isset( $activity_obj->current_comment ) ) {
     
    19071973 * @param string $cache An empty string passed by BP_Embed::parse_oembed() for
    19081974 *        functions like this one to filter.
     1975 * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
    19091976 * @param int $id The ID of the activity item.
    1910  * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
    19111977 * @return bool True on success, false on failure.
    19121978 */
Note: See TracChangeset for help on using the changeset viewer.