Skip to:
Content

BuddyPress.org

Changeset 10253


Ignore:
Timestamp:
10/12/2015 05:45:14 AM (8 years ago)
Author:
tw2113
Message:

Further documentation cleanup for Activity Component.

See #6396.

Location:
trunk/src
Files:
17 edited

Legend:

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

    r10077 r10253  
    99 */
    1010
    11 // Exit if accessed directly
     11// Exit if accessed directly.
    1212defined( 'ABSPATH' ) || exit;
    1313
     
    5151function bp_activity_action_permalink_router() {
    5252
    53     // Not viewing activity
     53    // Not viewing activity.
    5454    if ( ! bp_is_activity_component() || ! bp_is_current_action( 'p' ) )
    5555        return false;
    5656
    57     // No activity to display
     57    // No activity to display.
    5858    if ( ! bp_action_variable( 0 ) || ! is_numeric( bp_action_variable( 0 ) ) )
    5959        return false;
    6060
    61     // Get the activity details
     61    // Get the activity details.
    6262    $activity = bp_activity_get_specific( array( 'activity_ids' => bp_action_variable( 0 ), 'show_hidden' => true ) );
    6363
     
    7070    }
    7171
    72     // Do not redirect at default
     72    // Do not redirect at default.
    7373    $redirect = false;
    7474
    75     // Redirect based on the type of activity
     75    // Redirect based on the type of activity.
    7676    if ( bp_is_active( 'groups' ) && $activity->component == buddypress()->groups->id ) {
    7777
    78         // Activity is a user update
     78        // Activity is a user update.
    7979        if ( ! empty( $activity->user_id ) ) {
    8080            $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
    8181
    82         // Activity is something else
     82        // Activity is something else.
    8383        } else {
    8484
    85             // Set redirect to group activity stream
     85            // Set redirect to group activity stream.
    8686            if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
    8787                $redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/';
     
    8989        }
    9090
    91     // Set redirect to users' activity stream
     91    // Set redirect to users' activity stream.
    9292    } elseif ( ! empty( $activity->user_id ) ) {
    9393        $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
    9494    }
    9595
    96     // If set, add the original query string back onto the redirect URL
     96    // If set, add the original query string back onto the redirect URL.
    9797    if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
    9898        $query_frags = array();
     
    112112    }
    113113
    114     // Redirect to the actual activity permalink page
     114    // Redirect to the actual activity permalink page.
    115115    bp_core_redirect( $redirect );
    116116}
     
    121121 *
    122122 * @since 1.1.0
    123  *
    124  * @param int $activity_id Activity id to be deleted. Defaults to 0.
    125123 *
    126124 * @uses bp_is_activity_component()
     
    135133 * @uses bp_core_redirect()
    136134 *
     135 * @param int $activity_id Activity id to be deleted. Defaults to 0.
    137136 * @return bool False on failure.
    138137 */
    139138function bp_activity_action_delete_activity( $activity_id = 0 ) {
    140139
    141     // Not viewing activity or action is not delete
     140    // Not viewing activity or action is not delete.
    142141    if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) )
    143142        return false;
     
    146145        $activity_id = (int) bp_action_variable( 0 );
    147146
    148     // Not viewing a specific activity item
     147    // Not viewing a specific activity item.
    149148    if ( empty( $activity_id ) )
    150149        return false;
    151150
    152     // Check the nonce
     151    // Check the nonce.
    153152    check_admin_referer( 'bp_activity_delete_link' );
    154153
    155     // Load up the activity item
     154    // Load up the activity item.
    156155    $activity = new BP_Activity_Activity( $activity_id );
    157156
    158     // Check access
     157    // Check access.
    159158    if ( ! bp_activity_user_can_delete( $activity ) )
    160159        return false;
     
    170169    do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
    171170
    172     // Delete the activity item and provide user feedback
     171    // Delete the activity item and provide user feedback.
    173172    if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) )
    174173        bp_core_add_message( __( 'Activity deleted successfully', 'buddypress' ) );
     
    186185    do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
    187186
    188     // Check for the redirect query arg, otherwise let WP handle things
     187    // Check for the redirect query arg, otherwise let WP handle things.
    189188    if ( !empty( $_GET['redirect_to'] ) )
    190189        bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
     
    200199 *
    201200 * @param int $activity_id Activity id to be deleted. Defaults to 0.
    202  *
    203201 * @return bool False on failure.
    204202 */
     
    206204    $bp = buddypress();
    207205
    208     // Not viewing activity, or action is not spam, or Akismet isn't present
     206    // Not viewing activity, or action is not spam, or Akismet isn't present.
    209207    if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
    210208        return false;
     
    213211        $activity_id = (int) bp_action_variable( 0 );
    214212
    215     // Not viewing a specific activity item
     213    // Not viewing a specific activity item.
    216214    if ( empty( $activity_id ) )
    217215        return false;
     
    221219        return false;
    222220
    223     // Load up the activity item
     221    // Load up the activity item.
    224222    $activity = new BP_Activity_Activity( $activity_id );
    225223    if ( empty( $activity->id ) )
    226224        return false;
    227225
    228     // Check nonce
     226    // Check nonce.
    229227    check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
    230228
     
    239237    do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
    240238
    241     // Mark as spam
     239    // Mark as spam.
    242240    bp_activity_mark_as_spam( $activity );
    243241    $activity->save();
    244242
    245     // Tell the user the spamming has been successful
     243    // Tell the user the spamming has been successful.
    246244    bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
    247245
     
    256254    do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
    257255
    258     // Check for the redirect query arg, otherwise let WP handle things
     256    // Check for the redirect query arg, otherwise let WP handle things.
    259257    if ( !empty( $_GET['redirect_to'] ) )
    260258        bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
     
    287285function bp_activity_action_post_update() {
    288286
    289     // Do not proceed if user is not logged in, not viewing activity, or not posting
     287    // Do not proceed if user is not logged in, not viewing activity, or not posting.
    290288    if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
    291289        return false;
    292290
    293     // Check the nonce
     291    // Check the nonce.
    294292    check_admin_referer( 'post_update', '_wpnonce_post_update' );
    295293
     
    327325    }
    328326
    329     // No activity content so provide feedback and redirect
     327    // No activity content so provide feedback and redirect.
    330328    if ( empty( $content ) ) {
    331329        bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
     
    333331    }
    334332
    335     // No existing item_id
     333    // No existing item_id.
    336334    if ( empty( $item_id ) ) {
    337335        $activity_id = bp_activity_post_update( array( 'content' => $content ) );
    338336
    339     // Post to groups object
     337    // Post to groups object.
    340338    } elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) {
    341339        if ( (int) $item_id ) {
     
    357355    }
    358356
    359     // Provide user feedback
     357    // Provide user feedback.
    360358    if ( !empty( $activity_id ) )
    361359        bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
     
    363361        bp_core_add_message( __( 'There was an error when posting your update. Please try again.', 'buddypress' ), 'error' );
    364362
    365     // Redirect
     363    // Redirect.
    366364    bp_core_redirect( wp_get_referer() );
    367365}
     
    391389        return false;
    392390
    393     // Check the nonce
     391    // Check the nonce.
    394392    check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
    395393
     
    454452        return false;
    455453
    456     // Check the nonce
     454    // Check the nonce.
    457455    check_admin_referer( 'mark_favorite' );
    458456
     
    488486        return false;
    489487
    490     // Check the nonce
     488    // Check the nonce.
    491489    check_admin_referer( 'unmark_favorite' );
    492490
     
    518516        return false;
    519517
    520     // setup the feed
     518    // Setup the feed.
    521519    buddypress()->activity->feed = new BP_Activity_Feed( array(
    522520        'id'            => 'sitewide',
     
    548546    }
    549547
    550     // setup the feed
     548    // Setup the feed.
    551549    buddypress()->activity->feed = new BP_Activity_Feed( array(
    552550        'id'            => 'personal',
     
    581579    }
    582580
    583     // setup the feed
     581    // Setup the feed.
    584582    buddypress()->activity->feed = new BP_Activity_Feed( array(
    585583        'id'            => 'friends',
     
    614612    }
    615613
    616     // get displayed user's group IDs
     614    // Get displayed user's group IDs.
    617615    $groups    = groups_get_user_groups();
    618616    $group_ids = implode( ',', $groups['groups'] );
    619617
    620     // setup the feed
     618    // Setup the feed.
    621619    buddypress()->activity->feed = new BP_Activity_Feed( array(
    622620        'id'            => 'mygroups',
     
    657655    }
    658656
    659     // setup the feed
     657    // Setup the feed.
    660658    buddypress()->activity->feed = new BP_Activity_Feed( array(
    661659        'id'            => 'mentions',
     
    690688    }
    691689
    692     // get displayed user's favorite activity IDs
     690    // Get displayed user's favorite activity IDs.
    693691    $favs = bp_activity_get_user_favorites( bp_displayed_user_id() );
    694692    $fav_ids = implode( ',', (array) $favs );
    695693
    696     // setup the feed
     694    // Setup the feed.
    697695    buddypress()->activity->feed = new BP_Activity_Feed( array(
    698696        'id'            => 'favorites',
     
    717715    $bp = buddypress();
    718716
    719     // Bail if Akismet is not active
     717    // Bail if Akismet is not active.
    720718    if ( ! defined( 'AKISMET_VERSION' ) ) {
    721719        return;
    722720    }
    723721
    724     // Bail if older version of Akismet
     722    // Bail if older version of Akismet.
    725723    if ( ! class_exists( 'Akismet' ) ) {
    726724        return;
    727725    }
    728726
    729     // Bail if no Akismet key is set
     727    // Bail if no Akismet key is set.
    730728    if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) ) {
    731729        return;
     
    743741    }
    744742
    745     // Instantiate Akismet for BuddyPress
     743    // Instantiate Akismet for BuddyPress.
    746744    $bp->activity->akismet = new BP_Akismet();
    747745}
     
    828826    // Unpublishing a previously published post.
    829827    } elseif ( 'publish' === $old_status ) {
    830         // Some form of pending status - only remove the activity entry
     828        // Some form of pending status - only remove the activity entry.
    831829        bp_activity_post_type_unpublish( $post->ID, $post );
    832830    }
  • trunk/src/bp-activity/bp-activity-admin.php

    r10248 r10253  
    66 * help text, on which this implementation is heavily based.
    77 *
    8  * @since 1.6.0
    98 * @package BuddyPress
    109 * @subpackage ActivityAdmin
     10 * @since 1.6.0
    1111 */
    1212
    13 // Exit if accessed directly
     13// Exit if accessed directly.
    1414defined( 'ABSPATH' ) || exit;
    1515
    16 // Include WP's list table class
     16// Include WP's list table class.
    1717if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
    1818
    19 // per_page screen option. Has to be hooked in extremely early.
     19// Per_page screen option. Has to be hooked in extremely early.
    2020if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-activity' == $_REQUEST['page'] )
    2121    add_filter( 'set-screen-option', 'bp_activity_admin_screen_options', 10, 3 );
     
    2828function bp_activity_add_admin_menu() {
    2929
    30     // Add our screen
     30    // Add our screen.
    3131    $hook = add_menu_page(
    3232        _x( 'Activity', 'Admin Dashbord SWA page title', 'buddypress' ),
     
    5353 *
    5454 * @param array $custom_menus The list of top-level BP menu items.
    55  *
    5655 * @return array $custom_menus List of top-level BP menu items, with Activity added.
    5756 */
     
    7170 */
    7271function bp_activity_admin_reply() {
    73     // Check nonce
     72    // Check nonce.
    7473    check_ajax_referer( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply' );
    7574
     
    8180        die( '-1' );
    8281
    83     // If $root_id not set (e.g. for root items), use $parent_id
     82    // If $root_id not set (e.g. for root items), use $parent_id.
    8483    if ( empty( $root_id ) )
    8584        $root_id = $parent_id;
    8685
    87     // Check that a reply has been entered
     86    // Check that a reply has been entered.
    8887    if ( empty( $_REQUEST['content'] ) )
    8988        die( __( 'ERROR: Please type a reply.', 'buddypress' ) );
    9089
    91     // Check parent activity exists
     90    // Check parent activity exists.
    9291    $parent_activity = new BP_Activity_Activity( $parent_id );
    9392    if ( empty( $parent_activity->component ) )
     
    9998        die( '-1' );
    10099
    101     // Add new activity comment
     100    // Add new activity comment.
    102101    $new_activity_id = bp_activity_new_comment( array(
    103         'activity_id' => $root_id,              // ID of the root activity item
     102        'activity_id' => $root_id,              // ID of the root activity item.
    104103        'content'     => $_REQUEST['content'],
    105         'parent_id'   => $parent_id,            // ID of a parent comment
     104        'parent_id'   => $parent_id,            // ID of a parent comment.
    106105    ) );
    107106
    108     // Fetch the new activity item, as we need it to create table markup to return
     107    // Fetch the new activity item, as we need it to create table markup to return.
    109108    $new_activity = new BP_Activity_Activity( $new_activity_id );
    110109
    111     // This needs to be set for the BP_Activity_List_Table constructor to work
     110    // This needs to be set for the BP_Activity_List_Table constructor to work.
    112111    set_current_screen( 'toplevel_page_bp-activity' );
    113112
    114     // Set up an output buffer
     113    // Set up an output buffer.
    115114    ob_start();
    116115    $list_table = new BP_Activity_List_Table();
    117116    $list_table->single_row( (array) $new_activity );
    118117
    119     // Get table markup
     118    // Get table markup.
    120119    $response =  array(
    121120        'data'     => ob_get_contents(),
     
    126125    ob_end_clean();
    127126
    128     // Send response
     127    // Send response.
    129128    $r = new WP_Ajax_Response();
    130129    $r->add( $response );
     
    143142 * @param string $option    Screen option name.
    144143 * @param string $new_value Screen option form value.
    145  *
    146144 * @return string Option value. False to abandon update.
    147145 */
     
    150148        return $value;
    151149
    152     // Per page
     150    // Per page.
    153151    $new_value = (int) $new_value;
    154152    if ( $new_value < 1 || $new_value > 999 )
     
    165163 * @param array     $hidden Array of items to hide.
    166164 * @param WP_Screen $screen Screen identifier.
    167  *
    168165 * @return array Hidden Meta Boxes.
    169166 */
     
    172169        return $hidden;
    173170
    174     // Hide the primary link meta box by default
     171    // Hide the primary link meta box by default.
    175172    $hidden  = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) );
    176173
     
    205202    $bp = buddypress();
    206203
    207     // Decide whether to load the dev version of the CSS and JavaScript
     204    // Decide whether to load the dev version of the CSS and JavaScript.
    208205    $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : 'min.';
    209206
     
    219216    do_action( 'bp_activity_admin_load', $doaction );
    220217
    221     // Edit screen
     218    // Edit screen.
    222219    if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) {
    223         // columns screen option
     220        // Columns screen option.
    224221        add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) );
    225222
     
    243240        ) );
    244241
    245         // Help panel - sidebar links
     242        // Help panel - sidebar links.
    246243        get_current_screen()->set_help_sidebar(
    247244            '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    264261        do_action( 'bp_activity_admin_meta_boxes' );
    265262
    266         // Enqueue JavaScript files
     263        // Enqueue JavaScript files.
    267264        wp_enqueue_script( 'postbox' );
    268265        wp_enqueue_script( 'dashboard' );
    269266        wp_enqueue_script( 'comment' );
    270267
    271     // Index screen
     268    // Index screen.
    272269    } else {
    273         // Create the Activity screen list table
     270        // Create the Activity screen list table.
    274271        $bp_activity_list_table = new BP_Activity_List_Table();
    275272
    276         // per_page screen option
     273        // The per_page screen option.
    277274        add_screen_option( 'per_page', array( 'label' => _x( 'Activity', 'Activity items per page (screen options)', 'buddypress' )) );
    278275
    279         // Help panel - overview text
     276        // Help panel - overview text.
    280277        get_current_screen()->add_help_tab( array(
    281278            'id'      => 'bp-activity-overview',
     
    286283        ) );
    287284
    288         // Help panel - moderation text
     285        // Help panel - moderation text.
    289286        get_current_screen()->add_help_tab( array(
    290287            'id'        => 'bp-activity-moderating',
     
    295292        ) );
    296293
    297         // Help panel - sidebar links
     294        // Help panel - sidebar links.
    298295        get_current_screen()->set_help_sidebar(
    299296            '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    302299    }
    303300
    304     // Enqueue CSS and JavaScript
     301    // Enqueue CSS and JavaScript.
    305302    wp_enqueue_script( 'bp_activity_admin_js', $bp->plugin_url . "bp-activity/admin/js/admin.{$min}js",   array( 'jquery', 'wp-ajax-response' ), bp_get_version(), true );
    306303    wp_localize_script( 'bp_activity_admin_js', 'bp_activity_admin_vars', array(
     
    321318    do_action( 'bp_activity_admin_enqueue_scripts' );
    322319
    323     // Handle spam/un-spam/delete of activities
     320    // Handle spam/un-spam/delete of activities.
    324321    if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {
    325322
    326         // Build redirection URL
     323        // Build redirection URL.
    327324        $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() );
    328325        $redirect_to = add_query_arg( 'paged', $bp_activity_list_table->get_pagenum(), $redirect_to );
    329326
    330         // Get activity IDs
     327        // Get activity IDs.
    331328        $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] );
    332329
     
    342339        // Is this a bulk request?
    343340        if ( 'bulk_' == substr( $doaction, 0, 5 ) && ! empty( $_REQUEST['aid'] ) ) {
    344             // Check this is a valid form submission
     341            // Check this is a valid form submission.
    345342            check_admin_referer( 'bulk-activities' );
    346343
    347             // Trim 'bulk_' off the action name to avoid duplicating a ton of code
     344            // Trim 'bulk_' off the action name to avoid duplicating a ton of code.
    348345            $doaction = substr( $doaction, 5 );
    349346
     
    351348        } elseif ( !empty( $_REQUEST['aid'] ) ) {
    352349
    353             // Check this is a valid form submission
     350            // Check this is a valid form submission.
    354351            check_admin_referer( 'spam-activity_' . $activity_ids[0] );
    355352        }
    356353
    357         // Initialise counters for how many of each type of item we perform an action on
     354        // Initialise counters for how many of each type of item we perform an action on.
    358355        $deleted = $spammed = $unspammed = 0;
    359356
    360         // Store any errors that occurs when updating the database items
     357        // Store any errors that occurs when updating the database items.
    361358        $errors = array();
    362359
     
    365362            // @todo: Check the permissions on each
    366363            //if ( ! current_user_can( 'bp_edit_activity', $activity_id ) )
    367             //  continue;
    368 
    369             // Get the activity from the database
     364            // continue;
     365
     366            // Get the activity from the database.
    370367            $activity = new BP_Activity_Activity( $activity_id );
    371368            if ( empty( $activity->component ) ) {
     
    395392                    $result = $activity->save();
    396393
    397                     // Check for any error during activity save
     394                    // Check for any error during activity save.
    398395                    if ( ! $result )
    399396                        $errors[] = $activity->id;
     
    406403                    $result = $activity->save();
    407404
    408                     // Check for any error during activity save
     405                    // Check for any error during activity save.
    409406                    if ( ! $result )
    410407                        $errors[] = $activity->id;
     
    417414            }
    418415
    419             // Release memory
     416            // Release memory.
    420417            unset( $activity );
    421418        }
     
    444441            $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
    445442
    446         // If an error occurred, pass back the activity ID that failed
     443        // If an error occurred, pass back the activity ID that failed.
    447444        if ( ! empty( $errors ) )
    448445            $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to );
     
    459456
    460457
    461     // Save the edit
     458    // Save the edit.
    462459    } elseif ( $doaction && 'save' == $doaction ) {
    463         // Build redirection URL
     460        // Build redirection URL.
    464461        $redirect_to = remove_query_arg( array( 'action', 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
    465462
    466         // Get activity ID
     463        // Get activity ID.
    467464        $activity_id = (int) $_REQUEST['aid'];
    468465
    469         // Check this is a valid form submission
     466        // Check this is a valid form submission.
    470467        check_admin_referer( 'edit-activity_' . $activity_id );
    471468
    472         // Get the activity from the database
     469        // Get the activity from the database.
    473470        $activity = new BP_Activity_Activity( $activity_id );
    474471
    475         // If the activity doesn't exist, just redirect back to the index
     472        // If the activity doesn't exist, just redirect back to the index.
    476473        if ( empty( $activity->component ) ) {
    477474            wp_redirect( $redirect_to );
     
    479476        }
    480477
    481         // Check the form for the updated properties
    482 
    483         // Store any error that occurs when updating the database item
     478        // Check the form for the updated properties.
     479        // Store any error that occurs when updating the database item.
    484480        $error = 0;
    485481
    486         // Activity spam status
     482        // Activity spam status.
    487483        $prev_spam_status = $new_spam_status = false;
    488484        if ( ! empty( $_POST['activity_status'] ) ) {
     
    491487        }
    492488
    493         // Activity action
     489        // Activity action.
    494490        if ( isset( $_POST['bp-activities-action'] ) )
    495491            $activity->action = $_POST['bp-activities-action'];
    496492
    497         // Activity content
     493        // Activity content.
    498494        if ( isset( $_POST['bp-activities-content'] ) )
    499495            $activity->content = $_POST['bp-activities-content'];
    500496
    501         // Activity primary link
     497        // Activity primary link.
    502498        if ( ! empty( $_POST['bp-activities-link'] ) )
    503499            $activity->primary_link = $_POST['bp-activities-link'];
    504500
    505         // Activity user ID
     501        // Activity user ID.
    506502        if ( ! empty( $_POST['bp-activities-userid'] ) )
    507503            $activity->user_id = (int) $_POST['bp-activities-userid'];
    508504
    509         // Activity item primary ID
     505        // Activity item primary ID.
    510506        if ( isset( $_POST['bp-activities-primaryid'] ) )
    511507            $activity->item_id = (int) $_POST['bp-activities-primaryid'];
    512508
    513         // Activity item secondary ID
     509        // Activity item secondary ID.
    514510        if ( isset( $_POST['bp-activities-secondaryid'] ) )
    515511            $activity->secondary_item_id = (int) $_POST['bp-activities-secondaryid'];
    516512
    517         // Activity type
     513        // Activity type.
    518514        if ( ! empty( $_POST['bp-activities-type'] ) ) {
    519515            $actions = bp_activity_admin_get_activity_actions();
    520516
    521             // Check that the new type is a registered activity type
     517            // Check that the new type is a registered activity type.
    522518            if ( in_array( $_POST['bp-activities-type'], $actions ) ) {
    523519                $activity->type = $_POST['bp-activities-type'];
     
    525521        }
    526522
    527         // Activity timestamp
     523        // Activity timestamp.
    528524        if ( ! empty( $_POST['aa'] ) && ! empty( $_POST['mm'] ) && ! empty( $_POST['jj'] ) && ! empty( $_POST['hh'] ) && ! empty( $_POST['mn'] ) && ! empty( $_POST['ss'] ) ) {
    529525            $aa = $_POST['aa'];
     
    541537            $ss = ( $ss > 59 ) ? $ss -60 : $ss;
    542538
    543             // Reconstruct the date into a timestamp
     539            // Reconstruct the date into a timestamp.
    544540            $gmt_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
    545541
     
    555551        }
    556552
    557         // Save
     553        // Save.
    558554        $result = $activity->save();
    559555
    560         // Clear the activity stream first page cache, in case this activity's timestamp was changed
     556        // Clear the activity stream first page cache, in case this activity's timestamp was changed.
    561557        wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
    562558
    563         // Check for any error during activity save
     559        // Check for any error during activity save.
    564560        if ( false === $result )
    565561            $error = $activity->id;
     
    574570        do_action_ref_array( 'bp_activity_admin_edit_after', array( &$activity, $error ) );
    575571
    576         // If an error occurred, pass back the activity ID that failed
     572        // If an error occurred, pass back the activity ID that failed.
    577573        if ( $error )
    578574            $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
     
    604600 */
    605601function bp_activity_admin() {
    606     // Decide whether to load the index or edit screen
     602    // Decide whether to load the index or edit screen.
    607603    $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
    608604
    609     // Display the single activity edit screen
     605    // Display the single activity edit screen.
    610606    if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) )
    611607        bp_activity_admin_edit();
    612608
    613     // Otherwise, display the Activity index screen
     609    // Otherwise, display the Activity index screen.
    614610    else
    615611        bp_activity_admin_index();
     
    628624        die( '-1' );
    629625
    630     // Get the activity from the database
     626    // Get the activity from the database.
    631627    $activity = bp_activity_get( array(
    632628        'in'               => ! empty( $_REQUEST['aid'] ) ? (int) $_REQUEST['aid'] : 0,
     
    640636        $activity = $activity['activities'][0];
    641637
    642         // Workaround to use WP's touch_time() without duplicating that function
     638        // Workaround to use WP's touch_time() without duplicating that function.
    643639        $GLOBALS['comment'] = new stdClass;
    644640        $GLOBALS['comment']->comment_date = $activity->date_recorded;
     
    647643    }
    648644
    649     // Construct URL for form
     645    // Construct URL for form.
    650646    $form_url = remove_query_arg( array( 'action', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
    651647    $form_url = add_query_arg( 'action', 'save', $form_url );
     
    741737                <div class="misc-pub-section curtime misc-pub-section-last">
    742738                    <?php
    743                     // translators: Publish box date format, see http://php.net/date
     739                    // Translators: Publish box date format, see http://php.net/date.
    744740                    $datef = __( 'M j, Y @ G:i', 'buddypress' );
    745741                    $date  = date_i18n( $datef, strtotime( $item->date_recorded ) );
     
    808804 * @since 2.0.0
    809805 *
    810  * @return array
     806 * @return array $actions
    811807 */
    812808function bp_activity_admin_get_activity_actions() {
     
    822818    }
    823819
    824     // This was a mis-named activity type from before BP 1.6
     820    // This was a mis-named activity type from before BP 1.6.
    825821    unset( $actions['friends_register_activity_action'] );
    826822
    827     // Sort array by the human-readable value
     823    // Sort array by the human-readable value.
    828824    natsort( $actions );
    829825
     
    852848    }
    853849
    854     // This was a mis-named activity type from before BP 1.6
     850    // This was a mis-named activity type from before BP 1.6.
    855851    unset( $actions['friends_register_activity_action'] );
    856852
    857     // Sort array by the human-readable value
     853    // Sort array by the human-readable value.
    858854    natsort( $actions );
    859855
    860     // If the activity type is not registered properly (eg, a plugin has
    861     // not called bp_activity_set_action()), add the raw type to the end
    862     // of the list
     856    /*
     857     * If the activity type is not registered properly (eg, a plugin has
     858     * not called bp_activity_set_action()), add the raw type to the end
     859     * of the list.
     860     */
    863861    if ( ! isset( $actions[ $selected ] ) ) {
    864862        _doing_it_wrong( __FUNCTION__, sprintf( __( 'This activity item has a type (%s) that is not registered using bp_activity_set_action(), so no label is available.', 'buddypress' ), $selected ), '2.0.0' );
     
    912910    $messages = array();
    913911
    914     // If the user has just made a change to an activity item, build status messages
     912    // If the user has just made a change to an activity item, build status messages.
    915913    if ( ! empty( $_REQUEST['deleted'] ) || ! empty( $_REQUEST['spammed'] ) || ! empty( $_REQUEST['unspammed'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) ) {
    916914        $deleted   = ! empty( $_REQUEST['deleted']   ) ? (int) $_REQUEST['deleted']   : 0;
     
    922920        $errors = array_map( 'absint', explode( ',', $errors ) );
    923921
    924         // Make sure we don't get any empty values in $errors
     922        // Make sure we don't get any empty values in $errors.
    925923        for ( $i = 0, $errors_count = count( $errors ); $i < $errors_count; $i++ ) {
    926924            if ( 0 === $errors[$i] ) {
     
    929927        }
    930928
    931         // Reindex array
     929        // Reindex array.
    932930        $errors = array_values( $errors );
    933931
     
    943941                $error_msg .= '<ul class="activity-errors">';
    944942
    945                 // Display each error as a list item
     943                // Display each error as a list item.
    946944                foreach ( $errors as $error ) {
    947                     // Translators: This is a bulleted list of item IDs
     945                    // Translators: This is a bulleted list of item IDs.
    948946                    $error_msg .= '<li>' . sprintf( __( '#%s', 'buddypress' ), number_format_i18n( $error ) ) . '</li>';
    949947                }
     
    964962    }
    965963
    966     // Prepare the activity items for display
     964    // Prepare the activity items for display.
    967965    $bp_activity_list_table->prepare_items();
    968966
     
    989987        </h2>
    990988
    991         <?php // If the user has just made a change to an activity item, display the status messages ?>
     989        <?php // If the user has just made a change to an activity item, display the status messages. ?>
    992990        <?php if ( !empty( $messages ) ) : ?>
    993991            <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div>
    994992        <?php endif; ?>
    995993
    996         <?php // Display each activity on its own row ?>
     994        <?php // Display each activity on its own row. ?>
    997995        <?php $bp_activity_list_table->views(); ?>
    998996
     
    10031001        </form>
    10041002
    1005         <?php // This markup is used for the reply form ?>
     1003        <?php // This markup is used for the reply form. ?>
    10061004        <table style="display: none;">
    10071005            <tr id="bp-activities-container" style="display: none;">
     
    10421040     * What type of view is being displayed?
    10431041     *
    1044      * e.g. "all", "pending", "approved", "spam"...
    1045      *
    1046      * @since 1.6.0
    1047      * @var string
     1042     * E.g. "all", "pending", "approved", "spam"...
     1043     *
     1044     * @since 1.6.0
     1045     * @var string $view
    10481046     */
    10491047    public $view = 'all';
     
    10531051     *
    10541052     * @since 1.6.0
    1055      * @var int
     1053     * @var int $spam_count
    10561054     */
    10571055    public $spam_count = 0;
     
    10611059     *
    10621060     * @since 1.6.0
    1063      * @var array
     1061     * @var array $activity_user_id
    10641062     */
    10651063    protected $activity_user_id = array();
     
    10681066     * If users can comment on blog & forum activity items.
    10691067     *
     1068     * @link https://buddypress.trac.wordpress.org/ticket/6277
     1069     *
    10701070     * @since 2.2.2
    1071      *
    1072      * @link https://buddypress.trac.wordpress.org/ticket/6277
    1073      *
    1074      * @var bool
     1071     * @var bool $disable_blogforum_comments
    10751072     */
    10761073    public $disable_blogforum_comments = false;
     
    10831080    public function __construct() {
    10841081
    1085         // See if activity commenting is enabled for blog / forum activity items
     1082        // See if activity commenting is enabled for blog / forum activity items.
    10861083        $this->disable_blogforum_comments = bp_disable_blogforum_comments();
    10871084
     
    11021099    function prepare_items() {
    11031100
    1104         // Option defaults
     1101        // Option defaults.
    11051102        $filter           = array();
    11061103        $include_id       = false;
     
    11091106        $spam             = 'ham_only';
    11101107
    1111         // Set current page
     1108        // Set current page.
    11121109        $page = $this->get_pagenum();
    11131110
    1114         // Set per page from the screen options
     1111        // Set per page from the screen options.
    11151112        $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
    11161113
    1117         // Check if we're on the "Spam" view
     1114        // Check if we're on the "Spam" view.
    11181115        if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) {
    11191116            $spam       = 'spam_only';
     
    11211118        }
    11221119
    1123         // Sort order
     1120        // Sort order.
    11241121        if ( !empty( $_REQUEST['order'] ) && 'desc' != $_REQUEST['order'] )
    11251122            $sort = 'ASC';
    11261123
    1127         // Order by
     1124        // Order by.
    11281125        /*if ( !empty( $_REQUEST['orderby'] ) ) {
    11291126        }*/
    11301127
    1131         // Filter
     1128        // Filter.
    11321129        if ( !empty( $_REQUEST['activity_type'] ) )
    11331130            $filter = array( 'action' => $_REQUEST['activity_type'] );
     
    11411138            $include_id = (int) $_REQUEST['aid'];
    11421139
    1143         // Get the spam total (ignoring any search query or filter)
     1140        // Get the spam total (ignoring any search query or filter).
    11441141        $spams = bp_activity_get( array(
    11451142            'display_comments' => 'stream',
     
    11511148        unset( $spams );
    11521149
    1153         // Get the activities from the database
     1150        // Get the activities from the database.
    11541151        $activities = bp_activity_get( array(
    11551152            'display_comments' => 'stream',
     
    11601157            'search_terms'     => $search_terms,
    11611158            'show_hidden'      => true,
    1162             //'sort'             => $sort,
     1159            // 'sort'             => $sort,
    11631160            'spam'             => $spam,
    11641161            'count_total'      => 'count_query',
     
    11701167            $activities['total']      = count( $activities['activities'] );
    11711168
    1172             // Sort the array by the activity object's date_recorded value
     1169            // Sort the array by the activity object's date_recorded value.
    11731170            usort( $activities['activities'], create_function( '$a, $b', 'return $a->date_recorded > $b->date_recorded;' ) );
    11741171        }
    11751172
    1176         // bp_activity_get returns an array of objects; cast these to arrays for WP_List_Table.
     1173        // The bp_activity_get function returns an array of objects; cast these to arrays for WP_List_Table.
    11771174        $new_activities = array();
    11781175        foreach ( $activities['activities'] as $activity_item ) {
    11791176            $new_activities[] = (array) $activity_item;
    11801177
    1181             // Build an array of activity-to-user ID mappings for better efficiency in the In Response To column
     1178            // Build an array of activity-to-user ID mappings for better efficiency in the In Response To column.
    11821179            $this->activity_user_id[$activity_item->id] = $activity_item->user_id;
    11831180        }
    11841181
    1185         // Set raw data to display
     1182        // Set raw data to display.
    11861183        $this->items       = $new_activities;
    11871184
    1188         // Store information needed for handling table pagination
     1185        // Store information needed for handling table pagination.
    11891186        $this->set_pagination_args( array(
    11901187            'per_page'    => $per_page,
     
    12391236     *
    12401237     * @since 1.6.0
    1241     */
     1238     */
    12421239    function display() {
    12431240        $this->display_tablenav( 'top' ); ?>
     
    13981395    function extra_tablenav( $which ) {
    13991396
    1400         // Bail on bottom table nav
     1397        // Bail on bottom table nav.
    14011398        if ( 'bottom' === $which ) {
    14021399            return;
     
    14061403        $selected = ( ! empty( $_REQUEST['activity_type'] ) ) ? $_REQUEST['activity_type'] : '';
    14071404
    1408         // Get the actions
     1405        // Get the actions.
    14091406        $activity_actions = bp_activity_get_actions(); ?>
    14101407
     
    14221419                            <?php
    14231420
    1424                             // Skip the incorrectly named pre-1.6 action
     1421                            // Skip the incorrectly named pre-1.6 action.
    14251422                            if ( 'friends_register_activity_action' !== $action_key ) : ?>
    14261423
     
    14521449     * @since 2.3.4 Visibility set to public for compatibility with WP < 4.0.0.
    14531450     *
    1454      * @param array $actions The list of actions
    1455      * @param bool $always_visible Whether the actions should be always visible
     1451     * @param array $actions The list of actions.
     1452     * @param bool  $always_visible Whether the actions should be always visible.
    14561453     * @return string
    14571454     */
     
    15311528     */
    15321529    function column_comment( $item ) {
    1533         // Determine what type of item (row) we're dealing with
     1530        // Determine what type of item (row) we're dealing with.
    15341531        if ( $item['is_spam'] )
    15351532            $item_status = 'spam';
     
    15371534            $item_status = 'all';
    15381535
    1539         // Preorder items: Reply | Edit | Spam | Delete Permanently
     1536        // Preorder items: Reply | Edit | Spam | Delete Permanently.
    15401537        $actions = array(
    15411538            'reply'  => '',
     
    15451542        );
    15461543
    1547         // Build actions URLs
     1544        // Build actions URLs.
    15481545        $base_url   = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
    15491546        $spam_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'spam-activity_' . $item['id'] ) );
     
    15541551        $spam_url   = $base_url . "&amp;action=spam&amp;$spam_nonce";
    15551552
    1556         // Rollover actions
    1557 
     1553        // Rollover actions.
    15581554        // Reply - JavaScript only; implemented by AJAX.
    15591555        if ( 'spam' != $item_status ) {
     
    15641560            }
    15651561
    1566             // Edit
     1562            // Edit.
    15671563            $actions['edit'] = sprintf( '<a href="%s">%s</a>', $edit_url, __( 'Edit', 'buddypress' ) );
    15681564        }
    15691565
    1570         // Spam/unspam
     1566        // Spam/unspam.
    15711567        if ( 'spam' == $item_status )
    15721568            $actions['unspam'] = sprintf( '<a href="%s">%s</a>', $ham_url, __( 'Not Spam', 'buddypress' ) );
     
    15741570            $actions['spam'] = sprintf( '<a href="%s">%s</a>', $spam_url, __( 'Spam', 'buddypress' ) );
    15751571
    1576         // Delete
     1572        // Delete.
    15771573        $actions['delete'] = sprintf( '<a href="%s" onclick="%s">%s</a>', $delete_url, "javascript:return confirm('" . esc_js( __( 'Are you sure?', 'buddypress' ) ) . "'); ", __( 'Delete Permanently', 'buddypress' ) );
    15781574
    1579         // Start timestamp
     1575        // Start timestamp.
    15801576        echo '<div class="submitted-on">';
    15811577
     
    15981594        );
    15991595
    1600         // End timestamp
     1596        // End timestamp.
    16011597        echo '</div>';
    16021598
    1603         // Get activity content - if not set, use the action
     1599        // Get activity content - if not set, use the action.
    16041600        if ( ! empty( $item['content'] ) ) {
    16051601
     
    16241620
    16251621        /**
    1626          * Filter here to add extra output to the activity content into the Administration
     1622         * Filter here to add extra output to the activity content into the Administration.
    16271623         *
    16281624         * @since  2.4.0
    16291625         *
    1630          * @param  string $content The activity content
    1631          * @param  array  $item    The activity object converted into an array
     1626         * @param  string $content The activity content.
     1627         * @param  array  $item    The activity object converted into an array.
    16321628         */
    16331629        echo apply_filters( 'bp_activity_admin_comment_content', $content, $item ) . ' ' . $this->row_actions( $actions );
     
    16441640     */
    16451641    function column_response( $item ) {
     1642
    16461643        // Is $item is a root activity?
    16471644        ?>
     
    16701667            $root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&amp;aid=' . $item['id'] );
    16711668
    1672             // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
     1669            // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble.
    16731670            if ( $comment_count ) {
    16741671                $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) );
     
    16761673            }
    16771674
    1678         // For non-root activities, display a link to the replied-to activity's author's profile
     1675        // For non-root activities, display a link to the replied-to activity's author's profile.
    16791676        } else {
    16801677            echo '<strong>' . get_avatar( $this->get_activity_user_id( $item['item_id'] ), '32' ) . ' ' . bp_core_get_userlink( $this->get_activity_user_id( $item['item_id'] ) ) . '</strong><br />';
     
    16951692     * @param array  $item        Information about the current row.
    16961693     * @param string $column_name The column name.
    1697      *
    16981694     * @return string
    16991695     */
     
    17211717     *
    17221718     * @param int $activity_id Activity ID to retrieve User ID for.
    1723      *
    17241719     * @return int User ID of the activity item in question.
    17251720     */
     
    17291724            return $this->activity_user_id[$activity_id];
    17301725
    1731         /**
     1726        /*
    17321727         * We don't have a mapping. This means the $activity_id is not on the current
    17331728         * page of results, so fetch its details from the database.
     
    17361731            $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'show_hidden' => true, 'spam' => 'all', ) );
    17371732
    1738             /**
     1733            /*
    17391734             * If, somehow, the referenced activity has been deleted, leaving its associated
    17401735             * activities as orphans, use the logged in user's ID to avoid errors.
     
    17431738                return bp_loggedin_user_id();
    17441739
    1745             // Store the new activity/user ID mapping for any later re-use
     1740            // Store the new activity/user ID mapping for any later re-use.
    17461741            $this->activity_user_id[ $activity['activities'][0]->id ] = $activity['activities'][0]->user_id;
    17471742
    1748             // Return the user ID
     1743            // Return the user ID.
    17491744            return $activity['activities'][0]->user_id;
    17501745        }
     
    17621757     *
    17631758     * @param array $item An array version of the BP_Activity_Activity object.
    1764      *
    1765      * @return bool
     1759     * @return bool $can_comment
    17661760     */
    17671761    protected function can_comment( $item  ) {
     
    17781772            }
    17791773
    1780         // activity comments supported
     1774        // Activity comments supported.
    17811775        } else {
    1782             // activity comment
     1776            // Activity comment.
    17831777            if ( 'activity_comment' == $item['type'] ) {
    1784                 // blogs
     1778                // Blogs.
    17851779                if ( bp_is_active( 'blogs' ) ) {
    1786                     // grab the parent activity entry
     1780                    // Grab the parent activity entry.
    17871781                    $parent_activity = new BP_Activity_Activity( $item['item_id'] );
    17881782
    1789                     // fetch blog post comment depth and if the blog post's comments are open
     1783                    // Fetch blog post comment depth and if the blog post's comments are open.
    17901784                    bp_blogs_setup_activity_loop_globals( $parent_activity );
    17911785
    1792                     // check if the activity item can be replied to
     1786                    // Check if the activity item can be replied to.
    17931787                    if ( false === bp_blogs_can_comment_reply( true, $item ) ) {
    17941788                        $can_comment = false;
     
    17961790                }
    17971791
    1798             // blog post
     1792            // Blog post.
    17991793            } elseif ( 'new_blog_post' == $item['type'] ) {
    18001794                if ( bp_is_active( 'blogs' ) ) {
     
    18271821     *
    18281822     * @param array $tree Source array.
    1829      *
    18301823     * @return array Flattened array.
    18311824     */
  • trunk/src/bp-activity/bp-activity-akismet.php

    r10248 r10253  
    33 * Akismet support for BuddyPress' Activity Stream.
    44 *
    5  * @since 1.6.0
    65 * @package BuddyPress
    76 * @subpackage ActivityAkismet
     7 * @since 1.6.0
    88 */
    99
    10 // Exit if accessed directly
     10// Exit if accessed directly.
    1111defined( 'ABSPATH' ) || exit;
    1212
     
    1818 */
    1919class BP_Akismet {
     20
    2021    /**
    2122     * The activity last marked as spam.
    2223     *
     24     * @since 1.6.0
     25     *
    2326     * @var BP_Activity_Activity
    24      * @since 1.6.0
    2527     */
    2628    protected $last_activity = null;
     
    4143     */
    4244    protected function setup_actions() {
    43         // Add nonces to activity stream lists
     45        // Add nonces to activity stream lists.
    4446        add_action( 'bp_after_activity_post_form', array( $this, 'add_activity_stream_nonce' ) );
    4547        add_action( 'bp_activity_entry_comments',  array( $this, 'add_activity_stream_nonce' ) );
    4648
    47         // Add a "mark as spam" button to individual activity items
     49        // Add a "mark as spam" button to individual activity items.
    4850        add_action( 'bp_activity_entry_meta',      array( $this, 'add_activity_spam_button' ) );
    4951        add_action( 'bp_activity_comment_options', array( $this, 'add_activity_comment_spam_button' ) );
    5052
    51         // Check activity for spam
     53        // Check activity for spam.
    5254        add_action( 'bp_activity_before_save',     array( $this, 'check_activity' ), 4, 1 );
    5355
    54         // Tidy up member's latest (activity) update
     56        // Tidy up member's latest (activity) update.
    5557        add_action( 'bp_activity_posted_update',   array( $this, 'check_member_activity_update' ), 1, 3 );
    5658
    57         // Hooks to extend Activity core spam/ham functions for Akismet
     59        // Hooks to extend Activity core spam/ham functions for Akismet.
    5860        add_action( 'bp_activity_mark_as_spam',    array( $this, 'mark_as_spam' ), 10, 2 );
    5961        add_action( 'bp_activity_mark_as_ham',     array( $this, 'mark_as_ham' ),  10, 2 );
    6062
    61         // Hook into the Activity wp-admin screen
     63        // Hook into the Activity wp-admin screen.
    6264        add_action( 'bp_activity_admin_comment_row_actions', array( $this, 'comment_row_action' ), 10, 2 );
    6365        add_action( 'bp_activity_admin_load',                array( $this, 'add_history_metabox' ) );
     
    7476     * @param array $actions  The hover links.
    7577     * @param array $activity The activity for the current row being processed.
    76      *
    7778     * @return array The hover links.
    7879     */
     
    8384
    8485        if ( !$user_result || $user_result == $akismet_result ) {
    85             // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
     86            // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same.
    8687            if ( 'true' == $akismet_result && $activity['is_spam'] )
    8788                $desc = __( 'Flagged as spam by Akismet', 'buddypress' );
     
    99100        }
    100101
    101         // add a History item to the hover links, just after Edit
     102        // Add a History item to the hover links, just after Edit.
    102103        if ( $akismet_result ) {
    103104            $b = array();
     
    139140        $value   = '_bp_as_nonce_' . bp_loggedin_user_id();
    140141
    141         // If we're in the activity stream loop, we can use the current item's ID to make the nonce unique
     142        // If we're in the activity stream loop, we can use the current item's ID to make the nonce unique.
    142143        if ( 'bp_activity_entry_comments' == current_filter() ) {
    143144            $form_id .= '_' . bp_get_activity_id();
     
    245246     * @static
    246247     *
    247      * @return array List of activity types.
     248     * @return array $value List of activity types.
    248249     */
    249250    public static function get_activity_types() {
     
    270271     */
    271272    public function mark_as_spam( $activity, $source ) {
    272         // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
     273        // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update().
    273274        $this->last_activity = $activity;
    274275
     
    325326     *
    326327     * @param BP_Activity_Activity $activity Activity item data.
    327      *
    328      * @return array
     328     * @return array $activity_data
    329329     */
    330330    public static function build_akismet_data_package( $activity ) {
     
    383383            return;
    384384
    385         // Make sure last_activity is clear to avoid any confusion
     385        // Make sure last_activity is clear to avoid any confusion.
    386386        $this->last_activity = null;
    387387
    388         // Build data package for Akismet
     388        // Build data package for Akismet.
    389389        $activity_data = BP_Akismet::build_akismet_data_package( $activity );
    390390
    391         // Check with Akismet to see if this is spam
     391        // Check with Akismet to see if this is spam.
    392392        $activity_data = $this->send_akismet_request( $activity_data, 'check', 'spam' );
    393393
    394         // Record this item
     394        // Record this item.
    395395        $this->last_activity = $activity;
    396396
    397         // Store a copy of the data that was submitted to Akismet
     397        // Store a copy of the data that was submitted to Akismet.
    398398        $this->last_activity->akismet_submission = $activity_data;
    399399
    400         // Spam
     400        // Spam.
    401401        if ( 'true' == $activity_data['bp_as_result'] ) {
    402402            /**
     
    411411            do_action_ref_array( 'bp_activity_akismet_spam_caught', array( &$activity, $activity_data ) );
    412412
    413             // Mark as spam
     413            // Mark as spam.
    414414            bp_activity_mark_as_spam( $activity, 'by_akismet' );
    415415        }
    416416
    417         // Update activity meta after a spam check
     417        // Update activity meta after a spam check.
    418418        add_action( 'bp_activity_after_save', array( $this, 'update_activity_akismet_meta' ), 1, 1 );
    419419    }
     
    461461     */
    462462    public function update_activity_akismet_meta( $activity ) {
    463         // Check we're dealing with what was last updated by Akismet
     463        // Check we're dealing with what was last updated by Akismet.
    464464        if ( empty( $this->last_activity ) || !empty( $this->last_activity ) && $activity->id != $this->last_activity->id )
    465465            return;
     
    469469            return;
    470470
    471         // Spam
     471        // Spam.
    472472        if ( 'true' == $this->last_activity->akismet_submission['bp_as_result'] ) {
    473473            bp_activity_update_meta( $activity->id, '_bp_akismet_result', 'true' );
    474474            $this->update_activity_history( $activity->id, __( 'Akismet caught this item as spam', 'buddypress' ), 'check-spam' );
    475475
    476         // Not spam
     476        // Not spam.
    477477        } elseif ( 'false' == $this->last_activity->akismet_submission['bp_as_result'] ) {
    478478            bp_activity_update_meta( $activity->id, '_bp_akismet_result', 'false' );
     
    485485        }
    486486
    487         // Record the original data which was submitted to Akismet for checking
     487        // Record the original data which was submitted to Akismet for checking.
    488488        bp_activity_update_meta( $activity->id, '_bp_akismet_submission', $this->last_activity->akismet_submission );
    489489    }
     
    499499     * @param string $check         "check" or "submit".
    500500     * @param string $spam          "spam" or "ham".
    501      *
    502501     * @return array $activity_data Activity data, with Akismet data added.
    503502     */
     
    515514            $activity_data['is_test'] = 'true';
    516515
    517         // Loop through _POST args and rekey strings
     516        // Loop through _POST args and rekey strings.
    518517        foreach ( $_POST as $key => $value )
    519518            if ( is_string( $value ) && 'cookie' != $key )
    520519                $activity_data['POST_' . $key] = $value;
    521520
    522         // Keys to ignore
     521        // Keys to ignore.
    523522        $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
    524523
    525         // Loop through _SERVER args and remove whitelisted keys
     524        // Loop through _SERVER args and remove whitelisted keys.
    526525        foreach ( $_SERVER as $key => $value ) {
    527526
    528             // Key should not be ignored
     527            // Key should not be ignored.
    529528            if ( !in_array( $key, $ignore ) && is_string( $value ) ) {
    530529                $activity_data[$key] = $value;
    531530
    532             // Key should be ignored
     531            // Key should be ignored.
    533532            } else {
    534533                $activity_data[$key] = '';
     
    544543            $path = 'submit-' . $spam;
    545544
    546         // Send to Akismet
     545        // Send to Akismet.
    547546        add_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
    548547        $response = Akismet::http_post( $query_string, $path );
    549548        remove_filter( 'akismet_ua', array( $this, 'buddypress_ua' ) );
    550549
    551         // Get the response
     550        // Get the response.
    552551        if ( ! empty( $response[1] ) && ! is_wp_error( $response[1] ) )
    553552            $activity_data['bp_as_result'] = $response[1];
     
    555554            $activity_data['bp_as_result'] = false;
    556555
    557         // Perform a daily tidy up
     556        // Perform a daily tidy up.
    558557        if ( ! wp_next_scheduled( 'bp_activity_akismet_delete_old_metadata' ) )
    559558            wp_schedule_event( time(), 'daily', 'bp_activity_akismet_delete_old_metadata' );
     
    568567     *
    569568     * @param string $user_agent User agent string, as generated by Akismet.
    570      *
    571569     * @return string $user_agent Modified user agent string.
    572570     */
     
    584582     */
    585583    function add_history_metabox( $screen_action ) {
    586         // Only proceed if we're on the edit screen
     584        // Only proceed if we're on the edit screen.
    587585        if ( 'edit' != $screen_action )
    588586            return;
    589587
    590         // Display meta box with a low priority (low position on screen by default)
     588        // Display meta box with a low priority (low position on screen by default).
    591589        add_meta_box( 'bp_activity_history',  __( 'Activity History', 'buddypress' ), array( $this, 'history_metabox' ), get_current_screen()->id, 'normal', 'low' );
    592590    }
     
    630628        );
    631629
    632         // Save the history data
     630        // Save the history data.
    633631        bp_activity_update_meta( $activity_id, '_bp_akismet_history', $event );
    634632    }
     
    640638     *
    641639     * @param int $activity_id Activity item ID.
    642      *
    643640     * @return array The activity item's Akismet history.
    644641     */
     
    648645            $history = array();
    649646
    650         // Sort it by the time recorded
     647        // Sort it by the time recorded.
    651648        usort( $history, 'akismet_cmp_time' );
    652649
     
    679676    $interval = apply_filters( 'bp_activity_akismet_delete_meta_interval', 15 );
    680677
    681     // Enforce a minimum of 1 day
     678    // Enforce a minimum of 1 day.
    682679    $interval = max( 1, absint( $interval ) );
    683680
  • trunk/src/bp-activity/bp-activity-cache.php

    r10077 r10253  
    88 */
    99
    10 // Exit if accessed directly
     10// Exit if accessed directly.
    1111defined( 'ABSPATH' ) || exit;
    1212
     
    1919 *
    2020 * @param int|string|array|bool $activity_ids Accepts a single activity ID, or a comma-
    21  *                                            separated list or array of activity ids
     21 *                                            separated list or array of activity ids.
    2222 */
    2323function bp_activity_update_meta_cache( $activity_ids = false ) {
     
    4141 * @since 2.0.0
    4242 *
    43  * @param BP_Activity_Activity $activity
     43 * @param BP_Activity_Activity $activity Activity object.
    4444 */
    4545function bp_activity_clear_cache_for_activity( $activity ) {
  • trunk/src/bp-activity/bp-activity-classes.php

    r10077 r10253  
    11<?php
    22/**
    3  * BuddyPress Activity Classes
     3 * BuddyPress Activity Classes.
    44 *
    55 * @package BuddyPress
     
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
  • trunk/src/bp-activity/bp-activity-cssjs.php

    r10077 r10253  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    2020    }
    2121
    22     // Special handling for New/Edit screens in wp-admin
     22    // Special handling for New/Edit screens in wp-admin.
    2323    if ( is_admin() ) {
    2424        if (
     
    6464 * @param array  $settings   An array with TinyMCE config.
    6565 * @param string $editor_id Unique editor identifier, e.g. 'content'.
    66  *
    6766 * @return array  $mceInit   An array with TinyMCE config.
    6867 */
  • trunk/src/bp-activity/bp-activity-filters.php

    r10077 r10253  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
    1212/** Filters *******************************************************************/
    1313
    14 // Apply WordPress defined filters
     14// Apply WordPress defined filters.
    1515add_filter( 'bp_get_activity_action',                'bp_activity_filter_kses', 1 );
    1616add_filter( 'bp_get_activity_content_body',          'bp_activity_filter_kses', 1 );
     
    7878add_filter( 'bp_activity_primary_link_before_save',  'esc_url_raw' );
    7979
    80 // Apply BuddyPress-defined filters
     80// Apply BuddyPress-defined filters.
    8181add_filter( 'bp_get_activity_content',               'bp_activity_make_nofollow_filter' );
    8282add_filter( 'bp_get_activity_content_body',          'bp_activity_make_nofollow_filter' );
     
    101101/** Actions *******************************************************************/
    102102
    103 // At-name filter
     103// At-name filter.
    104104add_action( 'bp_activity_before_save', 'bp_activity_at_name_filter_updates' );
    105105
    106 // Activity stream moderation
     106// Activity stream moderation.
    107107add_action( 'bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1 );
    108108add_action( 'bp_activity_before_save', 'bp_activity_check_blacklist_keys',  2, 1 );
     
    142142function bp_activity_check_moderation_keys( $activity ) {
    143143
    144     // Only check specific types of activity updates
     144    // Only check specific types of activity updates.
    145145    if ( !in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
    146146        return;
    147147
    148148    // Unset the activity component so activity stream update fails
    149     // @todo This is temporary until some kind of moderation is built
     149    // @todo This is temporary until some kind of moderation is built.
    150150    if ( !bp_core_check_for_moderation( $activity->user_id, '', $activity->content ) )
    151151        $activity->component = false;
     
    161161function bp_activity_check_blacklist_keys( $activity ) {
    162162
    163     // Only check specific types of activity updates
     163    // Only check specific types of activity updates.
    164164    if ( ! in_array( $activity->type, bp_activity_get_moderated_activity_types() ) )
    165165        return;
    166166
    167     // Mark as spam
     167    // Mark as spam.
    168168    if ( ! bp_core_check_for_blacklist( $activity->user_id, '', $activity->content ) )
    169169        bp_activity_mark_as_spam( $activity, 'by_blacklist' );
     
    179179 *
    180180 * @param string $content The activity content.
    181  *
    182181 * @return string $content Filtered activity content.
    183182 */
     
    223222 * @param string $content     The contents of a given item.
    224223 * @param int    $activity_id The activity id. Deprecated.
    225  *
    226224 * @return string $content Content filtered for mentions.
    227225 */
     
    233231    }
    234232
    235     // Try to find mentions
     233    // Try to find mentions.
    236234    $usernames = bp_activity_find_mentions( $content );
    237235
     
    241239
    242240    // We don't want to link @mentions that are inside of links, so we
    243     // temporarily remove them
     241    // temporarily remove them.
    244242    $replace_count = 0;
    245243    $replacements = array();
    246244    foreach ( $usernames as $username ) {
    247         // prevent @ name linking inside <a> tags
     245        // Prevent @ name linking inside <a> tags.
    248246        preg_match_all( '/(<a.*?(?!<\/a>)@' . $username . '.*?<\/a>)/', $content, $content_matches );
    249247        if ( ! empty( $content_matches[1] ) ) {
     
    256254    }
    257255
    258     // Linkify the mentions with the username
     256    // Linkify the mentions with the username.
    259257    foreach ( (array) $usernames as $user_id => $username ) {
    260258        $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
    261259    }
    262260
    263     // put everything back
     261    // Put everything back.
    264262    if ( ! empty( $replacements ) ) {
    265263        foreach ( $replacements as $placeholder => $original ) {
     
    268266    }
    269267
    270     // Return the content
     268    // Return the content.
    271269    return $content;
    272270}
     
    282280 * @uses bp_activity_find_mentions()
    283281 *
    284  * @param BP_Activity_Activity $activity
     282 * @param BP_Activity_Activity $activity Activity Object.
    285283 */
    286284function bp_activity_at_name_filter_updates( $activity ) {
     
    294292        return;
    295293
    296     // Try to find mentions
     294    // Try to find mentions.
    297295    $usernames = bp_activity_find_mentions( $activity->content );
    298296
    299297    // We have mentions!
    300298    if ( ! empty( $usernames ) ) {
    301         // Replace @mention text with userlinks
     299        // Replace @mention text with userlinks.
    302300        foreach( (array) $usernames as $user_id => $username ) {
    303301            $activity->content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $activity->content );
    304302        }
    305303
    306         // Add our hook to send @mention emails after the activity item is saved
     304        // Add our hook to send @mention emails after the activity item is saved.
    307305        add_action( 'bp_activity_after_save', 'bp_activity_at_name_send_emails' );
    308306
    309         // temporary variable to avoid having to run bp_activity_find_mentions() again
     307        // Temporary variable to avoid having to run bp_activity_find_mentions() again.
    310308        buddypress()->activity->mentioned_users = $usernames;
    311309    }
     
    332330        return;
    333331
    334     // Grab our temporary variable from bp_activity_at_name_filter_updates()
     332    // Grab our temporary variable from bp_activity_at_name_filter_updates().
    335333    $usernames = buddypress()->activity->mentioned_users;
    336334
    337     // Get rid of temporary variable
     335    // Get rid of temporary variable.
    338336    unset( buddypress()->activity->mentioned_users );
    339337
    340     // Send @mentions and setup BP notifications
     338    // Send @mentions and setup BP notifications.
    341339    foreach( (array) $usernames as $user_id => $username ) {
    342340
     
    353351        }
    354352
    355         // Updates mention count for the user
     353        // Updates mention count for the user.
    356354        bp_activity_update_mention_count_for_user( $user_id, $activity->id );
    357355    }
     
    364362 *
    365363 * @param string $text Activity text.
    366  *
    367364 * @return string $text Text with rel=nofollow added to any links.
    368365 */
     
    377374     *
    378375     * @param array $matches Items matched by preg_replace_callback() in bp_activity_make_nofollow_filter().
    379      *
    380376     * @return string $text Link with rel=nofollow added.
    381377     */
     
    402398 *
    403399 * @param string $text The original activity entry text.
    404  *
    405400 * @return string $excerpt The truncated text.
    406401 */
     
    420415    );
    421416
    422     // The full text of the activity update should always show on the single activity screen
     417    // The full text of the activity update should always show on the single activity screen.
    423418    if ( ! $maybe_truncate_text || bp_is_single_activity() ) {
    424419        return $text;
     
    443438    $excerpt_length = apply_filters( 'bp_activity_excerpt_length', 358 );
    444439
    445     // Run the text through the excerpt function. If it's too short, the original text will be
    446     // returned.
     440    // Run the text through the excerpt function. If it's too short, the original text will be returned.
    447441    $excerpt        = bp_create_excerpt( $text, $excerpt_length, array( 'ending' => __( '&hellip;', 'buddypress' ) ) );
    448442
    449     // If the text returned by bp_create_excerpt() is different from the original text (ie it's
    450     // been truncated), add the "Read More" link. Note that bp_create_excerpt() is stripping
    451     // shortcodes, so we have strip them from the $text before the comparison
     443    /*
     444     * If the text returned by bp_create_excerpt() is different from the original text (ie it's
     445     * been truncated), add the "Read More" link. Note that bp_create_excerpt() is stripping
     446     * shortcodes, so we have strip them from the $text before the comparison.
     447     */
    452448    if ( $excerpt != strip_shortcodes( $text ) ) {
    453449        $id = !empty( $activities_template->activity->current_comment->id ) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id();
     
    476472 *
    477473 * @param array $js_handles The original dependencies.
    478  *
    479474 * @return array $js_handles The new dependencies.
    480475 */
     
    496491 * @since 2.0.0
    497492 *
    498  * @param string $classes
    499  *
     493 * @param string $classes Array of classes for most recent activity item.
    500494 * @return string $classes
    501495 */
     
    516510 * @since 2.0.0
    517511 *
    518  * @param string $classes
    519  *
     512 * @param string $classes Array of classes for timestamp.
    520513 * @return string $classes
    521514 */
     
    545538 * @uses bp_activity_get_last_updated() to get the recorded date of the last activity.
    546539 *
    547  * @param array $response
    548  * @param array $data
    549  *
     540 * @param array $response Array containing Heartbeat API response.
     541 * @param array $data     Array containing data for Heartbeat API response.
    550542 * @return array $response
    551543 */
     
    556548
    557549    // Use the querystring argument stored in the cookie (to preserve
    558     // filters), but force the offset to get only new items
     550    // filters), but force the offset to get only new items.
    559551    $activity_latest_args = bp_parse_args(
    560552        bp_ajax_querystring( 'activity' ),
     
    570562    $last_activity_recorded = 0;
    571563
    572     // Temporarily add a just-posted class for new activity items
     564    // Temporarily add a just-posted class for new activity items.
    573565    add_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
    574566
     
    591583    ob_end_clean();
    592584
    593     // Remove the temporary filter
     585    // Remove the temporary filter.
    594586    remove_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
    595587
     
    609601 *
    610602 * @param array $strings Localized strings.
    611  *
    612603 * @return array $strings
    613604 */
     
    672663 * @param array $retval Empty array by default.
    673664 * @param array $filter Current activity arguments.
    674  *
    675  * @return array
     665 * @return array $retval
    676666 */
    677667function bp_activity_filter_just_me_scope( $retval = array(), $filter = array() ) {
    678668
    679     // Determine the user_id
     669    // Determine the user_id.
    680670    if ( ! empty( $filter['user_id'] ) ) {
    681671        $user_id = $filter['user_id'];
     
    703693        $show_hidden,
    704694
    705         // overrides
     695        // Overrides.
    706696        'override' => array(
    707697            'display_comments' => 'stream',
     
    722712 * @param array $retval Empty array by default.
    723713 * @param array $filter Current activity arguments.
    724  *
    725  * @return array
     714 * @return array $retval
    726715 */
    727716function bp_activity_filter_favorites_scope( $retval = array(), $filter = array() ) {
    728717
    729     // Determine the user_id
     718    // Determine the user_id.
    730719    if ( ! empty( $filter['user_id'] ) ) {
    731720        $user_id = $filter['user_id'];
     
    736725    }
    737726
    738     // Determine the favorites
     727    // Determine the favorites.
    739728    $favs = bp_activity_get_user_favorites( $user_id );
    740729    if ( empty( $favs ) ) {
     
    760749        $show_hidden,
    761750
    762         // overrides
     751        // Overrides.
    763752        'override' => array(
    764753            'display_comments' => true,
     
    780769 * @param array $retval Empty array by default.
    781770 * @param array $filter Current activity arguments.
    782  *
    783  * @return array
     771 * @return array $retval
    784772 */
    785773function bp_activity_filter_mentions_scope( $retval = array(), $filter = array() ) {
     
    790778    }
    791779
    792     // Determine the user_id
     780    // Determine the user_id.
    793781    if ( ! empty( $filter['user_id'] ) ) {
    794782        $user_id = $filter['user_id'];
     
    819807        $show_hidden,
    820808
    821         // overrides
     809        // Overrides.
    822810        'override' => array(
    823811
    824             // clear search terms so 'mentions' scope works with other scopes
     812            // Clear search terms so 'mentions' scope works with other scopes.
    825813            'search_terms' => false,
    826814
  • trunk/src/bp-activity/bp-activity-functions.php

    r10217 r10253  
    99 */
    1010
    11 // Exit if accessed directly
     11// Exit if accessed directly.
    1212defined( 'ABSPATH' ) || exit;
    1313
     
    8686 * @param string $content The content of the activity, usually found in
    8787 *                        $activity->content.
    88  *
    8988 * @return array|bool Associative array with user ID as key and username as
    9089 *                    value. Boolean false if no mentions found.
     
    9594    preg_match_all( $pattern, $content, $usernames );
    9695
    97     // Make sure there's only one instance of each username
     96    // Make sure there's only one instance of each username.
    9897    $usernames = array_unique( $usernames[1] );
    9998
    100     // Bail if no usernames
     99    // Bail if no usernames.
    101100    if ( empty( $usernames ) ) {
    102101        return false;
     
    105104    $mentioned_users = array();
    106105
    107     // We've found some mentions! Check to see if users exist
     106    // We've found some mentions! Check to see if users exist.
    108107    foreach( (array) array_values( $usernames ) as $username ) {
    109108        $user_id = bp_activity_get_userid_from_mentionname( $username );
    110109
    111         // user ID exists, so let's add it to our array
     110        // The user ID exists, so let's add it to our array.
    112111        if ( ! empty( $user_id ) ) {
    113112            $mentioned_users[ $user_id ] = $username;
     
    151150 * @param int    $activity_id The unique id for the activity item.
    152151 * @param string $action      Can be 'delete' or 'add'. Defaults to 'add'.
    153  *
    154152 * @return bool
    155153 */
    156154function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) {
    157155
    158     // Bail if no activity ID passed
     156    // Bail if no activity ID passed.
    159157    if ( empty( $activity_id ) ) {
    160158        return false;
    161159    }
    162160
    163     // Get activity object
     161    // Get activity object.
    164162    $activity  = new BP_Activity_Activity( (int) $activity_id );
    165163
    166     // Try to find mentions
     164    // Try to find mentions.
    167165    $usernames = bp_activity_find_mentions( strip_tags( $activity->content ) );
    168166
    169     // Still empty? Stop now
     167    // Still empty? Stop now.
    170168    if ( empty( $usernames ) ) {
    171169        return false;
    172170    }
    173171
    174     // Increment mention count foreach mentioned user
     172    // Increment mention count foreach mentioned user.
    175173    foreach( (array) array_keys( $usernames ) as $user_id ) {
    176174        bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action );
     
    192190 * @param int    $activity_id The unique ID for the activity item.
    193191 * @param string $action      'delete' or 'add'. Default: 'add'.
    194  *
    195192 * @return bool
    196193 */
     
    201198    }
    202199
    203     // Adjust the mention list and count for the member
     200    // Adjust the mention list and count for the member.
    204201    $new_mention_count = (int) bp_get_user_meta( $user_id, 'bp_new_mention_count', true );
    205202    $new_mentions      =       bp_get_user_meta( $user_id, 'bp_new_mentions',      true );
    206203
    207     // Make sure new mentions is an array
     204    // Make sure new mentions is an array.
    208205    if ( empty( $new_mentions ) ) {
    209206        $new_mentions = array();
     
    229226    }
    230227
    231     // Get an updated mention count
     228    // Get an updated mention count.
    232229    $new_mention_count = count( $new_mentions );
    233230
    234     // Resave the user_meta
     231    // Resave the user_meta.
    235232    bp_update_user_meta( $user_id, 'bp_new_mention_count', $new_mention_count );
    236233    bp_update_user_meta( $user_id, 'bp_new_mentions',      $new_mentions );
     
    245242 *
    246243 * @param int|string $user_id ID of the user to get @-mention name for.
    247  *
    248  * @return string User name appropriate for @-mentions.
     244 * @return string $mentionname User name appropriate for @-mentions.
    249245 */
    250246function bp_activity_get_user_mentionname( $user_id ) {
     
    270266 *
    271267 * @param string $mentionname Username of user in @-mentions.
    272  *
    273268 * @return int|bool ID of the user, if one is found. Otherwise false.
    274269 */
     
    276271    $user_id = false;
    277272
    278     // In username compatibility mode, hyphens are ambiguous between
    279     // actual hyphens and converted spaces.
    280     //
    281     // @todo There is the potential for username clashes between 'foo bar'
    282     // and 'foo-bar' in compatibility mode. Come up with a system for
    283     // unique mentionnames.
     273    /*
     274     * In username compatibility mode, hyphens are ambiguous between
     275     * actual hyphens and converted spaces.
     276     *
     277     * @todo There is the potential for username clashes between 'foo bar'
     278     * and 'foo-bar' in compatibility mode. Come up with a system for
     279     * unique mentionnames.
     280     */
    284281    if ( bp_is_username_compatibility_mode() ) {
    285         // First, try the raw username
     282        // First, try the raw username.
    286283        $userdata = get_user_by( 'login', $mentionname );
    287284
     
    297294
    298295    // When username compatibility mode is disabled, the mentionname is
    299     // the same as the nicename
     296    // the same as the nicename.
    300297    } else {
    301298        $user_id = bp_core_get_userid_from_nicename( $mentionname );
     
    332329 *                                        Values: 'activity', 'member', 'member_groups', 'group'.
    333330 * @param  int           $position        Optional. The position of the action when listed in dropdowns.
    334  *
    335331 * @return bool False if any param is empty, otherwise true.
    336332 */
     
    338334    $bp = buddypress();
    339335
    340     // Return false if any of the above values are not set
     336    // Return false if any of the above values are not set.
    341337    if ( empty( $component_id ) || empty( $type ) || empty( $description ) ) {
    342338        return false;
    343339    }
    344340
    345     // Set activity action
     341    // Set activity action.
    346342    if ( ! isset( $bp->activity->actions ) || ! is_object( $bp->activity->actions ) ) {
    347343        $bp->activity->actions = new stdClass;
    348344    }
    349345
    350     // Verify callback
     346    // Verify callback.
    351347    if ( ! is_callable( $format_callback ) ) {
    352348        $format_callback = '';
     
    393389 * @param array  $args {
    394390 *     An associative array of tracking parameters. All items are optional.
    395  *
    396391 *     @type string   $bp_activity_admin_filter String to use in the Dashboard > Activity dropdown.
    397392 *     @type string   $bp_activity_front_filter String to use in frontend dropdown.
     
    415410 *                                              the post type does not natively support comments, otherwise false.
    416411 * }
    417  *
    418412 * @return bool
    419413 */
     
    445439 *
    446440 * @param  string $post_type Name of the post type.
    447  *
    448441 * @return object The tracking arguments of the post type.
    449442 */
     
    515508 */
    516509function bp_activity_get_post_types_tracking_args() {
    517     // Fetch all public post types
     510    // Fetch all public post types.
    518511    $post_types = get_post_types( array( 'public' => true ), 'names' );
    519512
     
    595588 * @param string $component_id The unique string ID of the component.
    596589 * @param string $key          The action key.
    597  *
    598590 * @return string|bool Action value if found, otherwise false.
    599591 */
    600592function bp_activity_get_action( $component_id, $key ) {
    601593
    602     // Return false if any of the above values are not set
     594    // Return false if any of the above values are not set.
    603595    if ( empty( $component_id ) || empty( $key ) ) {
    604596        return false;
     
    643635    }
    644636
    645     // This was a mis-named activity type from before BP 1.6
     637    // This was a mis-named activity type from before BP 1.6.
    646638    unset( $actions['friends_register_activity_action'] );
    647639
     
    667659 *
    668660 * @param int $user_id ID of the user whose favorites are being queried.
    669  *
    670661 * @return array IDs of the user's favorite activity items.
    671662 */
    672663function bp_activity_get_user_favorites( $user_id = 0 ) {
    673664
    674     // Fallback to logged in user if no user_id is passed
     665    // Fallback to logged in user if no user_id is passed.
    675666    if ( empty( $user_id ) ) {
    676667        $user_id = bp_displayed_user_id();
    677668    }
    678669
    679     // Get favorites for user
     670    // Get favorites for user.
    680671    $favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
    681672
     
    705696 * @param int $activity_id ID of the activity item being favorited.
    706697 * @param int $user_id     ID of the user favoriting the activity item.
    707  *
    708698 * @return bool True on success, false on failure.
    709699 */
    710700function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
    711701
    712     // Favorite activity stream items are for logged in users only
     702    // Favorite activity stream items are for logged in users only.
    713703    if ( ! is_user_logged_in() ) {
    714704        return false;
    715705    }
    716706
    717     // Fallback to logged in user if no user_id is passed
     707    // Fallback to logged in user if no user_id is passed.
    718708    if ( empty( $user_id ) ) {
    719709        $user_id = bp_loggedin_user_id();
     
    725715    }
    726716
    727     // Bail if the user has already favorited this activity item
     717    // Bail if the user has already favorited this activity item.
    728718    if ( in_array( $activity_id, $my_favs ) ) {
    729719        return false;
    730720    }
    731721
    732     // Add to user's favorites
     722    // Add to user's favorites.
    733723    $my_favs[] = $activity_id;
    734724
    735     // Update the total number of users who have favorited this activity
     725    // Update the total number of users who have favorited this activity.
    736726    $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
    737727    $fav_count = !empty( $fav_count ) ? (int) $fav_count + 1 : 1;
    738728
    739     // Update user meta
     729    // Update user meta.
    740730    bp_update_user_meta( $user_id, 'bp_favorite_activities', $my_favs );
    741731
    742     // Update activity meta counts
     732    // Update activity meta counts.
    743733    if ( bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ) ) {
    744734
     
    753743        do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
    754744
    755         // Success
     745        // Success.
    756746        return true;
    757747
    758     // Saving meta was unsuccessful for an unknown reason
     748    // Saving meta was unsuccessful for an unknown reason.
    759749    } else {
    760750
     
    787777 * @param int $activity_id ID of the activity item being unfavorited.
    788778 * @param int $user_id     ID of the user unfavoriting the activity item.
    789  *
    790779 * @return bool True on success, false on failure.
    791780 */
    792781function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
    793782
    794     // Favorite activity stream items are for logged in users only
     783    // Favorite activity stream items are for logged in users only.
    795784    if ( ! is_user_logged_in() ) {
    796785        return false;
    797786    }
    798787
    799     // Fallback to logged in user if no user_id is passed
     788    // Fallback to logged in user if no user_id is passed.
    800789    if ( empty( $user_id ) ) {
    801790        $user_id = bp_loggedin_user_id();
     
    805794    $my_favs = array_flip( (array) $my_favs );
    806795
    807     // Bail if the user has not previously favorited the item
     796    // Bail if the user has not previously favorited the item.
    808797    if ( ! isset( $my_favs[ $activity_id ] ) ) {
    809798        return false;
    810799    }
    811800
    812     // Remove the fav from the user's favs
     801    // Remove the fav from the user's favs.
    813802    unset( $my_favs[$activity_id] );
    814803    $my_favs = array_unique( array_flip( $my_favs ) );
    815804
    816     // Update the total number of users who have favorited this activity
     805    // Update the total number of users who have favorited this activity.
    817806    $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
    818807    if ( ! empty( $fav_count ) ) {
    819808
    820         // Deduct from total favorites
     809        // Deduct from total favorites.
    821810        if ( bp_activity_update_meta( $activity_id, 'favorite_count', (int) $fav_count - 1 ) ) {
    822811
    823             // Update users favorites
     812            // Update users favorites.
    824813            if ( bp_update_user_meta( $user_id, 'bp_favorite_activities', $my_favs ) ) {
    825814
     
    834823                do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
    835824
    836                 // Success
     825                // Success.
    837826                return true;
    838827
    839             // Error updating
     828            // Error updating.
    840829            } else {
    841830                return false;
    842831            }
    843832
    844         // Error updating favorite count
     833        // Error updating favorite count.
    845834        } else {
    846835            return false;
    847836        }
    848837
    849     // Error getting favorite count
     838    // Error getting favorite count.
    850839    } else {
    851840        return false;
     
    862851 *
    863852 * @param string $content The content to filter by.
    864  *
    865853 * @return int|null The ID of the located activity item. Null if none is found.
    866854 */
     
    907895 *
    908896 * @param int $user_id ID of the user whose favorite count is being requested.
    909  *
    910897 * @return int Total favorite count for the user.
    911898 */
    912899function bp_activity_total_favorites_for_user( $user_id = 0 ) {
    913900
    914     // Fallback on displayed user, and then logged in user
     901    // Fallback on displayed user, and then logged in user.
    915902    if ( empty( $user_id ) ) {
    916903        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
     
    937924 * @param bool   $delete_all  Optional. If true, delete matching metadata entries
    938925 *                            for all objects, ignoring the specified object_id. Otherwise,
    939  *                            only delete matching metadata entries for the specified
    940  *                            activity item. Default: false.
    941  *
     926 *                            only delete matching metadata entries for the specified
     927 *                            activity item. Default: false.
    942928 * @return bool True on success, false on failure.
    943929 */
    944930function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) {
    945931
    946     // Legacy - if no meta_key is passed, delete all for the item
     932    // Legacy - if no meta_key is passed, delete all for the item.
    947933    if ( empty( $meta_key ) ) {
    948934        $all_meta = bp_activity_get_meta( $activity_id );
    949935        $keys     = ! empty( $all_meta ) ? array_keys( $all_meta ) : array();
    950936
    951         // With no meta_key, ignore $delete_all
     937        // With no meta_key, ignore $delete_all.
    952938        $delete_all = false;
    953939    } else {
     
    978964 *                            activity item will be fetched.
    979965 * @param bool   $single      Optional. If true, return only the first value of the
    980  *                            specified meta_key. This parameter has no effect if meta_key is not
    981  *                            specified. Default: true.
    982  *
     966 *                            specified meta_key. This parameter has no effect if meta_key is not
     967 *                            specified. Default: true.
    983968 * @return mixed The meta value(s) being requested.
    984969 */
     
    1011996 * @param mixed  $prev_value  Optional. If specified, only update existing metadata entries
    1012997 *                            with the specified value. Otherwise, update all entries.
    1013  *
    1014998 * @return bool|int Returns false on failure. On successful update of existing
    1015999 *                  metadata, returns true. On successful creation of new metadata,
     
    10351019 *                            given key. If true, and the object already has a value for
    10361020 *                            the key, no change will be made. Default: false.
    1037  *
    10381021 * @return int|bool The meta ID on successful update, false on failure.
    10391022 */
     
    10601043 *
    10611044 * @param int $user_id ID of the user whose activity is being deleted.
    1062  *
    10631045 * @return bool
    10641046 */
    10651047function bp_activity_remove_all_user_data( $user_id = 0 ) {
    10661048
    1067     // Do not delete user data unless a logged in user says so
     1049    // Do not delete user data unless a logged in user says so.
    10681050    if ( empty( $user_id ) || ! is_user_logged_in() ) {
    10691051        return false;
    10701052    }
    10711053
    1072     // Clear the user's activity from the sitewide stream and clear their activity tables
     1054    // Clear the user's activity from the sitewide stream and clear their activity tables.
    10731055    bp_activity_delete( array( 'user_id' => $user_id ) );
    10741056
    1075     // Remove any usermeta
     1057    // Remove any usermeta.
    10761058    bp_delete_user_meta( $user_id, 'bp_latest_update'       );
    10771059    bp_delete_user_meta( $user_id, 'bp_favorite_activities' );
     
    11001082 *
    11011083 * @param int $user_id ID of the user whose activity is being spammed.
    1102  *
    11031084 * @return bool
    11041085 */
     
    11061087    global $wpdb;
    11071088
    1108     // Do not delete user data unless a logged in user says so
     1089    // Do not delete user data unless a logged in user says so.
    11091090    if ( empty( $user_id ) || ! is_user_logged_in() ) {
    11101091        return false;
     
    11201101    $bp = buddypress();
    11211102
    1122     // Mark each as spam
     1103    // Mark each as spam.
    11231104    foreach ( (array) $activities['activities'] as $activity ) {
    11241105
    1125         // Create an activity object
     1106        // Create an activity object.
    11261107        $activity_obj = new BP_Activity_Activity;
    11271108        foreach ( $activity as $k => $v ) {
     
    11291110        }
    11301111
    1131         // Mark as spam
     1112        // Mark as spam.
    11321113        bp_activity_mark_as_spam( $activity_obj );
    11331114
     
    11431124        }
    11441125
    1145         // Tidy up
     1126        // Tidy up.
    11461127        unset( $activity_obj );
    11471128    }
    11481129
    1149     // Mark all of this user's activities as spam
     1130    // Mark all of this user's activities as spam.
    11501131    $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id ) );
    11511132
     
    11701151 *
    11711152 * @param int $user_id ID of the user whose activity is being hammed.
    1172  *
    11731153 * @return bool
    11741154 */
     
    11761156    global $wpdb;
    11771157
    1178     // Do not delete user data unless a logged in user says so
     1158    // Do not delete user data unless a logged in user says so.
    11791159    if ( empty( $user_id ) || ! is_user_logged_in() ) {
    11801160        return false;
     
    11911171    $bp = buddypress();
    11921172
    1193     // Mark each as not spam
     1173    // Mark each as not spam.
    11941174    foreach ( (array) $activities['activities'] as $activity ) {
    11951175
    1196         // Create an activity object
     1176        // Create an activity object.
    11971177        $activity_obj = new BP_Activity_Activity;
    11981178        foreach ( $activity as $k => $v ) {
     
    12001180        }
    12011181
    1202         // Mark as not spam
     1182        // Mark as not spam.
    12031183        bp_activity_mark_as_ham( $activity_obj );
    12041184
     
    12141194        }
    12151195
    1216         // Tidy up
     1196        // Tidy up.
    12171197        unset( $activity_obj );
    12181198    }
    12191199
    1220     // Mark all of this user's activities as not spam
     1200    // Mark all of this user's activities as not spam.
    12211201    $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 0 WHERE user_id = %d", $user_id ) );
    12221202
     
    12761256 *
    12771257 * @param object $activity Activity data object.
    1278  *
    12791258 * @return string|bool Returns false if no callback is found, otherwise returns
    12801259 *                     the formatted action string.
     
    12821261function bp_activity_generate_action_string( $activity ) {
    12831262
    1284     // Check for valid input
     1263    // Check for valid input.
    12851264    if ( empty( $activity->component ) || empty( $activity->type ) ) {
    12861265        return false;
    12871266    }
    12881267
    1289     // Check for registered format callback
     1268    // Check for registered format callback.
    12901269    $actions = bp_activity_get_actions();
    12911270    if ( empty( $actions->{$activity->component}->{$activity->type}['format_callback'] ) ) {
     
    12931272    }
    12941273
    1295     // We apply the format_callback as a filter
     1274    // We apply the format_callback as a filter.
    12961275    add_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
    12971276
     
    13061285    $action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
    13071286
    1308     // Remove the filter for future activity items
     1287    // Remove the filter for future activity items.
    13091288    remove_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
    13101289
     
    13191298 * @param string $action   Static activity action.
    13201299 * @param object $activity Activity data object.
    1321  *
    1322  * @return string
     1300 * @return string $action
    13231301 */
    13241302function bp_activity_format_activity_action_activity_update( $action, $activity ) {
     
    13431321 * @param string $action   Static activity action.
    13441322 * @param object $activity Activity data object.
    1345  *
    1346  * @return string
     1323 * @return string $action
    13471324 */
    13481325function bp_activity_format_activity_action_activity_comment( $action, $activity ) {
     
    13671344 * @param string $action   Static activity action.
    13681345 * @param object $activity Activity data object.
    1369  *
    1370  * @return string
     1346 * @return string $action
    13711347 */
    13721348function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) {
     
    14181394}
    14191395
    1420 /******************************************************************************
     1396/*
    14211397 * Business functions are where all the magic happens in BuddyPress. They will
    14221398 * handle the actual saving or manipulation of information. Usually they will
     
    14281404 * Retrieve an activity or activities.
    14291405 *
    1430  * bp_activity_get() shares all arguments with BP_Activity_Activity::get(). The
    1431  * following is a list of bp_activity_get() parameters that have different
     1406 * The bp_activity_get() function shares all arguments with BP_Activity_Activity::get().
     1407 * The following is a list of bp_activity_get() parameters that have different
    14321408 * default values from BP_Activity_Activity::get() (value in parentheses is
    14331409 * the default for the bp_activity_get()).
     
    14461422 *
    14471423 * @param array|string $args See BP_Activity_Activity::get() for description.
    1448  *
    14491424 * @return array $activity See BP_Activity_Activity::get() for description.
    14501425 */
     
    14641439        'filter_query'      => false,
    14651440        'show_hidden'       => false,        // Show activity items that are hidden site-wide?
    1466         'exclude'           => false,        // Comma-separated list of activity IDs to exclude
    1467         'in'                => false,        // Comma-separated list or array of activity IDs to which you want to limit the query
     1441        'exclude'           => false,        // Comma-separated list of activity IDs to exclude.
     1442        'in'                => false,        // Comma-separated list or array of activity IDs to which you
     1443                                             // want to limit the query.
    14681444        'spam'              => 'ham_only',   // 'ham_only' (default), 'spam_only' or 'all'.
    14691445        'update_meta_cache' => true,
     
    14741450         * Pass filters as an array -- all filter items can be multiple values comma separated:
    14751451         * array(
    1476          *  'user_id'      => false, // user_id to filter on
    1477          *  'object'       => false, // object to filter on e.g. groups, profile, status, friends
    1478          *  'action'       => false, // action to filter on e.g. activity_update, profile_updated
    1479          *  'primary_id'   => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
    1480          *  'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
     1452         *     'user_id'      => false, // User ID to filter on.
     1453         *     'object'       => false, // Object to filter on e.g. groups, profile, status, friends.
     1454         *     'action'       => false, // Action to filter on e.g. activity_update, profile_updated.
     1455         *     'primary_id'   => false, // Object ID to filter on e.g. a group_id or forum_id or blog_id etc.
     1456         *     'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id.
    14811457         * );
    14821458         */
     
    15581534 *     except for the following:
    15591535 *     @type string|int|array Single activity ID, comma-separated list of IDs,
    1560  *           or array of IDs.
     1536 *                            or array of IDs.
    15611537 * }
    15621538 * @return array $activity See BP_Activity_Activity::get() for description.
     
    15661542    $r = bp_parse_args( $args, array(
    15671543        'activity_ids'      => false,      // A single activity_id or array of IDs.
    1568         'display_comments'  => false,      // true or false to display threaded comments for these specific activity items
    1569         'max'               => false,      // Maximum number of results to return
    1570         'page'              => 1,          // page 1 without a per_page will result in no pagination.
    1571         'per_page'          => false,      // results per page
    1572         'show_hidden'       => true,       // When fetching specific items, show all
    1573         'sort'              => 'DESC',     // sort ASC or DESC
    1574         'spam'              => 'ham_only', // Retrieve items marked as spam
     1544        'display_comments'  => false,      // True or false to display threaded comments for these specific activity items.
     1545        'max'               => false,      // Maximum number of results to return.
     1546        'page'              => 1,          // Page 1 without a per_page will result in no pagination.
     1547        'per_page'          => false,      // Results per page.
     1548        'show_hidden'       => true,       // When fetching specific items, show all.
     1549        'sort'              => 'DESC',     // Sort ASC or DESC
     1550        'spam'              => 'ham_only', // Retrieve items marked as spam.
    15751551        'update_meta_cache' => true,
    15761552    ) );
     
    16501626        'action'            => '',                     // The activity action - e.g. "Jon Doe posted an update"
    16511627        'content'           => '',                     // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
    1652         'component'         => false,                  // The name/ID of the component e.g. groups, profile, mycomponent
    1653         'type'              => false,                  // The activity type e.g. activity_update, profile_updated
    1654         'primary_link'      => '',                     // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
     1628        'component'         => false,                  // The name/ID of the component e.g. groups, profile, mycomponent.
     1629        'type'              => false,                  // The activity type e.g. activity_update, profile_updated.
     1630        'primary_link'      => '',                     // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink).
    16551631        '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.
    1656         'item_id'           => false,                  // Optional: The ID of the specific item being recorded, e.g. a blog_id
    1657         'secondary_item_id' => false,                  // Optional: A second ID used to further filter e.g. a comment_id
    1658         'recorded_time'     => bp_core_current_time(), // The GMT time that this activity was recorded
     1632        'item_id'           => false,                  // Optional: The ID of the specific item being recorded, e.g. a blog_id.
     1633        'secondary_item_id' => false,                  // Optional: A second ID used to further filter e.g. a comment_id.
     1634        'recorded_time'     => bp_core_current_time(), // The GMT time that this activity was recorded.
    16591635        'hide_sitewide'     => false,                  // Should this be hidden on the sitewide activity stream?
    16601636        'is_spam'           => false,                  // Is this activity item to be marked as spam?
    16611637    ), 'activity_add' );
    16621638
    1663     // Make sure we are backwards compatible
     1639    // Make sure we are backwards compatible.
    16641640    if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) {
    16651641        $r['component'] = $r['component_name'];
     
    16701646    }
    16711647
    1672     // Setup activity to be added
     1648    // Setup activity to be added.
    16731649    $activity                    = new BP_Activity_Activity( $r['id'] );
    16741650    $activity->user_id           = $r['user_id'];
     
    16901666    }
    16911667
    1692     // If this is an activity comment, rebuild the tree
     1668    // If this is an activity comment, rebuild the tree.
    16931669    if ( 'activity_comment' === $activity->type ) {
    1694         // Also clear the comment cache for the parent activity ID
     1670        // Also clear the comment cache for the parent activity ID.
    16951671        wp_cache_delete( $activity->item_id, 'bp_activity_comments' );
    16961672
     
    17491725    }
    17501726
    1751     // Record this on the user's profile
     1727    // Record this on the user's profile.
    17521728    $activity_content = $r['content'];
    17531729    $primary_link     = bp_core_get_userlink( $r['user_id'], false, true );
     
    17711747    $add_primary_link = apply_filters( 'bp_activity_new_update_primary_link', $primary_link );
    17721748
    1773     // Now write the values
     1749    // Now write the values.
    17741750    $activity_id = bp_activity_add( array(
    17751751        'user_id'      => $r['user_id'],
     
    18151791 * @since 2.2.0
    18161792 *
    1817  * @param  int      $post_id ID of the new post.
    1818  * @param  WP_Post  $post    Post object.
    1819  * @param  int      $user_id ID of the post author.
    1820  *
     1793 * @param int     $post_id ID of the new post.
     1794 * @param WP_Post $post    Post object.
     1795 * @param int     $user_id ID of the post author.
    18211796 * @return int|bool The ID of the activity on success. False on error.
    18221797 */
     
    19531928 * @since 2.2.0
    19541929 *
    1955  * @param  WP_Post $post Post item.
    1956  *
    1957  * @return bool    True on success, false on failure.
     1930 * @param WP_Post $post Post item.
     1931 * @return bool True on success, false on failure.
    19581932 */
    19591933function bp_activity_post_type_update( $post = null ) {
     
    20241998 * @param  int     $post_id ID of the post being unpublished.
    20251999 * @param  WP_Post $post    Post object.
    2026  *
    2027  * @return bool    True on success, false on failure.
     2000 * @return bool True on success, false on failure.
    20282001 */
    20292002function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) {
     
    20332006    }
    20342007
    2035     // Get the post type tracking args
     2008    // Get the post type tracking args.
    20362009    $activity_post_object = bp_activity_get_post_type_tracking_args( $post->post_type );
    20372010
     
    21062079        'content'     => false,
    21072080        'user_id'     => bp_loggedin_user_id(),
    2108         'activity_id' => false, // ID of the root activity item
    2109         'parent_id'   => false  // ID of a parent comment (optional)
     2081        'activity_id' => false, // ID of the root activity item.
     2082        'parent_id'   => false  // ID of a parent comment (optional).
    21102083    ) );
    21112084
    2112     // Bail if missing necessary data
     2085    // Bail if missing necessary data.
    21132086    if ( empty( $r['content'] ) || empty( $r['user_id'] ) || empty( $r['activity_id'] ) ) {
    21142087        $errors->add( 'missing_data', $feedback );
     
    21182091    }
    21192092
    2120     // Maybe set current activity ID as the parent
     2093    // Maybe set current activity ID as the parent.
    21212094    if ( empty( $r['parent_id'] ) ) {
    21222095        $r['parent_id'] = $r['activity_id'];
     
    21252098    $activity_id = $r['activity_id'];
    21262099
    2127     // Get the parent activity
     2100    // Get the parent activity.
    21282101    $activity  = new BP_Activity_Activity( $activity_id );
    21292102
    2130     // Bail if the parent activity does not exist
     2103    // Bail if the parent activity does not exist.
    21312104    if ( empty( $activity->date_recorded ) ) {
    21322105        $errors->add( 'missing_activity', __( 'Sorry, the item you are replying to no longer exists.', 'buddypress' ) );
     
    21482121    $comment_content = apply_filters( 'bp_activity_comment_content', $r['content'] );
    21492122
    2150     // Insert the activity comment
     2123    // Insert the activity comment.
    21512124    $comment_id = bp_activity_add( array(
    21522125        'id'                => $r['id'],
     
    21602133    ) );
    21612134
    2162     // Comment caches are stored only with the top-level item
     2135    // Comment caches are stored only with the top-level item.
    21632136    wp_cache_delete( $activity_id, 'bp_activity_comments' );
    21642137
    2165     // Walk the tree to clear caches for all parent items
     2138    // Walk the tree to clear caches for all parent items.
    21662139    $clear_id = $r['parent_id'];
    21672140    while ( $clear_id != $activity_id ) {
     
    22022175 *
    22032176 * @param array|string $args See BP_Activity_Activity::get() for description.
    2204  *
    22052177 * @return int $activity_id The ID of the activity item found.
    22062178 */
     
    22682240 *                           the same as BP_Activity_Activity::get().
    22692241 *                           See that method for a description.
    2270  *
    22712242 * @return bool True on success, false on failure.
    22722243 */
    22732244function bp_activity_delete( $args = '' ) {
    22742245
    2275     // Pass one or more the of following variables to delete by those variables
     2246    // Pass one or more the of following variables to delete by those variables.
    22762247    $args = bp_parse_args( $args, array(
    22772248        'id'                => false,
     
    22972268    do_action( 'bp_before_activity_delete', $args );
    22982269
    2299     // Adjust the new mention count of any mentioned member
     2270    // Adjust the new mention count of any mentioned member.
    23002271    bp_activity_adjust_mention_count( $args['id'], 'delete' );
    23012272
     
    23052276    }
    23062277
    2307     // Check if the user's latest update has been deleted
     2278    // Check if the user's latest update has been deleted.
    23082279    $user_id = empty( $args['user_id'] )
    23092280        ? bp_loggedin_user_id()
     
    23532324     * @param array|string $args See BP_Activity_Activity::get for a
    23542325     *                           description of accepted arguments.
    2355      *
    23562326     * @return bool True on success, false on failure.
    23572327     */
     
    23772347     *
    23782348     * @param int $activity_id ID of the activity item to be deleted.
    2379      *
    23802349     * @return bool True on success, false on failure.
    23812350     */
     
    23982367     * @param string $component The activity component.
    23992368     * @param string $type      The activity type.
    2400      *
    24012369     * @return bool True on success, false on failure.
    24022370     */
     
    24222390     * @param int    $user_id   The user id.
    24232391     * @param string $component The activity component.
    2424      *
    24252392     * @return bool True on success, false on failure.
    24262393     */
     
    24502417 *                         oldest ancestor.
    24512418 * @param int $comment_id  The ID of the comment to be deleted.
    2452  *
    24532419 * @return bool True on success, false on failure.
    24542420 */
     
    24742440    bp_activity_delete_children( $activity_id, $comment_id );
    24752441
    2476     // Delete the actual comment
     2442    // Delete the actual comment.
    24772443    if ( ! bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) ) {
    24782444        return false;
    24792445    }
    24802446
    2481     // Purge comment cache for the root activity update
     2447    // Purge comment cache for the root activity update.
    24822448    wp_cache_delete( $activity_id, 'bp_activity_comments' );
    24832449
    2484     // Recalculate the comment tree
     2450    // Recalculate the comment tree.
    24852451    BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
    24862452
     
    25132479    function bp_activity_delete_children( $activity_id, $comment_id ) {
    25142480
    2515         // Get activity children to delete
     2481        // Get activity children to delete.
    25162482        $children = BP_Activity_Activity::get_child_comments( $comment_id );
    25172483
     
    25232489        }
    25242490
    2525         // Delete the comment itself
     2491        // Delete the comment itself.
    25262492        bp_activity_delete( array(
    25272493            'secondary_item_id' => $comment_id,
     
    25472513 * @param int         $activity_id  The unique id of the activity object.
    25482514 * @param object|bool $activity_obj Optional. The activity object.
    2549  *
    25502515 * @return string $link Permalink for the activity item.
    25512516 */
     
    26002565 *
    26012566 * @param int $user_id The ID of the user whose activity is being hidden.
    2602  *
    26032567 * @return bool True on success, false on failure.
    26042568 */
     
    26292593 * @param array|bool  $args    Optional. The args passed to the activity
    26302594 *                             creation function (eg bp_blogs_record_activity()).
    2631  *
    26322595 * @return string $content The content with images stripped and replaced with a
    26332596 *                         single thumb.
     
    26372600    preg_match_all( '/<img[^>]*>/Ui', $content, $matches );
    26382601
    2639     // Remove <img> tags. Also remove caption shortcodes and caption text if present
     2602    // Remove <img> tags. Also remove caption shortcodes and caption text if present.
    26402603    $content = preg_replace('|(\[caption(.*?)\])?<img[^>]*>([^\[\[]*\[\/caption\])?|', '', $content );
    26412604
    26422605    if ( !empty( $matches ) && !empty( $matches[0] ) ) {
    26432606
    2644         // Get the SRC value
     2607        // Get the SRC value.
    26452608        preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i',    $matches[0][0], $src    );
    26462609
    2647         // Get the width and height
     2610        // Get the width and height.
    26482611        preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
    26492612        preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i',  $matches[0][0], $width  );
     
    27022665 * @param array  $activity The data passed to bp_activity_add() or the values
    27032666 *                         from an Activity obj.
    2704  *
    2705  * @return string
     2667 * @return string $summary
    27062668 */
    27072669function bp_activity_create_summary( $content, $activity ) {
     
    28862848    $activity->is_spam = 1;
    28872849
    2888     // Clear the activity stream first page cache
     2850    // Clear the activity stream first page cache.
    28892851    wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
    28902852
    2891     // Clear the activity comment cache for this activity item
     2853    // Clear the activity comment cache for this activity item.
    28922854    wp_cache_delete( $activity->id, 'bp_activity_comments' );
    28932855
    2894     // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity
     2856    // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity.
    28952857    if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {
    28962858        remove_action( 'bp_activity_before_save', array( $bp->activity->akismet, 'check_activity' ), 4, 1 );
    28972859
    2898         // Build data package for Akismet
     2860        // Build data package for Akismet.
    28992861        $activity_data = BP_Akismet::build_akismet_data_package( $activity );
    29002862
    2901         // Tell Akismet this is spam
     2863        // Tell Akismet this is spam.
    29022864        $activity_data = $bp->activity->akismet->send_akismet_request( $activity_data, 'submit', 'spam' );
    29032865
    2904         // Update meta
     2866        // Update meta.
    29052867        add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_spam_meta' ), 1, 1 );
    29062868    }
     
    29332895    $activity->is_spam = 0;
    29342896
    2935     // Clear the activity stream first page cache
     2897    // Clear the activity stream first page cache.
    29362898    wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
    29372899
    2938     // Clear the activity comment cache for this activity item
     2900    // Clear the activity comment cache for this activity item.
    29392901    wp_cache_delete( $activity->id, 'bp_activity_comments' );
    29402902
    2941     // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity
     2903    // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity.
    29422904    if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) {
    29432905        remove_action( 'bp_activity_before_save', array( $bp->activity->akismet, 'check_activity' ), 4, 1 );
    29442906
    2945         // Build data package for Akismet
     2907        // Build data package for Akismet.
    29462908        $activity_data = BP_Akismet::build_akismet_data_package( $activity );
    29472909
    2948         // Tell Akismet this is spam
     2910        // Tell Akismet this is spam.
    29492911        $activity_data = $bp->activity->akismet->send_akismet_request( $activity_data, 'submit', 'ham' );
    29502912
    2951         // Update meta
     2913        // Update meta.
    29522914        add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_ham_meta' ), 1, 1 );
    29532915    }
     
    30723034 * @param int    $id       The ID of the activity item.
    30733035 * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
    3074  *
    30753036 * @return mixed The cached embeds for this activity item.
    30763037 */
     
    30933054 * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().
    30943055 * @param int    $id       The ID of the activity item.
    3095  *
    3096  * @return bool True on success, false on failure.
    30973056 */
    30983057function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
  • trunk/src/bp-activity/bp-activity-loader.php

    r10110 r10253  
    99 */
    1010
    11 // Exit if accessed directly
     11// Exit if accessed directly.
    1212defined( 'ABSPATH' ) || exit;
    1313
     
    4747    public function includes( $includes = array() ) {
    4848
    49         // Files to include
     49        // Files to include.
    5050        $includes = array(
    5151            'cssjs',
     
    6060        );
    6161
    62         // Load Akismet support if Akismet is configured
     62        // Load Akismet support if Akismet is configured.
    6363        $akismet_key = bp_get_option( 'wordpress_api_key' );
    6464
     
    9090        $bp = buddypress();
    9191
    92         // Define a slug, if necessary
     92        // Define a slug, if necessary.
    9393        if ( ! defined( 'BP_ACTIVITY_SLUG' ) ) {
    9494            define( 'BP_ACTIVITY_SLUG', $this->id );
    9595        }
    9696
    97         // Global tables for activity component
     97        // Global tables for activity component.
    9898        $global_tables = array(
    9999            'table_name'      => $bp->table_prefix . 'bp_activity',
     
    101101        );
    102102
    103         // Metadata tables for groups component
     103        // Metadata tables for groups component.
    104104        $meta_tables = array(
    105105            'activity' => $bp->table_prefix . 'bp_activity_meta',
     
    138138    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    139139
    140         // Stop if there is no user displayed or logged in
     140        // Stop if there is no user displayed or logged in.
    141141        if ( ! is_user_logged_in() && ! bp_displayed_user_id() ) {
    142142            return;
    143143        }
    144144
    145         // Determine user to use
     145        // Determine user to use.
    146146        if ( bp_displayed_user_domain() ) {
    147147            $user_domain = bp_displayed_user_domain();
     
    155155        $activity_link = trailingslashit( $user_domain . $slug );
    156156
    157         // Add 'Activity' to the main navigation
     157        // Add 'Activity' to the main navigation.
    158158        $main_nav = array(
    159159            'name'                => _x( 'Activity', 'Profile activity screen nav', 'buddypress' ),
     
    165165        );
    166166
    167         // Add the subnav items to the activity nav item if we are using a theme that supports this
     167        // Add the subnav items to the activity nav item if we are using a theme that supports this.
    168168        $sub_nav[] = array(
    169169            'name'            => _x( 'Personal', 'Profile activity screen sub nav', 'buddypress' ),
     
    175175        );
    176176
    177         // @ mentions
     177        // Check @mentions.
    178178        if ( bp_activity_do_mentions() ) {
    179179            $sub_nav[] = array(
     
    188188        }
    189189
    190         // Favorite activity items
     190        // Favorite activity items.
    191191        if ( bp_activity_can_favorite() ) {
    192192            $sub_nav[] = array(
     
    201201        }
    202202
    203         // Additional menu if friends is active
     203        // Additional menu if friends is active.
    204204        if ( bp_is_active( 'friends' ) ) {
    205205            $sub_nav[] = array(
     
    214214        }
    215215
    216         // Additional menu if groups is active
     216        // Additional menu if groups is active.
    217217        if ( bp_is_active( 'groups' ) ) {
    218218            $sub_nav[] = array(
     
    250250    public function setup_admin_bar( $wp_admin_nav = array() ) {
    251251
    252         // Menus for logged in user
     252        // Menus for logged in user.
    253253        if ( is_user_logged_in() ) {
    254254
    255             // Setup the logged in user variables
     255            // Setup the logged in user variables.
    256256            $activity_link = trailingslashit( bp_loggedin_user_domain() . bp_get_activity_slug() );
    257257
    258             // Unread message count
     258            // Unread message count.
    259259            if ( bp_activity_do_mentions() ) {
    260260                $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
     
    266266            }
    267267
    268             // Add the "Activity" sub menu
     268            // Add the "Activity" sub menu.
    269269            $wp_admin_nav[] = array(
    270270                'parent' => buddypress()->my_account_menu_id,
     
    274274            );
    275275
    276             // Personal
     276            // Personal.
    277277            $wp_admin_nav[] = array(
    278278                'parent' => 'my-account-' . $this->id,
     
    282282            );
    283283
    284             // Mentions
     284            // Mentions.
    285285            if ( bp_activity_do_mentions() ) {
    286286                $wp_admin_nav[] = array(
     
    292292            }
    293293
    294             // Favorites
    295             // Favorite activity items
     294            // Favorite activity items.
    296295            if ( bp_activity_can_favorite() ) {
    297296                $wp_admin_nav[] = array(
     
    338337    public function setup_title() {
    339338
    340         // Adjust title based on view
     339        // Adjust title based on view.
    341340        if ( bp_is_activity_component() ) {
    342341            $bp = buddypress();
     
    364363    public function setup_actions() {
    365364
    366         // Spam prevention
     365        // Spam prevention.
    367366        add_action( 'bp_include', 'bp_activity_setup_akismet' );
    368367
     
    377376    public function setup_cache_groups() {
    378377
    379         // Global groups
     378        // Global groups.
    380379        wp_cache_add_global_groups( array(
    381380            'bp_activity',
  • trunk/src/bp-activity/bp-activity-notifications.php

    r10077 r10253  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    4141function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
    4242
    43     // Don't leave multiple notifications for the same activity item
     43    // Don't leave multiple notifications for the same activity item.
    4444    $notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id, 'all' );
    4545
     
    5656    $content = '';
    5757
    58     // Now email the user with the contents of the message (if they have enabled email notifications)
     58    // Now email the user with the contents of the message (if they have enabled email notifications).
    5959    if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
    6060        $poster_name = bp_core_get_user_displayname( $activity->user_id );
     
    6767        $content = bp_activity_filter_kses( strip_tags( stripslashes( $activity->content ) ) );
    6868
    69         // Set up and send the message
     69        // Set up and send the message.
    7070        $ud       = bp_core_get_core_userdata( $receiver_user_id );
    7171        $to       = $ud->user_email;
     
    9494        }
    9595
    96         // Only show the disable notifications line if the settings component is enabled
     96        // Only show the disable notifications line if the settings component is enabled.
    9797        if ( bp_is_active( 'settings' ) ) {
    9898            $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     
    175175 * @param int   $comment_id   The comment id.
    176176 * @param int   $commenter_id The ID of the user who posted the comment.
    177  * @param array $params       {@link bp_activity_new_comment()}
    178  *
     177 * @param array $params       {@link bp_activity_new_comment()}.
    179178 * @return bool
    180179 */
    181180function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
    182181
    183     // Set some default parameters
     182    // Set some default parameters.
    184183    $activity_id = 0;
    185184    $parent_id   = 0;
     
    198197        $content = bp_activity_filter_kses( stripslashes($content) );
    199198
    200         // Set up and send the message
     199        // Set up and send the message.
    201200        $ud      = bp_core_get_core_userdata( $original_activity->user_id );
    202201        $to      = $ud->user_email;
     
    212211', 'buddypress' ), $poster_name, $content, $thread_link );
    213212
    214         // Only show the disable notifications line if the settings component is enabled
     213        // Only show the disable notifications line if the settings component is enabled.
    215214        if ( bp_is_active( 'settings' ) ) {
    216215            $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     
    266265    }
    267266
    268     /***
     267    /*
    269268     * If this is a reply to another comment, send an email notification to the
    270269     * author of the immediate parent comment.
     
    282281        $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . $settings_slug . '/notifications/';
    283282
    284         // Set up and send the message
     283        // Set up and send the message.
    285284        $ud       = bp_core_get_core_userdata( $parent_comment->user_id );
    286285        $to       = $ud->user_email;
     
    300299', 'buddypress' ), $poster_name, $content, $thread_link );
    301300
    302         // Only show the disable notifications line if the settings component is enabled
     301        // Only show the disable notifications line if the settings component is enabled.
    303302        if ( bp_is_active( 'settings' ) ) {
    304303            $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     
    360359 * @since 1.9.0
    361360 *
    362  * @param int   $comment_id
    363  * @param array $params
     361 * @param int   $comment_id ID of the comment being notified about.
     362 * @param array $params     Parameters to use with notification.
    364363 */
    365364function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
     
    387386 * @param int    $total_items       The total number of notifications to format.
    388387 * @param string $format            'string' to get a BuddyBar-compatible notification, 'array' otherwise.
    389  *
    390388 * @return string $return Formatted @mention notification.
    391389 */
     
    476474 * @since 1.9.0
    477475 *
    478  * @param object $activity
    479  * @param string $subject (not used)
    480  * @param string $message (not used)
    481  * @param string $content (not used)
    482  * @param int    $receiver_user_id
     476 * @param object $activity           Activity object.
     477 * @param string $subject (not used) Notification subject.
     478 * @param string $message (not used) Notification message.
     479 * @param string $content (not used) Notification content.
     480 * @param int    $receiver_user_id   ID of user receiving notification.
    483481 */
    484482function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
     
    509507    }
    510508
    511     // Only mark read if you're looking at your own mentions
     509    // Only mark read if you're looking at your own mentions.
    512510    if ( ! bp_is_my_profile() ) {
    513511        return;
     
    523521 * @since 2.0.0
    524522 *
    525  * @param object BP_Activity_Activity
     523 * @param BP_Activity_Activity $activity Activity object.
    526524 */
    527525function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
     
    534532    }
    535533
    536     // Mark as read any notifications for the current user related to this
    537     // activity item
     534    // Mark as read any notifications for the current user related to this activity item.
    538535    bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' );
    539536}
     
    549546function bp_activity_at_mention_delete_notification( $activity_ids_deleted = array() ) {
    550547    // Let's delete all without checking if content contains any mentions
    551     // to avoid a query to get the activity
     548    // to avoid a query to get the activity.
    552549    if ( bp_is_active( 'notifications' ) && ! empty( $activity_ids_deleted ) ) {
    553550        foreach ( $activity_ids_deleted as $activity_id ) {
  • trunk/src/bp-activity/bp-activity-screens.php

    r10081 r10253  
    1111 */
    1212
    13 // Exit if accessed directly
     13// Exit if accessed directly.
    1414defined( 'ABSPATH' ) || exit;
    1515
     
    253253    $bp = buddypress();
    254254
    255     // No displayed user or not viewing activity component
     255    // No displayed user or not viewing activity component.
    256256    if ( !bp_is_activity_component() )
    257257        return false;
     
    260260        return false;
    261261
    262     // Get the activity details
     262    // Get the activity details.
    263263    $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), 'show_hidden' => true, 'spam' => 'ham_only', ) );
    264264
     
    272272    }
    273273
    274     // Default access is true
     274    // Default access is true.
    275275    $has_access = true;
    276276
    277     // If activity is from a group, do an extra cap check
     277    // If activity is from a group, do an extra cap check.
    278278    if ( isset( $bp->groups->id ) && $activity->component == $bp->groups->id ) {
    279279
    280         // Activity is from a group, but groups is currently disabled
     280        // Activity is from a group, but groups is currently disabled.
    281281        if ( !bp_is_active( 'groups') ) {
    282282            bp_do_404();
     
    285285
    286286        // Check to see if the group is not public, if so, check the
    287         // user has access to see this activity
     287        // user has access to see this activity.
    288288        if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
    289289
    290             // Group is not public
     290            // Group is not public.
    291291            if ( 'public' != $group->status ) {
    292292
    293                 // User is not a member of group
     293                // User is not a member of group.
    294294                if ( !groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) {
    295295                    $has_access = false;
     
    318318    do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
    319319
    320     // Access is specifically disallowed
     320    // Access is specifically disallowed.
    321321    if ( false === $has_access ) {
    322322
    323         // User feedback
     323        // User feedback.
    324324        bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
    325325
    326         // Redirect based on logged in status
     326        // Redirect based on logged in status.
    327327        if ( is_user_logged_in() ) {
    328328            $url = bp_loggedin_user_domain();
     
    442442    public function is_activity() {
    443443
    444         // Bail if not looking at a group
     444        // Bail if not looking at a group.
    445445        if ( ! bp_is_activity_component() )
    446446            return;
    447447
    448         // Activity Directory
     448        // Activity Directory.
    449449        if ( ! bp_displayed_user_id() && ! bp_current_action() ) {
    450450            bp_update_is_directory( true, 'activity' );
     
    457457            add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
    458458
    459         // Single activity
     459        // Single activity.
    460460        } elseif ( bp_is_single_activity() ) {
    461461            add_filter( 'bp_get_buddypress_template',                array( $this, 'single_template_hierarchy' ) );
     
    475475     *
    476476     * @param string $templates The templates from bp_get_theme_compat_templates().
    477      *
    478477     * @return array $templates Array of custom templates to look for.
    479478     */
     
    492491
    493492        // Merge new templates with existing stack
    494         // @see bp_get_theme_compat_templates()
     493        // @see bp_get_theme_compat_templates().
    495494        $templates = array_merge( (array) $new_templates, $templates );
    496495
     
    536535     *
    537536     * @param string $templates The templates from bp_get_theme_compat_templates().
    538      *
    539537     * @return array $templates Array of custom templates to look for.
    540538     */
     
    553551
    554552        // Merge new templates with existing stack
    555         // @see bp_get_theme_compat_templates()
     553        // @see bp_get_theme_compat_templates().
    556554        $templates = array_merge( (array) $new_templates, $templates );
    557555
  • trunk/src/bp-activity/bp-activity-template.php

    r10248 r10253  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    114114 */
    115115class BP_Activity_Template {
     116
    116117    /**
    117118     * The loop iterator.
     
    232233        $bp = buddypress();
    233234
    234         // Backward compatibility with old method of passing arguments
     235        // Backward compatibility with old method of passing arguments.
    235236        if ( !is_array( $args ) || func_num_args() > 1 ) {
    236237            _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
     
    285286        $this->pag_num  = bp_sanitize_pagination_arg( 'num',          $r['per_page'] );
    286287
    287         // Check if blog/forum replies are disabled
     288        // Check if blog/forum replies are disabled.
    288289        $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' );
    289290
    290         // Get an array of the logged in user's favorite activities
     291        // Get an array of the logged in user's favorite activities.
    291292        $this->my_favs = maybe_unserialize( bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ) );
    292293
    293         // Fetch specific activity items based on ID's
     294        // Fetch specific activity items based on ID's.
    294295        if ( !empty( $include ) ) {
    295296            $this->activities = bp_activity_get_specific( array(
     
    306307            ) );
    307308
    308         // Fetch all activity items
     309        // Fetch all activity items.
    309310        } else {
    310311            $this->activities = bp_activity_get( array(
     
    330331
    331332        // The total_activity_count property will be set only if a
    332         // 'count_total' query has taken place
     333        // 'count_total' query has taken place.
    333334        if ( ! is_null( $this->activities['total'] ) ) {
    334335            if ( ! $max || $max >= (int) $this->activities['total'] ) {
     
    355356        $this->full_name = bp_get_displayed_user_fullname();
    356357
    357         // Fetch parent content for activity comments so we do not have to query in the loop
     358        // Fetch parent content for activity comments so we do not have to query in the loop.
    358359        foreach ( (array) $this->activities as $activity ) {
    359360            if ( 'activity_comment' != $activity->type ) {
     
    451452            do_action( 'activity_loop_end' );
    452453
    453             // Do some cleaning up after the loop
     454            // Do some cleaning up after the loop.
    454455            $this->rewind_activities();
    455456        }
     
    478479        }
    479480
    480         // loop has just started
     481        // Loop has just started.
    481482        if ( $this->current_activity == 0 ) {
    482483
     
    605606    global $activities_template;
    606607
    607     // Get BuddyPress
     608    // Get BuddyPress.
    608609    $bp = buddypress();
    609610
    610     /** Smart Defaults ********************************************************/
    611 
    612     // User filtering
     611    /*
     612     * Smart Defaults.
     613     */
     614
     615    // User filtering.
    613616    $user_id = bp_displayed_user_id()
    614617        ? bp_displayed_user_id()
    615618        : false;
    616619
    617     // Group filtering
     620    // Group filtering.
    618621    if ( bp_is_group() ) {
    619622        $object      = $bp->groups->id;
     
    626629    }
    627630
    628     // The default scope should recognize custom slugs
     631    // The default scope should recognize custom slugs.
    629632    $scope = array_key_exists( bp_current_action(), (array) $bp->loaded_components )
    630633        ? $bp->loaded_components[ bp_current_action() ]
    631634        : bp_current_action();
    632635
    633     // Support for permalinks on single item pages: /groups/my-group/activity/124/
     636    // Support for permalinks on single item pages: /groups/my-group/activity/124/.
    634637    $include = bp_is_current_action( bp_get_activity_slug() )
    635638        ? bp_action_variable( 0 )
     
    642645    }
    643646
    644     /** Parse Args ************************************************************/
     647    /*
     648     * Parse Args.
     649     */
    645650
    646651    // Note: any params used for filtering can be a single value, or multiple
    647652    // values comma separated.
    648653    $r = bp_parse_args( $args, array(
    649         'display_comments'  => 'threaded',   // false for none, stream/threaded - show comments in the stream or threaded under items
    650         'include'           => $include,     // pass an activity_id or string of IDs comma-separated
    651         'exclude'           => false,        // pass an activity_id or string of IDs comma-separated
    652         'in'                => false,        // comma-separated list or array of activity IDs among which to search
    653         'sort'              => 'DESC',       // sort DESC or ASC
    654         'page'              => 1,            // which page to load
    655         'per_page'          => 20,           // number of items per page
    656         'page_arg'          => 'acpage',     // See https://buddypress.trac.wordpress.org/ticket/3679
    657         'max'               => false,        // max number to return
     654        'display_comments'  => 'threaded',   // False for none, stream/threaded - show comments in the stream or threaded under items.
     655        'include'           => $include,     // Pass an activity_id or string of IDs comma-separated.
     656        'exclude'           => false,        // Pass an activity_id or string of IDs comma-separated.
     657        'in'                => false,        // Comma-separated list or array of activity IDs among which to search.
     658        'sort'              => 'DESC',       // Sort DESC or ASC.
     659        'page'              => 1,            // Which page to load.
     660        'per_page'          => 20,           // Number of items per page.
     661        'page_arg'          => 'acpage',     // See https://buddypress.trac.wordpress.org/ticket/3679.
     662        'max'               => false,        // Max number to return.
    658663        'fields'            => 'all',
    659664        'count_total'       => false,
    660665        'show_hidden'       => $show_hidden, // Show activity items that are hidden site-wide?
    661         'spam'              => 'ham_only',   // Hide spammed items
    662 
    663         // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
     666        'spam'              => 'ham_only',   // Hide spammed items.
     667
     668        // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions).
    664669        'scope'             => $scope,
    665670
    666671        // Filtering
    667         'user_id'           => $user_id,     // user_id to filter on
    668         'object'            => $object,      // object to filter on e.g. groups, profile, status, friends
    669         'action'            => false,        // action to filter on e.g. activity_update, new_forum_post, profile_updated
    670         'primary_id'        => $primary_id,  // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
    671         'secondary_id'      => false,        // secondary object ID to filter on e.g. a post_id
    672         'offset'            => false,        // return only items >= this ID
    673         'since'             => false,        // return only items recorded since this Y-m-d H:i:s date
    674 
    675         'meta_query'        => false,        // filter on activity meta. See WP_Meta_Query for format
    676         'date_query'        => false,        // filter by date. See first parameter of WP_Date_Query for format
    677         'filter_query'      => false,        // advanced filtering.  See BP_Activity_Query for format
    678 
    679         // Searching
     672        'user_id'           => $user_id,     // user_id to filter on.
     673        'object'            => $object,      // Object to filter on e.g. groups, profile, status, friends.
     674        'action'            => false,        // Action to filter on e.g. activity_update, new_forum_post, profile_updated.
     675        'primary_id'        => $primary_id,  // Object ID to filter on e.g. a group_id or forum_id or blog_id etc.
     676        'secondary_id'      => false,        // Secondary object ID to filter on e.g. a post_id.
     677        'offset'            => false,        // Return only items >= this ID.
     678        'since'             => false,        // Return only items recorded since this Y-m-d H:i:s date.
     679
     680        'meta_query'        => false,        // Filter on activity meta. See WP_Meta_Query for format.
     681        'date_query'        => false,        // Filter by date. See first parameter of WP_Date_Query for format.
     682        'filter_query'      => false,        // Advanced filtering.  See BP_Activity_Query for format.
     683
     684        // Searching.
    680685        'search_terms'      => $search_terms_default,
    681686        'update_meta_cache' => true,
    682687    ), 'has_activities' );
    683688
    684     /** Smart Overrides *******************************************************/
     689    /*
     690     * Smart Overrides.
     691     */
    685692
    686693    // Translate various values for 'display_comments'
    687694    // This allows disabling comments via ?display_comments=0
    688     // or =none or =false. Final true is a strict type check. See #5029
     695    // or =none or =false. Final true is a strict type check. See #5029.
    689696    if ( in_array( $r['display_comments'], array( 0, '0', 'none', 'false' ), true ) ) {
    690697        $r['display_comments'] = false;
    691698    }
    692699
    693     // Ignore pagination if an offset is passed
     700    // Ignore pagination if an offset is passed.
    694701    if ( ! empty( $r['offset'] ) ) {
    695702        $r['page'] = 0;
    696703    }
    697704
    698     // Search terms
     705    // Search terms.
    699706    if ( ! empty( $_REQUEST['s'] ) && empty( $r['search_terms'] ) ) {
    700707        $r['search_terms'] = $_REQUEST['s'];
    701708    }
    702709
    703     // Do not exceed the maximum per page
     710    // Do not exceed the maximum per page.
    704711    if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) {
    705712        $r['per_page'] = $r['max'];
     
    741748    }
    742749
    743     /** Query *****************************************************************/
     750    /*
     751     * Query
     752     */
    744753
    745754    $activities_template = new BP_Activity_Template( $r );
     
    799808     *
    800809     * @since 2.1.0
     810     *
     811     * @return string $link
    801812     */
    802813    function bp_get_activity_load_more_link() {
     
    13171328     *
    13181329     * @todo Properly deprecate in favor of bp_activity_type() and
    1319      *      remove redundant echo
     1330     *      remove redundant echo
    13201331     *
    13211332     * @uses bp_activity_type()
     
    14611472        $bp = buddypress();
    14621473
    1463         // On activity permalink pages, default to the full-size avatar
     1474        // On activity permalink pages, default to the full-size avatar.
    14641475        $type_default = bp_is_single_activity() ? 'full' : 'thumb';
    14651476
     
    14681479        $current_activity_item = isset( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : $activities_template->activity;
    14691480
    1470         // Activity user display name
     1481        // Activity user display name.
    14711482        $dn_default  = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : '';
    14721483
    1473         // Prepend some descriptive text to alt
     1484        // Prepend some descriptive text to alt.
    14741485        $alt_default = !empty( $dn_default ) ? sprintf( __( 'Profile picture of %s', 'buddypress' ), $dn_default ) : __( 'Profile picture', 'buddypress' );
    14751486
     
    14871498        if ( !isset( $height ) && !isset( $width ) ) {
    14881499
    1489             // Backpat
     1500            // Backpat.
    14901501            if ( isset( $bp->avatar->full->height ) || isset( $bp->avatar->thumb->height ) ) {
    14911502                $height = ( 'full' == $type ) ? $bp->avatar->full->height : $bp->avatar->thumb->height;
     
    14941505            }
    14951506
    1496             // Backpat
     1507            // Backpat.
    14971508            if ( isset( $bp->avatar->full->width ) || isset( $bp->avatar->thumb->width ) ) {
    14981509                $width = ( 'full' == $type ) ? $bp->avatar->full->width : $bp->avatar->thumb->width;
     
    15871598     *     @type int|bool    $user_id Default: ID of the activity's user.
    15881599     * }
    1589      * @return string The secondary avatar
     1600     * @return string The secondary avatar.
    15901601     */
    15911602    function bp_get_activity_secondary_avatar( $args = '' ) {
     
    16041615        extract( $r, EXTR_SKIP );
    16051616
    1606         // Set item_id and object (default to user)
     1617        // Set item_id and object (default to user).
    16071618        switch ( $activities_template->activity->component ) {
    16081619            case 'groups' :
     
    16161627                $name    = '';
    16171628
    1618                 // Only if groups is active
     1629                // Only if groups is active.
    16191630                if ( bp_is_active( 'groups' ) ) {
    16201631                    $group = groups_get_group( array(
     
    16911702        $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id );
    16921703
    1693         // If we have no item_id or object, there is no avatar to display
     1704        // If we have no item_id or object, there is no avatar to display.
    16941705        if ( empty( $item_id ) || empty( $object ) ) {
    16951706            return false;
    16961707        }
    16971708
    1698         // Get the avatar
     1709        // Get the avatar.
    16991710        $avatar = bp_core_fetch_avatar( array(
    17001711            'item_id' => $item_id,
     
    17451756 * @since 1.2.0
    17461757 *
    1747  * @param array $args See bp_get_activity_action()
     1758 * @param array $args See bp_get_activity_action().
    17481759 * @uses bp_get_activity_action()
    17491760 */
     
    17581769     *
    17591770     * @global object $activities_template {@link BP_Activity_Template}
    1760      * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.
    17611771     * @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook.
    17621772     * @uses bp_insert_activity_meta()
     
    17891799        ) );
    17901800
    1791         // Prepend the activity action meta (link, time since, etc...)
     1801        // Prepend the activity action meta (link, time since, etc...).
    17921802        if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) {
    17931803            $action = bp_insert_activity_meta( $action );
     
    18331843        global $activities_template;
    18341844
    1835         // Backwards compatibility if action is not being used
     1845        // Backwards compatibility if action is not being used.
    18361846        if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) {
    18371847            $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
     
    19251935 *
    19261936 * @param string $content The activity content.
    1927  *
    19281937 * @return string The activity content with the metadata string attached.
    19291938 */
     
    19311940    global $activities_template;
    19321941
    1933     // Strip any legacy time since placeholders from BP 1.0-1.1
     1942    // Strip any legacy time since placeholders from BP 1.0-1.1.
    19341943    $new_content = str_replace( '<span class="time-since">%s</span>', '', $content );
    19351944
    1936     // Get the time since this activity was recorded
     1945    // Get the time since this activity was recorded.
    19371946    $date_recorded  = bp_core_time_since( $activities_template->activity->date_recorded );
    19381947
     
    19491958    ) );
    19501959
    1951     // Insert the permalink
     1960    // Insert the permalink.
    19521961    if ( ! bp_is_single_activity() ) {
    19531962
    1954         // Setup variables for activity meta
     1963        // Setup variables for activity meta.
    19551964        $activity_permalink = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
    19561965        $activity_meta      = sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>',
     
    19661975         * @since 1.2.0
    19671976         *
    1968          * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component.
     1977         * @param array $value Array containing the html markup for the activity permalink, after being parsed by
     1978         *                     sprintf and current activity component.
    19691979         */
    19701980        $new_content = apply_filters_ref_array( 'bp_activity_permalink', array(
     
    19952005 *
    19962006 * @param object|bool $activity Optional. Falls back on the current item in the loop.
    1997  *
    19982007 * @return bool True if can delete, false otherwise.
    19992008 */
     
    20012010    global $activities_template;
    20022011
    2003     // Try to use current activity if none was passed
     2012    // Try to use current activity if none was passed.
    20042013    if ( empty( $activity ) && ! empty( $activities_template->activity ) ) {
    20052014        $activity = $activities_template->activity;
    20062015    }
    20072016
    2008     // If current_comment is set, we'll use that in place of the main activity
     2017    // If current_comment is set, we'll use that in place of the main activity.
    20092018    if ( isset( $activity->current_comment ) ) {
    20102019        $activity = $activity->current_comment;
    20112020    }
    20122021
    2013     // Assume the user cannot delete the activity item
     2022    // Assume the user cannot delete the activity item.
    20142023    $can_delete = false;
    20152024
    2016     // Only logged in users can delete activity
     2025    // Only logged in users can delete activity.
    20172026    if ( is_user_logged_in() ) {
    20182027
    2019         // Community moderators can always delete activity (at least for now)
     2028        // Community moderators can always delete activity (at least for now).
    20202029        if ( bp_current_user_can( 'bp_moderate' ) ) {
    20212030            $can_delete = true;
     
    20292038        }
    20302039
    2031         // Viewing a single item, and this user is an admin of that item
     2040        // Viewing a single item, and this user is an admin of that item.
    20322041        if ( bp_is_single_item() && bp_is_item_admin() ) {
    20332042            $can_delete = true;
     
    20692078     *
    20702079     * @param string $args Unused. Left over from an earlier implementation.
    2071      *
    20722080     * @return mixed False on failure, otherwise the activity parent content.
    20732081     */
     
    20752083        global $activities_template;
    20762084
    2077         // Bail if no activity on no item ID
     2085        // Bail if no activity on no item ID.
    20782086        if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
    20792087            return false;
    20802088        }
    20812089
    2082         // Get the ID of the parent activity content
     2090        // Get the ID of the parent activity content.
    20832091        $parent_id = (int) $activities_template->activity->item_id;
    20842092
    2085         // Bail if no parent content
     2093        // Bail if no parent content.
    20862094        if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
    20872095            return false;
    20882096        }
    20892097
    2090         // Bail if no action
     2098        // Bail if no action.
    20912099        if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) {
    20922100            return false;
    20932101        }
    20942102
    2095         // Content always includes action
     2103        // Content always includes action.
    20962104        $content = $activities_template->activity_parents[ $parent_id ]->action;
    20972105
    2098         // Maybe append activity content, if it exists
     2106        // Maybe append activity content, if it exists.
    20992107        if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) {
    21002108            $content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content;
    21012109        }
    21022110
    2103         // Remove the time since content for backwards compatibility
     2111        // Remove the time since content for backwards compatibility.
    21042112        $content = str_replace( '<span class="time-since">%s</span>', '', $content );
    21052113
    2106         // Remove images
     2114        // Remove images.
    21072115        $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
    21082116
     
    21392147        global $activities_template;
    21402148
    2141         // Bail if no activity on no item ID
     2149        // Bail if no activity on no item ID.
    21422150        if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) {
    21432151            return false;
    21442152        }
    21452153
    2146         // Get the ID of the parent activity content
     2154        // Get the ID of the parent activity content.
    21472155        $parent_id = (int) $activities_template->activity->item_id;
    21482156
    2149         // Bail if no parent item
     2157        // Bail if no parent item.
    21502158        if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) {
    21512159            return false;
    21522160        }
    21532161
    2154         // Bail if no parent user ID
     2162        // Bail if no parent user ID.
    21552163        if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) {
    21562164            return false;
     
    22222230     *
    22232231     * @todo deprecate $args param
    2224      *
    22252232     * @todo Given that checks for children already happen in bp_activity_recurse_comments(),
    2226      *    this function can probably be streamlined or removed.
    2227      *
    2228      * @param string $args Unused. Left over from an earlier implementation.
     2233     *       this function can probably be streamlined or removed.
    22292234     *
    22302235     * @global object $activities_template {@link BP_Activity_Template}
    22312236     * @uses bp_activity_recurse_comments()
    22322237     *
     2238     * @param string $args Unused. Left over from an earlier implementation.
    22332239     * @return bool
    22342240     */
     
    22512257         * @since 1.2.0
    22522258         *
    2253          * @param object $comment The activity object currently being recursed.
    2254          *
    22552259         * @global object $activities_template {@link BP_Activity_Template}
    22562260         * @uses locate_template()
    22572261         *
     2262         * @param object $comment The activity object currently being recursed.
    22582263         * @return bool|string
    22592264         */
     
    22792284            foreach ( (array) $comment->children as $comment_child ) {
    22802285
    2281                 // Put the comment into the global so it's available to filters
     2286                // Put the comment into the global so it's available to filters.
    22822287                $activities_template->activity->current_comment = $comment_child;
    22832288
     
    24752480        if ( isset( $activities_template->activity->current_comment->user_fullname ) ) {
    24762481
    2477             $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment );  // backward compatibility
     2482            $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment );  // Backward compatibility.
    24782483        } else {
    24792484            $name = $activities_template->activity->current_comment->display_name;
     
    26612666     * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook.
    26622667     *
    2663      * @param array $deprecated Deprecated.
    2664      *
     2668     * @param array|null $deprecated Deprecated.
    26652669     * @return int $count The activity comment count.
    26662670     */
     
    26682672        global $activities_template;
    26692673
    2670         // Deprecated notice about $args
     2674        // Deprecated notice about $args.
    26712675        if ( ! empty( $deprecated ) ) {
    26722676            _deprecated_argument( __FUNCTION__, '1.2', sprintf( __( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ), __FUNCTION__, __FILE__ ) );
    26732677        }
    26742678
    2675         // Get the count using the purpose-built recursive function
     2679        // Get the count using the purpose-built recursive function.
    26762680        $count = ! empty( $activities_template->activity->children )
    26772681            ? bp_activity_recurse_comment_count( $activities_template->activity )
     
    27012705         * @param object $comment Activity comment object.
    27022706         * @param int    $count The current iteration count.
    2703          *
    27042707         * @return int $count The activity comment count.
    27052708         */
    27062709        function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
    27072710
    2708             // Copy the count
     2711            // Copy the count.
    27092712            $new_count = $count;
    27102713
    2711             // Loop through children and recursively count comments
     2714            // Loop through children and recursively count comments.
    27122715            if ( ! empty( $comment->children ) ) {
    27132716                foreach ( (array) $comment->children as $comment ) {
     
    29472950        global $activities_template;
    29482951
    2949         // Check that comment exists
     2952        // Check that comment exists.
    29502953        $comment_id = isset( $activities_template->activity->current_comment->id )
    29512954            ? $activities_template->activity->current_comment->id
    29522955            : 0;
    29532956
    2954         // Setup the comment link
     2957        // Setup the comment link.
    29552958        $comment_link = ! empty( $comment_id )
    29562959            ? '#acomment-' .$comment_id
    29572960            : false;
    29582961
    2959         // Append comment ID to end of activity permalink
     2962        // Append comment ID to end of activity permalink.
    29602963        $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . $comment_link;
    29612964
     
    31413144        $class = 'delete-activity';
    31423145
    3143         // Determine if we're on a single activity page, and customize accordingly
     3146        // Determine if we're on a single activity page, and customize accordingly.
    31443147        if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
    31453148            $class = 'delete-activity-single';
     
    31913194        $url = trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id );
    31923195
    3193         // Determine if we're on a single activity page, and customize accordingly
     3196        // Determine if we're on a single activity page, and customize accordingly.
    31943197        if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
    31953198            $url = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url );
     
    32373240     *
    32383241     * @param int $user_id If empty, will fall back on displayed user.
    3239      *
    32403242     * @return string|bool $latest_update The activity latest update link.
    32413243     *                                    False on failure.
     
    33213323        ) );
    33223324
    3323         // Define local variable
     3325        // Define local variable.
    33243326        $component_links = array();
    33253327
    3326         // Fetch the names of components that have activity recorded in the DB
     3328        // Fetch the names of components that have activity recorded in the DB.
    33273329        $components = BP_Activity_Activity::get_recorded_components();
    33283330
     
    33333335        foreach ( (array) $components as $component ) {
    33343336
    3335             // Skip the activity comment filter
     3337            // Skip the activity comment filter.
    33363338            if ( 'activity' == $component ) {
    33373339                continue;
     
    34113413    $bp = buddypress();
    34123414
    3413     // Assume activity can be commented on
     3415    // Assume activity can be commented on.
    34143416    $can_comment = true;
    34153417
    3416     // Determine ability to comment based on activity action name
     3418    // Determine ability to comment based on activity action name.
    34173419    $activity_action = bp_get_activity_action_name();
    34183420
     
    34663468function bp_activity_can_comment_reply( $comment = false ) {
    34673469
    3468     // Assume activity can be commented on
     3470    // Assume activity can be commented on.
    34693471    $can_comment = true;
    34703472
    3471     // Check that comment exists
     3473    // Check that comment exists.
    34723474    if ( empty( $comment ) ) {
    34733475        $comment = bp_activity_current_comment();
     
    34763478    if ( ! empty( $comment ) ) {
    34773479
    3478         // Fall back on current comment in activity loop
     3480        // Fall back on current comment in activity loop.
    34793481        $comment_depth = isset( $comment->depth )
    34803482            ? intval( $comment->depth )
    34813483            : bp_activity_get_comment_depth();
    34823484
    3483         // Threading is turned on, so check the depth
     3485        // Threading is turned on, so check the depth.
    34843486        if ( get_option( 'thread_comments' ) ) {
    34853487            $can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) );
    34863488
    3487         // No threading for comment replies if no threading for comments
     3489        // No threading for comment replies if no threading for comments.
    34883490        } else {
    34893491            $can_comment = false;
     
    35483550     *
    35493551     * @param int $user_id ID of user being queried. Default: displayed user ID.
    3550      *
    35513552     * @return int The total favorite count for the specified user.
    35523553     */
     
    35553556
    35563557        if ( bp_activity_can_favorite() ) {
    3557             // Default to displayed user if none is passed
     3558            // Default to displayed user if none is passed.
    35583559            $user_id = empty( $user_id )
    35593560                ? bp_displayed_user_id()
    35603561                : $user_id;
    35613562
    3562             // Get user meta if user ID exists
     3563            // Get user meta if user ID exists.
    35633564            if ( ! empty( $user_id ) ) {
    35643565                $retval = bp_activity_total_favorites_for_user( $user_id );
     
    36003601     *
    36013602     * @param int $user_id ID of user being queried. Default: displayed user ID.
    3602      *
    36033603     * @return int The total mention count for the specified user.
    36043604     */
    36053605    function bp_get_total_mention_count_for_user( $user_id = 0 ) {
    36063606
    3607         // Default to displayed user if none is passed
     3607        // Default to displayed user if none is passed.
    36083608        $user_id = empty( $user_id )
    36093609            ? bp_displayed_user_id()
    36103610            : $user_id;
    36113611
    3612         // Get user meta if user ID exists
     3612        // Get user meta if user ID exists.
    36133613        $retval = ! empty( $user_id )
    36143614            ? bp_get_user_meta( $user_id, 'bp_new_mention_count', true )
     
    36523652    function bp_get_send_public_message_link() {
    36533653
    3654         // No link if not logged in, not looking at someone else's profile
     3654        // No link if not logged in, not looking at someone else's profile.
    36553655        if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() ) {
    36563656            $retval = '';
     
    36783678 * @param array $activity Array of activities generated from {@link bp_activity_get()}.
    36793679 * @param array $activity_ids Used for recursion purposes in this function.
    3680  *
    36813680 * @return array
    36823681 */
     
    37213720     * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook.
    37223721     *
    3723      * @param int|string|bool User ID or username.
    3724      *
     3722     * @param int|string|bool $user_id_or_username User ID or username.
    37253723     * @return string The mentioned user's display name.
    37263724     */
    37273725    function bp_get_mentioned_user_display_name( $user_id_or_username = false ) {
    37283726
    3729         // Get user display name
     3727        // Get user display name.
    37303728        $name = bp_core_get_user_displayname( $user_id_or_username );
    37313729
    3732         // If user somehow has no name, return this really lame string
     3730        // If user somehow has no name, return this really lame string.
    37333731        if ( empty( $name ) ) {
    37343732            $name = __( 'a user', 'buddypress' );
     
    38683866    ) );
    38693867
    3870     // Get the user IDs of everyone who has left a comment to the current activity item
     3868    // Get the user IDs of everyone who has left a comment to the current activity item.
    38713869    $user_ids = bp_activity_get_comments_user_ids();
    38723870    $output   = array();
     
    38763874        foreach ( (array) $user_ids as $user_id ) {
    38773875
    3878             // Skip an empty user ID
     3876            // Skip an empty user ID.
    38793877            if ( empty( $user_id ) ) {
    38803878                continue;
    38813879            }
    38823880
    3883             // Get profile link for this user
     3881            // Get profile link for this user.
    38843882            $profile_link = bp_core_get_user_domain( $user_id );
    38853883
    3886             // Get avatar for this user
     3884            // Get avatar for this user.
    38873885            $image_html   = bp_core_fetch_avatar( array(
    38883886                'item_id' => $user_id,
     
    38933891            ) );
    38943892
    3895             // If user has link & avatar, add them to the output array
     3893            // If user has link & avatar, add them to the output array.
    38963894            if ( ! empty( $profile_link ) && ! empty( $image_html ) ) {
    38973895                $output[] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $profile_link ), $image_html );
     
    38993897        }
    39003898
    3901         // If output array is not empty, wrap everything in some list items
     3899        // If output array is not empty, wrap everything in some list items.
    39023900        if ( ! empty( $output ) ) {
    39033901            $retval = '<li>' . implode( '</li><li>', $output ) . '</li>';
     
    39473945     *
    39483946     * @param array $comments Array of {@link BP_Activity_Activity} items.
    3949      *
    39503947     * @return array Array of user IDs.
    39513948     */
    39523949    function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
    39533950
    3954         // Default user ID's array
     3951        // Default user ID's array.
    39553952        $user_ids = array();
    39563953
    3957         // Loop through comments and try to get user ID's
     3954        // Loop through comments and try to get user ID's.
    39583955        if ( ! empty( $comments ) ) {
    39593956            foreach ( $comments as $comment ) {
     
    39653962                }
    39663963
    3967                 // Add user ID to array
     3964                // Add user ID to array.
    39683965                $user_ids[] = $comment->user_id;
    39693966
    3970                 // Check for commentception
     3967                // Check for commentception.
    39713968                if ( ! empty( $comment->children ) ) {
    39723969                    $user_ids = array_merge( $user_ids, bp_activity_recurse_comments_user_ids( $comment->children ) );
     
    40374034    natsort( $activities );
    40384035
    4039     // Loop through the activity types and output markup
     4036    // Loop through the activity types and output markup.
    40404037    foreach ( $activities as $type => $description ) {
    40414038
    4042         // See if we need to preselect the current type
     4039        // See if we need to preselect the current type.
    40434040        $checked  = checked(  true, in_array( $type, (array) $args['selected'] ), false );
    40444041        $selected = selected( true, in_array( $type, (array) $args['selected'] ), false );
    40454042
    4046         // Switch output based on the element
     4043        // Switch output based on the element.
    40474044        switch ( $output ) {
    40484045            case 'select' :
     
    40694066    }
    40704067
    4071     // Backpat with BP-Default for dropdown boxes only
     4068    // Backpat with BP-Default for dropdown boxes only.
    40724069    if ( 'select' === $output ) {
    40734070        do_action( 'bp_activity_filter_options' );
     
    41534150    function bp_get_member_activity_feed_link() {
    41544151
    4155         // Single member activity feed link
     4152        // Single member activity feed link.
    41564153        if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) {
    41574154            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
    41584155
    4159         // Friend feed link
     4156        // Friend feed link.
    41604157        } elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
    41614158            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
    41624159
    4163         // Group feed link
     4160        // Group feed link.
    41644161        } elseif ( bp_is_active( 'groups'  ) && bp_is_current_action( bp_get_groups_slug()  ) ) {
    41654162            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
    41664163
    4167         // Favorites activity feed link
     4164        // Favorites activity feed link.
    41684165        } elseif ( 'favorites' === bp_current_action() ) {
    41694166            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
    41704167
    4171         // Mentions activity feed link
     4168        // Mentions activity feed link.
    41724169        } elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) {
    41734170            $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
    41744171
    4175         // No feed link
     4172        // No feed link.
    41764173        } else {
    41774174            $link = '';
     
    43954392        global $activities_template;
    43964393
    4397         // Get the content, if exists
     4394        // Get the content, if exists.
    43984395        $content = ! empty( $activities_template->activity->content )
    43994396            ? $activities_template->activity->content
    44004397            : '';
    44014398
    4402         // Perform a few string conversions on the content, if it's not empty
     4399        // Perform a few string conversions on the content, if it's not empty.
    44034400        if ( ! empty( $content ) ) {
    44044401            $content = ent2ncr( convert_chars( str_replace( '%s', '', $content ) ) );
     
    44384435 *
    44394436 * @param string $context The current context. 'activity', 'member',
    4440  *                        'member_groups', 'group'.
     4437 *                        'member_groups', 'group'.
    44414438 * @uses bp_get_activity_show_filters()
    44424439 */
     
    44504447     *
    44514448     * @param string $context The current context. 'activity', 'member',
    4452      *                        'member_groups', 'group'.
     4449     *                        'member_groups', 'group'.
    44534450     *
    44544451     * @return string HTML for <option> values.
    44554452     */
    44564453    function bp_get_activity_show_filters( $context = '' ) {
    4457         // Set default context based on current page
     4454        // Set default context based on current page.
    44584455        if ( empty( $context ) ) {
    44594456
    44604457            // On member pages, default to 'member', unless this
    4461             // is a user's Groups activity
     4458            // is a user's Groups activity.
    44624459            if ( bp_is_user() ) {
    44634460                if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
     
    44674464                }
    44684465
    4469             // On individual group pages, default to 'group'
     4466            // On individual group pages, default to 'group'.
    44704467            } elseif ( bp_is_active( 'groups' ) && bp_is_group() ) {
    44714468                $context = 'group';
    44724469
    4473             // 'activity' everywhere else
     4470            // 'activity' everywhere else.
    44744471            } else {
    44754472                $context = 'activity';
     
    44874484                }
    44884485
    4489                 // Friends activity collapses two filters into one
     4486                // Friends activity collapses two filters into one.
    44904487                if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) {
    44914488                    $action['key'] = 'friendship_accepted,friendship_created';
     
    45064503        $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context );
    45074504
    4508         // Build the options output
     4505        // Build the options output.
    45094506        $output = '';
    45104507
  • trunk/src/bp-activity/classes/class-bp-activity-activity.php

    r10217 r10253  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    164164        }
    165165
    166         // Generate dynamic 'action' when possible
     166        // Generate dynamic 'action' when possible.
    167167        $action = bp_activity_generate_action_string( $this );
    168168        if ( false !== $action ) {
     
    170170
    171171        // If no callback is available, use the literal string from
    172         // the database row
     172        // the database row.
    173173        } elseif ( ! empty( $row->action ) ) {
    174174            $this->action = $row->action;
    175175
    176         // Provide a fallback to avoid PHP notices
     176        // Provide a fallback to avoid PHP notices.
    177177        } else {
    178178            $this->action = '';
     
    235235        }
    236236
    237         // If this is a new activity item, set the $id property
     237        // If this is a new activity item, set the $id property.
    238238        if ( empty( $this->id ) ) {
    239239            $this->id = $wpdb->insert_id;
     
    271271     * @param array $args {
    272272     *     An array of arguments. All items are optional.
    273      *
    274273     *     @type int          $page              Which page of results to fetch. Using page=1 without per_page will result
    275274     *                                           in no pagination. Default: 1.
     
    296295     * }
    297296     * @return array The array returned has two keys:
    298      *     - 'total' is the count of located activities
    299      *     - 'activities' is an array of the located activities
     297     *               - 'total' is the count of located activities
     298     *               - 'activities' is an array of the located activities
    300299     */
    301300    public static function get( $args = array() ) {
    302301        global $wpdb;
    303302
    304         // Backward compatibility with old method of passing arguments
     303        // Backward compatibility with old method of passing arguments.
    305304        if ( !is_array( $args ) || func_num_args() > 1 ) {
    306305            _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
     
    326325        $bp = buddypress();
    327326        $r  = wp_parse_args( $args, array(
    328             'page'              => 1,          // The current page
    329             'per_page'          => 25,         // Activity items per page
    330             'max'               => false,      // Max number of items to return
    331             'fields'            => 'all',
    332             'sort'              => 'DESC',     // ASC or DESC
    333             'exclude'           => false,      // Array of ids to exclude
    334             'in'                => false,      // Array of ids to limit query by (IN)
    335             'meta_query'        => false,      // Filter by activitymeta
    336             'date_query'        => false,      // Filter by date
    337             'filter_query'      => false,      // Advanced filtering - see BP_Activity_Query
    338             'filter'            => false,      // See self::get_filter_sql()
    339             'scope'             => false,      // Preset activity arguments
    340             'search_terms'      => false,      // Terms to search by
    341             'display_comments'  => false,      // Whether to include activity comments
    342             'show_hidden'       => false,      // Show items marked hide_sitewide
    343             'spam'              => 'ham_only', // Spam status
    344             'update_meta_cache' => true,
    345             'count_total'       => false,
     327            'page'              => 1,          // The current page.
     328            'per_page'          => 25,         // Activity items per page.
     329            'max'               => false,      // Max number of items to return.
     330            'fields'            => 'all',      // Fields to include.
     331            'sort'              => 'DESC',     // ASC or DESC.
     332            'exclude'           => false,      // Array of ids to exclude.
     333            'in'                => false,      // Array of ids to limit query by (IN).
     334            'meta_query'        => false,      // Filter by activitymeta.
     335            'date_query'        => false,      // Filter by date.
     336            'filter_query'      => false,      // Advanced filtering - see BP_Activity_Query.
     337            'filter'            => false,      // See self::get_filter_sql().
     338            'scope'             => false,      // Preset activity arguments.
     339            'search_terms'      => false,      // Terms to search by.
     340            'display_comments'  => false,      // Whether to include activity comments.
     341            'show_hidden'       => false,      // Show items marked hide_sitewide.
     342            'spam'              => 'ham_only', // Spam status.
     343            'update_meta_cache' => true,       // Whether or not to update meta cache.
     344            'count_total'       => false,      // Whether or not to use count_total.
    346345        ) );
    347346
    348         // Select conditions
     347        // Select conditions.
    349348        $select_sql = "SELECT DISTINCT a.id";
    350349
     
    353352        $join_sql   = '';
    354353
    355         // Where conditions
     354        // Where conditions.
    356355        $where_conditions = array();
    357356
    358         // Excluded types
     357        // Excluded types.
    359358        $excluded_types = array();
    360359
    361         // Scope takes precedence
     360        // Scope takes precedence.
    362361        if ( ! empty( $r['scope'] ) ) {
    363362            $scope_query = self::get_scope_query_sql( $r['scope'], $r );
    364363
    365             // Add our SQL conditions if matches were found
     364            // Add our SQL conditions if matches were found.
    366365            if ( ! empty( $scope_query['sql'] ) ) {
    367366                $where_conditions['scope_query_sql'] = $scope_query['sql'];
    368367            }
    369368
    370             // override some arguments if needed
     369            // Override some arguments if needed.
    371370            if ( ! empty( $scope_query['override'] ) ) {
    372371                $r = self::array_replace_recursive( $r, $scope_query['override'] );
    373372            }
    374373
    375         // Advanced filtering
     374        // Advanced filtering.
    376375        } elseif ( ! empty( $r['filter_query'] ) ) {
    377376            $filter_query = new BP_Activity_Query( $r['filter_query'] );
     
    382381        }
    383382
    384         // Regular filtering
     383        // Regular filtering.
    385384        if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {
    386385            $where_conditions['filter_sql'] = $filter_sql;
    387386        }
    388387
    389         // Spam
     388        // Spam.
    390389        if ( 'ham_only' == $r['spam'] ) {
    391390            $where_conditions['spam_sql'] = 'a.is_spam = 0';
     
    394393        }
    395394
    396         // Searching
     395        // Searching.
    397396        if ( $r['search_terms'] ) {
    398397            $search_terms_like = '%' . bp_esc_like( $r['search_terms'] ) . '%';
     
    400399        }
    401400
    402         // Sorting
     401        // Sorting.
    403402        $sort = $r['sort'];
    404403        if ( $sort != 'ASC' && $sort != 'DESC' ) {
     
    411410        }
    412411
    413         // Exclude specified items
     412        // Exclude specified items.
    414413        if ( ! empty( $r['exclude'] ) ) {
    415414            $exclude = implode( ',', wp_parse_id_list( $r['exclude'] ) );
     
    417416        }
    418417
    419         // The specific ids to which you want to limit the query
     418        // The specific ids to which you want to limit the query.
    420419        if ( ! empty( $r['in'] ) ) {
    421420            $in = implode( ',', wp_parse_id_list( $r['in'] ) );
     
    423422        }
    424423
    425         // Process meta_query into SQL
     424        // Process meta_query into SQL.
    426425        $meta_query_sql = self::get_meta_query_sql( $r['meta_query'] );
    427426
     
    434433        }
    435434
    436         // Process date_query into SQL
     435        // Process date_query into SQL.
    437436        $date_query_sql = self::get_date_query_sql( $r['date_query'] );
    438437
     
    449448
    450449        // Exclude 'last_activity' items unless the 'action' filter has
    451         // been explicitly set
     450        // been explicitly set.
    452451        if ( empty( $r['filter']['object'] ) ) {
    453452            $excluded_types[] = 'last_activity';
    454453        }
    455454
    456         // Build the excluded type sql part
     455        // Build the excluded type sql part.
    457456        if ( ! empty( $excluded_types ) ) {
    458457            $not_in = "'" . implode( "', '", esc_sql( $excluded_types ) ) . "'";
     
    473472        $where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
    474473
    475         // Join the where conditions together
     474        // Join the where conditions together.
    476475        $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
    477476
     
    488487            if ( false !== strpos( $where_sql, $index ) ) {
    489488                $the_index = $index;
    490                 break; // Take the first one we find
     489                break; // Take the first one we find.
    491490            }
    492491        }
     
    498497        }
    499498
    500         // Sanitize page and per_page parameters
     499        // Sanitize page and per_page parameters.
    501500        $page     = absint( $r['page']     );
    502501        $per_page = absint( $r['per_page'] );
     
    521520        if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
    522521
    523             // Legacy queries joined against the user table
     522            // Legacy queries joined against the user table.
    524523            $select_sql = "SELECT DISTINCT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
    525524            $from_sql   = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
     
    528527                $pag_sql    = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
    529528
    530                 /** this filter is documented in bp-activity/bp-activity-classes.php */
     529                /** This filter is documented in bp-activity/bp-activity-classes.php */
    531530                $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
    532531            } else {
     
    548547
    549548        } else {
    550             // Query first for activity IDs
     549            // Query first for activity IDs.
    551550            $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}";
    552551
    553552            if ( ! empty( $per_page ) && ! empty( $page ) ) {
    554553                // We query for $per_page + 1 items in order to
    555                 // populate the has_more_items flag
     554                // populate the has_more_items flag.
    556555                $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 );
    557556            }
     
    572571
    573572            // If we've fetched more than the $per_page value, we
    574             // can discard the extra now
     573            // can discard the extra now.
    575574            if ( ! empty( $per_page ) && count( $activity_ids ) === $per_page + 1 ) {
    576575                array_pop( $activity_ids );
     
    585584
    586585        if ( 'ids' !== $r['fields'] ) {
    587             // Get the fullnames of users so we don't have to query in the loop
     586            // Get the fullnames of users so we don't have to query in the loop.
    588587            $activities = self::append_user_fullnames( $activities );
    589588
    590             // Get activity meta
     589            // Get activity meta.
    591590            $activity_ids = array();
    592591            foreach ( (array) $activities as $activity ) {
     
    602601            }
    603602
    604             // Pre-fetch data associated with activity users and other objects
     603            // Pre-fetch data associated with activity users and other objects.
    605604            BP_Activity_Activity::prefetch_object_data( $activities );
    606605
    607             // Generate action strings
     606            // Generate action strings.
    608607            $activities = BP_Activity_Activity::generate_action_strings( $activities );
    609608        }
     
    611610        $retval['activities'] = $activities;
    612611
    613         // If $max is set, only return up to the max results
     612        // If $max is set, only return up to the max results.
    614613        if ( ! empty( $r['count_total'] ) ) {
    615614
     
    644643     *
    645644     * @param array $activity_ids Array of activity IDs.
    646      *
    647645     * @return array
    648646     */
     
    650648        global $wpdb;
    651649
    652         // Bail if no activity ID's passed
     650        // Bail if no activity ID's passed.
    653651        if ( empty( $activity_ids ) ) {
    654652            return array();
    655653        }
    656654
    657         // Get BuddyPress
     655        // Get BuddyPress.
    658656        $bp = buddypress();
    659657
     
    661659        $uncached_ids = bp_get_non_cached_ids( $activity_ids, 'bp_activity' );
    662660
    663         // Prime caches as necessary
     661        // Prime caches as necessary.
    664662        if ( ! empty( $uncached_ids ) ) {
    665             // Format the activity ID's for use in the query below
     663            // Format the activity ID's for use in the query below.
    666664            $uncached_ids_sql = implode( ',', wp_parse_id_list( $uncached_ids ) );
    667665
    668             // Fetch data from activity table, preserving order
     666            // Fetch data from activity table, preserving order.
    669667            $queried_adata = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$uncached_ids_sql})");
    670668
    671669            // Put that data into the placeholders created earlier,
    672             // and add it to the cache
     670            // and add it to the cache.
    673671            foreach ( (array) $queried_adata as $adata ) {
    674672                wp_cache_set( $adata->id, $adata, 'bp_activity' );
     
    676674        }
    677675
    678         // Now fetch data from the cache
     676        // Now fetch data from the cache.
    679677        foreach ( $activity_ids as $activity_id ) {
    680678            $activities[] = wp_cache_get( $activity_id, 'bp_activity' );
    681679        }
    682680
    683         // Then fetch user data
     681        // Then fetch user data.
    684682        $user_query = new BP_User_Query( array(
    685683            'user_ids'        => wp_list_pluck( $activities, 'user_id' ),
     
    687685        ) );
    688686
    689         // Associated located user data with activity items
     687        // Associated located user data with activity items.
    690688        foreach ( $activities as $a_index => $a_item ) {
    691689            $a_user_id = intval( $a_item->user_id );
     
    709707     *
    710708     * @param array $activities Activities array.
    711      *
    712709     * @return array
    713710     */
     
    750747     *
    751748     * @param array $activities Array of activities.
    752      *
    753749     * @return array $activities Array of activities.
    754750     */
     
    776772     *
    777773     * @param array $activities Array of activities.
    778      *
    779774     * @return array
    780775     */
     
    805800     * @param array $meta_query An array of meta_query filters. See the
    806801     *                          documentation for WP_Meta_Query for details.
    807      *
    808802     * @return array $sql_array 'join' and 'where' clauses.
    809803     */
     
    820814
    821815            // WP_Meta_Query expects the table name at
    822             // $wpdb->activitymeta
     816            // $wpdb->activitymeta.
    823817            $wpdb->activitymeta = buddypress()->activity->table_name_meta;
    824818
    825819            $meta_sql = $activity_meta_query->get_sql( 'activity', 'a', 'id' );
    826820
    827             // Strip the leading AND - BP handles it in get()
     821            // Strip the leading AND - BP handles it in get().
    828822            $sql_array['where'] = preg_replace( '/^\sAND/', '', $meta_sql['where'] );
    829823            $sql_array['join']  = $meta_sql['join'];
     
    846840     * @param array $date_query An array of date_query parameters. See the
    847841     *                          documentation for the first parameter of WP_Date_Query.
    848      *
    849842     * @return string
    850843     */
     
    852845        $sql = '';
    853846
    854         // Date query
     847        // Date query.
    855848        if ( ! empty( $date_query ) && is_array( $date_query ) ) {
    856849            $date_query = new BP_Date_Query( $date_query, 'date_recorded' );
     
    874867     * @param  array $r      Current activity arguments. Same as those of BP_Activity_Activity::get(),
    875868     *                       but merged with defaults.
    876      *
    877869     * @return array 'sql' WHERE SQL string and 'override' activity args.
    878870     */
    879871    public static function get_scope_query_sql( $scope = false, $r = array() ) {
    880872
    881         // Define arrays for future use
     873        // Define arrays for future use.
    882874        $query_args = array();
    883875        $override   = array();
    884876        $retval     = array();
    885877
    886         // Check for array of scopes
     878        // Check for array of scopes.
    887879        if ( is_array( $scope ) ) {
    888880            $scopes = $scope;
    889881
    890         // Explode a comma separated string of scopes
     882        // Explode a comma separated string of scopes.
    891883        } elseif ( is_string( $scope ) ) {
    892884            $scopes = explode( ',', $scope );
    893885        }
    894886
    895         // Bail if no scope passed
     887        // Bail if no scope passed.
    896888        if ( empty( $scopes ) ) {
    897889            return false;
    898890        }
    899891
    900         // Helper to easily grab the 'user_id'
     892        // Helper to easily grab the 'user_id'.
    901893        if ( ! empty( $r['filter']['user_id'] ) ) {
    902894            $r['user_id'] = $r['filter']['user_id'];
    903895        }
    904896
    905         // parse each scope; yes! we handle multiples!
     897        // Parse each scope; yes! we handle multiples!
    906898        foreach ( $scopes as $scope ) {
    907899            $scope_args = array();
     
    922914             *  @param array {
    923915             *     Activity query clauses.
    924              *
    925916             *     @type array {
    926917             *         Activity arguments for your custom scope.
     
    934925
    935926            if ( ! empty( $scope_args ) ) {
    936                 // merge override properties from other scopes
     927                // Merge override properties from other scopes
    937928                // this might be a problem...
    938929                if ( ! empty( $scope_args['override'] ) ) {
     
    941932                }
    942933
    943                 // save scope args
     934                // Save scope args.
    944935                if ( ! empty( $scope_args ) ) {
    945936                    $query_args[] = $scope_args;
     
    949940
    950941        if ( ! empty( $query_args ) ) {
    951             // set relation to OR
     942            // Set relation to OR.
    952943            $query_args['relation'] = 'OR';
    953944
     
    982973     * @param string   $sort             MySQL column sort; ASC or DESC. (Optional; default is DESC).
    983974     * @param bool     $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false).
    984      *
    985975     * @return array
    986976     */
     
    992982    /**
    993983     * Get the first activity ID that matches a set of criteria.
     984     *
     985     * @todo Should parameters be optional?
    994986     *
    995987     * @param int    $user_id           User ID to filter by.
     
    1001993     * @param string $content           Content to filter by.
    1002994     * @param string $date_recorded     Date to filter by.
    1003      *
    1004      * @todo Should parameters be optional?
    1005      *
    1006995     * @return int|bool Activity ID on success, false if none is found.
    1007996     */
     
    10741063     *     @int    $hide_sitewide     Optional. Default: false.
    10751064     * }
    1076      *
    10771065     * @return array|bool An array of deleted activity IDs on success, false on failure.
    10781066     */
     
    10951083        ) );
    10961084
    1097         // Setup empty array from where query arguments
     1085        // Setup empty array from where query arguments.
    10981086        $where_args = array();
    10991087
    1100         // ID
     1088        // ID.
    11011089        if ( ! empty( $r['id'] ) ) {
    11021090            $where_args[] = $wpdb->prepare( "id = %d", $r['id'] );
    11031091        }
    11041092
    1105         // User ID
     1093        // User ID.
    11061094        if ( ! empty( $r['user_id'] ) ) {
    11071095            $where_args[] = $wpdb->prepare( "user_id = %d", $r['user_id'] );
    11081096        }
    11091097
    1110         // Action
     1098        // Action.
    11111099        if ( ! empty( $r['action'] ) ) {
    11121100            $where_args[] = $wpdb->prepare( "action = %s", $r['action'] );
    11131101        }
    11141102
    1115         // Content
     1103        // Content.
    11161104        if ( ! empty( $r['content'] ) ) {
    11171105            $where_args[] = $wpdb->prepare( "content = %s", $r['content'] );
    11181106        }
    11191107
    1120         // Component
     1108        // Component.
    11211109        if ( ! empty( $r['component'] ) ) {
    11221110            $where_args[] = $wpdb->prepare( "component = %s", $r['component'] );
    11231111        }
    11241112
    1125         // Type
     1113        // Type.
    11261114        if ( ! empty( $r['type'] ) ) {
    11271115            $where_args[] = $wpdb->prepare( "type = %s", $r['type'] );
    11281116        }
    11291117
    1130         // Primary Link
     1118        // Primary Link.
    11311119        if ( ! empty( $r['primary_link'] ) ) {
    11321120            $where_args[] = $wpdb->prepare( "primary_link = %s", $r['primary_link'] );
    11331121        }
    11341122
    1135         // Item ID
     1123        // Item ID.
    11361124        if ( ! empty( $r['item_id'] ) ) {
    11371125            $where_args[] = $wpdb->prepare( "item_id = %d", $r['item_id'] );
    11381126        }
    11391127
    1140         // Secondary item ID
     1128        // Secondary item ID.
    11411129        if ( ! empty( $r['secondary_item_id'] ) ) {
    11421130            $where_args[] = $wpdb->prepare( "secondary_item_id = %d", $r['secondary_item_id'] );
    11431131        }
    11441132
    1145         // Date Recorded
     1133        // Date Recorded.
    11461134        if ( ! empty( $r['date_recorded'] ) ) {
    11471135            $where_args[] = $wpdb->prepare( "date_recorded = %s", $r['date_recorded'] );
    11481136        }
    11491137
    1150         // Hidden sitewide
     1138        // Hidden sitewide.
    11511139        if ( ! empty( $r['hide_sitewide'] ) ) {
    11521140            $where_args[] = $wpdb->prepare( "hide_sitewide = %d", $r['hide_sitewide'] );
    11531141        }
    11541142
    1155         // Bail if no where arguments
     1143        // Bail if no where arguments.
    11561144        if ( empty( $where_args ) ) {
    11571145            return false;
    11581146        }
    11591147
    1160         // Join the where arguments for querying
     1148        // Join the where arguments for querying.
    11611149        $where_sql = 'WHERE ' . join( ' AND ', $where_args );
    11621150
    1163         // Fetch all activities being deleted so we can perform more actions
     1151        // Fetch all activities being deleted so we can perform more actions.
    11641152        $activities = $wpdb->get_results( "SELECT * FROM {$bp->activity->table_name} {$where_sql}" );
    11651153
     
    11741162        do_action_ref_array( 'bp_activity_before_delete', array( $activities, $r ) );
    11751163
    1176         // Attempt to delete activities from the database
     1164        // Attempt to delete activities from the database.
    11771165        $deleted = $wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" );
    11781166
    1179         // Bail if nothing was deleted
     1167        // Bail if nothing was deleted.
    11801168        if ( empty( $deleted ) ) {
    11811169            return false;
     
    11921180        do_action_ref_array( 'bp_activity_after_delete', array( $activities, $r ) );
    11931181
    1194         // Pluck the activity IDs out of the $activities array
     1182        // Pluck the activity IDs out of the $activities array.
    11951183        $activity_ids = wp_parse_id_list( wp_list_pluck( $activities, 'id' ) );
    11961184
    1197         // Handle accompanying activity comments and meta deletion
     1185        // Handle accompanying activity comments and meta deletion.
    11981186        if ( ! empty( $activity_ids ) ) {
    11991187
    1200             // Delete all activity meta entries for activity items
     1188            // Delete all activity meta entries for activity items.
    12011189            BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
    12021190
    1203             // Setup empty array for comments
     1191            // Setup empty array for comments.
    12041192            $comment_ids = array();
    12051193
    1206             // Loop through activity ids and attempt to delete comments
     1194            // Loop through activity ids and attempt to delete comments.
    12071195            foreach ( $activity_ids as $activity_id ) {
    12081196
    1209                 // Attempt to delete comments
     1197                // Attempt to delete comments.
    12101198                $comments = BP_Activity_Activity::delete( array(
    12111199                    'type'    => 'activity_comment',
     
    12131201                ) );
    12141202
    1215                 // Merge IDs together
     1203                // Merge IDs together.
    12161204                if ( ! empty( $comments ) ) {
    12171205                    $comment_ids = array_merge( $comment_ids, $comments );
     
    12191207            }
    12201208
    1221             // Merge activity IDs with any deleted comment IDs
     1209            // Merge activity IDs with any deleted comment IDs.
    12221210            if ( ! empty( $comment_ids ) ) {
    12231211                $activity_ids = array_unique( array_merge( $activity_ids, $comment_ids ) );
     
    12381226     *
    12391227     * @param array $activity_ids Activity IDs whose comments should be deleted.
    1240      * @param bool  $delete_meta  Should we delete the activity meta items for these comments?
     1228     * @param bool  $delete_meta  Should we delete the activity meta items for these comments.
    12411229     *
    12421230     * @return bool True on success.
     
    12511239
    12521240        if ( $delete_meta ) {
    1253             // Fetch the activity comment IDs for our deleted activity items
     1241            // Fetch the activity comment IDs for our deleted activity items.
    12541242            $activity_comment_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
    12551243
     
    12681256     *
    12691257     * @param array $activity_ids Activity IDs whose meta should be deleted.
    1270      *
    12711258     * @return bool True on success.
    12721259     */
     
    12901277     * @param array  $activities Activities to fetch comments for.
    12911278     * @param string $spam       Optional. 'ham_only' (default), 'spam_only' or 'all'.
    1292      *
    12931279     * @return array The updated activities with nested comments.
    12941280     */
     
    13021288        }
    13031289
    1304         // Merge the comments with the activity items
     1290        // Merge the comments with the activity items.
    13051291        foreach ( (array) $activities as $key => $activity ) {
    13061292            if ( isset( $activity_comments[$activity->id] ) ) {
     
    13241310     * @param string $spam                Optional. 'ham_only' (default), 'spam_only' or 'all'.
    13251311     * @param int    $top_level_parent_id Optional. The id of the root-level parent activity item.
    1326      *
    13271312     * @return array The updated activities with nested comments.
    13281313     */
     
    13371322
    13381323        // We store the string 'none' to cache the fact that the
    1339         // activity item has no comments
     1324        // activity item has no comments.
    13401325        if ( 'none' === $comments ) {
    13411326            $comments = false;
    13421327
    1343         // A true cache miss
     1328        // A true cache miss.
    13441329        } elseif ( empty( $comments ) ) {
    13451330
    13461331            $bp = buddypress();
    13471332
    1348             // Select the user's fullname with the query
     1333            // Select the user's fullname with the query.
    13491334            if ( bp_is_active( 'xprofile' ) ) {
    13501335                $fullname_select = ", pd.value as user_fullname";
     
    13521337                $fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1";
    13531338
    1354             // Prevent debug errors
     1339            // Prevent debug errors.
    13551340            } else {
    13561341                $fullname_select = $fullname_from = $fullname_where = '';
    13571342            }
    13581343
    1359             // Don't retrieve activity comments marked as spam
     1344            // Don't retrieve activity comments marked as spam.
    13601345            if ( 'ham_only' == $spam ) {
    13611346                $spam_sql = 'AND a.is_spam = 0';
     
    13661351            }
    13671352
    1368             // Legacy query - not recommended
     1353            // Legacy query - not recommended.
    13691354            $func_args = func_get_args();
    13701355
     
    14071392            $ref = array();
    14081393
    1409             // Loop descendants and build an assoc array
     1394            // Loop descendants and build an assoc array.
    14101395            foreach ( (array) $descendants as $d ) {
    14111396                $d->children = array();
    14121397
    1413                 // If we have a reference on the parent
     1398                // If we have a reference on the parent.
    14141399                if ( isset( $ref[ $d->secondary_item_id ] ) ) {
    14151400                    $ref[ $d->secondary_item_id ]->children[ $d->id ] = $d;
    14161401                    $ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ];
    14171402
    1418                 // If we don't have a reference on the parent, put in the root level
     1403                // If we don't have a reference on the parent, put in the root level.
    14191404                } else {
    14201405                    $comments[ $d->id ] = $d;
     
    14231408            }
    14241409
    1425             // Calculate depth for each item
     1410            // Calculate depth for each item.
    14261411            foreach ( $ref as &$r ) {
    14271412                $depth = 1;
     
    14321417
    14331418                    // When display_comments=stream, the parent comment may not be part of the
    1434                     // returned results, so we manually fetch it
     1419                    // returned results, so we manually fetch it.
    14351420                    if ( empty( $ref[ $parent_id ] ) ) {
    14361421                        $direct_parent = new BP_Activity_Activity( $parent_id );
    14371422                        if ( isset( $direct_parent->secondary_item_id ) ) {
    14381423                            // If the direct parent is not an activity update, that means we've reached
    1439                             // the parent activity item (eg. new_blog_post)
     1424                            // the parent activity item (eg. new_blog_post).
    14401425                            if ( 'activity_update' !== $direct_parent->type ) {
    14411426                                $parent_id = $r->item_id;
     
    14461431
    14471432                        } else {
    1448                             // Something went wrong.  Short-circuit the depth calculation
     1433                            // Something went wrong.  Short-circuit the depth calculation.
    14491434                            $parent_id = $r->item_id;
    14501435                        }
     
    14881473        $bp = buddypress();
    14891474
    1490         // The right value of this node is the left value + 1
     1475        // The right value of this node is the left value + 1.
    14911476        $right = intval( $left + 1 );
    14921477
    1493         // Get all descendants of this node
     1478        // Get all descendants of this node.
    14941479        $comments    = BP_Activity_Activity::get_child_comments( $parent_id );
    14951480        $descendants = wp_list_pluck( $comments, 'id' );
    14961481
    1497         // Loop the descendants and recalculate the left and right values
     1482        // Loop the descendants and recalculate the left and right values.
    14981483        foreach ( (array) $descendants as $descendant_id ) {
    14991484            $right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant_id, $right );
     
    15011486
    15021487        // We've got the left value, and now that we've processed the children
    1503         // of this node we also know the right value
     1488        // of this node we also know the right value.
    15041489        if ( 1 === $left ) {
    15051490            $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) );
     
    15081493        }
    15091494
    1510         // Return the right value of this node + 1
     1495        // Return the right value of this node + 1.
    15111496        return intval( $right + 1 );
    15121497    }
     
    15201505     *
    15211506     * @param int $parent_id ID of an activity or activity comment.
    1522      *
    15231507     * @return object Numerically indexed array of child comments.
    15241508     */
     
    15351519     *
    15361520     * @param bool $skip_last_activity If true, components will not be
    1537      *        included if the only activity type associated with them is
    1538      *        'last_activity'. (Since 2.0.0, 'last_activity' is stored in
    1539      *        the activity table, but these items are not full-fledged
    1540      *        activity items.) Default: true.
    1541      *
     1521     *                                 included if the only activity type associated with them is
     1522     *                                 'last_activity'. (Since 2.0.0, 'last_activity' is stored in
     1523     *                                 the activity table, but these items are not full-fledged
     1524     *                                 activity items.) Default: true.
    15421525     * @return array List of component names.
    15431526     */
     
    15601543     *
    15611544     * @param int $limit Optional. Number of items to fetch. Default: 35.
    1562      *
    15631545     * @return array $activity_feed List of activity items, with RSS data added.
    15641546     */
     
    15871569     * @param string     $field The database field.
    15881570     * @param array|bool $items The values for the IN clause, or false when none are found.
    1589      *
    15901571     * @return string|bool
    15911572     */
     
    15931574        global $wpdb;
    15941575
    1595         // split items at the comma
     1576        // Split items at the comma.
    15961577        if ( ! is_array( $items ) ) {
    15971578            $items = explode( ',', $items );
    15981579        }
    15991580
    1600         // array of prepared integers or quoted strings
     1581        // Array of prepared integers or quoted strings.
    16011582        $items_prepared = array();
    16021583
    1603         // clean up and format each item
     1584        // Clean up and format each item.
    16041585        foreach ( $items as $item ) {
    1605             // clean up the string
     1586            // Clean up the string.
    16061587            $item = trim( $item );
    1607             // pass everything through prepare for security and to safely quote strings
     1588            // Pass everything through prepare for security and to safely quote strings.
    16081589            $items_prepared[] = ( is_numeric( $item ) ) ? $wpdb->prepare( '%d', $item ) : $wpdb->prepare( '%s', $item );
    16091590        }
    16101591
    1611         // build IN operator sql syntax
     1592        // Build IN operator sql syntax.
    16121593        if ( count( $items_prepared ) )
    16131594            return sprintf( '%s IN ( %s )', trim( $field ), implode( ',', $items_prepared ) );
     
    16391620     *                                          given MySQL-formatted date.
    16401621     * }
    1641      *
    16421622     * @return string The filter clause, for use in a SQL query.
    16431623     */
     
    16821662
    16831663        if ( ! empty( $filter_array['since'] ) ) {
    1684             // Validate that this is a proper Y-m-d H:i:s date
    1685             // Trick: parse to UNIX date then translate back
     1664            // Validate that this is a proper Y-m-d H:i:s date.
     1665            // Trick: parse to UNIX date then translate back.
    16861666            $translated_date = date( 'Y-m-d H:i:s', strtotime( $filter_array['since'] ) );
    16871667            if ( $translated_date === $filter_array['since'] ) {
     
    17171697     *
    17181698     * @param int $user_id The ID of the user whose favorites you're counting.
    1719      *
    17201699     * @return int $value A count of the user's favorites.
    17211700     */
    17221701    public static function total_favorite_count( $user_id ) {
    17231702
    1724         // Get activities from user meta
     1703        // Get activities from user meta.
    17251704        $favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
    17261705        if ( ! empty( $favorite_activity_entries ) ) {
     
    17281707        }
    17291708
    1730         // No favorites
     1709        // No favorites.
    17311710        return 0;
    17321711    }
     
    17361715     *
    17371716     * @param string $content The content to filter by.
    1738      *
    17391717     * @return int|bool The ID of the first matching item if found, otherwise false.
    17401718     */
     
    17511729     *
    17521730     * @param int $user_id The ID of the user whose activity you want to mark hidden.
    1753      *
    17541731     * @return mixed
    17551732     */
     
    17651742     * PHP-agnostic version of {@link array_replace_recursive()}.
    17661743     *
    1767      * array_replace_recursive() is a PHP 5.3 function.  BuddyPress (and
     1744     * The array_replace_recursive() function is a PHP 5.3 function.  BuddyPress (and
    17681745     * WordPress) currently supports down to PHP 5.2, so this method is a workaround
    17691746     * for PHP 5.2.
     
    17801757     * @param  array $base         Array with keys needing to be replaced.
    17811758     * @param  array $replacements Array with the replaced keys.
    1782      *
    17831759     * @return array
    17841760     */
     
    17891765
    17901766        // PHP 5.2-compatible version
    1791         // http://php.net/manual/en/function.array-replace-recursive.php#109390
     1767        // http://php.net/manual/en/function.array-replace-recursive.php#109390.
    17921768        foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
    17931769            $bref_stack = array( &$base );
  • trunk/src/bp-activity/classes/class-bp-activity-feed.php

    r10248 r10253  
    11<?php
    22/**
    3  * BuddyPress Activity Classes
     3 * BuddyPress Activity Classes.
    44 *
    55 * @package BuddyPress
     
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    1616 * the appropriate screen.
    1717 *
     18 * @since 1.8.0
     19 *
    1820 * See {@link bp_activity_action_sitewide_feed()} as an example.
    1921 *
    2022 * @param array $args {
    21  *   @type string $id               Required. Internal id for the feed; should be alphanumeric only.
     23 *   @type string $id               Required. Internal id for the feed; should be alphanumeric only.
    2224 *   @type string $title            Optional. RSS feed title.
    2325 *   @type string $link             Optional. Relevant link for the RSS feed.
     
    3133 *   @type array  $activity_args    Optional. Arguments passed to {@link bp_has_activities()}
    3234 * }
    33  * @since 1.8.0
    3435 */
    3536class BP_Activity_Feed {
     
    4950     * Magic method for checking the existence of a certain data variable.
    5051     *
    51      * @param string $key
     52     * @param string $key Property to check.
    5253     *
    5354     * @return bool Whether or not data variable exists.
     
    5859     * Magic method for getting a certain data variable.
    5960     *
    60      * @param string $key
     61     * @param string $key Property to get.
    6162     *
    6263     * @return mixed Data in variable if available or null.
     
    9192            global $wp_query;
    9293
    93             // set feed flag to false
     94            // Set feed flag to false.
    9495            $wp_query->is_feed = false;
    9596
     
    9798        }
    9899
    99         // Setup data
     100        // Setup data.
    100101        $this->data = wp_parse_args( $args, array(
    101             // Internal identifier for the RSS feed - should be alphanumeric only
     102            // Internal identifier for the RSS feed - should be alphanumeric only.
    102103            'id'               => '',
    103104
    104             // RSS title - should be plain-text
     105            // RSS title - should be plain-text.
    105106            'title'            => '',
    106107
    107             // relevant link for the RSS feed
     108            // Relevant link for the RSS feed.
    108109            'link'             => '',
    109110
    110             // RSS description - should be plain-text
     111            // RSS description - should be plain-text.
    111112            'description'      => '',
    112113
     
    114115            // requests it again.  This is only acknowledged if the RSS client supports it
    115116            //
    116             // See: http://www.rssboard.org/rss-profile#element-channel-ttl
    117             //      http://www.kbcafe.com/rss/rssfeedstate.html#ttl
     117            // See: http://www.rssboard.org/rss-profile#element-channel-ttl.
     118            // See: http://www.kbcafe.com/rss/rssfeedstate.html#ttl.
    118119            'ttl'              => '30',
    119120
     
    121122            // clients
    122123            //
    123             // See: http://web.resource.org/rss/1.0/modules/syndication/#description
    124             //      http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule
     124            // See: http://web.resource.org/rss/1.0/modules/syndication/#description.
     125            // See: http://www.kbcafe.com/rss/rssfeedstate.html#syndicationmodule.
    125126            'update_period'    => 'hourly',
    126127            'update_frequency' => 2,
    127128
    128             // Number of items to display
     129            // Number of items to display.
    129130            'max'              => 50,
    130131
    131             // Activity arguments passed to bp_has_activities()
     132            // Activity arguments passed to bp_has_activities().
    132133            'activity_args'    => array()
    133134        ) );
     
    142143        do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
    143144
    144         // Setup class properties
     145        // Setup class properties.
    145146        $this->setup_properties();
    146147
    147         // Check if id is valid
     148        // Check if id is valid.
    148149        if ( empty( $this->id ) ) {
    149150            _doing_it_wrong( 'BP_Activity_Feed', __( "RSS feed 'id' must be defined", 'buddypress' ), 'BP 1.8' );
     
    160161        do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
    161162
    162         // Setup feed hooks
     163        // Setup feed hooks.
    163164        $this->setup_hooks();
    164165
    165         // Output the feed
     166        // Output the feed.
    166167        $this->output();
    167168
    168         // Kill the rest of the output
     169        // Kill the rest of the output.
    169170        die();
    170171    }
     
    242243        switch ( $this->id ) {
    243244
    244             // sitewide and friends feeds use the 'personal' hook
     245            // Sitewide and friends feeds use the 'personal' hook.
    245246            case 'sitewide' :
    246247            case 'friends' :
     
    275276        switch ( $this->id ) {
    276277
    277             // also output parent activity item if we're on a specific feed
     278            // Also output parent activity item if we're on a specific feed.
    278279            case 'favorites' :
    279280            case 'friends' :
     
    300301     */
    301302    protected function http_headers() {
    302         // set up some additional headers if not on a directory page
    303         // this is done b/c BP uses pseudo-pages
     303        // Set up some additional headers if not on a directory page
     304        // this is done b/c BP uses pseudo-pages.
    304305        if ( ! bp_is_directory() ) {
    305306            global $wp_query;
     
    309310        }
    310311
    311         // Set content-type
     312        // Set content-type.
    312313        @header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
    313314        send_nosniff_header();
    314315
    315         // Cache-related variables
     316        // Cache-related variables.
    316317        $last_modified      = mysql2date( 'D, d M Y H:i:s O', bp_activity_get_last_updated(), false );
    317318        $modified_timestamp = strtotime( $last_modified );
    318319        $etag               = md5( $last_modified );
    319320
    320         // Set cache-related headers
     321        // Set cache-related headers.
    321322        @header( 'Last-Modified: ' . $last_modified );
    322323        @header( 'Pragma: no-cache' );
    323324        @header( 'ETag: ' . '"' . $etag . '"' );
    324325
    325         // First commit of BuddyPress! (Easter egg)
     326        // First commit of BuddyPress! (Easter egg).
    326327        @header( 'Expires: Tue, 25 Mar 2008 17:13:55 GMT');
    327328
    328         // Get ETag from supported user agents
     329        // Get ETag from supported user agents.
    329330        if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) {
    330331            $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
    331332
    332             // Remove quotes from ETag
     333            // Remove quotes from ETag.
    333334            $client_etag = trim( $client_etag, '"' );
    334335
    335             // Strip suffixes from ETag if they exist (eg. "-gzip")
     336            // Strip suffixes from ETag if they exist (eg. "-gzip").
    336337            $etag_suffix_pos = strpos( $client_etag, '-' );
    337338            if ( ! empty( $etag_suffix_pos ) ) {
     
    339340            }
    340341
    341         // No ETag found
     342        // No ETag found.
    342343        } else {
    343344            $client_etag = false;
    344345        }
    345346
    346         // Get client last modified timestamp from supported user agents
     347        // Get client last modified timestamp from supported user agents.
    347348        $client_last_modified      = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
    348349        $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
    349350
    350         // Set 304 status if feed hasn't been updated since last fetch
     351        // Set 304 status if feed hasn't been updated since last fetch.
    351352        if ( ( $client_last_modified && $client_etag ) ?
    352353                 ( ( $client_modified_timestamp >= $modified_timestamp ) && ( $client_etag == $etag ) ) :
     
    357358        }
    358359
    359         // If feed hasn't changed as reported by the user agent, set 304 status header
     360        // If feed hasn't changed as reported by the user agent, set 304 status header.
    360361        if ( ! empty( $status ) ) {
    361362            status_header( $status );
    362363
    363             // cached response, so stop now!
     364            // Cached response, so stop now!
    364365            if ( $status == 304 ) {
    365366                exit();
  • trunk/src/bp-activity/classes/class-bp-activity-query.php

    r10248 r10253  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    5757     * @param array $query {
    5858     *     Array of query clauses.
    59      *
    6059     *     @type array {
    6160     *         @type string $column   Required. The column to query against. Basically, any DB column in the main
     
    8887     * @param string $alias An existing table alias that is compatible with the current query clause.
    8988     *                      Default: 'a'. BP_Activity_Activity::get() uses 'a', so we default to that.
    90      *
    9189     * @return string SQL fragment to append to the main WHERE clause.
    9290     */
     
    9896        $sql = $this->get_sql_clauses();
    9997
    100         // we only need the 'where' clause
     98        // We only need the 'where' clause.
    10199        //
    102         // also trim trailing "AND" clause from parent BP_Recursive_Query class
    103         // since it's not necessary for our needs
     100        // Also trim trailing "AND" clause from parent BP_Recursive_Query class
     101        // since it's not necessary for our needs.
    104102        return preg_replace( '/^\sAND/', '', $sql['where'] );
    105103    }
     
    112110     * @param  array $clause       Array of arguments belonging to the clause.
    113111     * @param  array $parent_query Parent query to which the clause belongs.
    114      *
    115112     * @return array {
    116113     *     @type array $where Array of subclauses for the WHERE statement.
     
    138135        }
    139136
    140         // default 'compare' to '=' if no valid operator is found
     137        // Default 'compare' to '=' if no valid operator is found.
    141138        if ( ! in_array( $clause['compare'], array(
    142139            '=', '!=', '>', '>=', '<', '<=',
     
    156153        $where = '';
    157154
    158         // value.
     155        // Value.
    159156        if ( isset( $clause['value'] ) ) {
    160157            if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
     
    164161            }
    165162
    166             // tinyint
     163            // Tinyint.
    167164            if ( ! empty( $column ) && true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) ) {
    168165                $sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value );
     
    170167            } else {
    171168                switch ( $compare ) {
    172                     // IN uses different syntax
     169                    // IN uses different syntax.
    173170                    case 'IN' :
    174171                    case 'NOT IN' :
     
    223220     *
    224221     * @param array $query Clause to check.
    225      *
    226222     * @return bool
    227223     */
     
    239235     *
    240236     * @param string $column The user-supplied column name.
    241      *
    242237     * @return string A validated column name value.
    243238     */
  • trunk/src/bp-blogs/bp-blogs-activity.php

    r10252 r10253  
    990990 * @since 2.0.0
    991991 *
    992  * @param bool   $retval  Are replies allowed for this activity reply?
    993  * @param object $comment The activity comment object.
     992 * @param bool         $retval  Are replies allowed for this activity reply?
     993 * @param object|array $comment The activity comment object.
    994994 *
    995995 * @return bool
  • trunk/src/bp-members/bp-members-functions.php

    r10149 r10253  
    608608 * Fetch the display name for a user.
    609609 *
    610  * @param int|string $user_id_or_username User ID or username.
     610 * @param int|string|bool $user_id_or_username User ID or username.
    611611 *
    612612 * @return string|bool The display name for the user in question, or false if
Note: See TracChangeset for help on using the changeset viewer.