function rtmedia_api_media_data_from_object($media) { if (empty($media)) { return false; } $media_data = array(); $media_data['id'] = $media["id"]; $media_data['src'] = rtmedia_image('rt_media_activity_image', $media["id"], false); $media_data["title"] = $media["media_title"]; $media_data['comment_count'] = bp_activity_get_comment_count(); return $media_data; }
/** * get_activity function. * * @access public * @param mixed $filter * @return void */ public function get_activity($filter) { $args = $filter; if (bp_has_activities($args)) { while (bp_activities()) { bp_the_activity(); $activity = array('avatar' => bp_core_fetch_avatar(array('html' => false, 'item_id' => bp_get_activity_id())), 'action' => bp_get_activity_action(), 'content' => bp_get_activity_content_body(), 'activity_id' => bp_get_activity_id(), 'activity_username' => bp_core_get_username(bp_get_activity_user_id()), 'user_id' => bp_get_activity_user_id(), 'comment_count' => bp_activity_get_comment_count(), 'can_comment' => bp_activity_can_comment(), 'can_favorite' => bp_activity_can_favorite(), 'is_favorite' => bp_get_activity_is_favorite(), 'can_delete' => bp_activity_user_can_delete()); $activity = apply_filters('bp_json_prepare_activity', $activity); $activities[] = $activity; } $data = array('activity' => $activities, 'has_more_items' => bp_activity_has_more_items()); $data = apply_filters('bp_json_prepare_activities', $data); } else { return new WP_Error('bp_json_activity', __('No Activity Found.', 'buddypress'), array('status' => 200)); } $response = new WP_REST_Response(); $response->set_data($data); $response = rest_ensure_response($response); return $response; }
</div> </div> <?php /** * Fires before the display of the activity entry comments. * * @since BuddyPress (1.2.0) */ do_action('bp_before_activity_entry_comments'); ?> <?php if (bp_activity_get_comment_count() || bp_activity_can_comment() || bp_is_single_activity()) { ?> <div class="activity-comments"> <?php bp_activity_comments(); ?> <?php if (is_user_logged_in() && bp_activity_can_comment()) { ?> <form action="<?php bp_activity_comment_form_action(); ?>
?> <div class="activity-meta"> <?php if (bp_activity_can_comment()) { ?> <a href="<?php bp_activity_comment_link(); ?> " class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?> "><?php printf(__('Comment <span>%s</span>', 'buddypress'), bp_activity_get_comment_count()); ?> </a> <?php } ?> <?php if (bp_activity_can_favorite()) { ?> <?php if (!bp_get_activity_is_favorite()) { ?>
function show_comment_form() { $activity_id = get_post_meta($this->id, 'bp_media_child_activity', true); if (bp_has_activities(array( 'display_comments' => 'stream', 'include' => $activity_id, 'max' => 1 ))) : while (bp_activities()) : bp_the_activity(); do_action('bp_before_activity_entry'); ?> <div class="activity"> <ul id="activity-stream" class="activity-list item-list"> <li class="activity activity_update" id="activity-<?php echo $activity_id; ?>"> <div class="activity-content"> <?php do_action('bp_activity_entry_content'); ?> <?php if (is_user_logged_in()) : ?> <div class="activity-meta no-ajax"> <?php if (bp_activity_can_comment()) : ?> <a href="<?php bp_get_activity_comment_link(); ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><?php printf(__('Comment <span>%s</span>', 'buddypress'), bp_activity_get_comment_count()); ?></a> <?php endif; ?> <?php if (bp_activity_can_favorite()) : ?> <?php if (!bp_get_activity_is_favorite()) : ?> <a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e('Mark as Favorite', 'buddypress'); ?>"><?php _e('Favorite', 'buddypress') ?></a> <?php else : ?> <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e('Remove Favorite', 'buddypress'); ?>"><?php _e('Remove Favorite', 'buddypress') ?></a> <?php endif; ?> <?php endif; ?> <?php if (bp_activity_user_can_delete()) bp_activity_delete_link(); ?> <?php do_action('bp_activity_entry_meta'); ?> </div> <?php endif; ?> </div> <?php do_action('bp_before_activity_entry_comments'); ?> <?php if (( is_user_logged_in() && bp_activity_can_comment() ) || bp_activity_get_comment_count()) : ?> <div class="activity-comments"> <?php bp_activity_comments(); ?> <?php if (is_user_logged_in()) : ?> <form action="<?php bp_activity_comment_form_action(); ?>" method="post" id="ac-form-<?php bp_activity_id(); ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display(); ?>> <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar('width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT); ?></div> <div class="ac-reply-content"> <div class="ac-textarea"> <textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input" name="ac_input_<?php bp_activity_id(); ?>"></textarea> </div> <input type="submit" name="ac_form_submit" value="<?php _e('Post', 'buddypress'); ?>" /> <?php _e('or press esc to cancel.', 'buddypress'); ?> <input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" /> </div> <?php do_action('bp_activity_entry_comments'); ?> <?php wp_nonce_field('new_activity_comment', '_wpnonce_new_activity_comment'); ?> </form> <?php endif; ?> </div> <?php endif; ?> <?php do_action('bp_after_activity_entry_comments'); ?> </li> </ul> </div> <?php endwhile; else: ?> <div class="activity"> <ul id="activity-stream" class="activity-list item-list"> <li class="activity activity_update" id="activity-<?php echo $activity_id; ?>"> <div class="activity-content"> <?php do_action('bp_activity_entry_content'); ?> <?php if (is_user_logged_in()) : ?> <div class="activity-meta no-ajax"> <a href="<?php echo $this->get_delete_url(); ?>" class="button item-button bp-secondary-action delete-activity-single confirm" rel="nofollow">Delete</a> </div> <?php endif; ?> </div> </li> </ul> </div> <? endif; }
/** * Gets the activity CSS class * * @since 1.0.0 * * @global object $activities_template {@link BP_Activity_Template} * @uses apply_filters() To call the 'bp_activity_mini_activity_types' hook * @uses bp_activity_get_comment_count() * @uses bp_activity_can_comment() * @uses apply_filters() To call the 'bp_get_activity_css_class' hook * * @return string The activity css class */ function bp_get_activity_css_class() { global $activities_template; $mini_activity_actions = apply_filters('bp_activity_mini_activity_types', array('friendship_accepted', 'friendship_created', 'new_blog', 'joined_group', 'created_group', 'new_member')); $class = ''; if (in_array($activities_template->activity->type, (array) $mini_activity_actions) || empty($activities_template->activity->content)) { $class = ' mini'; } if (bp_activity_get_comment_count() && bp_activity_can_comment()) { $class .= ' has-comments'; } return apply_filters('bp_get_activity_css_class', $activities_template->activity->component . ' ' . $activities_template->activity->type . $class); }
?> <div class="activity-meta"> <?php if (bp_activity_can_comment()) { ?> <a href="<?php bp_activity_comment_link(); ?> " class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?> "><?php printf(__('Comment <span>%s</span>', 'vibe'), bp_activity_get_comment_count()); ?> </a> <?php } ?> <?php if (bp_activity_can_favorite()) { ?> <?php if (!bp_get_activity_is_favorite()) { ?>
<?php if (is_user_logged_in()) { ?> <?php if (bp_activity_can_comment()) { ?> <a href="<?php bp_activity_comment_link(); ?> " class="acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?> "><?php printf(__('Comment <span class="x-bp-count">%s</span>', 'buddypress'), bp_activity_get_comment_count()); ?> </a> <?php } ?> <?php if (bp_activity_can_favorite()) { ?> <?php if (!bp_get_activity_is_favorite()) { ?>
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?> </pubDate> <description> <![CDATA[ <?php bp_activity_feed_item_description(); ?> <?php if (bp_activity_can_comment()) { ?> <p><?php printf(__('Comments: %s', 'dpa'), bp_activity_get_comment_count()); ?> </p> <?php } ?> ]]> </description> <?php do_action('dpa_myachievements_feed_item'); ?> </item> <?php } ?>
?> <div class="activity-meta"> <?php if (bp_activity_can_comment()) { ?> <a href="<?php bp_activity_comment_link(); ?> " class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?> "><?php printf(__('Comment <span>%s</span>', 'wplms_modern'), bp_activity_get_comment_count()); ?> </a> <?php } ?> <?php if (bp_activity_can_favorite()) { ?> <?php if (!bp_get_activity_is_favorite()) { ?>
?> </div> <?php do_action('bp_before_activity_entry_comments'); ?> <?php if (bp_activity_can_comment() || bp_activity_get_comment_count()) { ?> <div class="activity-comments"> <?php if (!bp_activity_can_comment() || !bp_activity_get_comment_count()) { ?> <?php wall_add_likes_comments(); ?> <?php } else { ?> <?php bp_activity_comments(); ?> <?php
function get_wall_add_likes_comments($activity_id) { global $bp, $buddyboss_wall; static $ran = array(); // Only get likes for parent comment items, this can be done else where // but let's take care if it at the source of the action if (isset($_POST['action']) && $_POST['action'] == 'new_activity_comment') { return; } // Only run once if (isset($ran[$activity_id]) && $ran[$activity_id] === true) { return; } $ran[$activity_id] = true; $activity_id = (int) $activity_id; if ($activity_id === 0) { return false; } $count = (int) bp_activity_get_meta($activity_id, 'favorite_count'); if ($count === 0) { return false; } $user_likes_this = false; $user_logged_in = is_user_logged_in(); $subject_single = __('person', 'buddyboss'); $subject_plural = __('people', 'buddyboss'); $subject = $count == 1 ? $subject_single : $subject_plural; $verb_single = __('likes', 'buddyboss'); $verb_plural = __('like', 'buddyboss'); $verb = $count > 1 ? $verb_plural : $verb_single; $count_txt = number_format_i18n($count) . ' '; $like_html = ''; $like_txt = ''; $tooltip_txt = ''; $tooltip_html = ''; $activity_classes = array('activity-like-count'); // If we don't have a current activity ID we're not in the loop and // this is an AJAX request and we need to create a loop $forced_loop = false; $wrap_in_ul = false; if (!bp_get_activity_id()) { if (bp_has_activities('include=' . $activity_id)) { while (bp_activities()) { bp_the_activity(); // If there are no comments we need to wrap this in a UL if (!bp_activity_get_comment_count()) { $wrap_in_ul = true; } $forced_loop = true; } } } else { // If there are no comments we need to wrap this in a UL if (!bp_activity_get_comment_count()) { $wrap_in_ul = true; } } // Check if user likes this if ($user_logged_in) { $user_id = intval(bp_loggedin_user_id()); $favorite_activity_entries = bp_get_user_meta($user_id, 'bp_favorite_activities', true); // Check if logged in user likes this as well if (!empty($favorite_activity_entries) && in_array($activity_id, $favorite_activity_entries)) { $user_likes_this = true; } } // If user isn't logged we show simple like html if (!$user_logged_in) { $like_txt = sprintf(__('%s %s %s this.', 'buddyboss'), $count_txt, $subject, $verb); } else { $users_who_liked = buddyboss_wall_get_users_who_liked($activity_id); $like_txt = $count . ($user_likes_this ? 'y' : 'n'); // Only user likes this if ($count === 1 && $user_likes_this) { $like_txt = __('You like this.', 'buddyboss'); } else { $liked_for_display = array(); $liked_for_tooltip = array(); $current = 0; // Fallback $like_txt = __('Error getting likes.', 'buddyboss'); foreach ($users_who_liked as $user) { $user_liked_html = '<a href="' . esc_url($user['profile']) . '" title="' . esc_attr($user['name']) . '">' . esc_html($user['name']) . '</a>'; // For the first two we want the output to show if ($current < 2) { $liked_for_display[] = $user_liked_html; } else { $liked_for_tooltip[] = $user_liked_html; } $current++; } $others = count($liked_for_tooltip); // 1 user if (count($liked_for_display) === 1) { if ($user_likes_this) { $like_txt = sprintf(__('You and %s %s this.', 'buddyboss'), $liked_for_display[0], $verb_plural); } else { $like_txt = sprintf(__('%s %s this.', 'buddyboss'), $liked_for_display[0], $verb_single); } } else { if (count($liked_for_display) === 2 && $others === 0) { if ($user_likes_this) { $like_txt = sprintf(__('You, %s and %s %s this.', 'buddyboss'), $liked_for_display[0], $liked_for_display[1], $verb_plural); } else { $like_txt = sprintf(__('%s and %s %s this.', 'buddyboss'), $liked_for_display[0], $liked_for_display[1], $verb_plural); } } else { if (count($liked_for_display) === 2 && $others > 0) { $subject = $others === 1 ? $subject_single : $subject_plural; $verb = $others === 1 ? $verb_single : $verb_plural; $others_count_txt = number_format_i18n($others); $others_i18n = sprintf(__('%s other %s', 'buddyboss'), $others_count_txt, $subject); $others_txt = '<a class="buddyboss-wall-tt-others">' . $others_i18n . '</a>'; if ($user_likes_this) { $like_txt = sprintf(__('You, %s, %s and %s %s this.', 'buddyboss'), $liked_for_display[0], $liked_for_display[1], $others_txt, $verb_plural); } else { $like_txt = sprintf(__('%s, %s and %s %s this.', 'buddyboss'), $liked_for_display[0], $liked_for_display[1], $others_txt, $verb_plural); } } } } // Tooltip if (!empty($liked_for_tooltip)) { $tooltip_html = implode('<br/>', $liked_for_tooltip); $like_txt .= '<div class="buddyboss-wall-tt-content">' . $tooltip_html . '</div>'; $activity_classes[] = 'buddyboss-wall-tt'; } $liked_for_display_html = implode(',', $liked_for_display); // var_dump( $liked_for_display ); // var_dump( $liked_for_tooltip ); } } $activity_class = implode(' ', $activity_classes); $like_html = sprintf('<li class="%s">%s</li>', $activity_class, $like_txt); if ($wrap_in_ul) { $like_html = '<ul>' . $like_html . '</ul>'; } return $like_html; }
bp_activity_delete_link(); } ?> <?php // Activity Comment Button if (bp_activity_can_comment()) { ?> <a href="<?php bp_activity_comment_link(); ?> " class="button-dark acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?> "><i class="fa fa-comments"></i>Comment <span class="comments-link-count activity-count"><?php echo bp_activity_get_comment_count(); ?> </span></a> <?php } ?> </div> <?php } ?> </header> <?php if (bp_activity_has_content()) { ?> <blockquote class="activity-content">
/** * Prints the markup for the activity embed comments button. * * Basically a copy of {@link print_embed_comments_button()}, but modified for * the BP activity component. * * @since 2.6.0 */ public function embed_comments_button() { if (!did_action('bp_embed_content') || !bp_is_single_activity()) { return; } // Make sure our custom permalink shows up in the 'WordPress Embed' block. add_filter('the_permalink', array($this, 'filter_embed_url')); // Only show comment bubble if we have some activity comments. $count = bp_activity_get_comment_count(); if (empty($count)) { return; } ?> <div class="wp-embed-comments"> <a href="<?php bp_activity_thread_permalink(); ?> "> <span class="dashicons dashicons-admin-comments"></span> <?php printf(_n('%s <span class="screen-reader-text">Comment</span>', '%s <span class="screen-reader-text">Comments</span>', $count, 'buddypress'), number_format_i18n($count)); ?> </a> </div> <?php }
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?> </pubDate> <description> <![CDATA[ <?php bp_activity_feed_item_description(); ?> <?php if (bp_activity_can_comment()) { ?> <p><?php printf(__('Comments: %s', 'buddypress'), bp_activity_get_comment_count()); ?> </p> <?php } ?> <?php if ('activity_comment' == bp_get_activity_action_name()) { ?> <br /><strong><?php _e('In reply to', 'buddypress'); ?> </strong> - <?php bp_activity_parent_content();
/** * Return the current activity item's CSS class. * * @since BuddyPress (1.0.0) * * @global object $activities_template {@link BP_Activity_Template} * @uses apply_filters() To call the 'bp_activity_mini_activity_types' hook. * @uses bp_activity_get_comment_count() * @uses bp_activity_can_comment() * @uses apply_filters() To call the 'bp_get_activity_css_class' hook. * * @return string The activity item's CSS class. */ function bp_get_activity_css_class() { global $activities_template; /** * Filters the available mini activity actions available as CSS classes. * * @since BuddyPress (1.2.0) * * @param array $value Array of classes used to determine classes applied to HTML element. */ $mini_activity_actions = apply_filters('bp_activity_mini_activity_types', array('friendship_accepted', 'friendship_created', 'new_blog', 'joined_group', 'created_group', 'new_member')); $class = ' activity-item'; if (in_array($activities_template->activity->type, (array) $mini_activity_actions) || empty($activities_template->activity->content)) { $class .= ' mini'; } if (bp_activity_get_comment_count() && bp_activity_can_comment()) { $class .= ' has-comments'; } /** * Filters the determined classes to add to the HTML element. * * @since BuddyPress (1.0.0) * * @param string $value Classes to be added to the HTML element. */ return apply_filters('bp_get_activity_css_class', $activities_template->activity->component . ' ' . $activities_template->activity->type . $class); }
?> </div> <?php } ?> </div> <?php do_action('bp_before_activity_entry_comments'); ?> <?php if (is_user_logged_in() && bp_activity_can_comment() || bp_activity_get_comment_count()) { ?> <div class="activity-comments"> <?php bp_activity_comments(); ?> <?php if (is_user_logged_in()) { ?> <form action="<?php bp_activity_comment_form_action(); ?>
<div class="activity-footer"> <?php if (is_user_logged_in()) { ?> <?php if (bp_activity_can_comment()) { ?> <a href="<?php bp_activity_comment_link(); ?> " class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?> "> <?php if ($c = bp_activity_get_comment_count()) { ?> <i class="fa fa-fw fa-comments-o"></i> <?php printf(__('Comment <span class="badge">%s</span>', 'buddypress'), $c); ?> <?php } else { ?> <i class="fa fa-fw fa-comment-o"></i> <?php printf(__('Comment', 'buddypress'), $c); ?> <?php } ?>