ap_user_link_anchor( string $user_id, boolean $output = true )

Description #

User name and link with anchor tag.

Parameters #

  • $user_id
    string (Required) User ID.
  • $output
    boolean (Optional) Echo or return. Default value: true

Source #

File: includes/functions.php

function ap_user_link_anchor( $user_id, $output = true ) {
	$name = ap_user_display_name( $user_id );

	if ( $user_id < 1 ) {
		if ( $output ) {
			echo $name; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		} else {
			return $name;
		}
	}

	$html  = '<a href="' . esc_url( ap_user_link( $user_id ) ) . '">';
	$html .= $name;
	$html .= '</a>';

	if ( $output ) {
		echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	}

	return $html;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment