function rmedia_single_comment($comment) { global $allowedtags; $html = ""; $html .= '<li class="rtmedia-comment">'; if ($comment['user_id']) { $user_link = "<a href='" . get_rtmedia_user_link($comment['user_id']) . "' title='" . rtmedia_get_author_name($comment['user_id']) . "'>" . rtmedia_get_author_name($comment['user_id']) . "</a>"; $user_name = apply_filters('rtmedia_comment_author_name', $user_link, $comment); $profile_pic = rtmedia_author_profile_pic($show_link = true, $echo = false, $comment['user_id']); } else { $user_name = "Annonymous"; $profile_pic = ""; } if ($profile_pic != "") { $html .= "<div class='rtmedia-comment-user-pic cleafix'>" . $profile_pic . "</div>"; } $html .= "<div class='rtm-comment-wrap'><div class='rtmedia-comment-details'>"; $html .= '<span class ="rtmedia-comment-author">' . '' . $user_name . '</span>'; $html .= '<span class ="rtmedia-comment-date"> ' . apply_filters('rtmedia_comment_date_format', rtmedia_convert_date($comment['comment_date_gmt']), $comment) . '</span>'; $comment_string = wp_kses($comment['comment_content'], $allowedtags); $html .= '<div class="rtmedia-comment-content">' . wpautop(make_clickable(apply_filters('bp_get_activity_content', $comment_string))) . '</div>'; global $rtmedia_media; if (is_rt_admin() || isset($comment['user_id']) && (get_current_user_id() == $comment['user_id'] || $rtmedia_media->media_author == get_current_user_id()) || apply_filters('rtmedia_allow_comment_delete', false)) { // show delete button for comment author and admins $html .= '<i data-id="' . $comment['comment_ID'] . '" class = "rtmedia-delete-comment dashicons dashicons-no-alt rtmicon" title="' . __('Delete Comment', 'rtmedia') . '"></i>'; } $html .= '<div class="clear"></div></div></div></li>'; return apply_filters('rtmedia_single_comment', $html, $comment); }
/** * * Outputs the HTML code of this widget. * * @param array An array of standard parameters for widgets in this theme * @param array An array of settings for this widget instance * @return void * **/ function widget($args, $instance) { global $bp; global $rtmedia_query, $rtmedia_interaction, $rtmedia_media; global $rtmedia_backbone; $cache = get_transient(md5($this->id)); // the part with the title and widget wrappers cannot be cached! // in order to avoid problems with the calculating columns // extract($args, EXTR_SKIP); $title = apply_filters('widget_title', empty($instance['title']) ? __('BuddyPress Activity', GKTPLNAME) : $instance['title'], $instance, $this->id_base); echo $before_widget; echo $before_title; echo $title; echo $after_title; if ($cache) { echo $cache; echo $after_widget; return; } ob_start(); // $data_source_type = empty($instance['data_source_type']) ? 'latest' : $instance['data_source_type']; $user_id = empty($instance['user_id']) ? '' : $instance['user_id']; $total_amount = empty($instance['total_amount']) ? 8 : $instance['total_amount']; $show_username = empty($instance['show_username']) ? 'enable' : $instance['show_username']; $show_readmore = empty($instance['show_readmore']) ? 'enable' : $instance['show_readmore']; $amount_page = empty($instance['amount_page']) ? 4 : $instance['amount_page']; $autoanimation = empty($instance['autoanimation']) ? 'disable' : $instance['autoanimation']; $photo_width = empty($instance['photo_width']) ? 310 : $instance['photo_width']; $offset = empty($instance['offset']) ? 0 : $instance['offset']; if (!is_numeric($offset)) { $offset = 0; } else { $offset = intval($offset); } if (!is_numeric($total_amount)) { $total_amount = 0; } else { $total_amount = intval($total_amount); } $width = 3000; $new_width = $total_amount * $photo_width; if ($new_width > 3000) { $width = $new_width; } $model = new RTMediaModel(); if ($data_source_type == 'user') { $media = $model->get_media(array('media_type' => 'photo', 'media_author' => $user_id), $offset, $total_amount); } else { $media = $model->get_media(array('media_type' => 'photo'), $offset, $total_amount); } ?> <div data-cols="<?php echo $amount_page; ?> " style="width: <?php echo $width; ?> px" <?php if ($autoanimation == 'enabled') { echo 'class="animate"'; } ?> > <?php if ($media == null) { ?> <h4> <?php echo __('GK BuddyPress Gallery: There has been no recent activity.', GKTPLNAME); ?> </h4> <?php } else { ?> <?php foreach ($media as $img) { ?> <figure style="width: <?php echo $photo_width; ?> px"> <img src="<?php rtmedia_image("rt_media_activity_image", rtmedia_id($img->media_id)); ?> " alt="<?php _e('View full image', GKTPLNAME); ?> " /> <figcaption> <?php if ($show_username == 'enabled') { ?> <small><?php echo rtmedia_get_author_name($img->media_author); ?> </small> <?php } ?> <p><?php echo $this->activity_text($this->gk_activity_content($img->activity_id), 15, false); ?> </p> <?php if ($show_readmore == 'enabled') { ?> <a href ="<?php echo get_rtmedia_permalink(rtmedia_id($img->media_id)); ?> "><?php _e('Read more...', GKTPLNAME); ?> </a> <?php } ?> </figcaption> </figure> <?php } ?> <?php } ?> </div> <?php // save the cache results $cache_output = ob_get_flush(); set_transient(md5($this->id), $cache_output, 3 * 60 * 60); // echo $after_widget; }
/** * Render single comment, * And display show all comment link to display all comment * @param [array] $comment [comment] * @param [int] $count [default false other ways comment count] * @param [int] $i [default false other ways increment with loop] * By: Yahil */ function rmedia_single_comment($comment, $count = false, $i = false) { $html = ''; $class = ''; if (isset($count) && $count) { $hide = $count - 5; if ($i < $hide) { $class = 'hide'; if (0 == $i) { echo '<div class="rtmedia-like-info"><span id="rtmedia_show_all_comment"> ' . esc_html('Show all ' . $count . ' comments', 'rtmedia') . ' </span></div>'; } } } global $allowedtags, $rtmedia_media; $html .= '<li class="rtmedia-comment ' . $class . ' ">'; if ($comment['user_id']) { $user_link = "<a href='" . esc_url(get_rtmedia_user_link($comment['user_id'])) . "' title='" . esc_attr(rtmedia_get_author_name($comment['user_id'])) . "'>" . esc_html(rtmedia_get_author_name($comment['user_id'])) . '</a>'; $user_name = apply_filters('rtmedia_comment_author_name', $user_link, $comment); $profile_pic = rtmedia_author_profile_pic($show_link = true, $echo = false, $comment['user_id']); } else { $user_name = 'Annonymous'; $profile_pic = ''; } if (!empty($profile_pic)) { $html .= "<div class='rtmedia-comment-user-pic cleafix'>" . $profile_pic . '</div>'; } $html .= "<div class='rtm-comment-wrap'><div class='rtmedia-comment-details'>"; $html .= '<span class ="rtmedia-comment-author">' . $user_name . '</span>'; $html .= '<span class ="rtmedia-comment-date"> ' . apply_filters('rtmedia_comment_date_format', rtmedia_convert_date($comment['comment_date_gmt']), $comment) . '</span>'; $comment_content = $comment['comment_content']; $activity_comment_content = get_comment_meta($comment['comment_ID'], 'activity_comment_content', true); if (empty($activity_comment_content)) { $activity_id = (int) get_comment_meta($comment['comment_ID'], 'activity_id', true); if ($activity_id) { $rtmedia_activity_comment = rtmedia_activity_comment($activity_id); if ($rtmedia_activity_comment['content']) { $comment_content = $rtmedia_activity_comment['content']; update_comment_meta($comment['comment_ID'], 'activity_comment_content', $rtmedia_activity_comment['content']); } } } else { $comment_content = $activity_comment_content; } $comment_string = wp_kses($comment_content, $allowedtags); $html .= '<div class="rtmedia-comment-content">' . wpautop(make_clickable(apply_filters('bp_get_activity_content', $comment_string))) . '</div>'; $html .= '<div class="rtmedia-comment-extra">' . apply_filters('rtmedia_comment_extra', '', $comment) . '</div>'; if (is_rt_admin() || isset($comment['user_id']) && (get_current_user_id() === intval($comment['user_id']) || intval($rtmedia_media->media_author) === get_current_user_id()) || apply_filters('rtmedia_allow_comment_delete', false)) { // show delete button for comment author and admins $html .= '<i data-id="' . esc_attr($comment['comment_ID']) . '" class = "rtmedia-delete-comment dashicons dashicons-no-alt rtmicon" title="' . esc_attr__('Delete Comment', 'buddypress-media') . '"></i>'; } $html .= '<div class="clear"></div></div></div></li>'; return apply_filters('rtmedia_single_comment', $html, $comment); }
function rmedia_single_comment($comment) { $html = ""; $html .= '<li class="rtmedia-comment">'; if ($comment['user_id']) { $user_name = "<a href='" . get_rtmedia_user_link($comment['user_id']) . "' title='" . rtmedia_get_author_name($comment['user_id']) . "'>" . rtmedia_get_author_name($comment['user_id']) . "</a>"; $profile_pic = rtmedia_author_profile_pic($show_link = true, $echo = false, $comment['user_id']); } else { $user_name = "Annonymous"; $profile_pic = ""; } if ($profile_pic != "") { $html .= "<div class='rtmedia-comment-user-pic cleafix'>" . $profile_pic . "</div>"; } $html .= "<div><div class='rtmedia-comment-details'>"; $html .= '<span class ="rtmedia-comment-author">' . '' . $user_name . '</span>'; $html .= '<div class="rtmedia-comment-content">' . wpautop(make_clickable($comment['comment_content'])) . '</div>'; global $rtmedia_media; if (isset($comment['user_id']) && isset($rtmedia_media->media_author) && (is_rt_admin() || (get_current_user_id() == $comment['user_id'] || $rtmedia_media->media_author == get_current_user_id()))) { // show delete button for comment author and admins $html .= '<i data-id="' . $comment['comment_ID'] . '" class = "rtmedia-delete-comment rtmicon-times" title="' . __('Delete Comment') . '"></i>'; } $html .= '<span class ="rtmedia-comment-date"> ' . rtmedia_convert_date($comment['comment_date_gmt']) . '</span>'; $html .= '<div class="clear"></div></div></div></li>'; return apply_filters('rtmedia_single_comment', $html, $comment); }