Changeset 8710
- Timestamp:
- 07/29/2014 01:24:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r8530 r8710 64 64 */ 65 65 function bp_activity_find_mentions( $content ) { 66 66 67 $pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/'; 67 68 preg_match_all( $pattern, $content, $usernames ); 68 69 69 70 // Make sure there's only one instance of each username 70 if ( !$usernames = array_unique( $usernames[1] ) ) 71 return false; 71 $usernames = array_unique( $usernames[1] ); 72 73 // Bail if no usernames 74 if ( empty( $usernames ) ) { 75 return false; 76 } 72 77 73 78 $mentioned_users = array(); … … 83 88 } 84 89 85 if ( empty( $mentioned_users ) ) 86 return false; 90 if ( empty( $mentioned_users ) ) { 91 return false; 92 } 87 93 88 94 return $mentioned_users; … … 100 106 function bp_activity_clear_new_mentions( $user_id ) { 101 107 bp_delete_user_meta( $user_id, 'bp_new_mention_count' ); 102 bp_delete_user_meta( $user_id, 'bp_new_mentions' );108 bp_delete_user_meta( $user_id, 'bp_new_mentions' ); 103 109 } 104 110 … … 120 126 */ 121 127 function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) { 122 if ( empty( $activity_id ) ) 123 return false; 128 129 // Bail if no activity ID passed 130 if ( empty( $activity_id ) ) { 131 return false; 132 } 124 133 125 134 // Get activity object 126 $activity = new BP_Activity_Activity( (int) $activity_id );135 $activity = new BP_Activity_Activity( (int) $activity_id ); 127 136 128 137 // Try to find mentions … … 130 139 131 140 // Still empty? Stop now 132 if ( empty( $usernames ) ) 133 return false; 141 if ( empty( $usernames ) ) { 142 return false; 143 } 134 144 135 145 // Increment mention count foreach mentioned user … … 156 166 */ 157 167 function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action = 'add' ) { 158 if ( empty( $user_id ) || empty( $activity_id ) ) 159 return false; 168 169 if ( empty( $user_id ) || empty( $activity_id ) ) { 170 return false; 171 } 160 172 161 173 // Adjust the mention list and count for the member 162 174 $new_mention_count = (int) bp_get_user_meta( $user_id, 'bp_new_mention_count', true ); 163 if ( !$new_mentions = bp_get_user_meta( $user_id, 'bp_new_mentions', true ) ) 175 $new_mentions = bp_get_user_meta( $user_id, 'bp_new_mentions', true ); 176 177 // Make sure new mentions is an array 178 if ( empty( $new_mentions ) ) { 164 179 $new_mentions = array(); 180 } 165 181 166 182 switch ( $action ) { … … 322 338 * @since BuddyPress (1.1.0) 323 339 * 324 * @global object $bp BuddyPress global settings.325 340 * @uses apply_filters() To call the 'bp_activity_get_action' hook. 326 341 * … … 330 345 */ 331 346 function bp_activity_get_action( $component_id, $key ) { 332 global $bp;333 347 334 348 // Return false if any of the above values are not set 335 if ( empty( $component_id ) || empty( $key ) ) 336 return false; 337 338 return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key ); 349 if ( empty( $component_id ) || empty( $key ) ) { 350 return false; 351 } 352 353 $bp = buddypress(); 354 $retval = isset( $bp->activity->actions->{$component_id}->{$key} ) 355 ? $bp->activity->actions->{$component_id}->{$key} 356 : false; 357 358 return apply_filters( 'bp_activity_get_action', $retval, $component_id, $key ); 339 359 } 340 360 … … 353 373 $action = array_values( (array) $action ); 354 374 355 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) 375 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) { 356 376 $actions[ $action[$i]['key'] ] = $action[$i]['value']; 377 } 357 378 } 358 379 … … 379 400 380 401 // Fallback to logged in user if no user_id is passed 381 if ( empty( $user_id ) ) 402 if ( empty( $user_id ) ) { 382 403 $user_id = bp_displayed_user_id(); 404 } 383 405 384 406 // Get favorites for user … … 408 430 409 431 // Favorite activity stream items are for logged in users only 410 if ( !is_user_logged_in() ) 411 return false; 432 if ( ! is_user_logged_in() ) { 433 return false; 434 } 412 435 413 436 // Fallback to logged in user if no user_id is passed 414 if ( empty( $user_id ) ) 437 if ( empty( $user_id ) ) { 415 438 $user_id = bp_loggedin_user_id(); 439 } 416 440 417 441 $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ); … … 472 496 473 497 // Favorite activity stream items are for logged in users only 474 if ( !is_user_logged_in() ) 475 return false; 498 if ( ! is_user_logged_in() ) { 499 return false; 500 } 476 501 477 502 // Fallback to logged in user if no user_id is passed 478 if ( empty( $user_id ) ) 503 if ( empty( $user_id ) ) { 479 504 $user_id = bp_loggedin_user_id(); 505 } 480 506 481 507 $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ); … … 492 518 493 519 // Update the total number of users who have favorited this activity 494 if ( $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' ) ) { 520 $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' ); 521 if ( ! empty( $fav_count ) ) { 495 522 496 523 // Deduct from total favorites … … 564 591 565 592 // Fallback on displayed user, and then logged in user 566 if ( empty( $user_id ) ) 593 if ( empty( $user_id ) ) { 567 594 $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id(); 595 } 568 596 569 597 return BP_Activity_Activity::total_favorite_count( $user_id ); … … 593 621 */ 594 622 function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '', $delete_all = false ) { 595 global $wpdb, $bp;596 623 597 624 // Legacy - if no meta_key is passed, delete all for the item … … 674 701 * @param string $meta_key Metadata key. 675 702 * @param mixed $meta_value Metadata value. 676 * @param bool $unique .Optional. Whether to enforce a single metadata value703 * @param bool $unique Optional. Whether to enforce a single metadata value 677 704 * for the given key. If true, and the object already has a value for 678 705 * the key, no change will be made. Default: false. … … 705 732 706 733 // Do not delete user data unless a logged in user says so 707 if ( empty( $user_id ) || !is_user_logged_in() ) 708 return false; 734 if ( empty( $user_id ) || ! is_user_logged_in() ) { 735 return false; 736 } 709 737 710 738 // Clear the user's activity from the sitewide stream and clear their activity tables … … 712 740 713 741 // Remove any usermeta 714 bp_delete_user_meta( $user_id, 'bp_latest_update' );742 bp_delete_user_meta( $user_id, 'bp_latest_update' ); 715 743 bp_delete_user_meta( $user_id, 'bp_favorite_activities' ); 716 744 … … 735 763 */ 736 764 function bp_activity_spam_all_user_data( $user_id = 0 ) { 737 global $ bp, $wpdb;765 global $wpdb; 738 766 739 767 // Do not delete user data unless a logged in user says so 740 if ( empty( $user_id ) || ! is_user_logged_in() ) 741 return false; 768 if ( empty( $user_id ) || ! is_user_logged_in() ) { 769 return false; 770 } 742 771 743 772 // Get all the user's activities. 744 $activities = bp_activity_get( array( 'display_comments' => 'stream', 'filter' => array( 'user_id' => $user_id ), 'show_hidden' => true, ) ); 773 $activities = bp_activity_get( array( 774 'display_comments' => 'stream', 775 'filter' => array( 'user_id' => $user_id ), 776 'show_hidden' => true 777 ) ); 778 779 $bp = buddypress(); 745 780 746 781 // Mark each as spam … … 749 784 // Create an activity object 750 785 $activity_obj = new BP_Activity_Activity; 751 foreach ( $activity as $k => $v ) 786 foreach ( $activity as $k => $v ) { 752 787 $activity_obj->$k = $v; 788 } 753 789 754 790 // Mark as spam … … 762 798 * we need to update manually. 763 799 */ 764 if ( ! empty( $bp->activity->akismet ) ) 800 if ( ! empty( $bp->activity->akismet ) ) { 765 801 $bp->activity->akismet->update_activity_spam_meta( $activity_obj ); 802 } 766 803 767 804 // Tidy up … … 788 825 */ 789 826 function bp_activity_ham_all_user_data( $user_id = 0 ) { 790 global $ bp, $wpdb;827 global $wpdb; 791 828 792 829 // Do not delete user data unless a logged in user says so 793 if ( empty( $user_id ) || ! is_user_logged_in() ) 794 return false; 830 if ( empty( $user_id ) || ! is_user_logged_in() ) { 831 return false; 832 } 795 833 796 834 // Get all the user's activities. 797 $activities = bp_activity_get( array( 'display_comments' => 'stream', 'filter' => array( 'user_id' => $user_id ), 'show_hidden' => true, 'spam' => 'all', ) ); 835 $activities = bp_activity_get( array( 836 'display_comments' => 'stream', 837 'filter' => array( 'user_id' => $user_id ), 838 'show_hidden' => true, 839 'spam' => 'all' 840 ) ); 841 842 $bp = buddypress(); 798 843 799 844 // Mark each as not spam … … 802 847 // Create an activity object 803 848 $activity_obj = new BP_Activity_Activity; 804 foreach ( $activity as $k => $v ) 849 foreach ( $activity as $k => $v ) { 805 850 $activity_obj->$k = $v; 851 } 806 852 807 853 // Mark as not spam … … 815 861 * we need to update manually. 816 862 */ 817 if ( ! empty( $bp->activity->akismet ) ) 863 if ( ! empty( $bp->activity->akismet ) ) { 818 864 $bp->activity->akismet->update_activity_ham_meta( $activity_obj ); 865 } 819 866 820 867 // Tidy up … … 834 881 * 835 882 * @since BuddyPress (1.6.0) 836 *837 * @global object $bp BuddyPress global settings.838 883 */ 839 884 function bp_activity_register_activity_actions() { 840 global $bp;885 $bp = buddypress(); 841 886 842 887 bp_activity_set_action( … … 872 917 */ 873 918 function bp_activity_generate_action_string( $activity ) { 919 874 920 // Check for valid input 875 921 if ( empty( $activity->component ) || empty( $activity->type ) ) { … … 952 998 */ 953 999 function bp_activity_get( $args = '' ) { 954 $defaults = array( 1000 1001 $r = bp_parse_args( $args, array( 955 1002 'max' => false, // Maximum number of results to return 956 1003 'page' => 1, // page 1 without a per_page will result in no pagination. … … 979 1026 */ 980 1027 'filter' => array() 981 ); 982 $r = wp_parse_args( $args, $defaults ); 1028 ) ); 983 1029 984 1030 // Attempt to return a cached copy of the first page of sitewide activity. 985 if ( 1 == (int) $r['page'] && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && 'DESC' == $r['sort'] && empty( $r['exclude'] ) && 'ham_only' == $r['spam'] ) { 986 if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) { 987 $args = array( 1031 if ( ( 1 === (int) $r['page'] ) && empty( $r['max'] ) && empty( $r['search_terms'] ) && empty( $r['meta_query'] ) && empty( $r['filter'] ) && empty( $r['exclude'] ) && empty( $r['in'] ) && ( 'DESC' === $r['sort'] ) && empty( $r['exclude'] ) && ( 'ham_only' === $r['spam'] ) ) { 1032 1033 $activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ); 1034 if ( false === $activity ) { 1035 1036 $activity = BP_Activity_Activity::get( array( 988 1037 'page' => $r['page'], 989 1038 'per_page' => $r['per_page'], … … 998 1047 'update_meta_cache' => $r['update_meta_cache'], 999 1048 'count_total' => $r['count_total'], 1000 ) ;1001 $activity = BP_Activity_Activity::get( $args ); 1049 ) ); 1050 1002 1051 wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' ); 1003 1052 } 1004 1053 1005 1054 } else { 1006 $a rgs =array(1055 $activity = BP_Activity_Activity::get( array( 1007 1056 'page' => $r['page'], 1008 1057 'per_page' => $r['per_page'], … … 1018 1067 'spam' => $r['spam'], 1019 1068 'count_total' => $r['count_total'], 1020 ); 1021 $activity = BP_Activity_Activity::get( $args ); 1069 ) ); 1022 1070 } 1023 1071 … … 1044 1092 */ 1045 1093 function bp_activity_get_specific( $args = '' ) { 1046 $defaults = array( 1047 'activity_ids' => false, // A single activity_id or array of IDs. 1048 'display_comments' => false, // true or false to display threaded comments for these specific activity items 1049 'max' => false, // Maximum number of results to return 1050 'page' => 1, // page 1 without a per_page will result in no pagination. 1051 'per_page' => false, // results per page 1052 'show_hidden' => true, // When fetching specific items, show all 1053 'sort' => 'DESC', // sort ASC or DESC 1054 'spam' => 'ham_only', // Retrieve items marked as spam 1094 1095 $r = bp_parse_args( $args, array( 1096 'activity_ids' => false, // A single activity_id or array of IDs. 1097 'display_comments' => false, // true or false to display threaded comments for these specific activity items 1098 'max' => false, // Maximum number of results to return 1099 'page' => 1, // page 1 without a per_page will result in no pagination. 1100 'per_page' => false, // results per page 1101 'show_hidden' => true, // When fetching specific items, show all 1102 'sort' => 'DESC', // sort ASC or DESC 1103 'spam' => 'ham_only', // Retrieve items marked as spam 1055 1104 'update_meta_cache' => true, 1056 ); 1057 $r = wp_parse_args( $args, $defaults ); 1105 ) ); 1058 1106 1059 1107 $get_args = array( 1108 'display_comments' => $r['display_comments'], 1109 'in' => $r['activity_ids'], 1110 'max' => $r['max'], 1060 1111 'page' => $r['page'], 1061 1112 'per_page' => $r['per_page'], 1062 ' max' => $r['max'],1113 'show_hidden' => $r['show_hidden'], 1063 1114 'sort' => $r['sort'], 1064 'display_comments' => $r['display_comments'],1065 'show_hidden' => $r['show_hidden'],1066 'in' => $r['activity_ids'],1067 1115 'spam' => $r['spam'], 1068 1116 'update_meta_cache' => $r['update_meta_cache'], 1069 1117 ); 1118 1070 1119 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args ); 1071 1120 } … … 1117 1166 function bp_activity_add( $args = '' ) { 1118 1167 1119 $defaults = array( 1120 'id' => false, // Pass an existing activity ID to update an existing entry. 1121 1122 'action' => '', // The activity action - e.g. "Jon Doe posted an update" 1123 'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!" 1124 1125 'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent 1126 'type' => false, // The activity type e.g. activity_update, profile_updated 1127 'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink) 1128 1129 'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user. 1130 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id 1131 'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id 1168 $r = bp_parse_args( $args, array( 1169 'id' => false, // Pass an existing activity ID to update an existing entry. 1170 'action' => '', // The activity action - e.g. "Jon Doe posted an update" 1171 'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!" 1172 'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent 1173 'type' => false, // The activity type e.g. activity_update, profile_updated 1174 'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink) 1175 'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user. 1176 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id 1177 'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id 1132 1178 'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded 1133 'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream? 1134 'is_spam' => false, // Is this activity item to be marked as spam? 1135 ); 1136 $r = wp_parse_args( $args, $defaults ); 1179 'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream? 1180 'is_spam' => false, // Is this activity item to be marked as spam? 1181 ) ); 1137 1182 1138 1183 // Make sure we are backwards compatible 1139 if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) 1184 if ( empty( $r['component'] ) && !empty( $r['component_name'] ) ) { 1140 1185 $r['component'] = $r['component_name']; 1141 1142 if ( empty( $r['type'] ) && !empty( $r['component_action'] ) ) 1186 } 1187 1188 if ( empty( $r['type'] ) && !empty( $r['component_action'] ) ) { 1143 1189 $r['type'] = $r['component_action']; 1190 } 1144 1191 1145 1192 // Setup activity to be added … … 1161 1208 1162 1209 // If this is an activity comment, rebuild the tree 1163 if ( 'activity_comment' == $activity->type ) 1210 if ( 'activity_comment' == $activity->type ) { 1164 1211 BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id ); 1212 } 1165 1213 1166 1214 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); … … 1175 1223 * @since BuddyPress (1.2.0) 1176 1224 * 1177 * @global object $bp BuddyPress global settings.1178 1225 * @uses wp_parse_args() 1179 1226 * @uses bp_is_user_inactive() … … 1194 1241 */ 1195 1242 function bp_activity_post_update( $args = '' ) { 1196 global $bp; 1197 1198 $defaults = array( 1243 1244 $r = wp_parse_args( $args, array( 1199 1245 'content' => false, 1200 1246 'user_id' => bp_loggedin_user_id() 1201 ); 1202 $r = wp_parse_args( $args, $defaults ); 1203 1204 if ( empty( $r['content'] ) || !strlen( trim( $r['content'] ) ) ) 1205 return false; 1206 1207 if ( bp_is_user_inactive( $r['user_id'] ) ) 1208 return false; 1247 ) ); 1248 1249 if ( empty( $r['content'] ) || !strlen( trim( $r['content'] ) ) ) { 1250 return false; 1251 } 1252 1253 if ( bp_is_user_inactive( $r['user_id'] ) ) { 1254 return false; 1255 } 1209 1256 1210 1257 // Record this on the user's profile 1211 $from_user_link = bp_core_get_userlink( $r['user_id'] );1212 1258 $activity_content = $r['content']; 1213 1259 $primary_link = bp_core_get_userlink( $r['user_id'], false, true ); … … 1218 1264 'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ), 1219 1265 'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ), 1220 'component' => $bp->activity->id,1266 'component' => buddypress()->activity->id, 1221 1267 'type' => 'activity_update', 1222 1268 ) ); … … 1225 1271 1226 1272 // Add this update to the "latest update" usermeta so it can be fetched anywhere. 1227 bp_update_user_meta( bp_loggedin_user_id(), 'bp_latest_update', array( 'id' => $activity_id, 'content' => $activity_content ) ); 1273 bp_update_user_meta( bp_loggedin_user_id(), 'bp_latest_update', array( 1274 'id' => $activity_id, 1275 'content' => $activity_content 1276 ) ); 1228 1277 1229 1278 do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id ); … … 1328 1377 */ 1329 1378 function bp_activity_get_activity_id( $args = '' ) { 1330 $defaults = array( 1379 1380 $r = bp_parse_args( $args, array( 1331 1381 'user_id' => false, 1332 1382 'component' => false, … … 1337 1387 'content' => false, 1338 1388 'date_recorded' => false, 1339 ); 1340 1341 $r = wp_parse_args( $args, $defaults ); 1342 1343 return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $r['user_id'], $r['component'], $r['type'], $r['item_id'], $r['secondary_item_id'], $r['action'], $r['content'], $r['date_recorded'] ) ); 1389 ) ); 1390 1391 return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( 1392 $r['user_id'], 1393 $r['component'], 1394 $r['type'], 1395 $r['item_id'], 1396 $r['secondary_item_id'], 1397 $r['action'], 1398 $r['content'], 1399 $r['date_recorded'] 1400 ) ); 1344 1401 } 1345 1402 … … 1379 1436 1380 1437 // Pass one or more the of following variables to delete by those variables 1381 $ defaults =array(1438 $args = bp_parse_args( $args, array( 1382 1439 'id' => false, 1383 1440 'action' => false, … … 1391 1448 'date_recorded' => false, 1392 1449 'hide_sitewide' => false 1393 ); 1394 1395 $args = wp_parse_args( $args, $defaults ); 1450 ) ); 1396 1451 1397 1452 do_action( 'bp_before_activity_delete', $args ); … … 1400 1455 bp_activity_adjust_mention_count( $args['id'], 'delete' ); 1401 1456 1402 if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) ) 1403 return false; 1457 $activity_ids_deleted = BP_Activity_Activity::delete( $args ); 1458 if ( empty( $activity_ids_deleted ) ) { 1459 return false; 1460 } 1404 1461 1405 1462 // Check if the user's latest update has been deleted 1406 if ( empty( $args['user_id'] ) ) 1407 $user_id = bp_loggedin_user_id(); 1408 else 1409 $user_id = $args['user_id']; 1463 $user_id = empty( $args['user_id'] ) 1464 ? bp_loggedin_user_id() 1465 : $args['user_id']; 1410 1466 1411 1467 $latest_update = bp_get_user_meta( $user_id, 'bp_latest_update', true ); … … 1442 1498 function bp_activity_delete_by_item_id( $args = '' ) { 1443 1499 1444 $ defaults =array(1500 $r = bp_parse_args( $args, array( 1445 1501 'item_id' => false, 1446 1502 'component' => false, … … 1448 1504 'user_id' => false, 1449 1505 'secondary_item_id' => false 1450 ); 1451 $r = wp_parse_args( $args, $defaults ); 1452 1453 return bp_activity_delete( array( 'item_id' => $r['item_id'], 'component' => $r['component'], 'type' => $r['type'], 'user_id' => $r['user_id'], 'secondary_item_id' => $r['secondary_item_id'] ) ); 1506 ) ); 1507 1508 return bp_activity_delete( $r ); 1454 1509 } 1455 1510 … … 1485 1540 */ 1486 1541 function bp_activity_delete_by_content( $user_id, $content, $component, $type ) { 1487 return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) ); 1542 return bp_activity_delete( array( 1543 'user_id' => $user_id, 1544 'content' => $content, 1545 'component' => $component, 1546 'type' => $type 1547 ) ); 1488 1548 } 1489 1549 … … 1503 1563 */ 1504 1564 function bp_activity_delete_for_user_by_component( $user_id, $component ) { 1505 return bp_activity_delete( array( 'user_id' => $user_id, 'component' => $component ) ); 1565 return bp_activity_delete( array( 1566 'user_id' => $user_id, 1567 'component' => $component 1568 ) ); 1506 1569 } 1507 1570 … … 1531 1594 * handle the deletion of child comments differently. Make sure you return false. 1532 1595 */ 1533 if ( !apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) 1534 return false; 1596 if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) { 1597 return false; 1598 } 1535 1599 1536 1600 // Delete any children of this comment. … … 1538 1602 1539 1603 // Delete the actual comment 1540 if ( !bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) ) 1541 return false; 1604 if ( ! bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) ) { 1605 return false; 1606 } 1542 1607 1543 1608 // Recalculate the comment tree … … 1592 1657 function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { 1593 1658 1594 if ( empty( $activity_obj ) ) 1659 if ( empty( $activity_obj ) ) { 1595 1660 $activity_obj = new BP_Activity_Activity( $activity_id ); 1661 } 1596 1662 1597 1663 if ( isset( $activity_obj->current_comment ) ) { … … 1907 1973 * @param string $cache An empty string passed by BP_Embed::parse_oembed() for 1908 1974 * functions like this one to filter. 1975 * @param string $cachekey The cache key generated in BP_Embed::parse_oembed(). 1909 1976 * @param int $id The ID of the activity item. 1910 * @param string $cachekey The cache key generated in BP_Embed::parse_oembed().1911 1977 * @return bool True on success, false on failure. 1912 1978 */
Note: See TracChangeset
for help on using the changeset viewer.