Changeset 10253 for trunk/src/bp-activity/bp-activity-template.php
- Timestamp:
- 10/12/2015 05:45:14 AM (10 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-activity/bp-activity-template.php (modified) (74 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-template.php
r10248 r10253 7 7 */ 8 8 9 // Exit if accessed directly 9 // Exit if accessed directly. 10 10 defined( 'ABSPATH' ) || exit; 11 11 … … 114 114 */ 115 115 class BP_Activity_Template { 116 116 117 /** 117 118 * The loop iterator. … … 232 233 $bp = buddypress(); 233 234 234 // Backward compatibility with old method of passing arguments 235 // Backward compatibility with old method of passing arguments. 235 236 if ( !is_array( $args ) || func_num_args() > 1 ) { 236 237 _deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); … … 285 286 $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] ); 286 287 287 // Check if blog/forum replies are disabled 288 // Check if blog/forum replies are disabled. 288 289 $this->disable_blogforum_replies = (bool) bp_core_get_root_option( 'bp-disable-blogforum-comments' ); 289 290 290 // Get an array of the logged in user's favorite activities 291 // Get an array of the logged in user's favorite activities. 291 292 $this->my_favs = maybe_unserialize( bp_get_user_meta( bp_loggedin_user_id(), 'bp_favorite_activities', true ) ); 292 293 293 // Fetch specific activity items based on ID's 294 // Fetch specific activity items based on ID's. 294 295 if ( !empty( $include ) ) { 295 296 $this->activities = bp_activity_get_specific( array( … … 306 307 ) ); 307 308 308 // Fetch all activity items 309 // Fetch all activity items. 309 310 } else { 310 311 $this->activities = bp_activity_get( array( … … 330 331 331 332 // The total_activity_count property will be set only if a 332 // 'count_total' query has taken place 333 // 'count_total' query has taken place. 333 334 if ( ! is_null( $this->activities['total'] ) ) { 334 335 if ( ! $max || $max >= (int) $this->activities['total'] ) { … … 355 356 $this->full_name = bp_get_displayed_user_fullname(); 356 357 357 // Fetch parent content for activity comments so we do not have to query in the loop 358 // Fetch parent content for activity comments so we do not have to query in the loop. 358 359 foreach ( (array) $this->activities as $activity ) { 359 360 if ( 'activity_comment' != $activity->type ) { … … 451 452 do_action( 'activity_loop_end' ); 452 453 453 // Do some cleaning up after the loop 454 // Do some cleaning up after the loop. 454 455 $this->rewind_activities(); 455 456 } … … 478 479 } 479 480 480 // loop has just started481 // Loop has just started. 481 482 if ( $this->current_activity == 0 ) { 482 483 … … 605 606 global $activities_template; 606 607 607 // Get BuddyPress 608 // Get BuddyPress. 608 609 $bp = buddypress(); 609 610 610 /** Smart Defaults ********************************************************/ 611 612 // User filtering 611 /* 612 * Smart Defaults. 613 */ 614 615 // User filtering. 613 616 $user_id = bp_displayed_user_id() 614 617 ? bp_displayed_user_id() 615 618 : false; 616 619 617 // Group filtering 620 // Group filtering. 618 621 if ( bp_is_group() ) { 619 622 $object = $bp->groups->id; … … 626 629 } 627 630 628 // The default scope should recognize custom slugs 631 // The default scope should recognize custom slugs. 629 632 $scope = array_key_exists( bp_current_action(), (array) $bp->loaded_components ) 630 633 ? $bp->loaded_components[ bp_current_action() ] 631 634 : bp_current_action(); 632 635 633 // Support for permalinks on single item pages: /groups/my-group/activity/124/ 636 // Support for permalinks on single item pages: /groups/my-group/activity/124/. 634 637 $include = bp_is_current_action( bp_get_activity_slug() ) 635 638 ? bp_action_variable( 0 ) … … 642 645 } 643 646 644 /** Parse Args ************************************************************/ 647 /* 648 * Parse Args. 649 */ 645 650 646 651 // Note: any params used for filtering can be a single value, or multiple 647 652 // values comma separated. 648 653 $r = bp_parse_args( $args, array( 649 'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items650 'include' => $include, // pass an activity_id or string of IDs comma-separated651 'exclude' => false, // pass an activity_id or string of IDs comma-separated652 'in' => false, // comma-separated list or array of activity IDs among which to search653 'sort' => 'DESC', // sort DESC or ASC654 'page' => 1, // which page to load655 'per_page' => 20, // number of items per page656 'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679 657 'max' => false, // max number to return654 'display_comments' => 'threaded', // False for none, stream/threaded - show comments in the stream or threaded under items. 655 'include' => $include, // Pass an activity_id or string of IDs comma-separated. 656 'exclude' => false, // Pass an activity_id or string of IDs comma-separated. 657 'in' => false, // Comma-separated list or array of activity IDs among which to search. 658 'sort' => 'DESC', // Sort DESC or ASC. 659 'page' => 1, // Which page to load. 660 'per_page' => 20, // Number of items per page. 661 'page_arg' => 'acpage', // See https://buddypress.trac.wordpress.org/ticket/3679. 662 'max' => false, // Max number to return. 658 663 'fields' => 'all', 659 664 'count_total' => false, 660 665 'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide? 661 'spam' => 'ham_only', // Hide spammed items 662 663 // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions) 666 'spam' => 'ham_only', // Hide spammed items. 667 668 // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions). 664 669 'scope' => $scope, 665 670 666 671 // Filtering 667 'user_id' => $user_id, // user_id to filter on 668 'object' => $object, // object to filter on e.g. groups, profile, status, friends669 'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated670 'primary_id' => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.671 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id672 'offset' => false, // return only items >= this ID673 'since' => false, // return only items recorded since this Y-m-d H:i:s date674 675 'meta_query' => false, // filter on activity meta. See WP_Meta_Query for format676 'date_query' => false, // filter by date. See first parameter of WP_Date_Query for format677 'filter_query' => false, // advanced filtering. See BP_Activity_Query for format678 679 // Searching 672 'user_id' => $user_id, // user_id to filter on. 673 'object' => $object, // Object to filter on e.g. groups, profile, status, friends. 674 'action' => false, // Action to filter on e.g. activity_update, new_forum_post, profile_updated. 675 'primary_id' => $primary_id, // Object ID to filter on e.g. a group_id or forum_id or blog_id etc. 676 'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id. 677 'offset' => false, // Return only items >= this ID. 678 'since' => false, // Return only items recorded since this Y-m-d H:i:s date. 679 680 'meta_query' => false, // Filter on activity meta. See WP_Meta_Query for format. 681 'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format. 682 'filter_query' => false, // Advanced filtering. See BP_Activity_Query for format. 683 684 // Searching. 680 685 'search_terms' => $search_terms_default, 681 686 'update_meta_cache' => true, 682 687 ), 'has_activities' ); 683 688 684 /** Smart Overrides *******************************************************/ 689 /* 690 * Smart Overrides. 691 */ 685 692 686 693 // Translate various values for 'display_comments' 687 694 // This allows disabling comments via ?display_comments=0 688 // or =none or =false. Final true is a strict type check. See #5029 695 // or =none or =false. Final true is a strict type check. See #5029. 689 696 if ( in_array( $r['display_comments'], array( 0, '0', 'none', 'false' ), true ) ) { 690 697 $r['display_comments'] = false; 691 698 } 692 699 693 // Ignore pagination if an offset is passed 700 // Ignore pagination if an offset is passed. 694 701 if ( ! empty( $r['offset'] ) ) { 695 702 $r['page'] = 0; 696 703 } 697 704 698 // Search terms 705 // Search terms. 699 706 if ( ! empty( $_REQUEST['s'] ) && empty( $r['search_terms'] ) ) { 700 707 $r['search_terms'] = $_REQUEST['s']; 701 708 } 702 709 703 // Do not exceed the maximum per page 710 // Do not exceed the maximum per page. 704 711 if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) { 705 712 $r['per_page'] = $r['max']; … … 741 748 } 742 749 743 /** Query *****************************************************************/ 750 /* 751 * Query 752 */ 744 753 745 754 $activities_template = new BP_Activity_Template( $r ); … … 799 808 * 800 809 * @since 2.1.0 810 * 811 * @return string $link 801 812 */ 802 813 function bp_get_activity_load_more_link() { … … 1317 1328 * 1318 1329 * @todo Properly deprecate in favor of bp_activity_type() and 1319 * remove redundant echo1330 * remove redundant echo 1320 1331 * 1321 1332 * @uses bp_activity_type() … … 1461 1472 $bp = buddypress(); 1462 1473 1463 // On activity permalink pages, default to the full-size avatar 1474 // On activity permalink pages, default to the full-size avatar. 1464 1475 $type_default = bp_is_single_activity() ? 'full' : 'thumb'; 1465 1476 … … 1468 1479 $current_activity_item = isset( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : $activities_template->activity; 1469 1480 1470 // Activity user display name 1481 // Activity user display name. 1471 1482 $dn_default = isset( $current_activity_item->display_name ) ? $current_activity_item->display_name : ''; 1472 1483 1473 // Prepend some descriptive text to alt 1484 // Prepend some descriptive text to alt. 1474 1485 $alt_default = !empty( $dn_default ) ? sprintf( __( 'Profile picture of %s', 'buddypress' ), $dn_default ) : __( 'Profile picture', 'buddypress' ); 1475 1486 … … 1487 1498 if ( !isset( $height ) && !isset( $width ) ) { 1488 1499 1489 // Backpat 1500 // Backpat. 1490 1501 if ( isset( $bp->avatar->full->height ) || isset( $bp->avatar->thumb->height ) ) { 1491 1502 $height = ( 'full' == $type ) ? $bp->avatar->full->height : $bp->avatar->thumb->height; … … 1494 1505 } 1495 1506 1496 // Backpat 1507 // Backpat. 1497 1508 if ( isset( $bp->avatar->full->width ) || isset( $bp->avatar->thumb->width ) ) { 1498 1509 $width = ( 'full' == $type ) ? $bp->avatar->full->width : $bp->avatar->thumb->width; … … 1587 1598 * @type int|bool $user_id Default: ID of the activity's user. 1588 1599 * } 1589 * @return string The secondary avatar 1600 * @return string The secondary avatar. 1590 1601 */ 1591 1602 function bp_get_activity_secondary_avatar( $args = '' ) { … … 1604 1615 extract( $r, EXTR_SKIP ); 1605 1616 1606 // Set item_id and object (default to user) 1617 // Set item_id and object (default to user). 1607 1618 switch ( $activities_template->activity->component ) { 1608 1619 case 'groups' : … … 1616 1627 $name = ''; 1617 1628 1618 // Only if groups is active 1629 // Only if groups is active. 1619 1630 if ( bp_is_active( 'groups' ) ) { 1620 1631 $group = groups_get_group( array( … … 1691 1702 $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id ); 1692 1703 1693 // If we have no item_id or object, there is no avatar to display 1704 // If we have no item_id or object, there is no avatar to display. 1694 1705 if ( empty( $item_id ) || empty( $object ) ) { 1695 1706 return false; 1696 1707 } 1697 1708 1698 // Get the avatar 1709 // Get the avatar. 1699 1710 $avatar = bp_core_fetch_avatar( array( 1700 1711 'item_id' => $item_id, … … 1745 1756 * @since 1.2.0 1746 1757 * 1747 * @param array $args See bp_get_activity_action() 1758 * @param array $args See bp_get_activity_action(). 1748 1759 * @uses bp_get_activity_action() 1749 1760 */ … … 1758 1769 * 1759 1770 * @global object $activities_template {@link BP_Activity_Template} 1760 * @param array $args Only parameter is "no_timestamp". If true, timestamp is shown in output.1761 1771 * @uses apply_filters_ref_array() To call the 'bp_get_activity_action_pre_meta' hook. 1762 1772 * @uses bp_insert_activity_meta() … … 1789 1799 ) ); 1790 1800 1791 // Prepend the activity action meta (link, time since, etc...) 1801 // Prepend the activity action meta (link, time since, etc...). 1792 1802 if ( ! empty( $action ) && empty( $r['no_timestamp'] ) ) { 1793 1803 $action = bp_insert_activity_meta( $action ); … … 1833 1843 global $activities_template; 1834 1844 1835 // Backwards compatibility if action is not being used 1845 // Backwards compatibility if action is not being used. 1836 1846 if ( empty( $activities_template->activity->action ) && ! empty( $activities_template->activity->content ) ) { 1837 1847 $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content ); … … 1925 1935 * 1926 1936 * @param string $content The activity content. 1927 *1928 1937 * @return string The activity content with the metadata string attached. 1929 1938 */ … … 1931 1940 global $activities_template; 1932 1941 1933 // Strip any legacy time since placeholders from BP 1.0-1.1 1942 // Strip any legacy time since placeholders from BP 1.0-1.1. 1934 1943 $new_content = str_replace( '<span class="time-since">%s</span>', '', $content ); 1935 1944 1936 // Get the time since this activity was recorded 1945 // Get the time since this activity was recorded. 1937 1946 $date_recorded = bp_core_time_since( $activities_template->activity->date_recorded ); 1938 1947 … … 1949 1958 ) ); 1950 1959 1951 // Insert the permalink 1960 // Insert the permalink. 1952 1961 if ( ! bp_is_single_activity() ) { 1953 1962 1954 // Setup variables for activity meta 1963 // Setup variables for activity meta. 1955 1964 $activity_permalink = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ); 1956 1965 $activity_meta = sprintf( '%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', … … 1966 1975 * @since 1.2.0 1967 1976 * 1968 * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component. 1977 * @param array $value Array containing the html markup for the activity permalink, after being parsed by 1978 * sprintf and current activity component. 1969 1979 */ 1970 1980 $new_content = apply_filters_ref_array( 'bp_activity_permalink', array( … … 1995 2005 * 1996 2006 * @param object|bool $activity Optional. Falls back on the current item in the loop. 1997 *1998 2007 * @return bool True if can delete, false otherwise. 1999 2008 */ … … 2001 2010 global $activities_template; 2002 2011 2003 // Try to use current activity if none was passed 2012 // Try to use current activity if none was passed. 2004 2013 if ( empty( $activity ) && ! empty( $activities_template->activity ) ) { 2005 2014 $activity = $activities_template->activity; 2006 2015 } 2007 2016 2008 // If current_comment is set, we'll use that in place of the main activity 2017 // If current_comment is set, we'll use that in place of the main activity. 2009 2018 if ( isset( $activity->current_comment ) ) { 2010 2019 $activity = $activity->current_comment; 2011 2020 } 2012 2021 2013 // Assume the user cannot delete the activity item 2022 // Assume the user cannot delete the activity item. 2014 2023 $can_delete = false; 2015 2024 2016 // Only logged in users can delete activity 2025 // Only logged in users can delete activity. 2017 2026 if ( is_user_logged_in() ) { 2018 2027 2019 // Community moderators can always delete activity (at least for now) 2028 // Community moderators can always delete activity (at least for now). 2020 2029 if ( bp_current_user_can( 'bp_moderate' ) ) { 2021 2030 $can_delete = true; … … 2029 2038 } 2030 2039 2031 // Viewing a single item, and this user is an admin of that item 2040 // Viewing a single item, and this user is an admin of that item. 2032 2041 if ( bp_is_single_item() && bp_is_item_admin() ) { 2033 2042 $can_delete = true; … … 2069 2078 * 2070 2079 * @param string $args Unused. Left over from an earlier implementation. 2071 *2072 2080 * @return mixed False on failure, otherwise the activity parent content. 2073 2081 */ … … 2075 2083 global $activities_template; 2076 2084 2077 // Bail if no activity on no item ID 2085 // Bail if no activity on no item ID. 2078 2086 if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) { 2079 2087 return false; 2080 2088 } 2081 2089 2082 // Get the ID of the parent activity content 2090 // Get the ID of the parent activity content. 2083 2091 $parent_id = (int) $activities_template->activity->item_id; 2084 2092 2085 // Bail if no parent content 2093 // Bail if no parent content. 2086 2094 if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) { 2087 2095 return false; 2088 2096 } 2089 2097 2090 // Bail if no action 2098 // Bail if no action. 2091 2099 if ( empty( $activities_template->activity_parents[ $parent_id ]->action ) ) { 2092 2100 return false; 2093 2101 } 2094 2102 2095 // Content always includes action 2103 // Content always includes action. 2096 2104 $content = $activities_template->activity_parents[ $parent_id ]->action; 2097 2105 2098 // Maybe append activity content, if it exists 2106 // Maybe append activity content, if it exists. 2099 2107 if ( ! empty( $activities_template->activity_parents[ $parent_id ]->content ) ) { 2100 2108 $content .= ' ' . $activities_template->activity_parents[ $parent_id ]->content; 2101 2109 } 2102 2110 2103 // Remove the time since content for backwards compatibility 2111 // Remove the time since content for backwards compatibility. 2104 2112 $content = str_replace( '<span class="time-since">%s</span>', '', $content ); 2105 2113 2106 // Remove images 2114 // Remove images. 2107 2115 $content = preg_replace( '/<img[^>]*>/Ui', '', $content ); 2108 2116 … … 2139 2147 global $activities_template; 2140 2148 2141 // Bail if no activity on no item ID 2149 // Bail if no activity on no item ID. 2142 2150 if ( empty( $activities_template->activity ) || empty( $activities_template->activity->item_id ) ) { 2143 2151 return false; 2144 2152 } 2145 2153 2146 // Get the ID of the parent activity content 2154 // Get the ID of the parent activity content. 2147 2155 $parent_id = (int) $activities_template->activity->item_id; 2148 2156 2149 // Bail if no parent item 2157 // Bail if no parent item. 2150 2158 if ( empty( $activities_template->activity_parents[ $parent_id ] ) ) { 2151 2159 return false; 2152 2160 } 2153 2161 2154 // Bail if no parent user ID 2162 // Bail if no parent user ID. 2155 2163 if ( empty( $activities_template->activity_parents[ $parent_id ]->user_id ) ) { 2156 2164 return false; … … 2222 2230 * 2223 2231 * @todo deprecate $args param 2224 *2225 2232 * @todo Given that checks for children already happen in bp_activity_recurse_comments(), 2226 * this function can probably be streamlined or removed. 2227 * 2228 * @param string $args Unused. Left over from an earlier implementation. 2233 * this function can probably be streamlined or removed. 2229 2234 * 2230 2235 * @global object $activities_template {@link BP_Activity_Template} 2231 2236 * @uses bp_activity_recurse_comments() 2232 2237 * 2238 * @param string $args Unused. Left over from an earlier implementation. 2233 2239 * @return bool 2234 2240 */ … … 2251 2257 * @since 1.2.0 2252 2258 * 2253 * @param object $comment The activity object currently being recursed.2254 *2255 2259 * @global object $activities_template {@link BP_Activity_Template} 2256 2260 * @uses locate_template() 2257 2261 * 2262 * @param object $comment The activity object currently being recursed. 2258 2263 * @return bool|string 2259 2264 */ … … 2279 2284 foreach ( (array) $comment->children as $comment_child ) { 2280 2285 2281 // Put the comment into the global so it's available to filters 2286 // Put the comment into the global so it's available to filters. 2282 2287 $activities_template->activity->current_comment = $comment_child; 2283 2288 … … 2475 2480 if ( isset( $activities_template->activity->current_comment->user_fullname ) ) { 2476 2481 2477 $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment ); // backward compatibility2482 $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment ); // Backward compatibility. 2478 2483 } else { 2479 2484 $name = $activities_template->activity->current_comment->display_name; … … 2661 2666 * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook. 2662 2667 * 2663 * @param array $deprecated Deprecated. 2664 * 2668 * @param array|null $deprecated Deprecated. 2665 2669 * @return int $count The activity comment count. 2666 2670 */ … … 2668 2672 global $activities_template; 2669 2673 2670 // Deprecated notice about $args 2674 // Deprecated notice about $args. 2671 2675 if ( ! empty( $deprecated ) ) { 2672 2676 _deprecated_argument( __FUNCTION__, '1.2', sprintf( __( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ), __FUNCTION__, __FILE__ ) ); 2673 2677 } 2674 2678 2675 // Get the count using the purpose-built recursive function 2679 // Get the count using the purpose-built recursive function. 2676 2680 $count = ! empty( $activities_template->activity->children ) 2677 2681 ? bp_activity_recurse_comment_count( $activities_template->activity ) … … 2701 2705 * @param object $comment Activity comment object. 2702 2706 * @param int $count The current iteration count. 2703 *2704 2707 * @return int $count The activity comment count. 2705 2708 */ 2706 2709 function bp_activity_recurse_comment_count( $comment, $count = 0 ) { 2707 2710 2708 // Copy the count 2711 // Copy the count. 2709 2712 $new_count = $count; 2710 2713 2711 // Loop through children and recursively count comments 2714 // Loop through children and recursively count comments. 2712 2715 if ( ! empty( $comment->children ) ) { 2713 2716 foreach ( (array) $comment->children as $comment ) { … … 2947 2950 global $activities_template; 2948 2951 2949 // Check that comment exists 2952 // Check that comment exists. 2950 2953 $comment_id = isset( $activities_template->activity->current_comment->id ) 2951 2954 ? $activities_template->activity->current_comment->id 2952 2955 : 0; 2953 2956 2954 // Setup the comment link 2957 // Setup the comment link. 2955 2958 $comment_link = ! empty( $comment_id ) 2956 2959 ? '#acomment-' .$comment_id 2957 2960 : false; 2958 2961 2959 // Append comment ID to end of activity permalink 2962 // Append comment ID to end of activity permalink. 2960 2963 $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . $comment_link; 2961 2964 … … 3141 3144 $class = 'delete-activity'; 3142 3145 3143 // Determine if we're on a single activity page, and customize accordingly 3146 // Determine if we're on a single activity page, and customize accordingly. 3144 3147 if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) { 3145 3148 $class = 'delete-activity-single'; … … 3191 3194 $url = trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id ); 3192 3195 3193 // Determine if we're on a single activity page, and customize accordingly 3196 // Determine if we're on a single activity page, and customize accordingly. 3194 3197 if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) { 3195 3198 $url = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url ); … … 3237 3240 * 3238 3241 * @param int $user_id If empty, will fall back on displayed user. 3239 *3240 3242 * @return string|bool $latest_update The activity latest update link. 3241 3243 * False on failure. … … 3321 3323 ) ); 3322 3324 3323 // Define local variable 3325 // Define local variable. 3324 3326 $component_links = array(); 3325 3327 3326 // Fetch the names of components that have activity recorded in the DB 3328 // Fetch the names of components that have activity recorded in the DB. 3327 3329 $components = BP_Activity_Activity::get_recorded_components(); 3328 3330 … … 3333 3335 foreach ( (array) $components as $component ) { 3334 3336 3335 // Skip the activity comment filter 3337 // Skip the activity comment filter. 3336 3338 if ( 'activity' == $component ) { 3337 3339 continue; … … 3411 3413 $bp = buddypress(); 3412 3414 3413 // Assume activity can be commented on 3415 // Assume activity can be commented on. 3414 3416 $can_comment = true; 3415 3417 3416 // Determine ability to comment based on activity action name 3418 // Determine ability to comment based on activity action name. 3417 3419 $activity_action = bp_get_activity_action_name(); 3418 3420 … … 3466 3468 function bp_activity_can_comment_reply( $comment = false ) { 3467 3469 3468 // Assume activity can be commented on 3470 // Assume activity can be commented on. 3469 3471 $can_comment = true; 3470 3472 3471 // Check that comment exists 3473 // Check that comment exists. 3472 3474 if ( empty( $comment ) ) { 3473 3475 $comment = bp_activity_current_comment(); … … 3476 3478 if ( ! empty( $comment ) ) { 3477 3479 3478 // Fall back on current comment in activity loop 3480 // Fall back on current comment in activity loop. 3479 3481 $comment_depth = isset( $comment->depth ) 3480 3482 ? intval( $comment->depth ) 3481 3483 : bp_activity_get_comment_depth(); 3482 3484 3483 // Threading is turned on, so check the depth 3485 // Threading is turned on, so check the depth. 3484 3486 if ( get_option( 'thread_comments' ) ) { 3485 3487 $can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) ); 3486 3488 3487 // No threading for comment replies if no threading for comments 3489 // No threading for comment replies if no threading for comments. 3488 3490 } else { 3489 3491 $can_comment = false; … … 3548 3550 * 3549 3551 * @param int $user_id ID of user being queried. Default: displayed user ID. 3550 *3551 3552 * @return int The total favorite count for the specified user. 3552 3553 */ … … 3555 3556 3556 3557 if ( bp_activity_can_favorite() ) { 3557 // Default to displayed user if none is passed 3558 // Default to displayed user if none is passed. 3558 3559 $user_id = empty( $user_id ) 3559 3560 ? bp_displayed_user_id() 3560 3561 : $user_id; 3561 3562 3562 // Get user meta if user ID exists 3563 // Get user meta if user ID exists. 3563 3564 if ( ! empty( $user_id ) ) { 3564 3565 $retval = bp_activity_total_favorites_for_user( $user_id ); … … 3600 3601 * 3601 3602 * @param int $user_id ID of user being queried. Default: displayed user ID. 3602 *3603 3603 * @return int The total mention count for the specified user. 3604 3604 */ 3605 3605 function bp_get_total_mention_count_for_user( $user_id = 0 ) { 3606 3606 3607 // Default to displayed user if none is passed 3607 // Default to displayed user if none is passed. 3608 3608 $user_id = empty( $user_id ) 3609 3609 ? bp_displayed_user_id() 3610 3610 : $user_id; 3611 3611 3612 // Get user meta if user ID exists 3612 // Get user meta if user ID exists. 3613 3613 $retval = ! empty( $user_id ) 3614 3614 ? bp_get_user_meta( $user_id, 'bp_new_mention_count', true ) … … 3652 3652 function bp_get_send_public_message_link() { 3653 3653 3654 // No link if not logged in, not looking at someone else's profile 3654 // No link if not logged in, not looking at someone else's profile. 3655 3655 if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() ) { 3656 3656 $retval = ''; … … 3678 3678 * @param array $activity Array of activities generated from {@link bp_activity_get()}. 3679 3679 * @param array $activity_ids Used for recursion purposes in this function. 3680 *3681 3680 * @return array 3682 3681 */ … … 3721 3720 * @uses apply_filters() To call the 'bp_get_mentioned_user_display_name' hook. 3722 3721 * 3723 * @param int|string|bool User ID or username. 3724 * 3722 * @param int|string|bool $user_id_or_username User ID or username. 3725 3723 * @return string The mentioned user's display name. 3726 3724 */ 3727 3725 function bp_get_mentioned_user_display_name( $user_id_or_username = false ) { 3728 3726 3729 // Get user display name 3727 // Get user display name. 3730 3728 $name = bp_core_get_user_displayname( $user_id_or_username ); 3731 3729 3732 // If user somehow has no name, return this really lame string 3730 // If user somehow has no name, return this really lame string. 3733 3731 if ( empty( $name ) ) { 3734 3732 $name = __( 'a user', 'buddypress' ); … … 3868 3866 ) ); 3869 3867 3870 // Get the user IDs of everyone who has left a comment to the current activity item 3868 // Get the user IDs of everyone who has left a comment to the current activity item. 3871 3869 $user_ids = bp_activity_get_comments_user_ids(); 3872 3870 $output = array(); … … 3876 3874 foreach ( (array) $user_ids as $user_id ) { 3877 3875 3878 // Skip an empty user ID 3876 // Skip an empty user ID. 3879 3877 if ( empty( $user_id ) ) { 3880 3878 continue; 3881 3879 } 3882 3880 3883 // Get profile link for this user 3881 // Get profile link for this user. 3884 3882 $profile_link = bp_core_get_user_domain( $user_id ); 3885 3883 3886 // Get avatar for this user 3884 // Get avatar for this user. 3887 3885 $image_html = bp_core_fetch_avatar( array( 3888 3886 'item_id' => $user_id, … … 3893 3891 ) ); 3894 3892 3895 // If user has link & avatar, add them to the output array 3893 // If user has link & avatar, add them to the output array. 3896 3894 if ( ! empty( $profile_link ) && ! empty( $image_html ) ) { 3897 3895 $output[] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $profile_link ), $image_html ); … … 3899 3897 } 3900 3898 3901 // If output array is not empty, wrap everything in some list items 3899 // If output array is not empty, wrap everything in some list items. 3902 3900 if ( ! empty( $output ) ) { 3903 3901 $retval = '<li>' . implode( '</li><li>', $output ) . '</li>'; … … 3947 3945 * 3948 3946 * @param array $comments Array of {@link BP_Activity_Activity} items. 3949 *3950 3947 * @return array Array of user IDs. 3951 3948 */ 3952 3949 function bp_activity_recurse_comments_user_ids( array $comments = array() ) { 3953 3950 3954 // Default user ID's array 3951 // Default user ID's array. 3955 3952 $user_ids = array(); 3956 3953 3957 // Loop through comments and try to get user ID's 3954 // Loop through comments and try to get user ID's. 3958 3955 if ( ! empty( $comments ) ) { 3959 3956 foreach ( $comments as $comment ) { … … 3965 3962 } 3966 3963 3967 // Add user ID to array 3964 // Add user ID to array. 3968 3965 $user_ids[] = $comment->user_id; 3969 3966 3970 // Check for commentception 3967 // Check for commentception. 3971 3968 if ( ! empty( $comment->children ) ) { 3972 3969 $user_ids = array_merge( $user_ids, bp_activity_recurse_comments_user_ids( $comment->children ) ); … … 4037 4034 natsort( $activities ); 4038 4035 4039 // Loop through the activity types and output markup 4036 // Loop through the activity types and output markup. 4040 4037 foreach ( $activities as $type => $description ) { 4041 4038 4042 // See if we need to preselect the current type 4039 // See if we need to preselect the current type. 4043 4040 $checked = checked( true, in_array( $type, (array) $args['selected'] ), false ); 4044 4041 $selected = selected( true, in_array( $type, (array) $args['selected'] ), false ); 4045 4042 4046 // Switch output based on the element 4043 // Switch output based on the element. 4047 4044 switch ( $output ) { 4048 4045 case 'select' : … … 4069 4066 } 4070 4067 4071 // Backpat with BP-Default for dropdown boxes only 4068 // Backpat with BP-Default for dropdown boxes only. 4072 4069 if ( 'select' === $output ) { 4073 4070 do_action( 'bp_activity_filter_options' ); … … 4153 4150 function bp_get_member_activity_feed_link() { 4154 4151 4155 // Single member activity feed link 4152 // Single member activity feed link. 4156 4153 if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) { 4157 4154 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/'; 4158 4155 4159 // Friend feed link 4156 // Friend feed link. 4160 4157 } elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) { 4161 4158 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/'; 4162 4159 4163 // Group feed link 4160 // Group feed link. 4164 4161 } elseif ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) { 4165 4162 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/'; 4166 4163 4167 // Favorites activity feed link 4164 // Favorites activity feed link. 4168 4165 } elseif ( 'favorites' === bp_current_action() ) { 4169 4166 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/'; 4170 4167 4171 // Mentions activity feed link 4168 // Mentions activity feed link. 4172 4169 } elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) { 4173 4170 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/'; 4174 4171 4175 // No feed link 4172 // No feed link. 4176 4173 } else { 4177 4174 $link = ''; … … 4395 4392 global $activities_template; 4396 4393 4397 // Get the content, if exists 4394 // Get the content, if exists. 4398 4395 $content = ! empty( $activities_template->activity->content ) 4399 4396 ? $activities_template->activity->content 4400 4397 : ''; 4401 4398 4402 // Perform a few string conversions on the content, if it's not empty 4399 // Perform a few string conversions on the content, if it's not empty. 4403 4400 if ( ! empty( $content ) ) { 4404 4401 $content = ent2ncr( convert_chars( str_replace( '%s', '', $content ) ) ); … … 4438 4435 * 4439 4436 * @param string $context The current context. 'activity', 'member', 4440 * 'member_groups', 'group'.4437 * 'member_groups', 'group'. 4441 4438 * @uses bp_get_activity_show_filters() 4442 4439 */ … … 4450 4447 * 4451 4448 * @param string $context The current context. 'activity', 'member', 4452 * 'member_groups', 'group'.4449 * 'member_groups', 'group'. 4453 4450 * 4454 4451 * @return string HTML for <option> values. 4455 4452 */ 4456 4453 function bp_get_activity_show_filters( $context = '' ) { 4457 // Set default context based on current page 4454 // Set default context based on current page. 4458 4455 if ( empty( $context ) ) { 4459 4456 4460 4457 // On member pages, default to 'member', unless this 4461 // is a user's Groups activity 4458 // is a user's Groups activity. 4462 4459 if ( bp_is_user() ) { 4463 4460 if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) { … … 4467 4464 } 4468 4465 4469 // On individual group pages, default to 'group' 4466 // On individual group pages, default to 'group'. 4470 4467 } elseif ( bp_is_active( 'groups' ) && bp_is_group() ) { 4471 4468 $context = 'group'; 4472 4469 4473 // 'activity' everywhere else 4470 // 'activity' everywhere else. 4474 4471 } else { 4475 4472 $context = 'activity'; … … 4487 4484 } 4488 4485 4489 // Friends activity collapses two filters into one 4486 // Friends activity collapses two filters into one. 4490 4487 if ( in_array( $action['key'], array( 'friendship_accepted', 'friendship_created' ) ) ) { 4491 4488 $action['key'] = 'friendship_accepted,friendship_created'; … … 4506 4503 $filters = apply_filters( 'bp_get_activity_show_filters_options', $filters, $context ); 4507 4504 4508 // Build the options output 4505 // Build the options output. 4509 4506 $output = ''; 4510 4507
Note: See TracChangeset
for help on using the changeset viewer.