本文整理汇总了PHP中get_comment_class函数的典型用法代码示例。如果您正苦于以下问题:PHP get_comment_class函数的具体用法?PHP get_comment_class怎么用?PHP get_comment_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_comment_class函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: comment
protected function comment($comment, $depth, $args)
{
// разметка каждого комментария, без закрывающего </li>!
$classes = implode(' ', get_comment_class()) . ($comment->comment_author_email == get_the_author_meta('email') ? ' author-comment' : '');
// берем стандартные классы комментария и если коммент пренадлежит автору поста добавляем класс author-comment
echo '<li id="li-comment-' . get_comment_ID() . '" class="' . $classes . '">' . "\n";
// родительский тэг комментария с классами выше и уникальным id
echo '<div id="comment-' . get_comment_ID() . '">' . "\n";
// элемент с таким id нужен для якорных ссылок на коммент
echo get_avatar($comment, 64) . "\n";
// покажем аватар с размером 64х64
echo '<p class="meta">Автор: ' . get_comment_author() . "\n";
// имя автора коммента
//echo ' '.get_comment_author_email(); // email автора коммента
echo ' ' . get_comment_author_url();
// url автора коммента
echo ' <br>Добавлено ' . get_comment_date('F j, Y') . ' в ' . get_comment_time() . "\n";
// дата и время комментирования
if ('0' == $comment->comment_approved) {
echo '<em class="comment-awaiting-moderation">Ваш комментарий будет опубликован после проверки модератором.</em>' . "\n";
}
// если комментарий должен пройти проверку
comment_text() . "\n";
// текст коммента
$reply_link_args = array('depth' => $depth, 'reply_text' => 'Ответить', 'login_text' => 'Вы должны быть залогинены');
echo get_comment_reply_link(array_merge($args, $reply_link_args));
// выводим ссылку ответить
echo '</div>' . "\n";
// закрываем див
}
示例2: comment
protected function comment($comment, $depth, $args)
{
// each comment markup, without </li>!
$classes = implode(' ', get_comment_class()) . ($comment->comment_author_email == get_the_author_meta('email') ? ' author-comment' : '');
// get typical wp comment classes and if comment belong post autor add "author-comment" class
echo '<li id="li-comment-' . get_comment_ID() . '" class="' . $classes . '">' . "\n";
// parent tag with classes and uniq id
echo '<div id="comment-' . get_comment_ID() . '">' . "\n";
// anchor element with this id need to anchor links on comments works
echo get_avatar($comment, 64) . "\n";
// show avatar with size 64x64 px
echo '<p class="meta">Posted by: ' . get_comment_author() . "\n";
// comment autor name
echo ' ' . get_comment_author_email();
// comment autor email
echo ' ' . get_comment_author_url();
// comment autor url
echo ' On ' . get_comment_date('F j, Y') . ' at ' . get_comment_time() . '</p>' . "\n";
// date and time of comment creating
if ('0' == $comment->comment_approved) {
echo '<em class="comment-awaiting-moderation">Your comment is awaiting moderation</em>' . "\n";
}
// if comment is not approved notify of it
comment_text() . "\n";
// display comment text
$reply_link_args = array('depth' => $depth, 'reply_text' => 'Reply on it', 'login_text' => 'You must be logged to post comments');
echo get_comment_reply_link(array_merge($args, $reply_link_args));
// display reply link
echo '</div>' . "\n";
// anchor element end
}
示例3: get_fields_for_render
public function get_fields_for_render()
{
$entry_id = $this->comment->comment_ID;
$post_id = $this->comment->comment_post_ID;
$avatar_size = apply_filters('liveblog_entry_avatar_size', self::default_avatar_size);
$comment_text = get_comment_text($entry_id);
$css_classes = implode(' ', get_comment_class('', $entry_id, $post_id));
$entry = array('entry_id' => $entry_id, 'post_id' => $post_id, 'css_classes' => $css_classes, 'content' => self::render_content($comment_text, $this->comment), 'original_content' => apply_filters('liveblog_before_edit_entry', $comment_text), 'avatar_size' => $avatar_size, 'avatar_img' => get_avatar($this->comment->comment_author_email, $avatar_size), 'author_link' => get_comment_author_link($entry_id), 'entry_date' => get_comment_date(get_option('date_format'), $entry_id), 'entry_time' => get_comment_date(get_option('time_format'), $entry_id), 'timestamp' => $this->get_timestamp(), 'is_liveblog_editable' => WPCOM_Liveblog::is_liveblog_editable());
return $entry;
}
示例4: commentClass
private function commentClass()
{
$classes = get_comment_class();
$comment_class = 'class="';
foreach ($classes as $class) {
// print_r($class . '<br>');
$comment_class .= $class . ' ';
}
$comment_class .= '"';
return $comment_class;
}
示例5: render
public static function render($comment, $args, $depth)
{
self::set_context($comment);
// Note that WordPress closes the div for you, do not close it here!
// https://codex.wordpress.org/Function_Reference/wp_list_comments
printf('<div class="%s">', implode(' ', get_comment_class(self::base_classes($comment), $comment, $comment->comment_post_ID)));
$comment_actions = '';
if (comments_open($comment->comment_post_ID)) {
$comment_actions = html('a', array('class' => 'reply-link', 'href' => sprintf('mailto:{{{reply_to_comment_%s}}}?subject=%s', $comment->comment_ID, rawurlencode(sprintf(__('Reply to %s', 'Postmatic'), $comment->comment_author)))), html('img', array('src' => 'https://s3-us-west-2.amazonaws.com/postmatic/assets/icons/reply.png', 'width' => '13', 'height' => '8')), __('Reply', 'Postmatic'));
}
echo html('div class="comment-header"', get_avatar($comment), html('div class="author-name"', get_comment_author_link($comment->comment_ID)), html('div class="comment-body"', apply_filters('comment_text', get_comment_text($comment->comment_ID), $comment), $comment_actions));
}
示例6: mystique_comment_class
function mystique_comment_class($class = '')
{
global $post, $comment;
$classes = get_comment_class();
if (get_option('show_avatars')) {
$classes[] = 'withAvatars';
}
if ($comment->user_id > 0) {
$user = new WP_User($comment->user_id);
if (is_array($user->roles)) {
foreach ($user->roles as $role) {
$classes[] = "role-{$role}";
}
}
$classes[] = 'user-' . sanitize_html_class($user->user_nicename, $user->user_id);
} else {
$classes[] = 'reader name-' . get_comment_author();
}
// user classes
if (!empty($class)) {
if (!is_array($class)) {
$class = preg_split('#\\s+#', $class);
}
$classes = array_merge($classes, $class);
}
echo join(' ', apply_filters("comment_class", $classes));
}
示例7: hybrid_comment_class
/**
* Sets a class for each comment. Sets alt, odd/even, and author/user classes. Adds author, user,
* and reader classes. Needs more work because WP, by default, assigns even/odd backwards
* (Odd should come first, even second).
*
* @since 0.2.0
* @global $wpdb WordPress DB access object.
* @global $comment The current comment's DB object.
*/
function hybrid_comment_class($class = '')
{
global $post, $comment, $hybrid;
/* Gets default WP comment classes. */
$classes = get_comment_class($class);
/* Get the comment type. */
$classes[] = get_comment_type();
/* User classes to match user role and user. */
if ($comment->user_id > 0) {
/* Create new user object. */
$user = new WP_User($comment->user_id);
/* Set a class with the user's role. */
if (is_array($user->roles)) {
foreach ($user->roles as $role) {
$classes[] = "role-{$role}";
}
}
/* Set a class with the user's name. */
$classes[] = 'user-' . sanitize_html_class($user->user_nicename, $user->ID);
} else {
$classes[] = 'reader';
}
/* Comment by the entry/post author. */
if ($post = get_post($post_id)) {
if ($comment->user_id === $post->post_author) {
$classes[] = 'entry-author';
}
}
/* Get comment types that are allowed to have an avatar. */
$avatar_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
/* If avatars are enabled and the comment types can display avatars, add the 'has-avatar' class. */
if (get_option('show_avatars') && in_array($comment->comment_type, $avatar_comment_types)) {
$classes[] = 'has-avatar';
}
/* Join all the classes into one string and echo them. */
$class = join(' ', $classes);
echo apply_filters("{$hybrid->prefix}_comment_class", $class);
}
示例8: single_row
/**
* @global WP_Post $post
*
* @param object $comment
*/
public function single_row($comment)
{
global $post;
$the_comment_class = wp_get_comment_status($comment);
if (!$the_comment_class) {
$the_comment_class = '';
}
$the_comment_class = join(' ', get_comment_class($the_comment_class, $comment, $comment->comment_post_ID));
if ($comment->comment_post_ID > 0) {
$post = get_post($comment->comment_post_ID);
}
$this->user_can = current_user_can('edit_comment', $comment->comment_ID);
echo "<tr id='comment-{$comment->comment_ID}' class='{$the_comment_class}'>";
$this->single_row_columns($comment);
echo "</tr>\n";
$post = null;
}
示例9: test_should_return_an_empty_array_for_invalid_comment_id
/**
* @ticket 33947
*/
public function test_should_return_an_empty_array_for_invalid_comment_id()
{
$this->assertSame(array(), get_comment_class('foo', 12345));
}
示例10: single_row
function single_row($a_comment)
{
global $post, $comment;
$comment = $a_comment;
$the_comment_class = join(' ', get_comment_class(wp_get_comment_status($comment->comment_ID)));
$post = get_post($comment->comment_post_ID);
$this->user_can = current_user_can('edit_comment', $comment->comment_ID);
echo "<tr id='comment-{$comment->comment_ID}' class='{$the_comment_class}'>";
echo $this->single_row_columns($comment);
echo "</tr>\n";
}
示例11: qb_comments
function qb_comments($comment, $args, $depth)
{
$GLOBALS['comment'] = $comment;
//$avatar = get_avatar( $comment, 48 );
$comment_author_id = get_comment(get_comment_ID())->user_id;
$comment_author_url = get_comment_author_url();
if (has_wp_user_avatar($comment_author_id)) {
//$avatar = get_wp_user_avatar_src( $comment_author_id, 48 );
$avatar = get_wp_user_avatar($comment_author_id, 48);
} else {
//$avatar = get_bloginfo( 'template_url' ) . '/images/default/48.png';
// temporary: this is the same for now, for testing; eventually, it should fall back to default image or Facebook image or smt else
//$avatar = get_wp_user_avatar_src( $comment_author_id, 48 );
$avatar = get_wp_user_avatar($comment_author_id, 48);
}
?>
<li <?php
get_comment_class();
?>
><?php
if ($comment_author_url) {
echo '<a href="' . $comment_author_url . '">' . $avatar . get_comment_author() . '</a>';
} else {
echo $avatar . get_comment_author();
}
echo '<time class="timeago" datetime="' . get_comment_date('c') . '">' . get_comment_date('F j, Y') . '</time>';
comment_text();
//edit_comment_link( 'Edit', '<span class="edit">', '</span>' );
if ($comment->comment_approved == '0') {
echo '<em class="moderate">Your comment is awaiting moderation.</em>';
}
/*comment_reply_link(
array_merge(
$args,
array(
'reply_text' => 'Reply',
'depth' => $depth,
'max_depth' => $args['max_depth']
)
)
);*/
echo '</li>';
}
示例12: momtaz_atts_comment
/**
* Add attributes for the comment element.
*
* @return array
* @since 1.3
*/
function momtaz_atts_comment($atts)
{
$comment_id = get_comment_ID();
if (empty($comment_id)) {
return $atts;
}
$atts['id'] = "comment-{$comment_id}";
$atts['class'] = get_comment_class();
$atts['itemprop'] = 'comment';
$atts['itemscope'] = 'itemscope';
$atts['itemtype'] = 'http://schema.org/UserComments';
return $atts;
}
示例13: adventure_tours_comment_renderer
/**
* Comment renderer function.
*
* @param Comment $comment comment instance.
* @param array $args array of options.
* @param int $depth current depth level.
* @return void
*/
function adventure_tours_comment_renderer($comment, $args, $depth)
{
$commentHtml = get_avatar($comment, 90) . '<div class="comments__item__info">' . '<div class="comments__item__name">' . get_comment_author_link() . '</div>' . '<div class="comments__item__reply-link">' . get_comment_reply_link(array('depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => esc_html__('Reply', 'adventure-tours'), 'login_text' => '')) . '</div>' . '</div>' . '<div class="comments__item__date">' . get_comment_date() . '</div>' . '<div class="comments__item__text">' . get_comment_text() . '</div>';
printf('<div class="%s" id="comment-%s">%s%s', implode(' ', get_comment_class('comments__item')), get_comment_ID(), $commentHtml, !empty($args['has_children']) ? '</div><div class="comments__item__reply">' : '');
}
示例14: hybrid_get_comment_class
/**
* Sets a class for each comment. Sets alt, odd/even, and author/user classes. Adds author, user,
* and reader classes. Needs more work because WP, by default, assigns even/odd backwards
* (Odd should come first, even second).
*
* @since 1.6.0
* @access public
* @global $comment The current comment's DB object
* @return void
*/
function hybrid_get_comment_class($class = '')
{
global $comment;
/* Gets default WP comment classes. */
$classes = get_comment_class($class);
/* Get the comment type. */
$comment_type = get_comment_type();
/* If the comment type is 'pingback' or 'trackback', add the 'ping' comment class. */
if ('pingback' == $comment_type || 'trackback' == $comment_type) {
$classes[] = 'ping';
}
/* User classes to match user role and user. */
if ($comment->user_id > 0) {
/* Create new user object. */
$user = new WP_User($comment->user_id);
/* Set a class with the user's role(s). */
if (is_array($user->roles)) {
foreach ($user->roles as $role) {
$classes[] = sanitize_html_class("role-{$role}");
}
}
/* Set a class with the user's name. */
$classes[] = sanitize_html_class("user-{$user->user_nicename}", "user-{$user->ID}");
} else {
$classes[] = 'reader';
}
/* Comment by the entry/post author. */
if ($post = get_post(get_the_ID())) {
if ($comment->user_id == $post->post_author) {
$classes[] = 'entry-author';
}
}
/* Get comment types that are allowed to have an avatar. */
$avatar_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
/* If avatars are enabled and the comment types can display avatars, add the 'has-avatar' class. */
if (get_option('show_avatars') && in_array($comment->comment_type, $avatar_comment_types)) {
$classes[] = 'has-avatar';
}
/* Make sure comment classes doesn't have any duplicates. */
return array_unique($classes);
}
示例15: enlightenment_comment
function enlightenment_comment($comment, $args, $depth)
{
$defaults = array('comment_class' => 'comment-body' . (empty($args['has_children']) ? '' : ' parent'), 'comment_id' => 'comment-' . get_comment_ID(), 'comment_extra_atts' => '', 'header_tag' => current_theme_supports('html5', 'comment-list') ? 'header' : 'div', 'header_class' => 'comment-header', 'comment_content_tag' => 'div', 'comment_content_class' => 'comment-content', 'comment_content_extra_atts' => '', 'echo' => true);
$defaults = apply_filters('enlightenment_comment_args', $defaults);
$comment_reply_link_defaults = array('add_below' => 'comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '<div class="reply">', 'after' => '</div>');
$comment_reply_link_defaults = apply_filters('enlightenment_comment_reply_link_args', $comment_reply_link_defaults);
$defaults = wp_parse_args($comment_reply_link_defaults, $defaults);
$args = wp_parse_args($args, $defaults);
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ('ul' == $args['style'] || 'ol' == $args['style']) {
$args['style'] = 'li';
} else {
$args['style'] = current_theme_supports('html5', 'comment-list') ? 'article' : 'div';
}
do_action('enlightenment_before_comment', $comment, $args);
echo enlightenment_open_tag($args['style'], join(' ', get_comment_class($args['comment_class'])), $args['comment_id'], $args['comment_extra_atts']);
do_action('enlightenment_before_comment_header', $comment, $args);
if (has_action('enlightenment_comment_header')) {
echo enlightenment_open_tag($args['header_tag'], $args['header_class']);
do_action('enlightenment_comment_header', $comment, $args);
echo enlightenment_close_tag($args['header_tag']);
}
do_action('enlightenment_after_comment_header', $comment, $args);
do_action('enlightenment_before_comment_content', $comment, $args);
if (has_action('enlightenment_comment_content')) {
echo enlightenment_open_tag($args['comment_content_tag'], $args['comment_content_class'], '', $args['comment_content_extra_atts']);
do_action('enlightenment_comment_content', $comment, $args);
echo enlightenment_close_tag($args['comment_content_tag']);
}
do_action('enlightenment_after_comment_content', $args, $comment);
}