Guest User

Untitled

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