Skip to:
Content

BuddyPress.org


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

Further documentation cleanup for Activity Component.

See #6396.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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         */
Note: See TracChangeset for help on using the changeset viewer.