| 1 |
<?php |
| 2 |
/** |
| 3 |
* The function to display Author Bio in a theme. |
| 4 |
*/ |
| 5 |
function jetpack_author_bio() { |
| 6 |
// If the theme doesn't support 'jetpack-content-options', don't continue. |
| 7 |
if ( ! current_theme_supports( 'jetpack-content-options' ) ) { |
| 8 |
return; |
| 9 |
} |
| 10 |
|
| 11 |
$options = get_theme_support( 'jetpack-content-options' ); |
| 12 |
$author_bio = ( ! empty( $options[0]['author-bio'] ) ) ? $options[0]['author-bio'] : null; |
| 13 |
$author_bio_default = ( isset( $options[0]['author-bio-default'] ) && false === $options[0]['author-bio-default'] ) ? '' : 1; |
| 14 |
|
| 15 |
// If the theme doesn't support 'jetpack-content-options[ 'author-bio' ]', don't continue. |
| 16 |
if ( true !== $author_bio ) { |
| 17 |
return; |
| 18 |
} |
| 19 |
|
| 20 |
// If 'jetpack_content_author_bio' is false, don't continue. |
| 21 |
if ( ! get_option( 'jetpack_content_author_bio', $author_bio_default ) ) { |
| 22 |
return; |
| 23 |
} |
| 24 |
|
| 25 |
// If we aren't on a single post, don't continue. |
| 26 |
if ( ! is_single() ) { |
| 27 |
return; |
| 28 |
} |
| 29 |
?> |
| 30 |
<div class="entry-author"> |
| 31 |
<div class="author-avatar"> |
| 32 |
<?php |
| 33 |
/** |
| 34 |
* Filter the author bio avatar size. |
| 35 |
* |
| 36 |
* @param int $size The avatar height and width size in pixels. |
| 37 |
* |
| 38 |
* @module theme-tools |
| 39 |
* |
| 40 |
* @since 4.5.0 |
| 41 |
*/ |
| 42 |
$author_bio_avatar_size = apply_filters( 'jetpack_author_bio_avatar_size', 48 ); |
| 43 |
|
| 44 |
echo get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size ); |
| 45 |
?> |
| 46 |
</div><!-- .author-avatar --> |
| 47 |
|
| 48 |
<div class="author-heading"> |
| 49 |
<h2 class="author-title"><?php printf( esc_html__( 'Published by %s', 'jetpack' ), '<span class="author-name">' . get_the_author() . '</span>' ); ?></h2> |
| 50 |
</div><!-- .author-heading --> |
| 51 |
|
| 52 |
<p class="author-bio"> |
| 53 |
<?php the_author_meta( 'description' ); ?> |
| 54 |
<a class="author-link" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author"> |
| 55 |
<?php printf( esc_html__( 'View all posts by %s', 'jetpack' ), get_the_author() ); ?> |
| 56 |
</a> |
| 57 |
</p><!-- .author-bio --> |
| 58 |
</div><!-- .entry-auhtor --> |
| 59 |
<?php |
| 60 |
} |
| 61 |
|