Changeset 13219
- Timestamp:
- 02/19/2024 02:39:00 AM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php
r12892 r13219 51 51 add_action( 'wporg_bbp_archived_topic', array( $this, 'clear_user_topics_count_cache' ) ); 52 52 add_action( 'wporg_bbp_unarchived_topic', array( $this, 'clear_user_topics_count_cache' ) ); 53 54 // Add bulk topic unsubscribe. 55 add_action( 'bbp_template_before_user_subscriptions', array( $this, 'bulk_topic_unsubscribe_process' ) ); 56 add_action( 'bbp_template_after_user_subscriptions', array( $this, 'bulk_topic_unsubscribe' ) ); 53 57 } 54 58 … … 609 613 } 610 614 615 /** 616 * Allow bulk unsubscribe from all topics. 617 */ 618 public function bulk_topic_unsubscribe() { 619 $user_id = bbp_get_displayed_user_id(); 620 if ( ! bbp_is_user_home() && ! current_user_can( 'edit_user', $user_id ) ) { 621 return; 622 } 623 if ( ! bbp_get_user_topic_subscriptions() ) { 624 return; 625 } 626 627 echo '<form method="post" style="margin-top: -2em;margin-bottom: 1em;">'; 628 wp_nonce_field( 'bulk_unsubscribe_' . $user_id ); 629 echo '<input type="submit" name="bulk-topic-unsub" class="button" value="' . esc_attr__( 'Unsubscribe from all topics', 'wporg-forums' ) . '">'; 630 echo '</form>'; 631 } 632 633 /** 634 * Bulk topic unsubscription handler for `bulk_topic_unsubscribe()`. 635 */ 636 public function bulk_topic_unsubscribe_process() { 637 $user_id = bbp_get_displayed_user_id(); 638 if ( 639 isset( $_POST['bulk-topic-unsub'], $_POST['_wpnonce'] ) && 640 ( bbp_is_user_home() || current_user_can( 'edit_user', $user_id ) ) && 641 wp_verify_nonce( $_POST['_wpnonce'], 'bulk_unsubscribe_' . $user_id ) 642 ) { 643 bbp_remove_user_from_all_objects( $user_id, '_bbp_subscription' ); 644 } 645 } 646 611 647 }
Note: See TracChangeset
for help on using the changeset viewer.