[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Messages: Bulk-manage star action handler. 4 * 5 * @package BuddyPress 6 * @subpackage MessageActions 7 * @since 3.0.0 8 */ 9 10 /** 11 * Bulk manage handler to set the star status for multiple messages. 12 * 13 * @since 2.3.0 14 */ 15 function bp_messages_star_bulk_manage_handler() { 16 if ( empty( $_POST['messages_bulk_nonce' ] ) ) { 17 return; 18 } 19 20 // Check the nonce. 21 if ( ! wp_verify_nonce( $_POST['messages_bulk_nonce'], 'messages_bulk_nonce' ) ) { 22 return; 23 } 24 25 // Check capability. 26 if ( ! is_user_logged_in() || ! bp_core_can_edit_settings() ) { 27 return; 28 } 29 30 $action = ! empty( $_POST['messages_bulk_action'] ) ? $_POST['messages_bulk_action'] : ''; 31 $threads = ! empty( $_POST['message_ids'] ) ? $_POST['message_ids'] : ''; 32 $threads = wp_parse_id_list( $threads ); 33 34 // Bail if action doesn't match our star actions or no IDs. 35 if ( false === in_array( $action, array( 'star', 'unstar' ), true ) || empty( $threads ) ) { 36 return; 37 } 38 39 // It's star time! 40 switch ( $action ) { 41 case 'star' : 42 $count = count( $threads ); 43 44 // If we're starring a thread, we only star the first message in the thread. 45 foreach ( $threads as $thread ) { 46 $thread = new BP_Messages_thread( $thread ); 47 $mids = wp_list_pluck( $thread->messages, 'id' ); 48 49 bp_messages_star_set_action( array( 50 'action' => 'star', 51 'message_id' => $mids[0], 52 ) ); 53 } 54 55 /* translators: %s: number of starred messages */ 56 bp_core_add_message( sprintf( _n( '%s message was successfully starred', '%s messages were successfully starred', $count, 'buddypress' ), $count ) ); 57 break; 58 59 case 'unstar' : 60 $count = count( $threads ); 61 62 foreach ( $threads as $thread ) { 63 bp_messages_star_set_action( array( 64 'action' => 'unstar', 65 'thread_id' => $thread, 66 'bulk' => true 67 ) ); 68 } 69 70 /* translators: %s: number of unstarred messages */ 71 bp_core_add_message( sprintf( _n( '%s message was successfully unstarred', '%s messages were successfully unstarred', $count, 'buddypress' ), $count ) ); 72 break; 73 } 74 75 // Redirect back to message box. 76 bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' ); 77 die(); 78 } 79 add_action( 'bp_actions', 'bp_messages_star_bulk_manage_handler', 5 );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Oct 14 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |