Changeset 10253 for trunk/src/bp-activity/bp-activity-admin.php
- Timestamp:
- 10/12/2015 05:45:14 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-activity/bp-activity-admin.php (modified) (85 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-admin.php
r10248 r10253 6 6 * help text, on which this implementation is heavily based. 7 7 * 8 * @since 1.6.09 8 * @package BuddyPress 10 9 * @subpackage ActivityAdmin 10 * @since 1.6.0 11 11 */ 12 12 13 // Exit if accessed directly 13 // Exit if accessed directly. 14 14 defined( 'ABSPATH' ) || exit; 15 15 16 // Include WP's list table class 16 // Include WP's list table class. 17 17 if ( !class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); 18 18 19 // per_page screen option. Has to be hooked in extremely early.19 // Per_page screen option. Has to be hooked in extremely early. 20 20 if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-activity' == $_REQUEST['page'] ) 21 21 add_filter( 'set-screen-option', 'bp_activity_admin_screen_options', 10, 3 ); … … 28 28 function bp_activity_add_admin_menu() { 29 29 30 // Add our screen 30 // Add our screen. 31 31 $hook = add_menu_page( 32 32 _x( 'Activity', 'Admin Dashbord SWA page title', 'buddypress' ), … … 53 53 * 54 54 * @param array $custom_menus The list of top-level BP menu items. 55 *56 55 * @return array $custom_menus List of top-level BP menu items, with Activity added. 57 56 */ … … 71 70 */ 72 71 function bp_activity_admin_reply() { 73 // Check nonce 72 // Check nonce. 74 73 check_ajax_referer( 'bp-activity-admin-reply', '_ajax_nonce-bp-activity-admin-reply' ); 75 74 … … 81 80 die( '-1' ); 82 81 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. 84 83 if ( empty( $root_id ) ) 85 84 $root_id = $parent_id; 86 85 87 // Check that a reply has been entered 86 // Check that a reply has been entered. 88 87 if ( empty( $_REQUEST['content'] ) ) 89 88 die( __( 'ERROR: Please type a reply.', 'buddypress' ) ); 90 89 91 // Check parent activity exists 90 // Check parent activity exists. 92 91 $parent_activity = new BP_Activity_Activity( $parent_id ); 93 92 if ( empty( $parent_activity->component ) ) … … 99 98 die( '-1' ); 100 99 101 // Add new activity comment 100 // Add new activity comment. 102 101 $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. 104 103 'content' => $_REQUEST['content'], 105 'parent_id' => $parent_id, // ID of a parent comment 104 'parent_id' => $parent_id, // ID of a parent comment. 106 105 ) ); 107 106 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. 109 108 $new_activity = new BP_Activity_Activity( $new_activity_id ); 110 109 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. 112 111 set_current_screen( 'toplevel_page_bp-activity' ); 113 112 114 // Set up an output buffer 113 // Set up an output buffer. 115 114 ob_start(); 116 115 $list_table = new BP_Activity_List_Table(); 117 116 $list_table->single_row( (array) $new_activity ); 118 117 119 // Get table markup 118 // Get table markup. 120 119 $response = array( 121 120 'data' => ob_get_contents(), … … 126 125 ob_end_clean(); 127 126 128 // Send response 127 // Send response. 129 128 $r = new WP_Ajax_Response(); 130 129 $r->add( $response ); … … 143 142 * @param string $option Screen option name. 144 143 * @param string $new_value Screen option form value. 145 *146 144 * @return string Option value. False to abandon update. 147 145 */ … … 150 148 return $value; 151 149 152 // Per page 150 // Per page. 153 151 $new_value = (int) $new_value; 154 152 if ( $new_value < 1 || $new_value > 999 ) … … 165 163 * @param array $hidden Array of items to hide. 166 164 * @param WP_Screen $screen Screen identifier. 167 *168 165 * @return array Hidden Meta Boxes. 169 166 */ … … 172 169 return $hidden; 173 170 174 // Hide the primary link meta box by default 171 // Hide the primary link meta box by default. 175 172 $hidden = array_merge( (array) $hidden, array( 'bp_activity_itemids', 'bp_activity_link', 'bp_activity_type', 'bp_activity_userid', ) ); 176 173 … … 205 202 $bp = buddypress(); 206 203 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. 208 205 $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : 'min.'; 209 206 … … 219 216 do_action( 'bp_activity_admin_load', $doaction ); 220 217 221 // Edit screen 218 // Edit screen. 222 219 if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) { 223 // columns screen option220 // Columns screen option. 224 221 add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); 225 222 … … 243 240 ) ); 244 241 245 // Help panel - sidebar links 242 // Help panel - sidebar links. 246 243 get_current_screen()->set_help_sidebar( 247 244 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 264 261 do_action( 'bp_activity_admin_meta_boxes' ); 265 262 266 // Enqueue JavaScript files 263 // Enqueue JavaScript files. 267 264 wp_enqueue_script( 'postbox' ); 268 265 wp_enqueue_script( 'dashboard' ); 269 266 wp_enqueue_script( 'comment' ); 270 267 271 // Index screen 268 // Index screen. 272 269 } else { 273 // Create the Activity screen list table 270 // Create the Activity screen list table. 274 271 $bp_activity_list_table = new BP_Activity_List_Table(); 275 272 276 // per_page screen option273 // The per_page screen option. 277 274 add_screen_option( 'per_page', array( 'label' => _x( 'Activity', 'Activity items per page (screen options)', 'buddypress' )) ); 278 275 279 // Help panel - overview text 276 // Help panel - overview text. 280 277 get_current_screen()->add_help_tab( array( 281 278 'id' => 'bp-activity-overview', … … 286 283 ) ); 287 284 288 // Help panel - moderation text 285 // Help panel - moderation text. 289 286 get_current_screen()->add_help_tab( array( 290 287 'id' => 'bp-activity-moderating', … … 295 292 ) ); 296 293 297 // Help panel - sidebar links 294 // Help panel - sidebar links. 298 295 get_current_screen()->set_help_sidebar( 299 296 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 302 299 } 303 300 304 // Enqueue CSS and JavaScript 301 // Enqueue CSS and JavaScript. 305 302 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 ); 306 303 wp_localize_script( 'bp_activity_admin_js', 'bp_activity_admin_vars', array( … … 321 318 do_action( 'bp_activity_admin_enqueue_scripts' ); 322 319 323 // Handle spam/un-spam/delete of activities 320 // Handle spam/un-spam/delete of activities. 324 321 if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) { 325 322 326 // Build redirection URL 323 // Build redirection URL. 327 324 $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() ); 328 325 $redirect_to = add_query_arg( 'paged', $bp_activity_list_table->get_pagenum(), $redirect_to ); 329 326 330 // Get activity IDs 327 // Get activity IDs. 331 328 $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] ); 332 329 … … 342 339 // Is this a bulk request? 343 340 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. 345 342 check_admin_referer( 'bulk-activities' ); 346 343 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. 348 345 $doaction = substr( $doaction, 5 ); 349 346 … … 351 348 } elseif ( !empty( $_REQUEST['aid'] ) ) { 352 349 353 // Check this is a valid form submission 350 // Check this is a valid form submission. 354 351 check_admin_referer( 'spam-activity_' . $activity_ids[0] ); 355 352 } 356 353 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. 358 355 $deleted = $spammed = $unspammed = 0; 359 356 360 // Store any errors that occurs when updating the database items 357 // Store any errors that occurs when updating the database items. 361 358 $errors = array(); 362 359 … … 365 362 // @todo: Check the permissions on each 366 363 //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. 370 367 $activity = new BP_Activity_Activity( $activity_id ); 371 368 if ( empty( $activity->component ) ) { … … 395 392 $result = $activity->save(); 396 393 397 // Check for any error during activity save 394 // Check for any error during activity save. 398 395 if ( ! $result ) 399 396 $errors[] = $activity->id; … … 406 403 $result = $activity->save(); 407 404 408 // Check for any error during activity save 405 // Check for any error during activity save. 409 406 if ( ! $result ) 410 407 $errors[] = $activity->id; … … 417 414 } 418 415 419 // Release memory 416 // Release memory. 420 417 unset( $activity ); 421 418 } … … 444 441 $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); 445 442 446 // If an error occurred, pass back the activity ID that failed 443 // If an error occurred, pass back the activity ID that failed. 447 444 if ( ! empty( $errors ) ) 448 445 $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to ); … … 459 456 460 457 461 // Save the edit 458 // Save the edit. 462 459 } elseif ( $doaction && 'save' == $doaction ) { 463 // Build redirection URL 460 // Build redirection URL. 464 461 $redirect_to = remove_query_arg( array( 'action', 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] ); 465 462 466 // Get activity ID 463 // Get activity ID. 467 464 $activity_id = (int) $_REQUEST['aid']; 468 465 469 // Check this is a valid form submission 466 // Check this is a valid form submission. 470 467 check_admin_referer( 'edit-activity_' . $activity_id ); 471 468 472 // Get the activity from the database 469 // Get the activity from the database. 473 470 $activity = new BP_Activity_Activity( $activity_id ); 474 471 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. 476 473 if ( empty( $activity->component ) ) { 477 474 wp_redirect( $redirect_to ); … … 479 476 } 480 477 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. 484 480 $error = 0; 485 481 486 // Activity spam status 482 // Activity spam status. 487 483 $prev_spam_status = $new_spam_status = false; 488 484 if ( ! empty( $_POST['activity_status'] ) ) { … … 491 487 } 492 488 493 // Activity action 489 // Activity action. 494 490 if ( isset( $_POST['bp-activities-action'] ) ) 495 491 $activity->action = $_POST['bp-activities-action']; 496 492 497 // Activity content 493 // Activity content. 498 494 if ( isset( $_POST['bp-activities-content'] ) ) 499 495 $activity->content = $_POST['bp-activities-content']; 500 496 501 // Activity primary link 497 // Activity primary link. 502 498 if ( ! empty( $_POST['bp-activities-link'] ) ) 503 499 $activity->primary_link = $_POST['bp-activities-link']; 504 500 505 // Activity user ID 501 // Activity user ID. 506 502 if ( ! empty( $_POST['bp-activities-userid'] ) ) 507 503 $activity->user_id = (int) $_POST['bp-activities-userid']; 508 504 509 // Activity item primary ID 505 // Activity item primary ID. 510 506 if ( isset( $_POST['bp-activities-primaryid'] ) ) 511 507 $activity->item_id = (int) $_POST['bp-activities-primaryid']; 512 508 513 // Activity item secondary ID 509 // Activity item secondary ID. 514 510 if ( isset( $_POST['bp-activities-secondaryid'] ) ) 515 511 $activity->secondary_item_id = (int) $_POST['bp-activities-secondaryid']; 516 512 517 // Activity type 513 // Activity type. 518 514 if ( ! empty( $_POST['bp-activities-type'] ) ) { 519 515 $actions = bp_activity_admin_get_activity_actions(); 520 516 521 // Check that the new type is a registered activity type 517 // Check that the new type is a registered activity type. 522 518 if ( in_array( $_POST['bp-activities-type'], $actions ) ) { 523 519 $activity->type = $_POST['bp-activities-type']; … … 525 521 } 526 522 527 // Activity timestamp 523 // Activity timestamp. 528 524 if ( ! empty( $_POST['aa'] ) && ! empty( $_POST['mm'] ) && ! empty( $_POST['jj'] ) && ! empty( $_POST['hh'] ) && ! empty( $_POST['mn'] ) && ! empty( $_POST['ss'] ) ) { 529 525 $aa = $_POST['aa']; … … 541 537 $ss = ( $ss > 59 ) ? $ss -60 : $ss; 542 538 543 // Reconstruct the date into a timestamp 539 // Reconstruct the date into a timestamp. 544 540 $gmt_date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); 545 541 … … 555 551 } 556 552 557 // Save 553 // Save. 558 554 $result = $activity->save(); 559 555 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. 561 557 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 562 558 563 // Check for any error during activity save 559 // Check for any error during activity save. 564 560 if ( false === $result ) 565 561 $error = $activity->id; … … 574 570 do_action_ref_array( 'bp_activity_admin_edit_after', array( &$activity, $error ) ); 575 571 576 // If an error occurred, pass back the activity ID that failed 572 // If an error occurred, pass back the activity ID that failed. 577 573 if ( $error ) 578 574 $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to ); … … 604 600 */ 605 601 function bp_activity_admin() { 606 // Decide whether to load the index or edit screen 602 // Decide whether to load the index or edit screen. 607 603 $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : ''; 608 604 609 // Display the single activity edit screen 605 // Display the single activity edit screen. 610 606 if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) 611 607 bp_activity_admin_edit(); 612 608 613 // Otherwise, display the Activity index screen 609 // Otherwise, display the Activity index screen. 614 610 else 615 611 bp_activity_admin_index(); … … 628 624 die( '-1' ); 629 625 630 // Get the activity from the database 626 // Get the activity from the database. 631 627 $activity = bp_activity_get( array( 632 628 'in' => ! empty( $_REQUEST['aid'] ) ? (int) $_REQUEST['aid'] : 0, … … 640 636 $activity = $activity['activities'][0]; 641 637 642 // Workaround to use WP's touch_time() without duplicating that function 638 // Workaround to use WP's touch_time() without duplicating that function. 643 639 $GLOBALS['comment'] = new stdClass; 644 640 $GLOBALS['comment']->comment_date = $activity->date_recorded; … … 647 643 } 648 644 649 // Construct URL for form 645 // Construct URL for form. 650 646 $form_url = remove_query_arg( array( 'action', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] ); 651 647 $form_url = add_query_arg( 'action', 'save', $form_url ); … … 741 737 <div class="misc-pub-section curtime misc-pub-section-last"> 742 738 <?php 743 // translators: Publish box date format, see http://php.net/date739 // Translators: Publish box date format, see http://php.net/date. 744 740 $datef = __( 'M j, Y @ G:i', 'buddypress' ); 745 741 $date = date_i18n( $datef, strtotime( $item->date_recorded ) ); … … 808 804 * @since 2.0.0 809 805 * 810 * @return array 806 * @return array $actions 811 807 */ 812 808 function bp_activity_admin_get_activity_actions() { … … 822 818 } 823 819 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. 825 821 unset( $actions['friends_register_activity_action'] ); 826 822 827 // Sort array by the human-readable value 823 // Sort array by the human-readable value. 828 824 natsort( $actions ); 829 825 … … 852 848 } 853 849 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. 855 851 unset( $actions['friends_register_activity_action'] ); 856 852 857 // Sort array by the human-readable value 853 // Sort array by the human-readable value. 858 854 natsort( $actions ); 859 855 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 */ 863 861 if ( ! isset( $actions[ $selected ] ) ) { 864 862 _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' ); … … 912 910 $messages = array(); 913 911 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. 915 913 if ( ! empty( $_REQUEST['deleted'] ) || ! empty( $_REQUEST['spammed'] ) || ! empty( $_REQUEST['unspammed'] ) || ! empty( $_REQUEST['error'] ) || ! empty( $_REQUEST['updated'] ) ) { 916 914 $deleted = ! empty( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; … … 922 920 $errors = array_map( 'absint', explode( ',', $errors ) ); 923 921 924 // Make sure we don't get any empty values in $errors 922 // Make sure we don't get any empty values in $errors. 925 923 for ( $i = 0, $errors_count = count( $errors ); $i < $errors_count; $i++ ) { 926 924 if ( 0 === $errors[$i] ) { … … 929 927 } 930 928 931 // Reindex array 929 // Reindex array. 932 930 $errors = array_values( $errors ); 933 931 … … 943 941 $error_msg .= '<ul class="activity-errors">'; 944 942 945 // Display each error as a list item 943 // Display each error as a list item. 946 944 foreach ( $errors as $error ) { 947 // Translators: This is a bulleted list of item IDs 945 // Translators: This is a bulleted list of item IDs. 948 946 $error_msg .= '<li>' . sprintf( __( '#%s', 'buddypress' ), number_format_i18n( $error ) ) . '</li>'; 949 947 } … … 964 962 } 965 963 966 // Prepare the activity items for display 964 // Prepare the activity items for display. 967 965 $bp_activity_list_table->prepare_items(); 968 966 … … 989 987 </h2> 990 988 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. ?> 992 990 <?php if ( !empty( $messages ) ) : ?> 993 991 <div id="moderated" class="<?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?>"><p><?php echo implode( "<br/>\n", $messages ); ?></p></div> 994 992 <?php endif; ?> 995 993 996 <?php // Display each activity on its own row ?>994 <?php // Display each activity on its own row. ?> 997 995 <?php $bp_activity_list_table->views(); ?> 998 996 … … 1003 1001 </form> 1004 1002 1005 <?php // This markup is used for the reply form ?>1003 <?php // This markup is used for the reply form. ?> 1006 1004 <table style="display: none;"> 1007 1005 <tr id="bp-activities-container" style="display: none;"> … … 1042 1040 * What type of view is being displayed? 1043 1041 * 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 1048 1046 */ 1049 1047 public $view = 'all'; … … 1053 1051 * 1054 1052 * @since 1.6.0 1055 * @var int 1053 * @var int $spam_count 1056 1054 */ 1057 1055 public $spam_count = 0; … … 1061 1059 * 1062 1060 * @since 1.6.0 1063 * @var array 1061 * @var array $activity_user_id 1064 1062 */ 1065 1063 protected $activity_user_id = array(); … … 1068 1066 * If users can comment on blog & forum activity items. 1069 1067 * 1068 * @link https://buddypress.trac.wordpress.org/ticket/6277 1069 * 1070 1070 * @since 2.2.2 1071 * 1072 * @link https://buddypress.trac.wordpress.org/ticket/6277 1073 * 1074 * @var bool 1071 * @var bool $disable_blogforum_comments 1075 1072 */ 1076 1073 public $disable_blogforum_comments = false; … … 1083 1080 public function __construct() { 1084 1081 1085 // See if activity commenting is enabled for blog / forum activity items 1082 // See if activity commenting is enabled for blog / forum activity items. 1086 1083 $this->disable_blogforum_comments = bp_disable_blogforum_comments(); 1087 1084 … … 1102 1099 function prepare_items() { 1103 1100 1104 // Option defaults 1101 // Option defaults. 1105 1102 $filter = array(); 1106 1103 $include_id = false; … … 1109 1106 $spam = 'ham_only'; 1110 1107 1111 // Set current page 1108 // Set current page. 1112 1109 $page = $this->get_pagenum(); 1113 1110 1114 // Set per page from the screen options 1111 // Set per page from the screen options. 1115 1112 $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) ); 1116 1113 1117 // Check if we're on the "Spam" view 1114 // Check if we're on the "Spam" view. 1118 1115 if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) { 1119 1116 $spam = 'spam_only'; … … 1121 1118 } 1122 1119 1123 // Sort order 1120 // Sort order. 1124 1121 if ( !empty( $_REQUEST['order'] ) && 'desc' != $_REQUEST['order'] ) 1125 1122 $sort = 'ASC'; 1126 1123 1127 // Order by 1124 // Order by. 1128 1125 /*if ( !empty( $_REQUEST['orderby'] ) ) { 1129 1126 }*/ 1130 1127 1131 // Filter 1128 // Filter. 1132 1129 if ( !empty( $_REQUEST['activity_type'] ) ) 1133 1130 $filter = array( 'action' => $_REQUEST['activity_type'] ); … … 1141 1138 $include_id = (int) $_REQUEST['aid']; 1142 1139 1143 // Get the spam total (ignoring any search query or filter) 1140 // Get the spam total (ignoring any search query or filter). 1144 1141 $spams = bp_activity_get( array( 1145 1142 'display_comments' => 'stream', … … 1151 1148 unset( $spams ); 1152 1149 1153 // Get the activities from the database 1150 // Get the activities from the database. 1154 1151 $activities = bp_activity_get( array( 1155 1152 'display_comments' => 'stream', … … 1160 1157 'search_terms' => $search_terms, 1161 1158 'show_hidden' => true, 1162 // 'sort' => $sort,1159 // 'sort' => $sort, 1163 1160 'spam' => $spam, 1164 1161 'count_total' => 'count_query', … … 1170 1167 $activities['total'] = count( $activities['activities'] ); 1171 1168 1172 // Sort the array by the activity object's date_recorded value 1169 // Sort the array by the activity object's date_recorded value. 1173 1170 usort( $activities['activities'], create_function( '$a, $b', 'return $a->date_recorded > $b->date_recorded;' ) ); 1174 1171 } 1175 1172 1176 // bp_activity_getreturns 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. 1177 1174 $new_activities = array(); 1178 1175 foreach ( $activities['activities'] as $activity_item ) { 1179 1176 $new_activities[] = (array) $activity_item; 1180 1177 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. 1182 1179 $this->activity_user_id[$activity_item->id] = $activity_item->user_id; 1183 1180 } 1184 1181 1185 // Set raw data to display 1182 // Set raw data to display. 1186 1183 $this->items = $new_activities; 1187 1184 1188 // Store information needed for handling table pagination 1185 // Store information needed for handling table pagination. 1189 1186 $this->set_pagination_args( array( 1190 1187 'per_page' => $per_page, … … 1239 1236 * 1240 1237 * @since 1.6.0 1241 */1238 */ 1242 1239 function display() { 1243 1240 $this->display_tablenav( 'top' ); ?> … … 1398 1395 function extra_tablenav( $which ) { 1399 1396 1400 // Bail on bottom table nav 1397 // Bail on bottom table nav. 1401 1398 if ( 'bottom' === $which ) { 1402 1399 return; … … 1406 1403 $selected = ( ! empty( $_REQUEST['activity_type'] ) ) ? $_REQUEST['activity_type'] : ''; 1407 1404 1408 // Get the actions 1405 // Get the actions. 1409 1406 $activity_actions = bp_activity_get_actions(); ?> 1410 1407 … … 1422 1419 <?php 1423 1420 1424 // Skip the incorrectly named pre-1.6 action 1421 // Skip the incorrectly named pre-1.6 action. 1425 1422 if ( 'friends_register_activity_action' !== $action_key ) : ?> 1426 1423 … … 1452 1449 * @since 2.3.4 Visibility set to public for compatibility with WP < 4.0.0. 1453 1450 * 1454 * @param array $actions The list of actions 1455 * @param bool $always_visible Whether the actions should be always visible1451 * @param array $actions The list of actions. 1452 * @param bool $always_visible Whether the actions should be always visible. 1456 1453 * @return string 1457 1454 */ … … 1531 1528 */ 1532 1529 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. 1534 1531 if ( $item['is_spam'] ) 1535 1532 $item_status = 'spam'; … … 1537 1534 $item_status = 'all'; 1538 1535 1539 // Preorder items: Reply | Edit | Spam | Delete Permanently 1536 // Preorder items: Reply | Edit | Spam | Delete Permanently. 1540 1537 $actions = array( 1541 1538 'reply' => '', … … 1545 1542 ); 1546 1543 1547 // Build actions URLs 1544 // Build actions URLs. 1548 1545 $base_url = bp_get_admin_url( 'admin.php?page=bp-activity&aid=' . $item['id'] ); 1549 1546 $spam_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'spam-activity_' . $item['id'] ) ); … … 1554 1551 $spam_url = $base_url . "&action=spam&$spam_nonce"; 1555 1552 1556 // Rollover actions 1557 1553 // Rollover actions. 1558 1554 // Reply - JavaScript only; implemented by AJAX. 1559 1555 if ( 'spam' != $item_status ) { … … 1564 1560 } 1565 1561 1566 // Edit 1562 // Edit. 1567 1563 $actions['edit'] = sprintf( '<a href="%s">%s</a>', $edit_url, __( 'Edit', 'buddypress' ) ); 1568 1564 } 1569 1565 1570 // Spam/unspam 1566 // Spam/unspam. 1571 1567 if ( 'spam' == $item_status ) 1572 1568 $actions['unspam'] = sprintf( '<a href="%s">%s</a>', $ham_url, __( 'Not Spam', 'buddypress' ) ); … … 1574 1570 $actions['spam'] = sprintf( '<a href="%s">%s</a>', $spam_url, __( 'Spam', 'buddypress' ) ); 1575 1571 1576 // Delete 1572 // Delete. 1577 1573 $actions['delete'] = sprintf( '<a href="%s" onclick="%s">%s</a>', $delete_url, "javascript:return confirm('" . esc_js( __( 'Are you sure?', 'buddypress' ) ) . "'); ", __( 'Delete Permanently', 'buddypress' ) ); 1578 1574 1579 // Start timestamp 1575 // Start timestamp. 1580 1576 echo '<div class="submitted-on">'; 1581 1577 … … 1598 1594 ); 1599 1595 1600 // End timestamp 1596 // End timestamp. 1601 1597 echo '</div>'; 1602 1598 1603 // Get activity content - if not set, use the action 1599 // Get activity content - if not set, use the action. 1604 1600 if ( ! empty( $item['content'] ) ) { 1605 1601 … … 1624 1620 1625 1621 /** 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. 1627 1623 * 1628 1624 * @since 2.4.0 1629 1625 * 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. 1632 1628 */ 1633 1629 echo apply_filters( 'bp_activity_admin_comment_content', $content, $item ) . ' ' . $this->row_actions( $actions ); … … 1644 1640 */ 1645 1641 function column_response( $item ) { 1642 1646 1643 // Is $item is a root activity? 1647 1644 ?> … … 1670 1667 $root_activity_url = bp_get_admin_url( 'admin.php?page=bp-activity&aid=' . $item['id'] ); 1671 1668 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. 1673 1670 if ( $comment_count ) { 1674 1671 $title_attr = sprintf( _n( '%s related activity', '%s related activities', $comment_count, 'buddypress' ), number_format_i18n( $comment_count ) ); … … 1676 1673 } 1677 1674 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. 1679 1676 } else { 1680 1677 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 />'; … … 1695 1692 * @param array $item Information about the current row. 1696 1693 * @param string $column_name The column name. 1697 *1698 1694 * @return string 1699 1695 */ … … 1721 1717 * 1722 1718 * @param int $activity_id Activity ID to retrieve User ID for. 1723 *1724 1719 * @return int User ID of the activity item in question. 1725 1720 */ … … 1729 1724 return $this->activity_user_id[$activity_id]; 1730 1725 1731 /* *1726 /* 1732 1727 * We don't have a mapping. This means the $activity_id is not on the current 1733 1728 * page of results, so fetch its details from the database. … … 1736 1731 $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'show_hidden' => true, 'spam' => 'all', ) ); 1737 1732 1738 /* *1733 /* 1739 1734 * If, somehow, the referenced activity has been deleted, leaving its associated 1740 1735 * activities as orphans, use the logged in user's ID to avoid errors. … … 1743 1738 return bp_loggedin_user_id(); 1744 1739 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. 1746 1741 $this->activity_user_id[ $activity['activities'][0]->id ] = $activity['activities'][0]->user_id; 1747 1742 1748 // Return the user ID 1743 // Return the user ID. 1749 1744 return $activity['activities'][0]->user_id; 1750 1745 } … … 1762 1757 * 1763 1758 * @param array $item An array version of the BP_Activity_Activity object. 1764 * 1765 * @return bool 1759 * @return bool $can_comment 1766 1760 */ 1767 1761 protected function can_comment( $item ) { … … 1778 1772 } 1779 1773 1780 // activity comments supported1774 // Activity comments supported. 1781 1775 } else { 1782 // activity comment1776 // Activity comment. 1783 1777 if ( 'activity_comment' == $item['type'] ) { 1784 // blogs1778 // Blogs. 1785 1779 if ( bp_is_active( 'blogs' ) ) { 1786 // grab the parent activity entry1780 // Grab the parent activity entry. 1787 1781 $parent_activity = new BP_Activity_Activity( $item['item_id'] ); 1788 1782 1789 // fetch blog post comment depth and if the blog post's comments are open1783 // Fetch blog post comment depth and if the blog post's comments are open. 1790 1784 bp_blogs_setup_activity_loop_globals( $parent_activity ); 1791 1785 1792 // check if the activity item can be replied to1786 // Check if the activity item can be replied to. 1793 1787 if ( false === bp_blogs_can_comment_reply( true, $item ) ) { 1794 1788 $can_comment = false; … … 1796 1790 } 1797 1791 1798 // blog post1792 // Blog post. 1799 1793 } elseif ( 'new_blog_post' == $item['type'] ) { 1800 1794 if ( bp_is_active( 'blogs' ) ) { … … 1827 1821 * 1828 1822 * @param array $tree Source array. 1829 *1830 1823 * @return array Flattened array. 1831 1824 */
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)