[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-notifications/actions/ -> delete.php (source)

   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      // Redirect.
  42      bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' );
  43  }
  44  add_action( 'bp_actions', 'bp_notifications_action_delete' );


Generated: Sat Dec 14 01:01:40 2019 Cross-referenced by PHPXref 0.7.1