Changeset 10253 for trunk/src/bp-activity/bp-activity-actions.php
- Timestamp:
- 10/12/2015 05:45:14 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-actions.php
r10077 r10253 9 9 */ 10 10 11 // Exit if accessed directly 11 // Exit if accessed directly. 12 12 defined( 'ABSPATH' ) || exit; 13 13 … … 51 51 function bp_activity_action_permalink_router() { 52 52 53 // Not viewing activity 53 // Not viewing activity. 54 54 if ( ! bp_is_activity_component() || ! bp_is_current_action( 'p' ) ) 55 55 return false; 56 56 57 // No activity to display 57 // No activity to display. 58 58 if ( ! bp_action_variable( 0 ) || ! is_numeric( bp_action_variable( 0 ) ) ) 59 59 return false; 60 60 61 // Get the activity details 61 // Get the activity details. 62 62 $activity = bp_activity_get_specific( array( 'activity_ids' => bp_action_variable( 0 ), 'show_hidden' => true ) ); 63 63 … … 70 70 } 71 71 72 // Do not redirect at default 72 // Do not redirect at default. 73 73 $redirect = false; 74 74 75 // Redirect based on the type of activity 75 // Redirect based on the type of activity. 76 76 if ( bp_is_active( 'groups' ) && $activity->component == buddypress()->groups->id ) { 77 77 78 // Activity is a user update 78 // Activity is a user update. 79 79 if ( ! empty( $activity->user_id ) ) { 80 80 $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/'; 81 81 82 // Activity is something else 82 // Activity is something else. 83 83 } else { 84 84 85 // Set redirect to group activity stream 85 // Set redirect to group activity stream. 86 86 if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) { 87 87 $redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/'; … … 89 89 } 90 90 91 // Set redirect to users' activity stream 91 // Set redirect to users' activity stream. 92 92 } elseif ( ! empty( $activity->user_id ) ) { 93 93 $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/'; 94 94 } 95 95 96 // If set, add the original query string back onto the redirect URL 96 // If set, add the original query string back onto the redirect URL. 97 97 if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { 98 98 $query_frags = array(); … … 112 112 } 113 113 114 // Redirect to the actual activity permalink page 114 // Redirect to the actual activity permalink page. 115 115 bp_core_redirect( $redirect ); 116 116 } … … 121 121 * 122 122 * @since 1.1.0 123 *124 * @param int $activity_id Activity id to be deleted. Defaults to 0.125 123 * 126 124 * @uses bp_is_activity_component() … … 135 133 * @uses bp_core_redirect() 136 134 * 135 * @param int $activity_id Activity id to be deleted. Defaults to 0. 137 136 * @return bool False on failure. 138 137 */ 139 138 function bp_activity_action_delete_activity( $activity_id = 0 ) { 140 139 141 // Not viewing activity or action is not delete 140 // Not viewing activity or action is not delete. 142 141 if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) ) 143 142 return false; … … 146 145 $activity_id = (int) bp_action_variable( 0 ); 147 146 148 // Not viewing a specific activity item 147 // Not viewing a specific activity item. 149 148 if ( empty( $activity_id ) ) 150 149 return false; 151 150 152 // Check the nonce 151 // Check the nonce. 153 152 check_admin_referer( 'bp_activity_delete_link' ); 154 153 155 // Load up the activity item 154 // Load up the activity item. 156 155 $activity = new BP_Activity_Activity( $activity_id ); 157 156 158 // Check access 157 // Check access. 159 158 if ( ! bp_activity_user_can_delete( $activity ) ) 160 159 return false; … … 170 169 do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id ); 171 170 172 // Delete the activity item and provide user feedback 171 // Delete the activity item and provide user feedback. 173 172 if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) ) 174 173 bp_core_add_message( __( 'Activity deleted successfully', 'buddypress' ) ); … … 186 185 do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id ); 187 186 188 // Check for the redirect query arg, otherwise let WP handle things 187 // Check for the redirect query arg, otherwise let WP handle things. 189 188 if ( !empty( $_GET['redirect_to'] ) ) 190 189 bp_core_redirect( esc_url( $_GET['redirect_to'] ) ); … … 200 199 * 201 200 * @param int $activity_id Activity id to be deleted. Defaults to 0. 202 *203 201 * @return bool False on failure. 204 202 */ … … 206 204 $bp = buddypress(); 207 205 208 // Not viewing activity, or action is not spam, or Akismet isn't present 206 // Not viewing activity, or action is not spam, or Akismet isn't present. 209 207 if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) ) 210 208 return false; … … 213 211 $activity_id = (int) bp_action_variable( 0 ); 214 212 215 // Not viewing a specific activity item 213 // Not viewing a specific activity item. 216 214 if ( empty( $activity_id ) ) 217 215 return false; … … 221 219 return false; 222 220 223 // Load up the activity item 221 // Load up the activity item. 224 222 $activity = new BP_Activity_Activity( $activity_id ); 225 223 if ( empty( $activity->id ) ) 226 224 return false; 227 225 228 // Check nonce 226 // Check nonce. 229 227 check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id ); 230 228 … … 239 237 do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity ); 240 238 241 // Mark as spam 239 // Mark as spam. 242 240 bp_activity_mark_as_spam( $activity ); 243 241 $activity->save(); 244 242 245 // Tell the user the spamming has been successful 243 // Tell the user the spamming has been successful. 246 244 bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) ); 247 245 … … 256 254 do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id ); 257 255 258 // Check for the redirect query arg, otherwise let WP handle things 256 // Check for the redirect query arg, otherwise let WP handle things. 259 257 if ( !empty( $_GET['redirect_to'] ) ) 260 258 bp_core_redirect( esc_url( $_GET['redirect_to'] ) ); … … 287 285 function bp_activity_action_post_update() { 288 286 289 // Do not proceed if user is not logged in, not viewing activity, or not posting 287 // Do not proceed if user is not logged in, not viewing activity, or not posting. 290 288 if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) ) 291 289 return false; 292 290 293 // Check the nonce 291 // Check the nonce. 294 292 check_admin_referer( 'post_update', '_wpnonce_post_update' ); 295 293 … … 327 325 } 328 326 329 // No activity content so provide feedback and redirect 327 // No activity content so provide feedback and redirect. 330 328 if ( empty( $content ) ) { 331 329 bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' ); … … 333 331 } 334 332 335 // No existing item_id 333 // No existing item_id. 336 334 if ( empty( $item_id ) ) { 337 335 $activity_id = bp_activity_post_update( array( 'content' => $content ) ); 338 336 339 // Post to groups object 337 // Post to groups object. 340 338 } elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) { 341 339 if ( (int) $item_id ) { … … 357 355 } 358 356 359 // Provide user feedback 357 // Provide user feedback. 360 358 if ( !empty( $activity_id ) ) 361 359 bp_core_add_message( __( 'Update Posted!', 'buddypress' ) ); … … 363 361 bp_core_add_message( __( 'There was an error when posting your update. Please try again.', 'buddypress' ), 'error' ); 364 362 365 // Redirect 363 // Redirect. 366 364 bp_core_redirect( wp_get_referer() ); 367 365 } … … 391 389 return false; 392 390 393 // Check the nonce 391 // Check the nonce. 394 392 check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' ); 395 393 … … 454 452 return false; 455 453 456 // Check the nonce 454 // Check the nonce. 457 455 check_admin_referer( 'mark_favorite' ); 458 456 … … 488 486 return false; 489 487 490 // Check the nonce 488 // Check the nonce. 491 489 check_admin_referer( 'unmark_favorite' ); 492 490 … … 518 516 return false; 519 517 520 // setup the feed518 // Setup the feed. 521 519 buddypress()->activity->feed = new BP_Activity_Feed( array( 522 520 'id' => 'sitewide', … … 548 546 } 549 547 550 // setup the feed548 // Setup the feed. 551 549 buddypress()->activity->feed = new BP_Activity_Feed( array( 552 550 'id' => 'personal', … … 581 579 } 582 580 583 // setup the feed581 // Setup the feed. 584 582 buddypress()->activity->feed = new BP_Activity_Feed( array( 585 583 'id' => 'friends', … … 614 612 } 615 613 616 // get displayed user's group IDs614 // Get displayed user's group IDs. 617 615 $groups = groups_get_user_groups(); 618 616 $group_ids = implode( ',', $groups['groups'] ); 619 617 620 // setup the feed618 // Setup the feed. 621 619 buddypress()->activity->feed = new BP_Activity_Feed( array( 622 620 'id' => 'mygroups', … … 657 655 } 658 656 659 // setup the feed657 // Setup the feed. 660 658 buddypress()->activity->feed = new BP_Activity_Feed( array( 661 659 'id' => 'mentions', … … 690 688 } 691 689 692 // get displayed user's favorite activity IDs690 // Get displayed user's favorite activity IDs. 693 691 $favs = bp_activity_get_user_favorites( bp_displayed_user_id() ); 694 692 $fav_ids = implode( ',', (array) $favs ); 695 693 696 // setup the feed694 // Setup the feed. 697 695 buddypress()->activity->feed = new BP_Activity_Feed( array( 698 696 'id' => 'favorites', … … 717 715 $bp = buddypress(); 718 716 719 // Bail if Akismet is not active 717 // Bail if Akismet is not active. 720 718 if ( ! defined( 'AKISMET_VERSION' ) ) { 721 719 return; 722 720 } 723 721 724 // Bail if older version of Akismet 722 // Bail if older version of Akismet. 725 723 if ( ! class_exists( 'Akismet' ) ) { 726 724 return; 727 725 } 728 726 729 // Bail if no Akismet key is set 727 // Bail if no Akismet key is set. 730 728 if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) ) { 731 729 return; … … 743 741 } 744 742 745 // Instantiate Akismet for BuddyPress 743 // Instantiate Akismet for BuddyPress. 746 744 $bp->activity->akismet = new BP_Akismet(); 747 745 } … … 828 826 // Unpublishing a previously published post. 829 827 } elseif ( 'publish' === $old_status ) { 830 // Some form of pending status - only remove the activity entry 828 // Some form of pending status - only remove the activity entry. 831 829 bp_activity_post_type_unpublish( $post->ID, $post ); 832 830 }
Note: See TracChangeset
for help on using the changeset viewer.