Esempio n. 1
0
 /**
  * "In response to" column markup.
  *
  * @since BuddyPress (1.6.0)
  *
  * @see WP_List_Table::single_row_columns()
  *
  * @param array $item A singular item (one full row).
  */
 function column_response($item)
 {
     // Is $item is a root activity?
     /**
      * Filters default list of default root activity types.
      *
      * @since BuddyPress (1.6.0)
      *
      * @param array $value Array of default activity types.
      * @param array $item  Current item being displayed.
      */
     if (empty($item['item_id']) || !in_array($item['type'], apply_filters('bp_activity_admin_root_activity_types', array('activity_comment'), $item))) {
         $comment_count = !empty($item['children']) ? bp_activity_recurse_comment_count((object) $item) : 0;
         $root_activity_url = bp_get_admin_url('admin.php?page=bp-activity&aid=' . $item['id']);
         // If the activity has comments, display a link to the activity's permalink, with its comment count in a speech bubble
         if ($comment_count) {
             $title_attr = sprintf(_n('%s related activity', '%s related activities', $comment_count, 'buddypress'), number_format_i18n($comment_count));
             printf('<a href="%1$s" title="%2$s" class="post-com-count"><span class="comment-count">%3$s</span></a>', esc_url($root_activity_url), esc_attr($title_attr), number_format_i18n($comment_count));
         }
         // For non-root activities, display a link to the replied-to activity's author's profile
     } else {
         echo '<strong>' . get_avatar($this->get_activity_user_id($item['item_id']), '32') . ' ' . bp_core_get_userlink($this->get_activity_user_id($item['item_id'])) . '</strong><br />';
     }
     // Activity permalink
     if (!$item['is_spam']) {
         printf(__('<a href="%1$s">View Activity</a>', 'buddypress'), bp_activity_get_permalink($item['id'], (object) $item));
     }
 }
Esempio n. 2
0
/**
 * Gets the content of the activity comment currently being displayed
 *
 * The content is run through two filters. bp_get_activity_content will apply all filters
 * applied to activity items in general. Use bp_activity_comment_content to modify the
 * content of activity comments only.
 *
 * @since 1.2.0
 *
 * @todo investigate why bp_activity_recurse_comment_count() is used while being declared
 *
 * @param object $comment Activity comments object
 *
 * @global object $activities_template {@link BP_Activity_Template}
 * @global object $bp BuddyPress global settings
 * @uses bp_activity_recurse_comment_count()
 * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook
 *
 * @return int $count The activity comment count.
 */
function bp_activity_recurse_comment_count($comment, $count = 0)
{
    global $activities_template, $bp;
    if (!$comment->children) {
        return $count;
    }
    foreach ((array) $comment->children as $comment) {
        $count++;
        $count = bp_activity_recurse_comment_count($comment, $count);
    }
    return $count;
}
/**
 * Return the total number of comments to the current comment.
 *
 * This function recursively adds the total number of comments each
 * activity child has, and returns them.
 *
 * @since BuddyPress (1.2.0)
 *
 * @uses bp_activity_recurse_comment_count()
 * @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook
 *
 * @param object $comment Activity comment object.
 * @param int $count The current iteration count.
 *
 * @return int $count The activity comment count.
 */
function bp_activity_recurse_comment_count($comment, $count = 0)
{
    // Copy the count
    $new_count = $count;
    // Loop through children and recursively count comments
    if (!empty($comment->children)) {
        foreach ((array) $comment->children as $comment) {
            $new_count++;
            $new_count = bp_activity_recurse_comment_count($comment, $new_count);
        }
    }
    /**
     * Filters the total number of comments for the current comment.
     *
     * @since BuddyPress (2.1.0)
     *
     * @param int    $new_count New total count for the current comment.
     * @param object $comment Activity comment object.
     * @param int    $count Current iteration count for the current comment.
     */
    return apply_filters('bp_activity_recurse_comment_count', $new_count, $comment, $count);
}
Esempio n. 4
0
/**
 * Return the total number of comments to the current comment.
 *
 * This function recursively adds the total number of comments each
 * activity child has, and returns them.
 *
 * @since BuddyPress (1.2)
 *
 * @uses bp_activity_recurse_comment_count()
 * @uses apply_filters() To call the 'bp_activity_recurse_comment_count' hook
 *
 * @param object $comment Activity comment object.
 * @param int $count The current iteration count.
 *
 * @return int $count The activity comment count.
 */
function bp_activity_recurse_comment_count($comment, $count = 0)
{
    // Copy the count
    $new_count = $count;
    // Loop through children and recursively count comments
    if (!empty($comment->children)) {
        foreach ((array) $comment->children as $comment) {
            $new_count++;
            $new_count = bp_activity_recurse_comment_count($comment, $new_count);
        }
    }
    // Filter and return
    return apply_filters('bp_activity_recurse_comment_count', $new_count, $comment, $count);
}
/**
 * Return the content of the activity comment currently being displayed.
 *
 * The content is run through two filters. 'bp_get_activity_content'
 * will apply all filters applied to activity items in general.
 * Use bp_activity_comment_content to modify the content of
 * activity comments only.
 *
 * @since BuddyPress (1.2)
 *
 * @uses bp_activity_recurse_comment_count()
 * @uses apply_filters() To call the 'bp_activity_get_comment_count' hook
 * @todo investigate why bp_activity_recurse_comment_count() is used while being declared
 *
 * @param object $comment Activity comment object.
 * @param int $count The current iteration count.
 * @return int $count The activity comment count.
 */
function bp_activity_recurse_comment_count($comment, $count = 0)
{
    if (empty($comment->children)) {
        return $count;
    }
    foreach ((array) $comment->children as $comment) {
        $count++;
        $count = bp_activity_recurse_comment_count($comment, $count);
    }
    return $count;
}
Esempio n. 6
0
 /**
  * "In response to" column
  *
  * @param array $item A singular item (one full row)
  * @see WP_List_Table::single_row_columns()
  * @since 1.6
  */
 function column_response($item)
 {
     // Display link to user's profile
     echo bp_core_get_userlink($item['user_id']);
     // Get activity permalink
     $activity_link = bp_activity_get_permalink($item['id'], (object) $item);
     // Get the root activity ID by parsing the permalink; this may be not be the same as $item['id'] for nested items (e.g. activity_comments)
     $root_activity_id = array();
     preg_match('/\\/p\\/(\\d+)\\/*$/i', $activity_link, $root_activity_id);
     if (empty($root_activity_id[1])) {
         return;
     }
     $root_activity_id = (int) $root_activity_id[1];
     // Is $item the root activity?
     if ((int) $item['id'] == $root_activity_id) {
         $root_activity = (object) $item;
         // Get root activity comment count
         $comment_count = !empty($root_activity->children) ? bp_activity_recurse_comment_count($root_activity) : 0;
         // Display a link to the root activity's permalink, with its comment count in a speech bubble
         printf('<br /><a href="%1$s" title="%2$s" class="post-com-count"><span class="comment-count">%3$d</span></a>', network_admin_url('admin.php?page=bp-activity&amp;aid=' . $root_activity_id), esc_attr(sprintf(__('%d related activities', 'buddypress'), $comment_count)), $comment_count);
         // $item is not the root activity (it is probably an activity_comment).
     } else {
         echo '<br />';
         // @todo Get comment count from a specific node ($root_activity_id) in the tree, not $root_activity_id's root.
     }
     // Link to the activity permalink
     printf(__('<a href="%1$s">View Activity</a>', 'buddypress'), bp_activity_get_permalink($item['id'], (object) $item));
 }