[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Notifications: User's "Notifications" screen handler. 4 * 5 * @package BuddyPress 6 * @subpackage NotificationsScreens 7 * @since 3.0.0 8 */ 9 10 /** 11 * Catch and route the 'unread' notifications screen. 12 * 13 * @since 1.9.0 14 */ 15 function bp_notifications_screen_unread() { 16 17 /** 18 * Fires right before the loading of the notifications unread screen template file. 19 * 20 * @since 1.9.0 21 */ 22 do_action( 'bp_notifications_screen_unread' ); 23 24 /** 25 * Filters the template to load for the notifications unread screen. 26 * 27 * @since 1.9.0 28 * 29 * @param string $template Path to the notifications unread template to load. 30 */ 31 bp_core_load_template( apply_filters( 'bp_notifications_template_unread', 'members/single/home' ) ); 32 } 33 34 /** 35 * Handle marking single notifications as read. 36 * 37 * @since 1.9.0 38 * 39 * @return bool 40 */ 41 function bp_notifications_action_mark_read() { 42 43 // Bail if not the unread screen. 44 if ( ! bp_is_notifications_component() || ! bp_is_current_action( 'unread' ) ) { 45 return false; 46 } 47 48 // Get the action. 49 $action = !empty( $_GET['action'] ) ? $_GET['action'] : ''; 50 $nonce = !empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : ''; 51 $id = !empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : ''; 52 53 // Bail if no action or no ID. 54 if ( ( 'read' !== $action ) || empty( $id ) || empty( $nonce ) ) { 55 return false; 56 } 57 58 // Check the nonce and mark the notification. 59 if ( bp_verify_nonce_request( 'bp_notification_mark_read_' . $id ) && bp_notifications_mark_notification( $id, false ) ) { 60 bp_core_add_message( __( 'Notification successfully marked read.', 'buddypress' ) ); 61 } else { 62 bp_core_add_message( __( 'There was a problem marking that notification.', 'buddypress' ), 'error' ); 63 } 64 65 // Redirect. 66 bp_core_redirect( bp_get_notifications_unread_permalink( bp_displayed_user_id() ) ); 67 } 68 add_action( 'bp_actions', 'bp_notifications_action_mark_read' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |