_wp_dashboard_recent_comments_row

函数


_wp_dashboard_recent_comments_row ( $comment, $show_date = true )
Access
Private
参数
  • (WP_Comment)
    $comment
    The current comment.
    Required:
  • (bool)
    $show_date
    Optional. Whether to display the date.
    Required:
    Default: true
定义位置
  • wp-admin/includes/dashboard.php
    , line 688
引入
2.7.0
弃用

Outputs a row for the Recent Comments widget.

function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
	$GLOBALS['comment'] = clone $comment;

	if ( $comment->comment_post_ID > 0 ) {
		$comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
		$comment_post_url   = get_the_permalink( $comment->comment_post_ID );
		$comment_post_link  = '' . $comment_post_title . '';
	} else {
		$comment_post_link = '';
	}

	$actions_string = '';
	if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
		// Pre-order it: Approve | Reply | Edit | Spam | Trash.
		$actions = array(
			'approve'   => '',
			'unapprove' => '',
			'reply'     => '',
			'edit'      => '',
			'spam'      => '',
			'trash'     => '',
			'delete'    => '',
			'view'      => '',
		);

		$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=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
		$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
		$spam_url      = esc_url( "comment.php?action=spamcomment&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" );
		$delete_url    = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );

		$actions['approve'] = sprintf(
			'%s',
			$approve_url,
			"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved",
			esc_attr__( 'Approve this comment' ),
			__( 'Approve' )
		);

		$actions['unapprove'] = sprintf(
			'%s',
			$unapprove_url,
			"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved",
			esc_attr__( 'Unapprove this comment' ),
			__( 'Unapprove' )
		);

		$actions['edit'] = sprintf(
			'%s',
			"comment.php?action=editcomment&c={$comment->comment_ID}",
			esc_attr__( 'Edit this comment' ),
			__( 'Edit' )
		);

		$actions['reply'] = sprintf(
			'',
			$comment->comment_ID,
			$comment->comment_post_ID,
			esc_attr__( 'Reply to this comment' ),
			__( 'Reply' )
		);

		$actions['spam'] = sprintf(
			'%s',
			$spam_url,
			"delete:the-comment-list:comment-{$comment->comment_ID}::spam=1",
			esc_attr__( 'Mark this comment as spam' ),
			/* translators: "Mark as spam" link. */
			_x( 'Spam', 'verb' )
		);

		if ( ! EMPTY_TRASH_DAYS ) {
			$actions['delete'] = sprintf(
				'%s',
				$delete_url,
				"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
				esc_attr__( 'Delete this comment permanently' ),
				__( 'Delete Permanently' )
			);
		} else {
			$actions['trash'] = sprintf(
				'%s',
				$trash_url,
				"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
				esc_attr__( 'Move this comment to the Trash' ),
				_x( 'Trash', 'verb' )
			);
		}

		$actions['view'] = sprintf(
			'%s',
			esc_url( get_comment_link( $comment ) ),
			esc_attr__( 'View this comment' ),
			__( 'View' )
		);

		/**
		 * Filters the action links displayed for each comment in the 'Recent Comments'
		 * dashboard widget.
		 *
		 * @since 2.6.0
		 *
		 * @param string[]   $actions An array of comment actions. Default actions include:
		 *                            'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
		 *                            'Delete', and 'Trash'.
		 * @param WP_Comment $comment The comment object.
		 */
		$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );

		$i = 0;

		foreach ( $actions as $action => $link ) {
			++$i;

			if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i )
				|| 1 === $i
			) {
				$separator = '';
			} else {
				$separator = ' | ';
			}

			// Reply and quickedit need a hide-if-no-js span.
			if ( 'reply' === $action || 'quickedit' === $action ) {
				$action .= ' hide-if-no-js';
			}

			if ( 'view' === $action && '1' !== $comment->comment_approved ) {
				$action .= ' hidden';
			}

			$actions_string .= "{$separator}{$link}";
		}
	}
	?>

		
  • >

    comment_type || ‘comment’ === $comment->comment_type ) : ?>

    <?php // Comments might not have a post they relate to, e.g. programmatically created ones.
    if ( $comment_post_link ) {
    printf(
    /* translators: 1: Comment author, 2: Post link, 3: Notification if the comment is pending. */
    __( 'From %1$s on %2$s %3$s' ),
    '‘ . get_comment_author_link( $comment ) . ”,
    $comment_post_link,
    ‘ . __( ‘[Pending]’ ) . ‘
    );
    } else {
    printf(
    /* translators: 1: Comment author, 2: Notification if the comment is pending. */
    __( ‘From %1$s %2$s’ ),
    ‘ . get_comment_author_link( $comment ) . ‘‘,
    ‘ . __( ‘[Pending]’ ) . ‘
    );
    }
    ?>

    comment_type ) {
    case ‘pingback’:
    $type = __( ‘Pingback’ );
    break;
    case ‘trackback’:
    $type = __( ‘Trackback’ );
    break;
    default:
    $type = ucwords( $comment->comment_type );
    }
    $type = esc_html( $type );
    ?>

    <?php // Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
    if ( $comment_post_link ) {
    printf(
    /* translators: 1: Type of comment, 2: Post link, 3: Notification if the comment is pending. */
    _x( '%1$s on %2$s %3$s', 'dashboard' ),
    "$type”,
    $comment_post_link,
    ‘ . __( ‘[Pending]’ ) . ‘
    );
    } else {
    printf(
    /* translators: 1: Type of comment, 2: Notification if the comment is pending. */
    _x( ‘%1$s %2$s’, ‘dashboard’ ),
    $type“,
    ‘ . __( ‘[Pending]’ ) . ‘
    );
    }
    ?>

    <?php $GLOBALS['comment'] = null;
    }