本文整理汇总了PHP中get_comment_excerpt函数的典型用法代码示例。如果您正苦于以下问题:PHP get_comment_excerpt函数的具体用法?PHP get_comment_excerpt怎么用?PHP get_comment_excerpt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_comment_excerpt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_get_comment_excerpt_filtered
public function test_get_comment_excerpt_filtered()
{
$comment_id = self::factory()->comment->create(array('comment_content' => self::$bacon_comment));
add_filter('comment_excerpt_length', array($this, '_filter_comment_excerpt_length'));
$excerpt = get_comment_excerpt($comment_id);
$this->assertEquals(10, count(explode(' ', $excerpt)));
}
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:7,代码来源:getCommentExcerpt.php
示例2: wildcat_recent_comments
function wildcat_recent_comments()
{
$comments = get_comments(array('number' => 5, 'date_query' => array(array('column' => 'comment_date', 'after' => '1 year ago'))));
echo '<ul>';
foreach ($comments as $comment) {
$link = get_comment_link($comment->comment_ID);
$author = get_comment_author($comment->comment_ID);
$excerpt = get_comment_excerpt($comment->comment_ID);
echo "<li><a href=\"{$link}\">{$author}</a>: {$excerpt}</li>";
}
echo "</ul>\n";
}
开发者ID:encse,项目名称:wildcat,代码行数:12,代码来源:functions.php
示例3: widget
function widget($args, $instance)
{
global $comments, $comment;
$cache = wp_cache_get('widget_recent_notes', 'widget');
if (!is_array($cache)) {
$cache = array();
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
extract($args, EXTR_SKIP);
$output = '';
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Notes') : $instance['title']);
if (!($number = (int) $instance['number'])) {
$number = 5;
} else {
if ($number < 1) {
$number = 1;
}
}
if ($instance['datetime'] == 'date') {
$new_instance['datetime'] = get_comment_date() . ": ";
} elseif ($instance['datetime'] == 'date/time') {
$new_instance['datetime'] = get_comment_date() . " at " . get_comment_time() . ": ";
} else {
$new_instance['datetime'] = null;
}
$datetime = $new_instance['datetime'];
$comments = get_comments(array('number' => $number, 'status' => 'approve'));
$output .= $before_widget;
if ($title) {
$output .= $before_title . $title . $after_title;
}
$output .= '<ul id="recentnotes">';
if ($comments) {
foreach ((array) $comments as $comment) {
$output .= '<li class="recentnotes">' . sprintf(_x('%1$s', 'widgets'), $datetime . '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . ': ' . get_comment_excerpt() . '</a>') . '</li>';
}
}
$output .= '</ul>';
$output .= $after_widget;
echo $output;
$cache[$args['widget_id']] = $output;
wp_cache_set('widget_recent_notes', $cache, 'widget');
}
开发者ID:sudar,项目名称:rolopress-core,代码行数:46,代码来源:recent-notes.php
示例4: widget
function widget($args, $instance)
{
extract($args);
/* User-selected settings. */
$title = apply_filters('widget_title', $instance['title']);
$show_count = $instance['show_count'];
$show_avatar = isset($instance['show_avatar']) ? $instance['show_avatar'] : false;
$avatar_size = $instance['avatar_size'];
$excerpt_length = $instance['excerpt_length'];
/* Before widget (defined by themes). */
echo $before_widget;
/* Title of widget (before and after defined by themes). */
if ($title) {
echo $before_title . $title . $after_title;
}
$comments = get_comments(array('number' => $show_count, 'status' => 'approve', 'type' => 'comment'));
echo '<ul class="recent-comments-list">';
foreach ($comments as $comment) {
$comm_title = get_the_title($comment->comment_post_ID);
$comm_link = get_comment_link($comment->comment_ID);
?>
<li>
<?php
if ($show_avatar) {
echo '<a href="' . $comm_link . '">' . get_avatar($comment, $size = $avatar_size) . '</a>';
}
?>
<a href="<?php
echo $comm_link;
?>
"><?php
echo $comment->comment_author;
?>
:</a> <?php
echo substr(get_comment_excerpt($comment->comment_ID), 0, $excerpt_length);
?>
…<div class="clear"></div>
</li>
<?php
}
echo '</ul>';
/* After widget (defined by themes). */
echo $after_widget;
}
开发者ID:kahlanamnell,项目名称:alpha,代码行数:46,代码来源:recentcomments.php
示例5: widget
function widget($args, $instance)
{
global $comments, $comment;
$cache = wp_cache_get('widget_recent_comments', 'widget');
if (!is_array($cache)) {
$cache = array();
}
if (!isset($args['widget_id'])) {
$args['widget_id'] = $this->id;
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
extract($args);
$output = '';
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments', 'largo') : $instance['title'], $instance, $this->id_base);
if (empty($instance['number']) || !($number = absint($instance['number']))) {
$number = 5;
}
$comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'type' => 'comment')));
$output .= $before_widget;
if ($title) {
$output .= $before_title . $title . $after_title;
}
$output .= '<ul id="recentcomments">';
if ($comments) {
foreach ((array) $comments as $comment) {
$output .= '<li class="recentcomments">';
$output .= '<p class="comment-excerpt">“' . get_comment_excerpt() . '”</p>';
$output .= '<p class="comment-meta">— ' . get_comment_author_link() . ' on <a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a></p>';
$output .= '</li>';
}
}
$output .= '</ul>';
$output .= $after_widget;
echo $output;
$cache[$args['widget_id']] = $output;
wp_cache_set('widget_recent_comments', $cache, 'widget');
}
开发者ID:uniteddiversity,项目名称:Largo,代码行数:40,代码来源:largo-recent-comments.php
示例6: tech_comment_preview
/**
* Techozoic Home Page Comment Preview
*
* Comment preview section on home page. Pull comment excerpt for approved comments
* displays in an unordered list at bottom of each post.
*
* @param string id of current post to pull comments for
*
* @access public
* @since 1.8.7
*/
function tech_comment_preview($ID)
{
global $comment;
$tech_comment_num = of_get_option('comment_preview_num', '3');
$output = "";
$comment_array = get_comments(array('post_id' => $ID, 'number' => $tech_comment_num, 'type' => 'comment', 'status' => 'approve'));
if ($comment_array) {
$output .= '<ul class="comment-preview">';
foreach ($comment_array as $comment) {
$output .= '<li class="comments-link">';
$output .= '<div class="comment-author">';
$output .= '<a href="' . get_comment_link() . '" title="' . $comment->comment_author . __(' posted on ', 'techozoic') . get_comment_date() . '">';
$output .= $comment->comment_author . __(' posted on ', 'techozoic') . get_comment_date();
$output .= '</a>';
$output .= '</div>';
$output .= '<div class="comment-text">';
$output .= get_comment_excerpt($comment->comment_ID);
$output .= '</div>';
$output .= '</li>';
}
$output .= '</ul>';
}
print $output;
}
开发者ID:ruby4web,项目名称:Techozoic-Fluid,代码行数:35,代码来源:functions.php
示例7: ap_get_activity_action_title
/**
* Return activity action title
* @param array $args Activity arguments.
* @return string
* @since 2.4
*/
function ap_get_activity_action_title($args)
{
$type = $args['type'];
$content = '';
$primary_user_link = ap_user_link($args['user_id']);
$primary_user_name = ap_user_display_name(array('user_id' => $args['user_id']));
$user = '<a href="' . $primary_user_link . '">' . $primary_user_name . '</a>';
switch ($type) {
case 'new_question':
$question_title = '<a href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$content .= sprintf(__('%s asked question %s', 'ap'), $user, $question_title);
break;
case 'new_answer':
$answer_title = '<a href="' . get_permalink($args['item_id']) . '">' . get_the_title($args['item_id']) . '</a>';
$content .= sprintf(__('%s answered on %s', 'ap'), $user, $answer_title);
break;
case 'new_comment':
$question_title = '<a href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$comment = '<span class="ap-comment-excerpt"><a href="' . get_comment_link($args['item_id']) . '">' . get_comment_excerpt($args['item_id']) . '</a></span>';
$content .= sprintf(__('%s commented on question %s %s', 'ap'), $user, $question_title, $comment);
break;
case 'new_comment_answer':
$title = '<a href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$comment = '<span class="ap-comment-excerpt"><a href="' . get_comment_link($args['item_id']) . '">' . get_comment_excerpt($args['item_id']) . '</a></span>';
$content .= sprintf(__('%s commented on answer %s %s', 'ap'), $user, $title, $comment);
break;
case 'edit_question':
$question_title = '<a href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$content .= sprintf(__('%s edited question %s', 'ap'), $user, $question_title);
break;
case 'edit_answer':
$answer_title = '<a href="' . get_permalink($args['item_id']) . '">' . get_the_title($args['item_id']) . '</a>';
$content .= sprintf(__('%s edited answer %s', 'ap'), $user, $answer_title);
break;
case 'edit_comment':
$comment = '<a href="' . get_comment_link($args['item_id']) . '">' . get_comment_excerpt($args['item_id']) . '</a>';
$question_title = '<a href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$content .= sprintf(__('%s edited comment on %s %s', 'ap'), $user, $question_title, $comment);
break;
case 'answer_selected':
$question_title = '<a href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$content .= sprintf(__('%s selected best answer for %s', 'ap'), $user, $question_title);
break;
case 'answer_unselected':
$question_title = '<a href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$content .= sprintf(__('%s unselected best answer for question %s', 'ap'), $user, $question_title);
break;
case 'status_updated':
$title = '<a href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$content .= sprintf(__('%s updated status of question %s', 'ap'), $user, $title);
break;
case 'status_updated_answer':
$title = '<a href="' . get_permalink($args['item_id']) . '">' . get_the_title($args['item_id']) . '</a>';
$content .= sprintf(__('%s updated status of answer %s', 'ap'), $user, $title);
break;
}
return apply_filters('ap_activity_action_title', $content, $args);
}
开发者ID:kennyma603,项目名称:anspress,代码行数:64,代码来源:activity.php
示例8: cf_json_encode
?>
{
'author_name': <?php
echo cf_json_encode(get_comment_author());
?>
,
'author_url': <?php
echo cf_json_encode(get_comment_author_url());
?>
,
'date': <?php
echo cf_json_encode(get_comment_date('m/d/Y h:i A'));
?>
,
'excerpt': <?php
echo cf_json_encode(str_replace(array("\r\n", "\n", "\r"), '<br />', get_comment_excerpt()));
?>
,
'type': <?php
echo cf_json_encode($comment_type);
?>
}
<?php
$count++;
}
}
?>
],
'trackback_url': <?php
echo cf_json_encode(get_trackback_url());
?>
开发者ID:jonathansewell,项目名称:Learning-Journal,代码行数:31,代码来源:comments.php
示例9: edit_comment
public function edit_comment($comment_id)
{
$comment = get_comment($comment_id);
$post = get_post($comment->comment_post_ID);
if (!('question' == $post->post_type || 'answer' == $post->post_type)) {
return;
}
$activity_arr = array('item_id' => $comment->comment_ID, 'permalink' => get_comment_link($comment), 'parent_type' => 'comment');
$user = ap_activity_user_name(get_current_user_id());
$comment_excerpt = '<span class="ap-comment-excerpt"><a href="' . get_comment_link($comment->comment_ID) . '">' . get_comment_excerpt($comment->comment_ID) . '</a></span>';
$post_title = '<a class="ap-q-link" href="' . wp_get_shortlink($comment->comment_post_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>';
if ($post->post_type == 'question') {
$activity_arr['type'] = 'new_comment';
$activity_arr['question_id'] = $comment->comment_post_ID;
$activity_arr['content'] = sprintf(__('%s commented on question %s %s', 'anspress-question-answer'), $user, $post_title, $comment_excerpt);
} else {
$activity_arr['type'] = 'new_comment_answer';
$activity_arr['question_id'] = $post->post_parent;
$activity_arr['answer_id'] = $comment->comment_post_ID;
$activity_arr['content'] = sprintf(__('%s commented on answer %s %s', 'anspress-question-answer'), $user, $post_title, $comment_excerpt);
}
$activity_id = ap_new_activity($activity_arr);
// Add comment activity meta.
update_post_meta($comment->comment_post_ID, '__ap_activity', array('type' => 'new_comment', 'user_id' => $comment->user_id, 'date' => current_time('mysql')));
if ($post->post_type == 'question') {
$subscribers = ap_subscriber_ids($comment->comment_post_ID, array('q_post', 'q_all'));
} else {
$subscribers = ap_subscriber_ids($comment->comment_post_ID, 'a_all');
}
// Remove current user from subscribers.
$subscribers = ap_unset_current_user_from_subscribers($subscribers);
ap_new_notification($activity_id, $subscribers);
}
开发者ID:erashu212,项目名称:anspress,代码行数:33,代码来源:activity-hooks.php
示例10: get_avatar
$i++;
global $comment;
$comment = $comments[$id];
?>
<div class="index-comment">
<div class="ic-avatar"><?php
echo get_avatar(get_comment_author_email(), '37');
?>
</div>
<div class="ic-text">
<div class="ic-meta ic-author"><?php
echo get_comment_author_link();
?>
</div>
<div class="ic-content"><?php
echo get_comment_excerpt();
?>
</div>
<div class="ic-meta ic-date"><?php
echo get_comment_date('j F y');
?>
at <?php
echo get_comment_date('H:i');
?>
</div>
</div>
</div>
<?php
}
}
}
开发者ID:nerdherd,项目名称:nh_website,代码行数:31,代码来源:fv.php
示例11: widget
function widget($args, $instance)
{
global $comments, $comment;
$cache = wp_cache_get('widget_recent_comments', 'widget');
if (!is_array($cache)) {
$cache = array();
}
if (!isset($args['widget_id'])) {
$args['widget_id'] = $this->id;
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
extract($args, EXTR_SKIP);
$output = '';
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments', 'shiword') : $instance['title'], $instance, $this->id_base);
if (empty($instance['number']) || !($number = absint($instance['number']))) {
$number = 5;
}
if (!isset($instance['excerpt']) || empty($instance['excerpt']) || !($excerpt = absint($instance['excerpt']))) {
$excerpt = 0;
}
$comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish'));
$output .= $before_widget;
if ($title) {
$output .= $before_title . $title . $after_title;
}
$output .= '<ul id="recentcomments">';
if ($comments) {
foreach ((array) $comments as $comment) {
$the_excerpt = $excerpt ? '<div class="rc-preview">' . get_comment_excerpt($comment->comment_ID) . '</div>' : '';
$the_class = $excerpt ? ' class="small"' : '';
$output .= '<li class="recentcomments">
<span' . $the_class . '>' . sprintf(_x('%1$s on %2$s', 'widgets', 'shiword'), get_comment_author_link(), '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</span>
' . $the_excerpt . '
</li>';
}
}
$output .= '</ul>';
$output .= $after_widget;
echo $output;
$cache[$args['widget_id']] = $output;
wp_cache_set('widget_recent_comments', $cache, 'widget');
}
开发者ID:TwoBeers,项目名称:shiword,代码行数:45,代码来源:widgets.php
示例12: ap_get_activity_action_title
/**
* Return activity action title
* @param array $args Activity arguments.
* @return string
* @since 2.4
*/
function ap_get_activity_action_title($args)
{
$type = $args['type'];
$content = '';
$primary_user_link = ap_user_link($args['user_id']);
$primary_user_name = ap_user_display_name(array('user_id' => $args['user_id']));
$user = '<a class="ap-user-link" href="' . $primary_user_link . '">' . $primary_user_name . '</a>';
switch ($type) {
case 'edit_comment':
$comment = '<a class="ap-c-link" href="' . get_comment_link($args['item_id']) . '">' . get_comment_excerpt($args['item_id']) . '</a>';
$question_title = '<a class="ap-q-link" href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$content .= sprintf(__('%s edited comment on %s %s', 'ap'), $user, $question_title, $comment);
break;
case 'status_updated':
$title = '<a class="ap-q-link" href="' . get_permalink($args['question_id']) . '">' . get_the_title($args['question_id']) . '</a>';
$content .= sprintf(__('%s updated status of question %s', 'ap'), $user, $title);
break;
case 'status_updated_answer':
$title = '<a class="ap-q-link" href="' . get_permalink($args['item_id']) . '">' . get_the_title($args['item_id']) . '</a>';
$content .= sprintf(__('%s updated status of answer %s', 'ap'), $user, $title);
break;
case 'vote_up':
$post = get_post($args['item_id']);
$cpt_type = $post->post_type == 'question' ? __('question', 'ap') : __('answer', 'ap');
$title = '<a class="ap-q-link" href="' . $args['permalink'] . '">' . $post->post_title . '</a>';
$content .= sprintf(__('%s voted up on %s %s', 'ap'), $user, $cpt_type, $title);
break;
case 'reputation_gain':
$post = get_post($args['item_id']);
$title = '<a class="ap-q-link" href="' . $args['permalink'] . '">' . $post->post_title . '</a>';
$content .= sprintf(__('%s received %d reputation on %s', 'ap'), $user, $args['reputation'], $title);
break;
}
return apply_filters('ap_activity_action_title', $content, $args);
}
开发者ID:Krl4,项目名称:anspress,代码行数:41,代码来源:activity.php
示例13: getExcerpt
public function getExcerpt()
{
return get_comment_excerpt($this->getId());
}
开发者ID:hemangsk,项目名称:TCB,代码行数:4,代码来源:Answer.php
示例14: htmlspecialchars
?>
{
'author_name': '<?php
echo htmlspecialchars(get_comment_author(), ENT_QUOTES);
?>
',
'author_url': '<?php
echo htmlspecialchars(get_comment_author_url(), ENT_QUOTES);
?>
',
'date': '<?php
comment_date('m/d/Y h:i A');
?>
',
'excerpt': '<?php
echo str_replace(array("\r\n", "\n", "\r"), '<br />', htmlspecialchars(get_comment_excerpt(), ENT_QUOTES));
?>
',
'type': '<?php
echo $comment_type;
?>
'
}
<?php
$count++;
}
}
?>
],
'trackback_url': '<?php
trackback_url();
开发者ID:julianbonilla,项目名称:three20.info,代码行数:31,代码来源:comments.php
示例15: wp_idea_stream_comments_get_comment_excerpt
/**
* Return the excerpt of the comment currently being iterated on.
*
* @package WP Idea Stream
* @subpackage comments/tags
*
* @since 2.0.0
*
* @uses wp_idea_stream() to get plugin's main instance
* @uses get_post() to get the idea the comment is linked to
* @uses get_comment_excerpt() to get the comment excerpt
* @uses apply_filters() call 'wp_idea_stream_comments_get_comment_excerpt' to override the output
* @return string the excerpt.
*/
function wp_idea_stream_comments_get_comment_excerpt()
{
$comment = wp_idea_stream()->comment_query_loop->comment;
$title = '';
$idea = $comment->comment_post_ID;
if (!empty($comment->idea)) {
$idea = $comment->idea;
}
$idea = get_post($idea);
if (post_password_required($idea)) {
$excerpt = __('The idea, the comment was posted on, is password protected, you will need it to view its content.', 'wp-idea-stream');
// Private
} else {
if (!empty($idea->post_status) && 'private' == $idea->post_status && !wp_idea_stream_user_can('read_idea', $idea->ID)) {
$excerpt = __('The idea, the comment was posted on is private, you cannot view its content.', 'wp-idea-stream');
// Public
} else {
$excerpt = get_comment_excerpt(wp_idea_stream()->comment_query_loop->comment->comment_ID);
}
}
/**
* @param string $excerpt the comment excerpt
*/
return apply_filters('wp_idea_stream_comments_get_comment_excerpt', $excerpt);
}
开发者ID:BoweFrankema,项目名称:wp-idea-stream,代码行数:39,代码来源:tags.php
示例16: widget
function widget($args, $instance)
{
global $comments, $comment;
$cache = wp_cache_get('widget_recent_comments', 'widget');
if (!is_array($cache)) {
$cache = array();
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
extract($args, EXTR_SKIP);
$output = '';
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
if (!($number = absint($instance['number']))) {
$number = 5;
}
$comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish'));
$output .= $before_widget;
if ($title) {
$output .= $before_title . $title . $after_title;
}
$output .= '<ul id="recentcomments">';
if ($comments) {
foreach ((array) $comments as $comment) {
//$output .= '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
$output .= '<li class="recentcomments"><a class="ui-link-inherit" href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . sprintf(_x('%1$s %2$s %3$s', 'widgets'), '<span class="ui-li-heading">' . get_the_title($comment->comment_post_ID) . '</span>', '<p><strong>' . get_comment_author($comment->comment_ID) . '</strong></p>', '<div><p>' . get_comment_excerpt($comment->comment_ID) . '</p></div>') . '</a></li>';
}
}
$output .= '</ul>';
$output .= $after_widget;
echo $output;
$cache[$args['widget_id']] = $output;
wp_cache_set('widget_recent_comments', $cache, 'widget');
}
开发者ID:Bencheci,项目名称:blueRavenStudiosProject,代码行数:35,代码来源:classes.php
示例17: foreach
<?php
foreach ($ultimatemember->shortcodes->loop as $comment) {
?>
<div class="um-item">
<div class="um-item-link"><i class="um-icon-chatboxes"></i><a href="<?php
echo get_comment_link($comment->comment_ID);
?>
"><?php
echo get_comment_excerpt($comment->comment_ID);
?>
</a></div>
<div class="um-item-meta">
<span><?php
printf(__('On <a href="%1$s">%2$s</a>', 'ultimatemember'), get_permalink($comment->comment_post_ID), get_the_title($comment->comment_post_ID));
?>
</span>
</div>
</div>
<?php
}
?>
<?php
if (isset($ultimatemember->shortcodes->modified_args) && count($ultimatemember->shortcodes->loop) >= 10) {
?>
开发者ID:Makenrro,项目名称:repos,代码行数:29,代码来源:comments-single.php
示例18: content
public function content($atts, $content = null)
{
$title = $order = $page_link = $text_size = $items = $el_class = $width = $el_position = '';
extract(shortcode_atts(array('title' => '', 'text_size' => '', 'item_count' => '-1', 'display_type' => 'standard', 'order_by' => 'rand', 'order' => 'ASC', 'link' => 'no', 'show_thumbnail' => 'yes', 'show_rating' => 'yes', 'columns' => '1', 'el_class' => '', 'el_position' => '', 'width' => '1/2'), $atts));
$output = '';
$next_icon = apply_filters('sf_next_icon', '<i class="ss-navigateright"></i>');
// REVIEWS QUERY SETUP
global $woocommerce, $wpdb, $product;
if ($display_type == "masonry") {
$items .= '<ul class="product-reviews testimonials woocommerce masonry-items spb-isotope col-' . $columns . ' gutters row clearfix" data-layout-mode="masonry">';
} else {
$items .= '<ul class="product-reviews testimonials woocommerce clearfix">';
}
/* COLUMN VARIABLE CONFIG
================================================== */
$item_class = "";
if ($display_type == "masonry") {
if ($columns == "1") {
$item_class = "col-sm-12 ";
} else {
if ($columns == "2") {
$item_class = "col-sm-6 ";
} else {
if ($columns == "3") {
$item_class = "col-sm-4 ";
} else {
if ($columns == "4") {
$item_class = "col-sm-3 ";
} else {
if ($columns == "5") {
$item_class = "col-sm-sf-5 ";
}
}
}
}
}
}
// PRODUCT REVIEWS LOOP
$rand_numeric = rand(1, 2500000);
if ($order_by == 'rand') {
$order_by = 'RAND (' . $rand_numeric . ')';
} else {
if ($order_by == 'title') {
$order_by = 'p.post_title' . ' ' . $order;
} else {
if ($order_by == 'date') {
$order_by = 'c.comment_date' . ' ' . $order;
}
}
}
$query = "SELECT c.* FROM {$wpdb->prefix}posts p, {$wpdb->prefix}comments c WHERE p.ID = c.comment_post_ID AND c.comment_approved > 0 AND p.post_type = 'product' AND p.post_status = 'publish' AND p.comment_count > 0 ORDER BY " . $order_by . " LIMIT 0, " . $item_count;
$comments_products = $wpdb->get_results($query, OBJECT);
if ($comments_products) {
foreach ($comments_products as $comment_product) {
$id_ = $comment_product->comment_post_ID;
$name_author = $comment_product->comment_author;
$comment_id = $comment_product->comment_ID;
$_product = get_product($id_);
$rating = intval(get_comment_meta($comment_id, 'rating', true));
$rating_html = $_product->get_rating_html($rating);
if (get_the_title($id_)) {
$link_title = get_the_title($id_);
} else {
$link_title = $id_;
}
$image_link = wp_get_attachment_image_src(get_post_thumbnail_id($id_), 'shop_thumbnail');
$items .= '<li id="comment-' . $comment_id . '" class="testimonial has-cite ' . $item_class . '">';
$items .= '<div class="content-comment testimonial-text">';
if ($link == "yes") {
$items .= '<a href="' . get_comment_link($comment_id) . '" title="' . esc_attr($link_title) . '"></a>';
}
$items .= '<div class="product-details clearfix">';
if (has_post_thumbnail($id_) && $show_thumbnail == "yes") {
$items .= get_the_post_thumbnail($id_, 'shop_thumbnail');
}
$items .= '<h4>' . $link_title . '</h4>';
if ($show_thumbnail == "yes") {
$items .= $rating_html;
}
$items .= '</div>';
$items .= get_comment_excerpt($comment_id);
$items .= '</div>';
$items .= '<div class="testimonial-cite">';
$items .= get_avatar($comment_product->comment_author_email, apply_filters('woocommerce_review_gravatar_size', '60'), '');
$items .= '<div class="cite-text has-cite-image">';
$items .= '<span class="cite-name">' . $name_author . '</span>';
$items .= '</div>';
$items .= '</li>';
}
} else {
$items .= '<li><p>' . __('No products reviews found.', 'swift-framework-plugin') . '</p></li>';
}
$items .= '</ul>';
$el_class = $this->getExtraClass($el_class);
$width = spb_translateColumnWidthToSpan($width);
$el_class .= ' testimonial';
$output .= "\n\t" . '<div class="spb_content_element ' . $width . $el_class . '">';
$output .= "\n\t\t" . '<div class="spb-asset-content product-reviews-wrap ' . $text_size . '">';
$output .= $title != '' ? "\n\t\t\t" . $this->spb_title($title, '') : '';
$output .= "\n\t\t\t" . $items;
//.........这里部分代码省略.........
开发者ID:arobbins,项目名称:spellestate,代码行数:101,代码来源:product-reviews.php
示例19: comment_list_item
private function comment_list_item($_comment)
{
global $comment;
$comment = $_comment;
$comment_status = wp_get_comment_status($comment->comment_ID);
if ('unapproved' == $comment_status) {
$gray_start = '<font color="gray">';
$gray_end = '</font>';
} else {
$gray_start = '';
$gray_end = '';
}
$checkbox = '';
if (current_user_can('edit_post', $comment->comment_post_ID)) {
$checkbox = '<input type="checkbox" name="delete_comments[]" value="' . intval($comment->comment_ID) . '" />';
}
echo '<dt>';
printf(_c('%1$s%2$d:%3$s|comment-list-title', 'ktai_style'), $checkbox, $comment->comment_ID, $gray_start . mb_strcut(get_comment_excerpt(), 0, self::COMMENT_EXCERPT_SIZE) . $gray_end);
echo '</dt><dd>';
?>
<img localsrc="46" alt=" @ " /><font color="<?php
echo ks_option('ks_date_color');
?>
"><?php
echo ks_comment_datetime();
?>
</font>
<img localsrc="<?php
comment_type(68, 112, 112);
?>
" alt="[<?php
comment_type(__('Comment', 'ktai_style'), __('Trackback'), __('Pingback'));
?>
] " /><?php
comment_author();
?>
<br /><?php
if (strlen($author_url_display) > self::COMMENT_AUTHOR_URL_LENGTH) {
$author_url_display = substr($author_url_display, 0, self::COMMENT_AUTHOR_URL_LENGTH - 1) . '...';
}
if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) {
$author_url_display = $comment->comment_author_url;
$author_url_display = str_replace('http://www.', '', $author_url_display);
$author_url_display = str_replace('http://', '', $author_url_display);
if (strlen($author_url_display) > self::COMMENT_AUTHOR_URL_LENGTH) {
$author_url_display = substr($author_url_display, 0, self::COMMENT_AUTHOR_URL_LENGTH - 1) . '...';
}
?>
<img localsrc="112" alt="" /><font color="olive"><?php
echo esc_html($author_url_display);
?>
</font><br /><?php
}
if ($comment->comment_author_email && current_user_can('edit_post', $comment->comment_post_ID)) {
?>
<img localsrc="108" alt="" /><font color="olive"><?php
comment_author_email();
?>
</font><br /><?php
}
if (!$this->post_id && ($title = $this->get_post_title($comment->comment_post_ID))) {
?>
<font color="gray" size="-1"><img localsrc="97" /><?php
echo $title;
?>
</font><br /><?php
}
$app_nonce = esc_html('&_wpnonce=' . wp_create_nonce("approve-comment_{$comment->comment_ID}"));
$del_nonce = esc_html('&_wpnonce=' . wp_create_nonce("delete-comment_{$comment->comment_ID}"));
$approve_url = esc_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID . $app_nonce);
$unapprove_url = esc_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID . $app_nonce);
$spam_url = esc_url('comment.php?action=spamcomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID . $del_nonce);
$unspam_url = esc_url('comment.php?action=unspamcomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID . $del_nonce);
$trash_url = esc_url('comment.php?action=trashcomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID . $del_nonce);
$untrash_url = esc_url('comment.php?action=untrashcomment&c=' . $comment->comment_ID . $del_nonce);
$delete_url = esc_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID);
// do not add nonce
$edit_url = esc_url('comment.php?action=editcomment&c=' . $comment->comment_ID);
$reply_url = esc_url('comment-reply.php?replytocom=' . $comment->comment_ID);
$action_template_color = '<a href="%s"><font color="%s">%s</font></a>';
$action_template = '<a href="%s">%s</a>';
if (current_user_can('edit_post', $comment->comment_post_ID)) {
$actions = array();
if (current_user_can('moderate_comments')) {
if ('unapproved' == $comment_status || 'moderated' == $comment_status) {
$actions['approve'] = sprintf($action_template_color, $approve_url, 'green', __('Approve'));
$actions['spam'] = sprintf($action_template_color, $spam_url, 'red', __('Spam'));
} elseif ('approved' == $_GET['comment_status'] && 'approved' == $comment_status) {
$actions['unapprove'] = sprintf($action_template_color, $unapprove_url, '#ff9900', __('Unapprove'));
} elseif ('spam' == $comment_status) {
if (function_exists('wp_trash_comment') && EMPTY_TRASH_DAYS) {
$actions['unspam'] = sprintf($action_template_color, $unspam_url, 'orange', __('Restore'));
|
请发表评论