Ticket #8304: 8304-3.patch
File 8304-3.patch, 9.5 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. … … 349 349 // Trim 'bulk_' off the action name to avoid duplicating a ton of code. 350 350 $doaction = substr( $doaction, 5 ); 351 351 352 // This is a request to delete, spam, or un-spam, a single item. 352 // This is a request to delete single or multiple item. 353 } elseif ( 'do_delete' === $doaction && ! empty( $_REQUEST['aid'] ) ) { 354 check_admin_referer( 'bp-activities-delete' ); 355 356 // This is a request to spam, or un-spam, a single item. 353 357 } elseif ( !empty( $_REQUEST['aid'] ) ) { 354 358 355 359 // Check this is a valid form submission. … … 375 379 } 376 380 377 381 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 ) ); 382 case 'do_delete' : 383 if ( 'activity_comment' === $activity->type ) { 384 $delete_result = bp_activity_delete_comment( $activity->item_id, $activity->id ); 385 } else { 386 $delete_result = bp_activity_delete( array( 'id' => $activity->id ) ); 387 } 383 388 384 $deleted++; 389 if ( ! $delete_result ) { 390 $errors[] = $activity->id; 391 } else { 392 $deleted++; 393 } 385 394 break; 386 395 387 396 case 'ham' : … … 396 405 $result = $activity->save(); 397 406 398 407 // Check for any error during activity save. 399 if ( ! $result ) 408 if ( ! $result ) { 400 409 $errors[] = $activity->id; 401 else410 } else { 402 411 $unspammed++; 412 } 403 413 break; 404 414 405 415 case 'spam' : … … 407 417 $result = $activity->save(); 408 418 409 419 // Check for any error during activity save. 410 if ( ! $result ) 420 if ( ! $result ) { 411 421 $errors[] = $activity->id; 412 else422 } else { 413 423 $spammed++; 424 } 414 425 break; 415 426 416 427 default: … … 435 446 do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $errors ), $redirect_to, $activity_ids ); 436 447 437 448 // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done. 438 if ( $spammed ) 449 if ( $spammed ) { 439 450 $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to ); 451 } 440 452 441 if ( $unspammed ) 453 if ( $unspammed ) { 442 454 $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to ); 455 } 443 456 444 if ( $deleted ) 457 if ( $deleted ) { 445 458 $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); 459 } 446 460 447 461 // If an error occurred, pass back the activity ID that failed. 448 if ( ! empty( $errors ) ) 462 if ( ! empty( $errors ) ) { 449 463 $redirect_to = add_query_arg( 'error', implode ( ',', array_map( 'absint', $errors ) ), $redirect_to ); 464 } 450 465 451 466 /** 452 467 * Filters redirect URL after activity spamming/un-spamming/deletion occurs. … … 604 619 */ 605 620 function bp_activity_admin() { 606 621 // Decide whether to load the index or edit screen. 607 $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';622 $doaction = bp_admin_list_table_current_bulk_action(); 608 623 609 624 // Display the single activity edit screen. 610 if ( 'edit' == $doaction && ! empty( $_GET['aid'] ) )625 if ( 'edit' === $doaction && ! empty( $_GET['aid'] ) ) { 611 626 bp_activity_admin_edit(); 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 613 632 // Otherwise, display the Activity index screen. 614 else633 } else { 615 634 bp_activity_admin_index(); 635 } 616 636 } 617 637 618 638 /** 639 * Display the Activity delete confirmation screen. 640 * 641 * @since 7.0.0 642 */ 643 function bp_activity_admin_delete() { 644 645 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 646 die( '-1' ); 647 } 648 649 $activity_ids = isset( $_REQUEST['aid'] ) ? $_REQUEST['aid'] : 0; 650 651 if ( ! is_array( $activity_ids ) ) { 652 $activity_ids = explode( ',', $activity_ids ); 653 } 654 655 $activities = bp_activity_get( array( 656 'in' => $activity_ids, 657 'show_hidden' => true, 658 'spam' => 'all', 659 'display_comments' => 0, 660 'per_page' => null 661 ) ); 662 663 // Create a new list of activity ids, based on those that actually exist. 664 $aids = array(); 665 foreach ( $activities['activities'] as $activity ) { 666 $aids[] = $activity->id; 667 } 668 669 $base_url = remove_query_arg( array( 'action', 'action2', 'paged', 's', '_wpnonce', 'aid' ), $_SERVER['REQUEST_URI'] ); ?> 670 671 <div class="wrap"> 672 <h1><?php esc_html_e( 'Delete Activities', 'buddypress' ) ?></h1> 673 <p><?php esc_html_e( 'You are about to delete the following activities:', 'buddypress' ) ?></p> 674 675 <ul class="bp-activity-delete-list"> 676 <?php foreach ( $activities['activities'] as $activity ) : ?> 677 <li> 678 <?php 679 $actions = bp_activity_admin_get_activity_actions(); 680 681 if ( isset( $actions[ $activity->type ] ) ) { 682 $activity_type = $actions[ $activity->type ]; 683 } else { 684 /* translators: %s: the name of the activity type */ 685 $activity_type = sprintf( __( 'Unregistered action - %s', 'buddypress' ), $activity->type ); 686 } 687 688 printf( 689 /* translators: %1$s: activity type. %2$s: activity author. %3$s: activity date and time. */ 690 __( '"%1$s" activity submitted by %2$s on %3$s', 'buddypress' ), 691 $activity_type, 692 bp_core_get_userlink( $activity->user_id ), 693 sprintf( 694 '<a href="%1$s">%2$s</a>', 695 bp_activity_get_permalink( $activity->id ), 696 date_i18n( bp_get_option( 'date_format' ), strtotime( $activity->date_recorded ) ) 697 ) 698 ); 699 ?> 700 </li> 701 <?php endforeach; ?> 702 </ul> 703 704 <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p> 705 706 <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 esc_html_e( 'Delete Permanently', 'buddypress' ) ?></a> 707 <a class="button" href="<?php echo esc_attr( $base_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a> 708 </div> 709 710 <?php 711 } 712 713 714 /** 619 715 * Display the single activity edit screen. 620 716 * 621 717 * @since 1.6.0 … … 741 837 * @param object $item Activity item. 742 838 */ 743 839 function bp_activity_admin_edit_metabox_status( $item ) { 840 $base_url = add_query_arg( array( 841 'page' => 'bp-activity', 842 'aid' => $item->id 843 ), bp_get_admin_url( 'admin.php' ) ); 744 844 ?> 745 845 746 846 <div class="submitbox" id="submitcomment"> … … 783 883 </div><!-- #minor-publishing --> 784 884 785 885 <div id="major-publishing-actions"> 886 <div id="delete-action"> 887 <a class="submitdelete deletion" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'action', 'delete', $base_url ), 'bp-activities-delete' ) ); ?>"><?php esc_html_e( 'Delete Permanently', 'buddypress' ) ?></a> 888 </div> 889 786 890 <div id="publishing-action"> 787 891 <?php submit_button( __( 'Update', 'buddypress' ), 'primary', 'save', false ); ?> 788 892 </div> -
src/bp-activity/classes/class-bp-activity-list-table.php
664 664 $actions['spam'] = sprintf( '<a href="%s">%s</a>', $spam_url, __( 'Spam', 'buddypress' ) ); 665 665 666 666 // Delete. 667 $actions['delete'] = sprintf( '<a href="% s" onclick="%s">%s</a>', $delete_url, "javascript:return confirm('" . esc_js( __( 'Are you sure?', 'buddypress' ) ) . "'); ", __( 'Delete Permanently', 'buddypress' ) );667 $actions['delete'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $delete_url ), __( 'Delete Permanently', 'buddypress' ) ); 668 668 669 669 // Start timestamp. 670 670 echo '<div class="submitted-on">';