本文整理汇总了PHP中get_comment_excerpt函数的典型用法代码示例。如果您正苦于以下问题:PHP get_comment_excerpt函数的具体用法?PHP get_comment_excerpt怎么用?PHP get_comment_excerpt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_comment_excerpt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)));
}
示例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";
}
示例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');
}
示例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;
}
示例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');
}
示例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;
}
示例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);
}
示例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());
?>
示例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);
}
示例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
}
}
}
示例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');
}
示例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);
}
示例13: getExcerpt
public function getExcerpt()
{
return get_comment_excerpt($this->getId());
}
示例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();
示例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);
}