/** * Echo a list of linked avatars of users who have commented on the current activity item. * * Use this function to easily output activity comment authors' avatars. * * Avatars are wrapped in <li> elements, but you've got to provide your own * <ul> or <ol> wrapper markup. * * @since BuddyPress (1.7) * * @see bp_core_fetch_avatar() for a description of arguments. * * @param array $args See {@link bp_core_fetch_avatar()}. */ function bp_activity_comments_user_avatars($args = array()) { $r = bp_parse_args($args, array('height' => false, 'html' => true, 'type' => 'thumb', 'width' => false)); // Get the user IDs of everyone who has left a comment to the current activity item $user_ids = bp_activity_get_comments_user_ids(); $output = array(); $retval = ''; if (!empty($user_ids)) { foreach ((array) $user_ids as $user_id) { // Skip an empty user ID if (empty($user_id)) { continue; } // Get profile link for this user $profile_link = bp_core_get_user_domain($user_id); // Get avatar for this user $image_html = bp_core_fetch_avatar(array('item_id' => $user_id, 'height' => $r['height'], 'html' => $r['html'], 'type' => $r['type'], 'width' => $r['width'])); // If user has link & avatar, add them to the output array if (!empty($profile_link) && !empty($image_html)) { $output[] = sprintf('<a href="%1$s">%2$s</a>', esc_url($profile_link), $image_html); } } // If output array is not empty, wrap everything in some list items if (!empty($output)) { $retval = '<li>' . implode('</li><li>', $output) . '</li>'; } } echo apply_filters('bp_activity_comments_user_avatars', $retval, $r, $output); }
/** * Echo a list of linked avatars of users who have commented on the current activity item. * * Use this function to easily output activity comment authors' avatars. * * Avatars are wrapped in <li> elements, but you've got to provide your own * <ul> or <ol> wrapper markup. * * @since BuddyPress (1.7.0) * * @see bp_core_fetch_avatar() for a description of arguments. * * @param array $args See {@link bp_core_fetch_avatar()}. */ function bp_activity_comments_user_avatars($args = array()) { $r = bp_parse_args($args, array('height' => false, 'html' => true, 'type' => 'thumb', 'width' => false)); // Get the user IDs of everyone who has left a comment to the current activity item $user_ids = bp_activity_get_comments_user_ids(); $output = array(); $retval = ''; if (!empty($user_ids)) { foreach ((array) $user_ids as $user_id) { // Skip an empty user ID if (empty($user_id)) { continue; } // Get profile link for this user $profile_link = bp_core_get_user_domain($user_id); // Get avatar for this user $image_html = bp_core_fetch_avatar(array('item_id' => $user_id, 'height' => $r['height'], 'html' => $r['html'], 'type' => $r['type'], 'width' => $r['width'])); // If user has link & avatar, add them to the output array if (!empty($profile_link) && !empty($image_html)) { $output[] = sprintf('<a href="%1$s">%2$s</a>', esc_url($profile_link), $image_html); } } // If output array is not empty, wrap everything in some list items if (!empty($output)) { $retval = '<li>' . implode('</li><li>', $output) . '</li>'; } } /** * Filters the list of linked avatars for users who have commented on the current activity item. * * @since BuddyPress (1.7.0) * * @param string $retval HTML markup for the list of avatars. * @param array $r Array of arguments used for each avatar. * @param array $output Array of each avatar found, before imploded into single string. */ echo apply_filters('bp_activity_comments_user_avatars', $retval, $r, $output); }
/** * Echo a list of linked avatars of users who have commented on the current activity item. * * Use this function to easily output activity comment authors' avatars. * * Avatars are wrapped in <li> elements, but you've got to provide your own * <ul> or <ol> wrapper markup. * * @since BuddyPress (1.7) * * @see bp_core_fetch_avatar() for a description of arguments. * * @param array $args See {@link bp_core_fetch_avatar()}. */ function bp_activity_comments_user_avatars($args = array()) { $defaults = array('height' => false, 'html' => true, 'type' => 'thumb', 'width' => false); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); // Get the user IDs of everyone who has left a comment to the current activity item $user_ids = bp_activity_get_comments_user_ids(); $output = array(); foreach ((array) $user_ids as $user_id) { $profile_link = bp_core_get_user_domain($user_id); $image_html = bp_core_fetch_avatar(array('item_id' => $user_id, 'height' => $height, 'html' => $html, 'type' => $type, 'width' => $width)); $output[] = sprintf('<a href="%1$s">%2$s</a>', esc_url($profile_link), $image_html); } echo apply_filters('bp_activity_comments_user_avatars', '<li>' . implode('</li><li>', $output) . '</li>', $args, $output); }