
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php

defined( 'PRESSO_CONST_AVATAR_SIZE__POST_BOX' ) || define( 'PRESSO_CONST_AVATAR_SIZE__POST_BOX', 16 );
defined( 'PRESSO_CONST_AVATAR_SIZE__SINGLE' ) || define( 'PRESSO_CONST_AVATAR_SIZE__SINGLE', 24 );

/* -----------------------------------------------------------------------------
 * The Author
 * -------------------------------------------------------------------------- */
if ( ! function_exists( 'presso_the_author' ) ) {
	function presso_the_author( $avatar_size = PRESSO_CONST_AVATAR_SIZE__POST_BOX ) {
		?>
		<span class="vw-post-author" <?php presso_itemprop('author'); ?>>

			<?php presso_the_avatar( null, $avatar_size ); ?>

			<a class="vw-post-author__name" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php esc_attr_e( 'Posts by %s', 'presso'); ?> <?php the_author(); ?>" rel="author" <?php presso_itemprop('name'); ?>><?php the_author(); ?></a>

		</span>
		<?php
	}
}

if ( ! function_exists( 'presso_the_author_name' ) ) {
	function presso_the_author_name() {
		?>
		<span class="vw-post-author" <?php presso_itemprop('author'); ?>>

			<a class="vw-post-author__name" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php echo esc_attr( sprintf( __('Posts by %s', 'presso'), get_the_author_meta( 'display_name', get_the_author_meta( 'ID' ) ) ) ); ?>" rel="author" <?php presso_itemprop('name'); ?>><?php the_author(); ?></a>

		</span>
		<?php
	}
}


/* -----------------------------------------------------------------------------
 * The Author Avatar
 * -------------------------------------------------------------------------- */
if ( ! function_exists( 'presso_the_avatar' ) ) {
	function presso_the_avatar( $author = null, $avatar_size = PRESSO_CONST_AVATAR_SIZE__POST_BOX ) {
		if ( ! $author ) {
			$author = presso_get_current_author();
		}

		if ( empty( $author ) ) return;

		$author_avatar = presso_get_avatar( get_the_author_meta( 'user_email', $author->ID ), $avatar_size, '', get_the_author_meta( 'display_name', $author->ID ) );
		if ( empty( $author_avatar ) || empty( $avatar_size ) ) {
			echo '<i class="vw-icon icon-entypo-user"></i>';

		} else {
			echo '<a class="vw-avatar" href="' . esc_url( get_author_posts_url( $author->ID ) ).'" title="' . sprintf( esc_attr__('Posts by %s', 'presso'), esc_attr( get_the_author_meta( 'display_name', $author->ID ) ) ) . '">';
			echo wp_kses_post( $author_avatar );
			echo '</a>';
			
		}

	}
}

/* -----------------------------------------------------------------------------
 * Get current author
 * -------------------------------------------------------------------------- */
if ( ! function_exists( 'presso_get_current_author' ) ) {
	function presso_get_current_author() {
		global $post;

		if ( ! is_author() && isset( $post->post_author ) ) {
			return get_userdata( $post->post_author );

		} else {
			return (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));

		}
	}
}

/* -----------------------------------------------------------------------------
 * Get Avatar
 * -------------------------------------------------------------------------- */
if ( ! function_exists( 'presso_get_avatar' ) ) {
	function presso_get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) {
		$html = get_avatar( $id_or_email, $size, $default, $alt );

		// Add schema.org
		$html = str_replace( '<img ', '<img itemprop="image" ', $html );

		return $html;
	}
}