Ticket #2002: 2002.002.diff
File 2002.002.diff, 5.5 KB (added by , 14 years ago) |
---|
-
bp-activity.php
280 280 } 281 281 add_action( 'wp', 'bp_activity_action_permalink_router', 3 ); 282 282 283 /** 284 * bp_activity_action_delete_activity() 285 * 286 * Delete specific activity item and redirect to previous page ( if applicable ). 287 * 288 * @package BuddyPress Activity 289 * @since 1.1 290 * 291 * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions 292 * to be taken before the activity is deleted. 293 * @uses bp_activity_delete() 294 * @uses bp_core_add_message() 295 * @uses bp_core_redirect() 296 * 297 * @global object $bp 298 */ 283 299 function bp_activity_action_delete_activity() { 284 300 global $bp; 285 301 … … 289 305 if ( empty( $bp->action_variables[0] ) || !is_numeric( $bp->action_variables[0] ) ) 290 306 return false; 291 307 292 / * Check the nonce */308 // Check the nonce 293 309 check_admin_referer( 'bp_activity_delete_link' ); 294 310 295 311 $activity_id = $bp->action_variables[0]; 296 312 $activity = new BP_Activity_Activity( $activity_id ); 297 313 298 / * Check access */314 // Check access 299 315 if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id ) 300 316 return false; 301 317 302 318 /* Call the action before the delete so plugins can still fetch information about it */ 303 319 do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id ); 304 320 305 /* Now delete the activity item */ 321 // Always redirect somewhere 322 $bp_redirect_to = $bp->root_domain; 323 324 // Check for the redirect query arg, otherwise let WP handle things 325 if ( isset( $_GET['bp_redirect_to'] ) ) { 326 $bp_redirect_to = $_GET['bp_redirect_to']; 327 } else { 328 $bp_redirect_to = wp_get_referer(); 329 } 330 331 // Now delete the activity item 306 332 if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) ) 307 333 bp_core_add_message( __( 'Activity deleted', 'buddypress' ) ); 308 334 else 309 335 bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' ); 310 336 311 bp_core_redirect( wp_get_referer());337 bp_core_redirect( $bp_redirect_to ); 312 338 } 313 339 add_action( 'wp', 'bp_activity_action_delete_activity', 3 ); 314 340 -
bp-themes/bp-default/_inc/ajax.php
221 221 } 222 222 add_action( 'wp_ajax_new_activity_comment', 'bp_dtheme_new_activity_comment' ); 223 223 224 /* AJAX delete an activity */ 224 /** 225 * bp_dtheme_delete_activity() 226 * 227 * Delete specific activity item via AJAX. 228 * 229 * @since 1.2 230 * 231 * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow action 232 * to be taken before the activity is deleted. 233 * @uses bp_activity_delete() 234 * 235 * @global object $bp BuddyPress global settings 236 * @return bool False on failure. True if activity deleted. 237 */ 225 238 function bp_dtheme_delete_activity() { 226 239 global $bp; 227 240 -
bp-activity/bp-activity-templatetags.php
841 841 return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component . ' ' . $activities_template->activity->type . $class ); 842 842 } 843 843 844 /** 845 * bp_activity_delete_link() 846 * 847 * Display the activity delete link. 848 * 849 * @package BuddyPress Activity 850 * @since 1.1 851 * 852 * @uses bp_get_activity_delete_link() 853 */ 844 854 function bp_activity_delete_link() { 845 855 echo bp_get_activity_delete_link(); 846 856 } 857 /** 858 * bp_get_activity_delete_link() 859 * 860 * Return the activity delete link. 861 * 862 * @package BuddyPress Activity 863 * @since 1.1 864 * 865 * @uses apply_filters() Calls 'bp_get_activity_delete_link' hook to allow altering 866 * of the activity delete link. 867 * @uses wp_nonce_url() 868 * @uses add_query_arg() 869 * @uses wp_get_referer() 870 * 871 * @global object $bp BuddyPress global settings 872 * @global object $activities_template BuddyPress Activities Template 873 * @return string Activity delete link. Contains $bp_redirect_to arg if on single activity page. 874 */ 847 875 function bp_get_activity_delete_link() { 848 876 global $activities_template, $bp; 849 877 850 return apply_filters( 'bp_get_activity_delete_link', '<a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . $activities_template->activity->id, 'bp_activity_delete_link' ) . '" class="item-button delete-activity confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>' ); 878 // Determine if we're on a single activity page, and customize accordingly 879 if ( !empty( $bp->current_component ) && $bp->current_component == BP_ACTIVITY_SLUG && !empty( $bp->current_action ) && is_numeric( $bp->current_action ) ) 880 return apply_filters( 'bp_get_activity_delete_link', '<a href="' . wp_nonce_url( add_query_arg( array( 'bp_redirect_to' => wp_get_referer() ), $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . $activities_template->activity->id ), 'bp_activity_delete_link' ) . '" class="item-button delete-single-activity confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>' ); 881 else 882 return apply_filters( 'bp_get_activity_delete_link', '<a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . $activities_template->activity->id, 'bp_activity_delete_link' ) . '" class="item-button delete-activity confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>' ); 851 883 } 852 884 853 885 function bp_activity_latest_update( $user_id = false ) {