Skip to content

Instantly share code, notes, and snippets.

@xavierroy
Last active July 31, 2018 16:40
Show Gist options
  • Save xavierroy/a4ff273bb1f3756e7a99324e2b368dcf to your computer and use it in GitHub Desktop.
Save xavierroy/a4ff273bb1f3756e7a99324e2b368dcf to your computer and use it in GitHub Desktop.
This adds triple tags for audio posts. The file is indieweb-post-kinds/views/kind-listen.php. For this to work, you should have some tags available in the Tags section for your Post Kind metadata.
<?php
/*
Listen 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'] );
$site_name = Kind_View::get_site_name( $cite, $url );
$title = Kind_View::get_cite_title( $cite, $url );
$embed = self::get_embed( $url );
$duration = $mf2_post->get( 'duration', true );
if ( ! $duration ) {
$duration = calculate_duration( $mf2_post->get( 'dt-start' ), $mf2_post->get( 'dt-end' ) );
}
?>
<section class="response u-listen-of h-cite">
<header>
<?php
echo Kind_Taxonomy::get_before_kind( 'listen' );
if ( ! $embed ) {
if ( $title ) {
echo $title;
}
if ( $author ) {
echo ' ' . __( 'by', 'indieweb-post-kinds' ) . ' ' . $author;
}
if ( $site_name ) {
echo __( ' from ', 'indieweb-post-kinds' ) . '<em>' . $site_name . '</em>';
}
if ( $duration ) {
echo '(<data class="p-duration" value="' . $duration . '">' . Kind_View::display_duration( $duration ) . '</data>)';
}
}
?>
</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'] );
}
}
if ( isset( $_POST['cite_tags'] ) ) {
$cite['category'] = array_filter( explode( ';', $_POST['cite_tags'] ) );
}
echo '<footer><p>Machine tags for this post: <br />';
echo sprintf ( '<small><span class="machinetags">%1s</span></small></p></footer>', implode (", ",$cite['category']) );
// Close Response
?>
</section>
<?php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment