Ticket #8304: 8304-2.patch
File 8304-2.patch, 8.3 KB (added by , 5 years ago) |
---|
-
src/bp-activity/admin/css/admin-rtl.css
97 97 width: 12%; 98 98 } 99 99 100 ul.bp-activity-delete-list { 101 list-style-type: disc; 102 margin: 4px 26px; 103 } 104 100 105 @media screen and (max-width: 782px) { 101 106 102 107 body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) { -
src/bp-activity/admin/css/admin.css
97 97 width: 12%; 98 98 } 99 99 100 ul.bp-activity-delete-list { 101 list-style-type: disc; 102 margin: 4px 26px; 103 } 104 100 105 @media screen and (max-width: 782px) { 101 106 102 107 body.toplevel_page_bp-activity .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) { -
src/bp-activity/bp-activity-admin.php
323 323 do_action( 'bp_activity_admin_enqueue_scripts' ); 324 324 325 325 // Handle spam/un-spam/delete of activities. 326 if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', ) ) ) {326 if ( !empty( $doaction ) && ! in_array( $doaction, array( '-1', 'edit', 'save', 'delete', 'bulk_delete' ) ) ) { 327 327 328 328 // Build redirection URL. 329 329 $redirect_to = remove_query_arg( array( 'aid', 'deleted', 'error', 'spammed', 'unspammed', ), wp_get_referer() ); … … 330 330 $redirect_to = add_query_arg( 'paged', $bp_activity_list_table->get_pagenum(), $redirect_to ); 331 331 332 332 // Get activity IDs. 333 $activity_ids = array_map( 'absint', (array)$_REQUEST['aid'] );333 $activity_ids = wp_parse_id_list( $_REQUEST['aid'] ); 334 334 335 335 /** 336 336 * Filters list of IDs being spammed/un-spammed/deleted. … … 348 348 349 349 // Trim 'bulk_' off the action name to avoid duplicating a ton of code. 350 350 $doaction = substr( $doaction, 5 ); 351 // This is a request to delete single or multiple item 352 } elseif ( 'do_delete' == $doaction && ! empty( $_REQUEST['aid'] ) ) { 353 check_admin_referer( 'bp-activities-delete' ); 351 354 352 // This is a request to delete,spam, or un-spam, a single item.355 // This is a request to spam, or un-spam, a single item. 353 356 } elseif ( !empty( $_REQUEST['aid'] ) ) { 354 357 355 358 // Check this is a valid form submission. … … 375 378 } 376 379 377 380 switch ( $doaction ) { 378 case 'delete' : 379 if ( 'activity_comment' == $activity->type ) 380 bp_activity_delete_comment( $activity->item_id, $activity->id ); 381 else 382 bp_activity_delete( array( 'id' => $activity->id ) ); 381 case 'do_delete' : 382 if ( 'activity_comment' == $activity->type ) { 383 $delete_result = bp_activity_delete_comment( $activity->item_id, $activity->id ); 384 } else { 385 $delete_result = bp_activity_delete( array( 'id' => $activity->id ) ); 386 } 383 387 384 $deleted++; 388 if ( ! $delete_result ) { 389 $errors[] = $activity->id; 390 } else { 391 $deleted++; 392 } 385 393 break; 386 394 387 395 case 'ham' : … … 396 404 $result = $activity->save(); 397 405 398 406 // Check for any error during activity save. 399 if ( ! $result ) 407 if ( ! $result ) { 400 408 $errors[] = $activity->id; 401 else409 } else { 402 410 $unspammed++; 411 } 403 412 break; 404 413 405 414 case 'spam' : … … 407 416 $result = $activity->save(); 408 417 409 418 // Check for any error during activity save. 410 if ( ! $result ) 419 if ( ! $result ) { 411 420 $errors[] = $activity->id; 412 else421 } else { 413 422 $spammed++; 423 } 414 424 break; 415 425 416 426 default: … … 435 445 do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids ); 436 446 437 447 // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done. 438 if ( $spammed ) 448 if ( $spammed ) { 439 449 $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to ); 450 } 440 451 441 if ( $unspammed ) 452 if ( $unspammed ) { 442 453 $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to ); 454 } 443 455 444 if ( $deleted ) 456 if ( $deleted ) { 445 457 $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); 458 } 446 459 447 460 // If an error occurred, pass back the activity ID that failed. 448 if ( ! empty( $errors ) ) 461 if ( ! empty( $errors ) ) { 449 462 $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to ); 463 } 450 464 451 465 /** 452 466 * Filters redirect URL after activity spamming/un-spamming/deletion occurs. … … 604 618 */ 605 619 function bp_activity_admin() { 606 620 // Decide whether to load the index or edit screen. 607 $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';621 $doaction = bp_admin_list_table_current_bulk_action(); 608 622 609 623 // Display the single activity edit screen. 610 if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) 624 if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) ) { 611 625 bp_activity_admin_edit(); 626 } 612 627 628 // Display the activty delete confirmation screen. 629 elseif ( in_array( $doaction, array( 'bulk_delete', 'delete' ) ) && ! empty( $_GET['aid'] ) ) { 630 bp_activity_admin_delete(); 631 } 632 613 633 // Otherwise, display the Activity index screen. 614 else 634 else { 615 635 bp_activity_admin_index(); 636 } 616 637 } 617 638 618 639 /** 640 * Display the Activity delete confirmation screen. 641 * 642 * @since 7.0.0 643 */ 644 function bp_activity_admin_delete() { 645 646 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 647 die( '-1' ); 648 } 649 650 $activity_ids = isset( $_REQUEST['aid'] ) ? $_REQUEST['aid'] : 0; 651 652 if ( ! is_array( $activity_ids ) ) { 653 $activity_ids = explode( ',', $activity_ids ); 654 } 655 656 $activities = bp_activity_get( array( 657 'in' => $activity_ids, 658 'show_hidden' => true, 659 'spam' => 'all', 660 'display_comments' => 0, 661 'per_page' => null 662 ) ); 663 664 // Create a new list of activity ids, based on those that actually exist. 665 $aids = array(); 666 foreach ( $activities['activities'] as $activity ) { 667 $aids[] = $activity->id; 668 } 669 670 $base_url = remove_query_arg( array( 'action', 'action2', 'paged', 's', '_wpnonce', 'aid' ), $_SERVER['REQUEST_URI'] ); ?> 671 672 <div class="wrap"> 673 <h1><?php _e( 'Delete Activities', 'buddypress' ) ?></h1> 674 <p><?php _e( 'You are about to delete the following activities:', 'buddypress' ) ?></p> 675 676 <ul class="bp-activity-delete-list"> 677 <?php foreach ( $activities['activities'] as $activity ) : ?> 678 <?php 679 if ( ! empty( $activity->content ) ) { 680 $content = apply_filters_ref_array( 'bp_get_activity_content_body', array( $activity->content, &$activity ) ); 681 } else { 682 // Emulate bp_get_activity_action(). 683 $r = array( 684 'no_timestamp' => false, 685 ); 686 $content = apply_filters_ref_array( 'bp_get_activity_action', array( $activity->action, &$activity, $r ) ); 687 } 688 ?> 689 <li><?php echo $content; ?></li> 690 <?php endforeach; ?> 691 </ul> 692 693 <p><strong><?php _e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p> 694 695 <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'do_delete', 'aid' => implode( ',', $aids ) ), $base_url ), 'bp-activities-delete' ) ); ?>"><?php _e( 'Delete Permanently', 'buddypress' ) ?></a> 696 <a class="button" href="<?php echo esc_attr( $base_url ); ?>"><?php _e( 'Cancel', 'buddypress' ) ?></a> 697 </div> 698 699 <?php 700 } 701 702 703 /** 619 704 * Display the single activity edit screen. 620 705 * 621 706 * @since 1.6.0 … … 741 826 * @param object $item Activity item. 742 827 */ 743 828 function bp_activity_admin_edit_metabox_status( $item ) { 829 $base_url = add_query_arg( array( 830 'page' => 'bp-activity', 831 'aid' => $item->id 832 ), bp_get_admin_url( 'admin.php' ) ); 744 833 ?> 745 834 746 835 <div class="submitbox" id="submitcomment"> … … 783 872 </div><!-- #minor-publishing --> 784 873 785 874 <div id="major-publishing-actions"> 875 <div id="delete-action"> 876 <a class="submitdelete deletion" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'action', 'delete', $base_url ), 'bp-activities-delete' ) ); ?>"><?php _e( 'Delete Permanently', 'buddypress' ) ?></a> 877 </div> 878 786 879 <div id="publishing-action"> 787 880 <?php submit_button( __( 'Update', 'buddypress' ), 'primary', 'save', false ); ?> 788 881 </div>