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