Changeset 12990 for trunk/src/bp-messages/actions/notices.php
- Timestamp:
- 07/08/2021 05:23:32 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/actions/notices.php
r11925 r12990 93 93 } 94 94 add_action( 'bp_actions', 'bp_messages_action_edit_notice' ); 95 96 /** 97 * Handle user dismissal of sitewide notices. 98 * 99 * @since 9.0.0 100 * 101 * @return bool False on failure. 102 */ 103 function bp_messages_action_dismiss_notice() { 104 105 // Bail if not viewing a notice dismissal URL. 106 if ( ! bp_is_messages_component() || ! bp_is_current_action( 'notices' ) || 'dismiss' !== sanitize_key( bp_action_variable( 0 ) ) ) { 107 return false; 108 } 109 110 // Bail if the current user isn't logged in. 111 if ( ! is_user_logged_in() ) { 112 return false; 113 } 114 115 // Check the nonce. 116 check_admin_referer( 'messages_dismiss_notice' ); 117 118 // Dismiss the notice. 119 $success = bp_messages_dismiss_sitewide_notice(); 120 121 // User feedback. 122 if ( $success ) { 123 $feedback = __( 'Notice has been dismissed.', 'buddypress' ); 124 $type = 'success'; 125 } else { 126 $feedback = __( 'There was a problem dismissing the notice.', 'buddypress'); 127 $type = 'error'; 128 } 129 130 // Add feedback message. 131 bp_core_add_message( $feedback, $type ); 132 133 // Redirect. 134 $redirect_to = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() ); 135 136 bp_core_redirect( $redirect_to ); 137 } 138 add_action( 'bp_actions', 'bp_messages_action_dismiss_notice' );
Note: See TracChangeset
for help on using the changeset viewer.