Automattic\WooCommerce\Internal\Admin\ProductReviews

ReviewsListTable::column_author()protectedWC 1.0

Renders the author column.

Method of the class: ReviewsListTable{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->column_author( $item ) : void;
$item(WP_Comment|mixed) (required)
Review or reply being rendered.

Notes

ReviewsListTable::column_author() code WC 8.6.1

<?php
protected function column_author( $item ) : void {
	global $comment_status;

	$author_url = $this->get_item_author_url();
	$author_url_display = $this->get_item_author_url_for_display( $author_url );

	if ( get_option( 'show_avatars' ) ) {
		$author_avatar = get_avatar( $item, 32, 'mystery' );
	} else {
		$author_avatar = '';
	}

	ob_start();

	echo '<strong>' . $author_avatar; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	comment_author();
	echo '</strong><br>';

	if ( ! empty( $author_url ) ) :

		?>
		<a title="<?php echo esc_attr( $author_url ); ?>" href="<?php echo esc_url( $author_url ); ?>" rel="noopener noreferrer"><?php echo esc_html( $author_url_display ); ?></a>
		<br>
		<?php

	endif;

	if ( $this->current_user_can_edit_review ) :

		if ( ! empty( $item->comment_author_email ) && is_email( $item->comment_author_email ) ) :

			?>
			<a href="mailto:<?php echo esc_attr( $item->comment_author_email ); ?>"><?php echo esc_html( $item->comment_author_email ); ?></a><br>
			<?php

		endif;

		$link = add_query_arg(
			[
				's'    => urlencode( get_comment_author_IP( $item->comment_ID ) ),
				'page' => Reviews::MENU_SLUG,
				'mode' => 'detail',
			],
			'admin.php'
		);

		if ( 'spam' === $comment_status ) :
			$link = add_query_arg( [ 'comment_status' => 'spam' ], $link );
		endif;

		?>
		<a href="<?php echo esc_url( $link ); ?>"><?php comment_author_IP( $item->comment_ID ); ?></a>
		<?php

	endif;

	echo $this->filter_column_output( 'author', ob_get_clean(), $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}