[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-messages/actions/ -> star.php (source)

   1  <?php
   2  /**
   3   * Messages: Star action handler.
   4   *
   5   * @package BuddyPress
   6   * @subpackage MessageActions
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Action handler to set a message's star status for those not using JS.
  12   *
  13   * @since 2.3.0
  14   */
  15  function bp_messages_star_action_handler() {
  16      if ( ! bp_is_user_messages() ) {
  17          return;
  18      }
  19  
  20      if ( false === ( bp_is_current_action( 'unstar' ) || bp_is_current_action( 'star' ) ) ) {
  21          return;
  22      }
  23  
  24      if ( ! wp_verify_nonce( bp_action_variable( 1 ), 'bp-messages-star-' . bp_action_variable( 0 ) ) ) {
  25          wp_die( "Oops!  That's a no-no!" );
  26      }
  27  
  28      // Check capability.
  29      if ( ! is_user_logged_in() || ! bp_core_can_edit_settings() ) {
  30          return;
  31      }
  32  
  33      // Mark the star.
  34      bp_messages_star_set_action( array(
  35          'action'     => bp_current_action(),
  36          'message_id' => bp_action_variable(),
  37          'bulk'       => (bool) bp_action_variable( 2 )
  38      ) );
  39  
  40      // Redirect back to previous screen.
  41      $redirect = wp_get_referer() ? wp_get_referer() : bp_displayed_user_domain() . bp_get_messages_slug();
  42      bp_core_redirect( $redirect );
  43      die();
  44  }
  45  add_action( 'bp_actions', 'bp_messages_star_action_handler' );


Generated: Thu Nov 21 01:00:57 2024 Cross-referenced by PHPXref 0.7.1