[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Notifications: Delete action handler. 4 * 5 * @package BuddyPress 6 * @subpackage NotificationsActions 7 * @since 3.0.0 8 */ 9 10 /** 11 * Handle deleting single notifications. 12 * 13 * @since 1.9.0 14 * 15 * @return bool 16 */ 17 function bp_notifications_action_delete() { 18 19 // Bail if not the read or unread screen. 20 if ( ! bp_is_notifications_component() || ! ( bp_is_current_action( 'read' ) || bp_is_current_action( 'unread' ) ) ) { 21 return false; 22 } 23 24 // Get the action. 25 $action = ! empty( $_GET['action'] ) ? $_GET['action'] : ''; 26 $nonce = ! empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : ''; 27 $id = ! empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : ''; 28 29 // Bail if no action or no ID. 30 if ( ( 'delete' !== $action ) || empty( $id ) || empty( $nonce ) ) { 31 return false; 32 } 33 34 // Check the nonce and delete the notification. 35 if ( bp_verify_nonce_request( 'bp_notification_delete_' . $id ) && bp_notifications_delete_notification( $id ) ) { 36 bp_core_add_message( __( 'Notification successfully deleted.', 'buddypress' ) ); 37 } else { 38 bp_core_add_message( __( 'There was a problem deleting that notification.', 'buddypress' ), 'error' ); 39 } 40 41 // URL to redirect to. 42 if ( bp_is_current_action( 'unread' ) ) { 43 $redirect = bp_get_notifications_unread_permalink( bp_displayed_user_id() ); 44 } elseif ( bp_is_current_action( 'read' ) ) { 45 $redirect = bp_get_notifications_read_permalink( bp_displayed_user_id() ); 46 } 47 48 // Redirect. 49 bp_core_redirect( $redirect ); 50 } 51 add_action( 'bp_actions', 'bp_notifications_action_delete' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 01:00:53 2024 | Cross-referenced by PHPXref 0.7.1 |