-
-
Save braddalton/2b2d096e63c1f2852aa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode( 'post_author_posts_link', 'genesis_post_author_posts_link_shortcode' ); | |
/** | |
* Produces the author of the post (link to author archive). | |
* | |
* Supported shortcode attributes are: | |
* after (output after link, default is empty string), | |
* before (output before link, default is empty string). | |
* | |
* Output passes through 'genesis_post_author_posts_link_shortcode' filter before returning. | |
* | |
* @since 1.1.0 | |
* | |
* @param array|string $atts Shortcode attributes. Empty string if no attributes. | |
* @return string Shortcode output | |
*/ | |
function genesis_post_author_posts_link_shortcode( $atts ) { | |
$defaults = array( | |
'after' => '', | |
'before' => '', | |
); | |
$atts = shortcode_atts( $defaults, $atts, 'post_author_posts_link' ); | |
$author = get_the_author(); | |
$url = get_author_posts_url( get_the_author_meta( 'ID' ) ); | |
if ( genesis_html5() ) { | |
$output = sprintf( '<span %s>', genesis_attr( 'entry-author' ) ); | |
$output .= $atts['before']; | |
$output .= sprintf( '<a href="%s" %s>', $url, genesis_attr( 'entry-author-link' ) ); | |
$output .= sprintf( '<span %s>', genesis_attr( 'entry-author-name' ) ); | |
$output .= esc_html( $author ); | |
$output .= '</span></a>' . $atts['after'] . '</span>'; | |
} else { | |
$link = sprintf( '<a href="%s" title="%s" rel="author">%s</a>', esc_url( $url ), esc_attr( $author ), esc_html( $author ) ); | |
$output = sprintf( '<span class="author vcard">%2$s<span class="fn">%1$s</span>%3$s</span>', $link, $atts['before'], $atts['after'] ); | |
} | |
return apply_filters( 'genesis_post_author_posts_link_shortcode', $output, $atts ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment