Changeset 7398 for trunk/bp-activity/bp-activity-functions.php
- Timestamp:
- 10/08/2013 08:58:00 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-functions.php
r7349 r7398 2 2 3 3 /** 4 * BuddyPress Activity Functions 5 * 6 * Functions for the Activity Streams component 4 * BuddyPress Activity Functions. 5 * 6 * Functions for the Activity Streams component. 7 7 * 8 8 * @package BuddyPress … … 14 14 15 15 /** 16 * Check s $bp pages global and looks for directory page16 * Check whether the $bp global lists an activity directory page. 17 17 * 18 18 * @since BuddyPress (1.5) … … 20 20 * @global object $bp BuddyPress global settings 21 21 * 22 * @return bool True if set, False if empty22 * @return bool True if activity directory page is found, otherwise false. 23 23 */ 24 24 function bp_activity_has_directory() { … … 46 46 * 47 47 * @uses apply_filters() To call 'bp_activity_do_mentions' hook. 48 * 48 49 * @return bool $retval True to enable mentions, false to disable. 49 50 */ … … 53 54 54 55 /** 55 * Searches through the content of an activity item to locate usernames, 56 * designated by an @ sign. 56 * Locate usernames in an activity content string, as designated by an @ sign. 57 57 * 58 58 * @since BuddyPress (1.5) 59 59 * 60 60 * @param string $content The content of the activity, usually found in $activity->content. 61 * @return mixedAssociative array with user ID as key and username as value. Boolean false if no mentions found.61 * @return array|bool Associative array with user ID as key and username as value. Boolean false if no mentions found. 62 62 */ 63 63 function bp_activity_find_mentions( $content ) { … … 92 92 93 93 /** 94 * Reset s a user's unread mentions list and count94 * Reset a user's unread mentions list and count. 95 95 * 96 96 * @since BuddyPress (1.5) 97 97 * 98 * @param int $user_id The id of the user whose unread mentions are being reset99 98 * @uses bp_delete_user_meta() 99 * 100 * @param int $user_id The id of the user whose unread mentions are being reset. 100 101 */ 101 102 function bp_activity_clear_new_mentions( $user_id ) { … … 114 115 * @since BuddyPress (1.5) 115 116 * 116 * @param int $activity_id The unique id for the activity item117 * @param string $action Can be 'delete' or 'add'. Defaults to 'add'.118 *119 117 * @uses bp_activity_find_mentions() 120 118 * @uses bp_activity_update_mention_count_for_user() 119 * 120 * @param int $activity_id The unique id for the activity item. 121 * @param string $action Can be 'delete' or 'add'. Defaults to 'add'. 121 122 */ 122 123 function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) { … … 141 142 142 143 /** 143 * Update s the mention count for the user in question.144 * Update the mention count for a given user. 144 145 * 145 146 * This function should be used when you've already parsed your activity item … … 148 149 * @since BuddyPress (1.7) 149 150 * 150 * @param int $user_id The user ID151 * @param int $activity_id The unique id for the activity item152 * @param string $action Can be 'delete' or 'add'. Defaults to 'add'153 *154 151 * @uses bp_get_user_meta() 155 152 * @uses bp_update_user_meta() 153 * 154 * @param int $user_id The user ID. 155 * @param int $activity_id The unique ID for the activity item. 156 * @param string $action 'delete' or 'add'. Default: 'add'. 156 157 * @return bool 157 158 */ … … 195 196 196 197 /** 197 * Format s notifications related to activity198 * Format notifications related to activity. 198 199 * 199 200 * @since BuddyPress (1.5) 200 *201 * @param string $action The type of activity item. Just 'new_at_mention' for now202 * @param int $item_id The activity id203 * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's id204 * @param int $total_items The total number of notifications to format205 * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise206 201 * 207 202 * @uses bp_loggedin_user_domain() 208 203 * @uses bp_get_activity_slug() 209 204 * @uses bp_core_get_user_displayname() 210 * @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook 211 * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook 212 * @uses do_action() To call 'activity_format_notifications' hook 213 * 214 * @return string $return Formatted @mention notification 205 * @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook. 206 * @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook. 207 * @uses do_action() To call 'activity_format_notifications' hook. 208 * 209 * @param string $action The type of activity item. Just 'new_at_mention' for now. 210 * @param int $item_id The activity ID. 211 * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID. 212 * @param int $total_items The total number of notifications to format. 213 * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise. 214 * @return string $return Formatted @mention notification. 215 215 */ 216 216 function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { … … 251 251 252 252 /** 253 * Set s the current action for a given activity stream location253 * Set the current action for a given activity stream location. 254 254 * 255 255 * @since BuddyPress (1.1) 256 *257 * @param string $component_id258 * @param string $key259 * @param string $value260 256 * 261 257 * @global object $bp BuddyPress global settings 262 258 * @uses apply_filters() To call the 'bp_activity_set_action' hook 263 259 * 264 * @return bool False if any param is empty, otherwise true 260 * @param string $component_id The unique string ID of the component. 261 * @param string $key The action key. 262 * @param string $value The action value. 263 * @return bool False if any param is empty, otherwise true. 265 264 */ 266 265 function bp_activity_set_action( $component_id, $key, $value ) { … … 289 288 290 289 /** 291 * Retreive s the current action from a component and key290 * Retreive the current action from a component and key. 292 291 * 293 292 * @since BuddyPress (1.1) 294 293 * 295 * @param string $component_id 296 * @param string $key 297 * 298 * @global object $bp BuddyPress global settings 299 * @uses apply_filters() To call the 'bp_activity_get_action' hook 300 * 301 * @return mixed False on error, action on success 294 * @global object $bp BuddyPress global settings. 295 * @uses apply_filters() To call the 'bp_activity_get_action' hook. 296 * 297 * @param string $component_id The unique string ID of the component. 298 * @param string $key The action key. 299 * @return string|bool Action value if found, otherwise false. 302 300 */ 303 301 function bp_activity_get_action( $component_id, $key ) { … … 312 310 313 311 /** 314 * Fetch details of all registered activity types 312 * Fetch details of all registered activity types. 313 * 314 * @since BuddyPress (1.7) 315 315 * 316 316 * @return array array( type => description ), ... 317 * @since BuddyPress (1.7)318 317 */ 319 318 function bp_activity_get_types() { … … 340 339 341 340 /** 342 * Get a users favorite activity stream items 341 * Get a users favorite activity stream items. 343 342 * 344 343 * @since BuddyPress (1.2) 345 344 * 346 * @param int $user_id347 *348 345 * @uses bp_get_user_meta() 349 * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook 350 * 351 * @return array Array of users favorite activity stream ID's 346 * @uses apply_filters() To call the 'bp_activity_get_user_favorites' hook. 347 * 348 * @param int $user_id ID of the user whose favorites are being queried. 349 * @return array IDs of the user's favorite activity items. 352 350 */ 353 351 function bp_activity_get_user_favorites( $user_id = 0 ) { … … 364 362 365 363 /** 366 * Add an activity stream item as a favorite for a user 364 * Add an activity stream item as a favorite for a user. 367 365 * 368 366 * @since BuddyPress (1.2) 369 *370 * @param int $activity_id371 * @param int $user_id372 367 * 373 368 * @uses is_user_logged_in() … … 376 371 * @uses bp_update_user_meta() 377 372 * @uses bp_activity_update_meta() 378 * @uses do_action() To call the 'bp_activity_add_user_favorite' hook 379 * @uses do_action() To call the 'bp_activity_add_user_favorite_fail' hook 380 * 381 * @return bool True on success, false on failure 373 * @uses do_action() To call the 'bp_activity_add_user_favorite' hook. 374 * @uses do_action() To call the 'bp_activity_add_user_favorite_fail' hook. 375 * 376 * @param int $activity_id ID of the activity item being favorited. 377 * @param int $user_id ID of the user favoriting the activity item. 378 * @return bool True on success, false on failure. 382 379 */ 383 380 function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) { … … 421 418 422 419 /** 423 * Remove an activity stream item as a favorite for a user 420 * Remove an activity stream item as a favorite for a user. 424 421 * 425 422 * @since BuddyPress (1.2) 426 *427 * @param int $activity_id428 * @param int $user_id429 423 * 430 424 * @uses is_user_logged_in() … … 433 427 * @uses bp_activity_update_meta() 434 428 * @uses bp_update_user_meta() 435 * @uses do_action() To call the 'bp_activity_remove_user_favorite' hook 436 * 437 * @return bool True on success, false on failure 429 * @uses do_action() To call the 'bp_activity_remove_user_favorite' hook. 430 * 431 * @param int $activity_id ID of the activity item being unfavorited. 432 * @param int $user_id ID of the user unfavoriting the activity item. 433 * @return bool True on success, false on failure. 438 434 */ 439 435 function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) { … … 485 481 486 482 /** 487 * Check if activity exists by scanning content483 * Check whether an activity item exists with a given content string. 488 484 * 489 485 * @since BuddyPress (1.1) 490 486 * 491 * @param string $content492 *493 487 * @uses BP_Activity_Activity::check_exists_by_content() {@link BP_Activity_Activity} 494 * @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook 495 * 496 * @return bool 488 * @uses apply_filters() To call the 'bp_activity_check_exists_by_content' hook. 489 * 490 * @param string $content The content to filter by. 491 * @return int|null The ID of the located activity item. Null if none is found. 497 492 */ 498 493 function bp_activity_check_exists_by_content( $content ) { … … 501 496 502 497 /** 503 * Retrieve the last time activity was updated 498 * Retrieve the last time activity was updated. 504 499 * 505 500 * @since BuddyPress (1.0) 506 501 * 507 502 * @uses BP_Activity_Activity::get_last_updated() {@link BP_Activity_Activity} 508 * @uses apply_filters() To call the 'bp_activity_get_last_updated' hook 509 * 510 * @return string Date last updated 503 * @uses apply_filters() To call the 'bp_activity_get_last_updated' hook. 504 * 505 * @return string Date last updated. 511 506 */ 512 507 function bp_activity_get_last_updated() { … … 515 510 516 511 /** 517 * Retrieve the number of favorite activity stream items a user has 512 * Retrieve the number of favorite activity stream items a user has. 518 513 * 519 514 * @since BuddyPress (1.2) 520 515 * 521 * @param int $user_id522 *523 516 * @uses BP_Activity_Activity::total_favorite_count() {@link BP_Activity_Activity} 524 517 * 525 * @return int Total favorite count 518 * @param int $user_id ID of the user whose favorite count is being requested. 519 * @return int Total favorite count for the user. 526 520 */ 527 521 function bp_activity_total_favorites_for_user( $user_id = 0 ) { … … 537 531 538 532 /** 539 * Delete a meta entry from the DB for an activity stream item 533 * Delete a meta entry from the DB for an activity stream item. 540 534 * 541 535 * @since BuddyPress (1.2) 542 536 * 543 * @param int $activity_id 544 * @param string $meta_key 545 * @param string $meta_value 546 * 547 * @global object $wpdb 548 * @global object $bp BuddyPress global settings 537 * @global object $wpdb WordPress database access object. 538 * @global object $bp BuddyPress global settings. 549 539 * @uses wp_cache_delete() 550 540 * @uses is_wp_error() 551 541 * 552 * @return bool True on success, false on failure 542 * @param int $activity_id ID of the activity item whose metadata is being deleted. 543 * @param string $meta_key Optional. The key of the metadata being deleted. If 544 * omitted, all metadata associated with the activity 545 * item will be deleted. 546 * @param string $meta_value Optional. If present, the metadata will only be 547 * deleted if the meta_value matches this parameter. 548 * @return bool True on success, false on failure. 553 549 */ 554 550 function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '' ) { … … 593 589 594 590 /** 595 * Get activity meta591 * Get metadata for a given activity item. 596 592 * 597 593 * @since BuddyPress (1.2) 598 594 * 599 * @param int $activity_id 600 * @param string $meta_key 601 * 602 * @global object $wpdb 603 * @global object $bp BuddyPress global settings 595 * @global object $wpdb WordPress database access object. 596 * @global object $bp BuddyPress global settings. 604 597 * @uses wp_cache_get() 605 598 * @uses wp_cache_set() 606 * @uses apply_filters() To call the 'bp_activity_get_meta' hook 607 * 608 * @return bool 599 * @uses apply_filters() To call the 'bp_activity_get_meta' hook. 600 * 601 * @param int $activity_id ID of the activity item whose metadata is being requseted. 602 * @param string $meta_key Optional. If present, only the metadata matching 603 * that meta key will be returned. Otherwise, all 604 * metadata for the activity item will be fetched. 605 * @return mixed The meta value(s) being requested. 609 606 */ 610 607 function bp_activity_get_meta( $activity_id = 0, $meta_key = '' ) { … … 658 655 659 656 /** 660 * Update a ctivity meta657 * Update a piece of activity meta. 661 658 * 662 659 * @since BuddyPress (1.2) 663 660 * 664 * @param int $activity_id 665 * @param string $meta_key 666 * @param string $meta_value 667 * 668 * @global object $wpdb 669 * @global object $bp BuddyPress global settings 661 * @global object $wpdb WordPress database access object. 662 * @global object $bp BuddyPress global settings. 670 663 * @uses maybe_serialize() 671 664 * @uses bp_activity_delete_meta() 672 665 * @uses wp_cache_set() 673 666 * 674 * @return bool True on success, false on failure 667 * @param int $activity_id ID of the activity item whose metadata is being updated. 668 * @param string $meta_key Key of the metadata being updated. 669 * @param mixed $meta_value Value to be set. 670 * @return bool True on success, false on failure. 675 671 */ 676 672 function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) { … … 720 716 721 717 /** 722 * Completely remove a user's activity data 718 * Completely remove a user's activity data. 723 719 * 724 720 * @since BuddyPress (1.5) 725 *726 * @param int $user_id727 721 * 728 722 * @uses is_user_logged_in() 729 723 * @uses bp_activity_delete() 730 724 * @uses bp_delete_user_meta() 731 * @uses do_action() To call the 'bp_activity_remove_data' hook 732 * @uses do_action() To call the 'bp_activity_remove_all_user_data' hook 725 * @uses do_action() To call the 'bp_activity_remove_data' hook. 726 * @uses do_action() To call the 'bp_activity_remove_all_user_data' hook. 727 * 728 * @param int $user_id ID of the user whose activity is being deleted. 733 729 */ 734 730 function bp_activity_remove_all_user_data( $user_id = 0 ) { … … 755 751 756 752 /** 757 * Mark all of the user's activity as spam 758 * 759 * @global object $wpdb 760 * @global object $bp BuddyPress global settings 761 * @param int $user_id 753 * Mark all of the user's activity as spam. 754 * 762 755 * @since BuddyPress (1.6) 756 * 757 * @global object $wpdb WordPress database access object. 758 * @global object $bp BuddyPress global settings. 759 * 760 * @param int $user_id ID of the user whose activity is being spammed. 763 761 */ 764 762 function bp_activity_spam_all_user_data( $user_id = 0 ) { … … 806 804 807 805 /** 808 * Mark all of the user's activity as ham (not spam) 809 * 810 * @global object $wpdb 811 * @global object $bp BuddyPress global settings 812 * @param int $user_id 806 * Mark all of the user's activity as ham (not spam). 807 * 813 808 * @since BuddyPress (1.6) 809 * 810 * @global object $wpdb WordPress database access object. 811 * @global object $bp BuddyPress global settings. 812 * 813 * @param int $user_id ID of the user whose activity is being hammed. 814 814 */ 815 815 function bp_activity_ham_all_user_data( $user_id = 0 ) { … … 859 859 * Register the activity stream actions for updates 860 860 * 861 * @global object $bp BuddyPress global settings862 861 * @since BuddyPress (1.6) 862 * 863 * @global object $bp BuddyPress global settings. 863 864 */ 864 865 function bp_activity_register_activity_actions() { … … 883 884 884 885 /** 885 * Retrieve an activity or activities 886 * Retrieve an activity or activities. 887 * 888 * bp_activity_get() shares all arguments with BP_Activity_Activity::get(). The 889 * following is a list of bp_activity_get() parameters that have different 890 * default values from BP_Activity_Activity::get() (value in parentheses is 891 * the default for the bp_activity_get()). 892 * - 'per_page' (false) 886 893 * 887 894 * @since BuddyPress (1.2) 888 895 * 889 * @ param array $args890 * 896 * @see BP_Activity_Activity::get() For more information on accepted arguments 897 * and the format of the returned value. 891 898 * @uses wp_parse_args() 892 899 * @uses wp_cache_get() 893 900 * @uses wp_cache_set() 894 901 * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity} 895 * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook 896 * 897 * @return object $activity The activity/activities object 902 * @uses apply_filters_ref_array() To call the 'bp_activity_get' hook. 903 * 904 * @param array $args See BP_Activity_Activity::get() for description. 905 * @return array $activity See BP_Activity_Activity::get() for description. 898 906 */ 899 907 function bp_activity_get( $args = '' ) { … … 968 976 969 977 /** 970 * Fetch specific activity items 978 * Fetch specific activity items. 971 979 * 972 980 * @since BuddyPress (1.2) 973 981 * 974 * @param array $args See docs for $defaults for details 975 * 982 * @see BP_Activity_Activity::get() For more information on accepted arguments 976 983 * @uses wp_parse_args() 977 984 * @uses apply_filters() To call the 'bp_activity_get_specific' hook 978 985 * @uses BP_Activity_Activity::get() {@link BP_Activity_Activity} 979 986 * 980 * @return array The array returned by BP_Activity_Activity::get() 987 * @param array $args { 988 * All arguments and defaults are shared with BP_Activity_Activity::get(), 989 * except for the following: 990 * @string|int|array Single activity ID, comma-separated list of IDs, or 991 * array of IDs. 992 * } 993 * @return array $activity See BP_Activity_Activity::get() for description. 981 994 */ 982 995 function bp_activity_get_specific( $args = '' ) { … … 1008 1021 1009 1022 /** 1010 * Add an activity item 1023 * Add an activity item. 1011 1024 * 1012 1025 * @since BuddyPress (1.1) 1013 *1014 * @param array $args See docs for $defaults for details1015 1026 * 1016 1027 * @uses wp_parse_args() … … 1020 1031 * @uses do_action() To call the 'bp_activity_add' hook 1021 1032 * 1022 * @return int The activity id 1033 * @param array $args { 1034 * An array of arguments. 1035 * @int|bool $id Pass an activity ID to update an existing item, or false 1036 * to create a new item. Default: false. 1037 * @string $action Optional. The activity action/description, typically 1038 * something like "Joe posted an update". 1039 * @string $content Optional. The content of the activity item. 1040 * @string $component The unique name of the component associated with the 1041 * activity item - 'groups', 'profile', etc. 1042 * @string $type The specific activity type, used for directory filtering. 1043 * 'new_blog_post', 'activity_update', etc. 1044 * @string $primary_link Optional. The URL for this item, as used in RSS 1045 * feeds. Defaults to the URL for this activity 1046 * item's permalink page. 1047 * @int|bool $user_id Optional. The ID of the user associated with the 1048 * activity item. May be set to false or 0 if the item 1049 * is not related to any user. Default: the ID of the 1050 * currently logged-in user. 1051 * @int $item_id Optional. The ID of the associated item. 1052 * @int $secondary_item_id Optional. The ID of a secondary associated item. 1053 * @string $date_recorded Optional. The GMT time, in Y-m-d h:i:s format, 1054 * when the item was recorded. Defaults to the 1055 * current time. 1056 * @bool $hide_sitewide Should the item be hidden on sitewide streams? 1057 * Default: false. 1058 * @bool $is_spam Should the item be marked as spam? Default: false. 1059 * } 1060 * @return int|bool The ID of the activity on success. False on error. 1023 1061 */ 1024 1062 function bp_activity_add( $args = '' ) { … … 1079 1117 1080 1118 /** 1081 * Post an activity update 1119 * Post an activity update. 1082 1120 * 1083 1121 * @since BuddyPress (1.2) 1084 1122 * 1085 * @param array $args See docs for $defaults for details 1086 * 1087 * @global object $bp BuddyPress global settings 1123 * @global object $bp BuddyPress global settings. 1088 1124 * @uses wp_parse_args() 1089 1125 * @uses bp_is_user_inactive() 1090 1126 * @uses bp_core_get_userlink() 1091 1127 * @uses bp_activity_add() 1092 * @uses apply_filters() To call the 'bp_activity_new_update_action' hook 1093 * @uses apply_filters() To call the 'bp_activity_new_update_content' hook 1094 * @uses apply_filters() To call the 'bp_activity_new_update_primary_link' hook 1128 * @uses apply_filters() To call the 'bp_activity_new_update_action' hook. 1129 * @uses apply_filters() To call the 'bp_activity_new_update_content' hook. 1130 * @uses apply_filters() To call the 'bp_activity_new_update_primary_link' hook. 1095 1131 * @uses bp_update_user_meta() 1096 1132 * @uses wp_filter_kses() 1097 * @uses do_action() To call the 'bp_activity_posted_update' hook 1098 * 1133 * @uses do_action() To call the 'bp_activity_posted_update' hook. 1134 * 1135 * @param array $args { 1136 * @string $content The content of the activity update. 1137 * @int $user_id Optional. Defaults to the logged-in user. 1138 * } 1099 1139 * @return int $activity_id The activity id 1100 1140 */ … … 1142 1182 1143 1183 /** 1144 * Add an activity comment 1184 * Add an activity comment. 1145 1185 * 1146 1186 * @since BuddyPress (1.2) 1147 1187 * 1148 * @param array $args See docs for $defaults for details 1149 * 1150 * @global object $bp BuddyPress global settings 1188 * @global object $bp BuddyPress global settings. 1151 1189 * @uses wp_parse_args() 1152 1190 * @uses bp_activity_add() 1153 * @uses apply_filters() To call the 'bp_activity_comment_action' hook 1154 * @uses apply_filters() To call the 'bp_activity_comment_content' hook 1191 * @uses apply_filters() To call the 'bp_activity_comment_action' hook. 1192 * @uses apply_filters() To call the 'bp_activity_comment_content' hook. 1155 1193 * @uses bp_activity_new_comment_notification() 1156 1194 * @uses wp_cache_delete() 1157 * @uses do_action() To call the 'bp_activity_comment_posted' hook 1158 * 1159 * @return int $comment_id The comment id 1195 * @uses do_action() To call the 'bp_activity_comment_posted' hook. 1196 * 1197 * @param array $args { 1198 * @int $id Optional. Pass an ID to update an existing comment. 1199 * @string $content The content of the comment. 1200 * @int $user_id Optional. The ID of the user making the comment. Defaults 1201 * to the ID of the logged-in user. 1202 * @int $activity_id The ID of the "root" activity item, ie the oldest 1203 * ancestor of the comment. 1204 * @int $parent_id Optional. The ID of the parent activity item, ie the 1205 * item to which the comment is an immediate reply. If 1206 * not provided, this value defaults to the $activity_id. 1207 * } 1208 * @return int|bool The ID of the comment on success, otherwise false. 1160 1209 */ 1161 1210 function bp_activity_new_comment( $args = '' ) { … … 1212 1261 * @since BuddyPress (1.2) 1213 1262 * 1214 * @param array $args See docs for $defaults for details 1215 * 1263 * @see BP_Activity_Activity::get() For more information on accepted arguments. 1216 1264 * @uses wp_parse_args() 1217 * @uses apply_filters() To call the 'bp_activity_get_activity_id' hook 1265 * @uses apply_filters() To call the 'bp_activity_get_activity_id' hook. 1218 1266 * @uses BP_Activity_Activity::save() {@link BP_Activity_Activity} 1219 1267 * 1220 * @return int $activity_id The activity id 1268 * @param array $args See BP_Activity_Activity::get() for description. 1269 * @return int $activity_id The ID of the activity item found. 1221 1270 */ 1222 1271 function bp_activity_get_activity_id( $args = '' ) { … … 1239 1288 1240 1289 /** 1241 * Delet ing Activity1290 * Delete activity item(s). 1242 1291 * 1243 1292 * If you're looking to hook into one action that provides the ID(s) of … … 1253 1302 * @since BuddyPress (1.0) 1254 1303 * 1255 * @param array $args See docs for $defaults for details 1256 * 1304 * @see BP_Activity_Activity::get() For more information on accepted arguments. 1257 1305 * @uses wp_parse_args() 1258 1306 * @uses bp_activity_adjust_mention_count() 1259 1307 * @uses BP_Activity_Activity::delete() {@link BP_Activity_Activity} 1260 * @uses do_action() To call the 'bp_before_activity_delete' hook 1308 * @uses do_action() To call the 'bp_before_activity_delete' hook. 1261 1309 * @uses bp_get_user_meta() 1262 1310 * @uses bp_delete_user_meta() 1263 * @uses do_action() To call the 'bp_activity_delete' hook 1264 * @uses do_action() To call the 'bp_activity_deleted_activities' hook 1311 * @uses do_action() To call the 'bp_activity_delete' hook. 1312 * @uses do_action() To call the 'bp_activity_deleted_activities' hook. 1265 1313 * @uses wp_cache_delete() 1266 1314 * 1267 * @return bool True on success, false on failure 1315 * @param array $args To delete specific activity items, use 1316 * $args = array( 'id' => $ids ); 1317 * Otherwise, to use filters for item deletion, the argument 1318 * format is the same as BP_Activity_Activity::get(). See 1319 * that method for a description. 1320 * @return bool True on success, false on failure. 1268 1321 */ 1269 1322 function bp_activity_delete( $args = '' ) { … … 1316 1369 1317 1370 /** 1318 * Delete an activity item by activity id 1371 * Delete an activity item by activity id. 1319 1372 * 1320 * You should use bp_activity_delete() instead 1373 * You should use bp_activity_delete() instead. 1321 1374 * 1322 1375 * @since BuddyPress (1.1) 1323 1376 * @deprecated BuddyPress (1.2) 1324 1377 * 1325 * @param array $args See docs for $defaults for details1326 *1327 1378 * @uses wp_parse_args() 1328 1379 * @uses bp_activity_delete() 1329 1380 * 1330 * @return bool True on success, false on failure 1381 * @param array $args See BP_Activity_Activity::get for a description 1382 * of accepted arguments. 1383 * 1384 * @return bool True on success, false on failure. 1331 1385 */ 1332 1386 function bp_activity_delete_by_item_id( $args = '' ) { … … 1346 1400 1347 1401 /** 1348 * Delete an activity item by activity id 1402 * Delete an activity item by activity id. 1349 1403 * 1350 * You should use bp_activity_delete() instead 1404 * @since BuddyPress (1.1) 1405 * 1406 * @uses bp_activity_delete() 1407 * 1408 * @param int ID of the activity item to be deleted. 1409 * @return bool True on success, false on failure. 1410 */ 1411 function bp_activity_delete_by_activity_id( $activity_id ) { 1412 return bp_activity_delete( array( 'id' => $activity_id ) ); 1413 } 1414 1415 /** 1416 * Delete an activity item by its content. 1417 * 1418 * You should use bp_activity_delete() instead. 1351 1419 * 1352 1420 * @since BuddyPress (1.1) 1353 1421 * @deprecated BuddyPress (1.2) 1354 1422 * 1355 * @param int $activity_id The activity id1356 *1357 1423 * @uses bp_activity_delete() 1358 1424 * 1359 * @return bool True on success, false on failure 1425 * @param int $user_id The user id. 1426 * @param string $content The activity id. 1427 * @param string $component The activity component. 1428 * @param string $type The activity type. 1429 * @return bool True on success, false on failure. 1360 1430 */ 1361 function bp_activity_delete_by_ activity_id( $activity_id) {1362 return bp_activity_delete( array( ' id' => $activity_id) );1431 function bp_activity_delete_by_content( $user_id, $content, $component, $type ) { 1432 return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) ); 1363 1433 } 1364 1434 1365 1435 /** 1366 * Delete a n activity item by it's content1436 * Delete a user's activity for a component. 1367 1437 * 1368 * You should use bp_activity_delete() instead 1438 * You should use bp_activity_delete() instead. 1369 1439 * 1370 1440 * @since BuddyPress (1.1) 1371 1441 * @deprecated BuddyPress (1.2) 1372 1442 * 1373 * @param int $user_id The user id1374 * @param string $content The activity id1375 * @param string $component The activity component1376 * @param string $type The activity type1377 *1378 1443 * @uses bp_activity_delete() 1379 1444 * 1380 * @return bool True on success, false on failure 1381 */ 1382 function bp_activity_delete_by_content( $user_id, $content, $component, $type ) { 1383 return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) ); 1384 } 1385 1386 /** 1387 * Delete a user's activity for a component 1388 * 1389 * You should use bp_activity_delete() instead 1390 * 1391 * @since BuddyPress (1.1) 1392 * @deprecated BuddyPress (1.2) 1393 * 1394 * @param int $user_id The user id 1395 * @param string $component The activity component 1396 * 1397 * @uses bp_activity_delete() 1398 * 1399 * @return bool True on success, false on failure 1445 * @param int $user_id The user id. 1446 * @param string $component The activity component. 1447 * @return bool True on success, false on failure. 1400 1448 */ 1401 1449 function bp_activity_delete_for_user_by_component( $user_id, $component ) { … … 1404 1452 1405 1453 /** 1406 * Delete an activity comment 1454 * Delete an activity comment. 1407 1455 * 1408 1456 * @since BuddyPress (1.2) 1409 1457 * 1410 * @param int $activity_id The activity id 1411 * @param int $comment_id The activity comment id 1412 * 1413 * @uses apply_filters() To call the 'bp_activity_delete_comment_pre' hook 1458 * @uses apply_filters() To call the 'bp_activity_delete_comment_pre' hook. 1414 1459 * @uses bp_activity_delete_children() 1415 1460 * @uses bp_activity_delete() 1416 1461 * @uses BP_Activity_Activity::rebuild_activity_comment_tree() {@link BP_Activity_Activity} 1417 * @uses do_action() To call the 'bp_activity_delete_comment' hook 1418 * 1462 * @uses do_action() To call the 'bp_activity_delete_comment' hook. 1463 * @todo Why is an activity id required? We could look this up. 1464 * @todo Why do we encourage users to call this function directly? We could just 1465 * as easily examine the activity type in bp_activity_delete() and then 1466 * call this function with the proper arguments if necessary. 1467 * 1468 * @param int $activity_id The ID of the "root" activity, ie the comment's 1469 * oldest ancestor. 1470 * @param int $comment_id The ID of the comment to be deleted. 1419 1471 * @return bool True on success, false on failure 1420 1472 */ … … 1443 1495 1444 1496 /** 1445 * Delete an activity comment's children 1497 * Delete an activity comment's children. 1446 1498 * 1447 1499 * @since BuddyPress (1.2) 1448 *1449 * @param int $activity_id The activity id1450 * @param int $comment_id The activity comment id1451 1500 * 1452 1501 * @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity} 1453 1502 * @uses bp_activity_delete_children() 1454 1503 * @uses bp_activity_delete() 1504 * 1505 * @param int $activity_id The ID of the "root" activity, ie the 1506 * comment's oldest ancestor. 1507 * @param int $comment_id The ID of the comment to be deleted. 1455 1508 */ 1456 1509 function bp_activity_delete_children( $activity_id, $comment_id) { … … 1465 1518 1466 1519 /** 1467 * Get the permalink for a single activity item 1468 * 1469 * When only the $activity_id param is passed, BP has to instantiate a new BP_Activity_Activity 1470 * object. To save yourself some processing overhead, be sure to pass the full $activity_obj param 1471 * as well, if you already have it available. 1520 * Get the permalink for a single activity item. 1521 * 1522 * When only the $activity_id param is passed, BP has to instantiate a new 1523 * BP_Activity_Activity object. To save yourself some processing overhead, 1524 * be sure to pass the full $activity_obj parameter as well, if you already 1525 * have it available. 1472 1526 * 1473 1527 * @since BuddyPress (1.2) 1474 *1475 * @param int $activity_id The unique id of the activity object1476 * @param object $activity_obj (optional) The activity object1477 1528 * 1478 1529 * @uses bp_get_root_domain() 1479 1530 * @uses bp_get_activity_root_slug() 1480 * @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook 1481 * 1482 * @return string $link Permalink for the activity item 1531 * @uses apply_filters_ref_array() To call the 'bp_activity_get_permalink' hook. 1532 * 1533 * @param int $activity_id The unique id of the activity object. 1534 * @param object $activity_obj Optional. The activity object. 1535 * @return string $link Permalink for the activity item. 1483 1536 */ 1484 1537 function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { … … 1505 1558 1506 1559 /** 1507 * Hide a user's activity 1560 * Hide a user's activity. 1508 1561 * 1509 1562 * @since BuddyPress (1.2) 1510 1563 * 1511 * @param int $user_id The user id1512 *1513 1564 * @uses BP_Activity_Activity::hide_all_for_user() {@link BP_Activity_Activity} 1514 1565 * 1515 * @return bool True on success, false on failure 1566 * @param int $user_id The ID of the user whose activity is being hidden. 1567 * @return bool True on success, false on failure. 1516 1568 */ 1517 1569 function bp_activity_hide_user_activity( $user_id ) { … … 1520 1572 1521 1573 /** 1522 * Take content, remove all images and replace them with one thumbnail image. 1574 * Take content, remove images, and replace them with a single thumbnail image. 1575 * 1576 * The format of items in the activity stream is such that we do not want to 1577 * allow an arbitrary number of arbitrarily large images to be rendered. 1578 * However, the activity stream is built to elegantly display a single 1579 * thumbnail corresponding to the activity comment. This function looks 1580 * through the content, grabs the first image and converts it to a thumbnail, 1581 * and removes the rest of the images from the string. 1523 1582 * 1524 1583 * @since BuddyPress (1.2) 1525 *1526 * @param string $content The content to work with1527 * @param string $link Optional. The unescaped URL that the image should link to1528 * @param array $activity_args Optional. The args passed to the activity1529 * creation function (eg bp_blogs_record_activity())1530 1584 * 1531 1585 * @uses esc_attr() 1532 1586 * @uses apply_filters() To call the 'bp_activity_thumbnail_content_images' hook 1533 1587 * 1534 * @return string $content The content with images stripped and replaced with a single thumb. 1588 * @param string $content The content of the activity item. 1589 * @param string $link Optional. The unescaped URL that the image should link 1590 * to. If absent, the image will not be a link. 1591 * @param array $activity_args Optional. The args passed to the activity 1592 * creation function (eg bp_blogs_record_activity()). 1593 * @return string $content The content with images stripped and replaced with a 1594 * single thumb. 1535 1595 */ 1536 1596 function bp_activity_thumbnail_content_images( $content, $link = false, $args = false ) { … … 1576 1636 1577 1637 /** 1578 * Convenience function to control whether the current user is allowed to mark activity items as spam 1579 * 1580 * @return bool True if user is allowed to mark activity items as spam 1638 * Fetch whether the current user is allowed to mark items as spam. 1639 * 1581 1640 * @since BuddyPress (1.6) 1582 * @static 1641 * 1642 * @return bool True if user is allowed to mark activity items as spam. 1583 1643 */ 1584 1644 function bp_activity_user_can_mark_spam() { … … 1587 1647 1588 1648 /** 1589 * Mark activity item as spam 1590 * 1591 * @global object $bp BuddyPress global settings 1592 * @param BP_Activity_Activity $activity 1593 * @param string $source Optional; default is "by_a_person" (e.g. a person has manually marked the activity as spam). 1649 * Mark an activity item as spam. 1650 * 1594 1651 * @since BuddyPress (1.6) 1652 * 1653 * @global object $bp BuddyPress global settings. 1654 * 1655 * @param BP_Activity_Activity $activity The activity item to be spammed. 1656 * @param string $source Optional. Default is "by_a_person" (ie, a person has 1657 * manually marked the activity as spam). BP core also 1658 * accepts 'by_akismet'. 1595 1659 */ 1596 1660 function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) { … … 1623 1687 1624 1688 /** 1625 * Mark activity item as ham 1626 * 1627 * @global object $bp BuddyPress global settings 1628 * @param BP_Activity_Activity $activity 1629 * @param string $source Optional; default is "by_a_person" (e.g. a person has manually marked the activity as spam). 1689 * Mark an activity item as ham. 1690 * 1630 1691 * @since BuddyPress (1.6) 1692 * 1693 * @global object $bp BuddyPress global settings. 1694 * 1695 * @param BP_Activity_Activity $activity The activity item to be hammed. 1696 * @param string $source Optional. Default is "by_a_person" (ie, a person has 1697 * manually marked the activity as spam). BP core also 1698 * accepts 'by_akismet'. 1631 1699 */ 1632 1700 function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) { … … 1662 1730 1663 1731 /** 1664 * Grabs the activity update ID and attempts to retrieve the oEmbed cache (if it exists) 1665 * during the activity loop. If no cache and link is embeddable, cache it. 1732 * Set up activity oEmbed cache during the activity loop. 1733 * 1734 * During an activity loop, this function sets up the hooks necessary to grab 1735 * each item's embeds from the cache, or put them in the cache if they are 1736 * not there yet. 1666 1737 * 1667 1738 * This does not cover recursive activity comments, as they do not use a real loop. … … 1673 1744 * @see bp_embed_activity_cache() 1674 1745 * @see bp_embed_activity_save_cache() 1675 * 1676 * @uses add_filter() To attach 'bp_get_activity_id' to 'embed_post_id' 1677 * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache' 1678 * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache' 1746 * @uses add_filter() To attach 'bp_get_activity_id' to 'embed_post_id'. 1747 * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'. 1748 * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'. 1679 1749 */ 1680 1750 function bp_activity_embed() { … … 1686 1756 1687 1757 /** 1688 * Grabs the activity comment ID and attempts to retrieve the oEmbed cache (if it exists) 1689 * when BP is recursing through activity comments {@link bp_activity_recurse_comments()}. 1690 * If no cache and link is embeddable, cache it. 1758 * Set up activity oEmbed cache while recursing through activity comments. 1759 * 1760 * While crawling through an activity comment tree 1761 * ({@link bp_activity_recurse_comments}), this function sets up the hooks 1762 * necessary to grab each comment's embeds from the cache, or put them in 1763 * the cache if they are not there yet. 1691 1764 * 1692 1765 * @since BuddyPress (1.5) … … 1695 1768 * @see bp_embed_activity_cache() 1696 1769 * @see bp_embed_activity_save_cache() 1697 * 1698 * @uses add_filter() To attach 'bp_get_activity_comment_id' to 'embed_post_id' 1699 * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache' 1700 * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache' 1770 * @uses add_filter() To attach 'bp_get_activity_comment_id' to 'embed_post_id'. 1771 * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'. 1772 * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'. 1701 1773 */ 1702 1774 function bp_activity_comment_embed() { … … 1713 1785 * 1714 1786 * @see BP_Embed 1715 *1716 * @param object $activity The activity that is being expanded1717 *1718 1787 * @global object $bp BuddyPress global settings 1719 * @uses add_filter() To attach create_function() to 'embed_post_id' 1720 * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache' 1721 * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache' 1788 * @uses add_filter() To attach create_function() to 'embed_post_id'. 1789 * @uses add_filter() To attach 'bp_embed_activity_cache' to 'bp_embed_get_cache'. 1790 * @uses add_action() To attach 'bp_embed_activity_save_cache' to 'bp_embed_update_cache'. 1791 * 1792 * @param object $activity The activity that is being expanded. 1722 1793 */ 1723 1794 function bp_dtheme_embed_read_more( $activity ) { … … 1733 1804 1734 1805 /** 1735 * Removes the 'embed_post_id' filter after {@link bp_activity_recurse_comments()} 1736 * is rendered to avoid conflict with the 'embed_post_id' filter in 1737 * {@link bp_activity_embed()} or any other component embeds. 1806 * Clean up 'embed_post_id' filter after comment recursion. 1807 * 1808 * This filter must be removed so that the non-comment filters take over again 1809 * once the comments are done being processed. 1738 1810 * 1739 1811 * @since BuddyPress (1.5) 1740 1812 * 1741 1813 * @see bp_activity_comment_embed() 1742 * 1743 * @uses remove_filter() To remove 'bp_get_activity_comment_id' from 'embed_post_id' 1814 * @uses remove_filter() To remove 'bp_get_activity_comment_id' from 'embed_post_id'. 1744 1815 */ 1745 1816 function bp_activity_comment_embed_after_recurse() { … … 1749 1820 1750 1821 /** 1751 * Wrapper function for {@link bp_activity_get_meta()}. 1822 * Fetch an activity item's cached embeds. 1823 * 1752 1824 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}. 1753 1825 * 1754 1826 * @since BuddyPress (1.5) 1755 1827 * 1828 * @see BP_Embed::parse_oembed() 1756 1829 * @uses bp_activity_get_meta() 1757 1830 * 1758 * @return mixed The activity meta 1831 * @param string $cache An empty string passed by BP_Embed::parse_oembed() for 1832 * functions like this one to filter. 1833 * @param int $id The ID of the activity item. 1834 * @param string $cachekey The cache key generated in BP_Embed::parse_oembed(). 1835 * @return mixed The cached embeds for this activity item. 1759 1836 */ 1760 1837 function bp_embed_activity_cache( $cache, $id, $cachekey ) { … … 1763 1840 1764 1841 /** 1765 * Wrapper function for {@link bp_activity_update_meta()}. 1842 * Set an activity item's embed cache. 1843 * 1766 1844 * Used during {@link BP_Embed::parse_oembed()} via {@link bp_activity_embed()}. 1767 1845 * 1768 1846 * @since BuddyPress (1.5) 1769 1847 * 1848 * @see BP_Embed::parse_oembed() 1770 1849 * @uses bp_activity_update_meta() 1850 * 1851 * @param string $cache An empty string passed by BP_Embed::parse_oembed() for 1852 * functions like this one to filter. 1853 * @param int $id The ID of the activity item. 1854 * @param string $cachekey The cache key generated in BP_Embed::parse_oembed(). 1855 * @return bool True on success, false on failure. 1771 1856 */ 1772 1857 function bp_embed_activity_save_cache( $cache, $cachekey, $id ) {
Note: See TracChangeset
for help on using the changeset viewer.