Changeset 9135
- Timestamp:
- 11/11/2014 08:12:02 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r9054 r9135 46 46 */ 47 47 function bp_activity_do_mentions() { 48 49 /** 50 * Filters whether or not mentions are enabled. 51 * 52 * @since BuddyPress (1.8.0) 53 * 54 * @param bool $enabled True to enable mentions, false to disable. 55 */ 48 56 return (bool) apply_filters( 'bp_activity_do_mentions', true ); 49 57 } … … 62 70 ( bp_is_activity_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin() ); 63 71 72 /** 73 * Filters whether or not BuddyPress should load mentions scripts and assets. 74 * 75 * @since BuddyPress (2.1.0) 76 * 77 * @param bool $retval True to load mentions assets, false otherwise. 78 */ 64 79 return (bool) apply_filters( 'bp_activity_maybe_load_mentions_scripts', $retval ); 65 80 } … … 334 349 } 335 350 351 /** 352 * Filters the action type being set for the current activity item. 353 * 354 * @since BuddyPress (1.1.0) 355 * 356 * @param array $array Array of arguments for action type being set. 357 * @param string $component_id ID of the current component being set. 358 * @param string $type Action type being set. 359 * @param string $description Action description for action being set. 360 * @param callable $format_callback Callback for formatting the action string. 361 * @param string $label String to describe this action in the activity stream filter dropdown. 362 * @param array $context Activity stream contexts where the filter should appear. 'activity', 'member', 363 * 'member_groups', 'group'. 364 */ 336 365 $bp->activity->actions->{$component_id}->{$type} = apply_filters( 'bp_activity_set_action', array( 337 366 'key' => $type, … … 368 397 : false; 369 398 399 /** 400 * Filters the current action by component and key. 401 * 402 * @since BuddyPress (1.1.0) 403 * 404 * @param string|bool $retval The action key. 405 * @param string $component_id The unique string ID of the component. 406 * @param string $key The action key. 407 */ 370 408 return apply_filters( 'bp_activity_get_action', $retval, $component_id, $key ); 371 409 } … … 393 431 unset( $actions['friends_register_activity_action'] ); 394 432 433 /** 434 * Filters the available activity types. 435 * 436 * @since BuddyPress (1.7.0) 437 * 438 * @param array $actions Array of registered activity types. 439 */ 395 440 return apply_filters( 'bp_activity_get_types', $actions ); 396 441 } … … 419 464 $favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ); 420 465 466 /** 467 * Filters the favorited activity items for a specified user. 468 * 469 * @since BuddyPress (1.2.0) 470 * 471 * @param array $favs Array of user's favorited activity items. 472 */ 421 473 return apply_filters( 'bp_activity_get_user_favorites', $favs ); 422 474 } … … 474 526 if ( bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ) ) { 475 527 476 // Execute additional code 528 /** 529 * Fires if bp_activity_update_meta() for favorite_count is successful and before returning a true value for success. 530 * 531 * @since BuddyPress (1.2.1) 532 * 533 * @param int $activity_id ID of the activity item being favorited. 534 * @param int $user_id ID of the user doing the favoriting. 535 */ 477 536 do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id ); 478 537 … … 482 541 // Saving meta was unsuccessful for an unknown reason 483 542 } else { 484 // Execute additional code 543 544 /** 545 * Fires if bp_activity_update_meta() for favorite_count is unsuccessful and before returning a false value for failure. 546 * 547 * @since BuddyPress (1.5.0) 548 * 549 * @param int $activity_id ID of the activity item being favorited. 550 * @param int $user_id ID of the user doing the favoriting. 551 */ 485 552 do_action( 'bp_activity_add_user_favorite_fail', $activity_id, $user_id ); 486 553 … … 539 606 if ( bp_update_user_meta( $user_id, 'bp_favorite_activities', $my_favs ) ) { 540 607 541 // Execute additional code 608 /** 609 * Fires if bp_update_user_meta() is successful and before returning a true value for success. 610 * 611 * @since BuddyPress (1.2.1) 612 * 613 * @param int $activity_id ID of the activity item being unfavorited. 614 * @param int $user_id ID of the user doing the unfavoriting. 615 */ 542 616 do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id ); 543 617 … … 573 647 */ 574 648 function bp_activity_check_exists_by_content( $content ) { 649 650 /** 651 * Filters the results of the check for whether an activity item exists by specified content. 652 * 653 * @since BuddyPress (1.1.0) 654 * 655 * @param BP_Activity_Activity $content_exists ID of the activity if found, else null. 656 */ 575 657 return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) ); 576 658 } … … 587 669 */ 588 670 function bp_activity_get_last_updated() { 671 672 /** 673 * Filters the value for the last updated time for an activity item. 674 * 675 * @since BuddyPress (1.1.0) 676 * 677 * @param BP_Activity_Activity $last_updated Date last updated. 678 */ 589 679 return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() ); 590 680 } … … 677 767 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 678 768 679 // Filter result before returning 769 /** 770 * Filters the metadata for a specified activity item. 771 * 772 * @since BuddyPress (1.5.0) 773 * 774 * @param mixed $retval The meta values for the activity item. 775 * @param int $activity_id ID of the activity item. 776 * @param string $meta_key Meta key for the value being requested. 777 * @param bool $single Whether to return one matched meta key row or all. 778 */ 680 779 return apply_filters( 'bp_activity_get_meta', $retval, $activity_id, $meta_key, $single ); 681 780 } … … 758 857 do_action( 'bp_activity_remove_data', $user_id ); // Deprecated! Do not use! 759 858 760 // Use this going forward 859 /** 860 * Fires after the removal of all of a user's activity data. 861 * 862 * @since BuddyPress (1.5.0) 863 * 864 * @param int $user_id ID of the user being deleted. 865 */ 761 866 do_action( 'bp_activity_remove_all_user_data', $user_id ); 762 867 } … … 821 926 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id ) ); 822 927 823 // Call an action for plugins to use 928 /** 929 * Fires after all activity data from a user has been marked as spam. 930 * 931 * @since BuddyPress (1.6.0) 932 * 933 * @param int $user_id ID of the user whose activity is being marked as spam. 934 * @param array $activities Array of activity items being marked as spam. 935 */ 824 936 do_action( 'bp_activity_spam_all_user_data', $user_id, $activities['activities'] ); 825 937 } … … 881 993 } 882 994 883 // Mark all of this user's activities as spam995 // Mark all of this user's activities as not spam 884 996 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET is_spam = 0 WHERE user_id = %d", $user_id ) ); 885 997 886 // Call an action for plugins to use 998 /** 999 * Fires after all activity data from a user has been marked as ham. 1000 * 1001 * @since BuddyPress (1.6.0) 1002 * 1003 * @param int $user_id ID of the user whose activity is being marked as ham. 1004 * @param array $activities Array of activity items being marked as ham. 1005 */ 887 1006 do_action( 'bp_activity_ham_all_user_data', $user_id, $activities['activities'] ); 888 1007 } … … 914 1033 ); 915 1034 1035 /** 1036 * Fires at the end of the activity actions registration. 1037 * 1038 * Allows plugin authors to add their own activity actions alongside the core actions. 1039 * 1040 * @since BuddyPress (1.6.0) 1041 */ 916 1042 do_action( 'bp_activity_register_activity_actions' ); 917 1043 … … 943 1069 add_filter( 'bp_activity_generate_action_string', buddypress()->activity->actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 ); 944 1070 945 // Generate the action string (run through the filter defined above) 1071 /** 1072 * Filters the string for the activity action being returned. 1073 * 1074 * @since BuddyPress (2.0.0) 1075 * 1076 * @param BP_Activity_Activity $action Action string being requested. 1077 * @param BP_Activity_Activity $activity Activity item object. 1078 */ 946 1079 $action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity ); 947 1080 … … 963 1096 function bp_activity_format_activity_action_activity_update( $action, $activity ) { 964 1097 $action = sprintf( __( '%s posted an update', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) ); 1098 1099 /** 1100 * Filters the formatted activity action update string. 1101 * 1102 * @since BuddyPress (1.2.0) 1103 * 1104 * @param string $action Activity action string value. 1105 * @param BP_Activity_Activity $activity Activity item object. 1106 */ 965 1107 return apply_filters( 'bp_activity_new_update_action', $action, $activity ); 966 1108 } … … 977 1119 function bp_activity_format_activity_action_activity_comment( $action, $activity ) { 978 1120 $action = sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $activity->user_id ) ); 1121 1122 /** 1123 * Filters the formatted activity action comment string. 1124 * 1125 * @since BuddyPress (1.2.0) 1126 * 1127 * @param string $action Activity action string value. 1128 * @param BP_Activity_Activity $activity Activity item object. 1129 */ 979 1130 return apply_filters( 'bp_activity_comment_action', $action, $activity ); 980 1131 } … … 1085 1236 } 1086 1237 1238 /** 1239 * Filters the requested activity item(s). 1240 * 1241 * @since BuddyPress (1.2.0) 1242 * 1243 * @param BP_Activity_Activity $activity Requested activity object. 1244 * @param array $r Arguments used for the activity query. 1245 */ 1087 1246 return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) ); 1088 1247 } … … 1132 1291 ); 1133 1292 1293 /** 1294 * Filters the requested specific activity item. 1295 * 1296 * @since BuddyPress (1.2.0) 1297 * 1298 * @param BP_Activity_Activity $activity Requested activity object. 1299 * @param array $args Original passed in arguments. 1300 * @param array $get_args Constructed arguments used with request. 1301 */ 1134 1302 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args ); 1135 1303 } … … 1234 1402 1235 1403 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 1404 1405 /** 1406 * Fires at the end of the execution of adding a new activity item, before returning the new activity item ID. 1407 * 1408 * @since BuddyPress (1.1.0) 1409 * 1410 * @param array $r Array of parsed arguments for the activity item being added. 1411 */ 1236 1412 do_action( 'bp_activity_add', $r ); 1237 1413 … … 1280 1456 $primary_link = bp_core_get_userlink( $r['user_id'], false, true ); 1281 1457 1458 /** 1459 * Filters the new activity content for current activity item. 1460 * 1461 * @since BuddyPress (1.2.0) 1462 * 1463 * @param string $activity_content Activity content posted by user. 1464 */ 1465 $add_content = apply_filters( 'bp_activity_new_update_content', $activity_content ); 1466 1467 /** 1468 * Filters the activity primary link for current activity item. 1469 * 1470 * @since BuddyPress (1.2.0) 1471 * 1472 * @param string $primary_link Link to the profile for the user who posted the activity. 1473 */ 1474 $add_primary_link = apply_filters( 'bp_activity_new_update_primary_link', $primary_link ); 1475 1282 1476 // Now write the values 1283 1477 $activity_id = bp_activity_add( array( 1284 1478 'user_id' => $r['user_id'], 1285 'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),1286 'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),1479 'content' => $add_content, 1480 'primary_link' => $add_primary_link, 1287 1481 'component' => buddypress()->activity->id, 1288 1482 'type' => 'activity_update', 1289 1483 ) ); 1290 1484 1485 /** 1486 * Filters the latest update content for the activity item. 1487 * 1488 * @since BuddyPress (1.6.0) 1489 * 1490 * @param string $r Content of the activity update. 1491 * @param string $activity_content Content of the activity update. 1492 */ 1291 1493 $activity_content = apply_filters( 'bp_activity_latest_update_content', $r['content'], $activity_content ); 1292 1494 … … 1297 1499 ) ); 1298 1500 1501 /** 1502 * Fires at the end of an activity post update, before returning the updated activity item ID. 1503 * 1504 * @since BuddyPress (1.2.0) 1505 * 1506 * @param string $content Content of the activity post update. 1507 * @param int $user_id ID of the user posting the activity update. 1508 * @param int $activity_id ID of the activity item being updated. 1509 */ 1299 1510 do_action( 'bp_activity_posted_update', $r['content'], $r['user_id'], $activity_id ); 1300 1511 … … 1375 1586 $is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0; 1376 1587 1588 /** 1589 * Filters the content of a new comment. 1590 * 1591 * @since BuddyPress (1.2.0) 1592 * 1593 * @param string $r Content for the newly posted comment. 1594 */ 1595 $comment_content = apply_filters( 'bp_activity_comment_content', $r['content'] ); 1596 1377 1597 // Insert the activity comment 1378 1598 $comment_id = bp_activity_add( array( 1379 1599 'id' => $r['id'], 1380 'content' => apply_filters( 'bp_activity_comment_content', $r['content'] ),1600 'content' => $comment_content, 1381 1601 'component' => buddypress()->activity->id, 1382 1602 'type' => 'activity_comment', … … 1399 1619 wp_cache_delete( $activity_id, 'bp_activity' ); 1400 1620 1621 /** 1622 * Fires near the end of an activity comment posting, before the returning of the comment ID. 1623 * 1624 * @since BuddyPress (1.2.0) 1625 * 1626 * @param int $comment_id ID of the newly posted activity comment. 1627 * @param array $r Array of parsed comment arguments. 1628 * @param int $activity ID of the activity item being commented on. 1629 */ 1401 1630 do_action( 'bp_activity_comment_posted', $comment_id, $r, $activity ); 1402 1631 … … 1435 1664 ) ); 1436 1665 1666 /** 1667 * Filters the activity ID being requested. 1668 * 1669 * @since BuddyPress (1.2.0) 1670 * 1671 * @param BP_Activity_Activity ID returned by BP_Activity_Activity get_id() method with provided arguments. 1672 */ 1437 1673 return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( 1438 1674 $r['user_id'], … … 1496 1732 ) ); 1497 1733 1734 /** 1735 * Fires before an activity item proceeds to be deleted. 1736 * 1737 * @since BuddyPress (1.5.0) 1738 * 1739 * @param array $args Array of arguments to be used with the activity deletion. 1740 */ 1498 1741 do_action( 'bp_before_activity_delete', $args ); 1499 1742 … … 1518 1761 } 1519 1762 1763 /** 1764 * Fires after the activity item has been deleted. 1765 * 1766 * @since BuddyPress (1.0.0) 1767 * 1768 * @param array $args Array of arguments used with the activity deletion. 1769 */ 1520 1770 do_action( 'bp_activity_delete', $args ); 1771 1772 /** 1773 * Fires after the activity item has been deleted. 1774 * 1775 * @since BuddyPress (1.2.0) 1776 * 1777 * @param array $activity_ids_deleted Array of affected activity item IDs. 1778 */ 1521 1779 do_action( 'bp_activity_deleted_activities', $activity_ids_deleted ); 1522 1780 … … 1532 1790 * 1533 1791 * @since BuddyPress (1.1.0) 1534 * @deprecated BuddyPress (1.2 )1792 * @deprecated BuddyPress (1.2.0) 1535 1793 * 1536 1794 * @uses wp_parse_args() … … 1575 1833 * 1576 1834 * @since BuddyPress (1.1.0) 1577 * @deprecated BuddyPress (1.2 )1835 * @deprecated BuddyPress (1.2.0) 1578 1836 * 1579 1837 * @uses bp_activity_delete() … … 1600 1858 * 1601 1859 * @since BuddyPress (1.1.0) 1602 * @deprecated BuddyPress (1.2 )1860 * @deprecated BuddyPress (1.2.0) 1603 1861 * 1604 1862 * @uses bp_activity_delete() … … 1636 1894 */ 1637 1895 function bp_activity_delete_comment( $activity_id, $comment_id ) { 1638 /*** 1896 1897 /** 1898 * Filters whether BuddyPress should delete an activity comment or not. 1899 * 1639 1900 * You may want to hook into this filter if you want to override this function and 1640 1901 * handle the deletion of child comments differently. Make sure you return false. 1902 * 1903 * @since BuddyPress (1.2.0) 1904 * 1905 * @param bool $value Whether BuddyPress should continue or not. 1906 * @param int $activity_id ID of the root activity item being deleted. 1907 * @param int $comment_id ID of the comment being deleted. 1641 1908 */ 1642 1909 if ( ! apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) ) { … … 1658 1925 BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id ); 1659 1926 1927 /** 1928 * Fires at the end of the deletion of an activity comment, before returning success. 1929 * 1930 * @since BuddyPress (1.2.0) 1931 * 1932 * @param int $activity_id ID of the activity that has had a comment deleted from. 1933 * @param int $comment_id ID of the comment that was deleted. 1934 */ 1660 1935 do_action( 'bp_activity_delete_comment', $activity_id, $comment_id ); 1661 1936 … … 1734 2009 } 1735 2010 2011 /** 2012 * Filters the activity permalink for the specified activity item. 2013 * 2014 * @since BuddyPress (1.2.0) 2015 * 2016 * @param array $array Array holding activity permalink and activity item object. 2017 */ 1736 2018 return apply_filters_ref_array( 'bp_activity_get_permalink', array( $link, &$activity_obj ) ); 1737 2019 } … … 1813 2095 } 1814 2096 2097 /** 2098 * Filters the activity content that had a thumbnail replace images. 2099 * 2100 * @since BuddyPress (1.2.0) 2101 * 2102 * @param string $content Activity content that had images replaced in. 2103 * @param array $matches Array of all image tags found in the posted content. 2104 * @param array $args Arguments passed into function creating the activity update. 2105 */ 1815 2106 return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches, $args ); 1816 2107 } … … 1824 2115 */ 1825 2116 function bp_activity_user_can_mark_spam() { 2117 2118 /** 2119 * Filters whether the current user should be able to mark items as spam. 2120 * 2121 * @since BuddyPress (1.6.0) 2122 * 2123 * @param bool $moderate Whether or not the current user has bp_moderate capability. 2124 */ 1826 2125 return apply_filters( 'bp_activity_user_can_mark_spam', bp_current_user_can( 'bp_moderate' ) ); 1827 2126 } … … 1862 2161 } 1863 2162 2163 /** 2164 * Fires at the end of the process to mark an activity item as spam. 2165 * 2166 * @since BuddyPress (1.6.0) 2167 * 2168 * @param BP_Activity_Activity $activity Activity item being marked as spam. 2169 * @param string $source Source of determination of spam status. For example 2170 * "by_a_person" or "by_akismet". 2171 */ 1864 2172 do_action( 'bp_activity_mark_as_spam', $activity, $source ); 1865 2173 } … … 1900 2208 } 1901 2209 2210 /** 2211 * Fires at the end of the process to mark an activity item as ham. 2212 * 2213 * @since BuddyPress (1.6.0) 2214 * 2215 * @param BP_Activity_Activity $activity Activity item being marked as ham. 2216 * @param string $source Source of determination of ham status. For example 2217 * "by_a_person" or "by_akismet". 2218 */ 1902 2219 do_action( 'bp_activity_mark_as_ham', $activity, $source ); 1903 2220 }
Note: See TracChangeset
for help on using the changeset viewer.