_wp_comment_row

Definition:
function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {}

Parameters

  • unknown_type $comment_id
  • unknown_type $mode
  • unknown_type $comment_status
  • unknown_type $checkbox
  • $from_ajax

Defined filters

  • get_comment_author
    apply_filters( 'get_comment_author', $parent->comment_author )
  • comment_edit_pre
    apply_filters('comment_edit_pre', $comment->comment_content)
  • comment_row_actions
    apply_filters( 'comment_row_actions', array_filter($actions)

Defined actions

  • manage_comments_custom_column
    do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );

Source code

function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {

	global $comment, $post, $_comment_pending_count;

	$comment = get_comment( $comment_id );

	$post = get_post($comment->comment_post_ID);

	$the_comment_status = wp_get_comment_status($comment->comment_ID);

	$post_type_object = get_post_type_object($post->post_type);

	$user_can = current_user_can($post_type_object->cap->edit_post, $post->ID);



	$comment_url = esc_url(get_comment_link($comment->comment_ID));

	$author_url = get_comment_author_url();

	if ( 'http://' == $author_url )

		$author_url = '';

	$author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url);

	if ( strlen($author_url_display) > 50 )

		$author_url_display = substr($author_url_display, 0, 49) . '...';



	$ptime = date('G', strtotime( $comment->comment_date ) );

	if ( ( abs(time() - $ptime) ) < 86400 )

		$ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );

	else

		$ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );



	if ( $user_can ) {

		$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );

		$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );



		$approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );

		$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );

		$spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

		$unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

		$trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

		$untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

		$delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );

	}



	echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";

	$columns = get_column_headers('edit-comments');

	$hidden = get_hidden_columns('edit-comments');

	foreach ( $columns as $column_name => $column_display_name ) {

		$class = "class=\"$column_name column-$column_name\"";



		$style = '';

		if ( in_array($column_name, $hidden) )

			$style = ' style="display:none;"';



		$attributes = "$class$style";



		switch ($column_name) {

			case 'cb':

				if ( !$checkbox ) break;

				echo '<th scope="row" class="check-column">';

				if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";

				echo '</th>';

				break;

			case 'comment':

				echo "<td $attributes>";

				echo '<div id="submitted-on">';

				/* translators: 2: comment date, 3: comment time */

				printf( __( '<a href="%1$s">%2$s at %3$s</a>' ), $comment_url,

					/* translators: comment date format. See http://php.net/date */ get_comment_date( __('Y/m/d') ),

					/* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) );



				if ( $comment->comment_parent ) {

					$parent = get_comment( $comment->comment_parent );

					$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );

					$name = apply_filters( 'get_comment_author', $parent->comment_author ); // there's no API function for this

					printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );

				}



				echo '</div>';

				comment_text();

				if ( $user_can ) { ?>

				<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">

				<textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars( apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES ); ?></textarea>

				<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>

				<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>

				<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>

				<div class="comment_status"><?php echo $comment->comment_approved; ?></div>

				</div>

				<?php

				}



				if ( $user_can ) {

					// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash

					$actions = array(

						'approve' => '', 'unapprove' => '',

						'reply' => '',

						'quickedit' => '',

						'edit' => '',

						'spam' => '', 'unspam' => '',

						'trash' => '', 'untrash' => '', 'delete' => ''

					);



					if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments

						if ( 'approved' == $the_comment_status )

							$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';

						else if ( 'unapproved' == $the_comment_status )

							$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';

					} else {

						$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';

						$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';

					}



					if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {

						$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';

					} elseif ( 'spam' == $the_comment_status ) {

						$actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';

					} elseif ( 'trash' == $the_comment_status ) {

						$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';

					}



					if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {

						$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';

					} else {

						$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';

					}



					if ( 'trash' != $the_comment_status ) {

						$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';

						$actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.esc_attr__('Quick Edit').'" href="#">' . __('Quick&nbsp;Edit') . '</a>';

						if ( 'spam' != $the_comment_status )

							$actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';

					}



					$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );



					$i = 0;

					echo '<div class="row-actions">';

					foreach ( $actions as $action => $link ) {

						++$i;

						( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';



						// Reply and quickedit need a hide-if-no-js span when not added with ajax

						if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )

							$action .= ' hide-if-no-js';

						elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) {

							if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true))

								$action .= ' approve';

							else

								$action .= ' unapprove';

						}



						echo "<span class='$action'>$sep$link</span>";

					}

					echo '</div>';

				}



				echo '</td>';

				break;

			case 'author':

				echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';

				if ( !empty($author_url) )

					echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";

				if ( $user_can ) {

					if ( !empty($comment->comment_author_email) ) {

						comment_author_email_link();

						echo '<br />';

					}

					echo '<a href="edit-comments.php?s=';

					comment_author_IP();

					echo '&amp;mode=detail';

					if ( 'spam' == $comment_status )

						echo '&amp;comment_status=spam';

					echo '">';

					comment_author_IP();

					echo '</a>';

				} //current_user_can

				echo '</td>';

				break;

			case 'date':

				echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';

				break;

			case 'response':

				if ( 'single' !== $mode ) {

					if ( isset( $_comment_pending_count[$post->ID] ) ) {

						$pending_comments = $_comment_pending_count[$post->ID];

					} else {

						$_comment_pending_count_temp = get_pending_comments_num( array( $post->ID ) );

						$pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];

					}

					if ( $user_can ) {

						$post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";

						$post_link .= get_the_title($post->ID) . '</a>';

					} else {

						$post_link = get_the_title($post->ID);

					}

					echo "<td $attributes>\n";

					echo '<div class="response-links"><span class="post-com-count-wrapper">';

					echo $post_link . '<br />';

					$pending_phrase = esc_attr(sprintf( __('%s pending'), number_format( $pending_comments ) ));

					if ( $pending_comments )

						echo '<strong>';

					comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');

					if ( $pending_comments )

						echo '</strong>';

					echo '</span> ';

					echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";

					echo '</div>';

					if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) )

						echo $thumb;

					echo '</td>';

				}

				break;

			default:

				echo "<td $attributes>\n";

				do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );

				echo "</td>\n";

				break;

		}

	}

4387

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: