Guest User

promoted activity

a guest
Jan 16th, 2011
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.32 KB | None | 0 0
  1. function activity_is_promoted() {
  2.     echo get_activity_is_promoted();
  3. }
  4.     function get_activity_is_promoted() {
  5.         global $bp, $activities_template;
  6.  
  7.         return apply_filters( 'get_activity_is_promoted', in_array( $activities_template->activity->id, (array)$activities_template->promoted ) );
  8.     }
  9.    
  10.  
  11.  
  12.  
  13. function activity_action_mark_promoted() {
  14.     global $bp;
  15.  
  16.     if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'promoted' )
  17.         return false;
  18.  
  19.     /* Check the nonce */
  20.     check_admin_referer( 'promoted' );
  21.  
  22.     if ( activity_add_user_promoted( $bp->action_variables[0] ) )
  23.         bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) );
  24.     else
  25.         bp_core_add_message( __( 'There was an error marking that activity as a promoted, please try again.', 'buddypress' ), 'error' );
  26.  
  27.     bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] );
  28. }
  29. add_action( 'wp', 'activity_action_mark_promoted', 3 );
  30.  
  31.  
  32.  
  33.  
  34. function activity_action_remove_promoted() {
  35.     global $bp;
  36.  
  37.     if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'unpromote' )
  38.         return false;
  39.  
  40.     /* Check the nonce */
  41.     check_admin_referer( 'unpromote' );
  42.  
  43.     if ( activity_remove_user_promoted( $bp->action_variables[0] ) )
  44.         bp_core_add_message( __( 'Activity removed as promoted.', 'buddypress' ) );
  45.     else
  46.         bp_core_add_message( __( 'There was an error removing that activity as a promoted, please try again.', 'buddypress' ), 'error' );
  47.  
  48.     bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] );
  49. }
  50. add_action( 'wp', 'activity_action_remove_promoted', 3 );
  51.  
  52.  
  53.  
  54.  
  55. function activity_promoted_link() {
  56.     echo get_activity_promoted_link();
  57. }
  58.     function get_activity_promoted_link() {
  59.         global $activities_template;
  60.         return apply_filters( 'get_activity_promoted_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG . '/promoted/' . $activities_template->activity->id . '/' ), 'mark_promoted' ) );
  61.     }
  62.  
  63. function activity_unpromoted_link() {
  64.     echo get_activity_unpromoted_link();
  65. }
  66.     function get_activity_unpromoted_link() {
  67.         global $activities_template;
  68.         return apply_filters( 'get_activity_unpromoted_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG . '/unpromoted/' . $activities_template->activity->id . '/' ), 'unmark_promoted' ) );
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment