-
-
Save willtm/f011321dd45d939fb8ed1f1b2e7a7de1 to your computer and use it in GitHub Desktop.
My annotation template to be put into a sub-folder called `kind_views` in one's theme/child theme
This file contains hidden or 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
<?php | |
/* | |
* Annotation Template | |
* | |
*/ | |
$mf2_post = new MF2_Post( get_the_ID() ); | |
$cite = $mf2_post->fetch(); | |
if ( ! $cite ) { | |
return; | |
} | |
$author = Kind_View::get_hcard( ifset( $cite['author'] ) ); | |
$url = ifset( $cite['url'] ); | |
$embed = self::get_embed( $url ); | |
?> | |
<section class="response u-annotation-of u-in-reply-to u-bookmark-of h-cite"> | |
<header> | |
<?php | |
echo Kind_Taxonomy::get_before_kind( 'annotation' ); | |
if ( ! $embed ) { | |
if ( ! array_key_exists( 'name', $cite ) ) { | |
$cite['name'] = self::get_post_type_string( $url ); | |
} | |
if ( isset( $url ) ) { | |
echo sprintf( '<a href="%1s" class="p-name u-url">%2s</a>', $url, $cite['name'] ); | |
} else { | |
echo sprintf( '<span class="p-name">%1s</span>', $cite['name'] ); | |
} | |
if ( $author ) { | |
echo ' ' . __( 'by', 'indieweb-post-kinds' ) . ' ' . $author; | |
} | |
if ( array_key_exists( 'publication', $cite ) ) { | |
echo sprintf( ' <em>(<span class="p-publication">%1s</span>)</em>', $cite['publication'] ); | |
} | |
} | |
?> | |
</header> | |
<?php | |
if ( $cite ) { | |
if ( $embed ) { | |
echo sprintf( '<blockquote class="e-summary">%1s</blockquote>', $embed ); | |
} elseif ( array_key_exists( 'summary', $cite ) ) { | |
echo sprintf( '<blockquote class="e-summary">%1s</blockquote>', $cite['summary'] ); | |
} | |
} | |
// Close Response | |
?> | |
</section> | |
<?php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment