Created
July 1, 2017 17:35
-
-
Save miklb/f26236fc71e85af598a2a4a73d65bb39 to your computer and use it in GitHub Desktop.
custom post-kind template to deal with rich twitter embed and adding u-url to link
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 | |
/** | |
* Quote Kind Reply. | |
* | |
* @package independence | |
*/ | |
?> | |
<?php | |
$kind = get_post_kind_slug( get_the_ID() ); | |
$meta = new Kind_Meta( get_the_ID() ); | |
$author = Kind_View::get_hcard( $meta->get_author() ); | |
$cite = $meta->get_cite(); | |
$site_name = Kind_View::get_site_name( $meta->get_cite(), $meta->get_url() ); | |
$title = Kind_View::get_cite_title( $meta->get_cite(), $meta->get_url() ); | |
$embed_html = self::get_embed( $meta->get_url() ); | |
if ( '' !== $embed_html ) { | |
$dom = new DOMDocument; | |
$dom->loadHTML( $embed_html, LIBXML_HTML_NOIMPLIED ); | |
$nodelinks = $dom->getElementsByTagName( 'a' ); | |
$links = iterator_to_array( $nodelinks ); | |
$count = count( $links ); | |
$i = 0; | |
foreach ( $links as $link ) $i++; { | |
if ( $i === $count ) { | |
$link->setAttribute( 'class', 'u-url' ); | |
} | |
}; | |
$embed_html = $dom->saveHTML(); | |
} | |
?> | |
<div class="level"> | |
<p class="level-left"> | |
<span class="icon is-large level-item"> | |
<?xml version="1.0" encoding="UTF-8"?> <svg width="28px" height="32px" viewBox="0 0 14 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="Octicons" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g id="reply" fill="#000000"> <path d="M6,3.5 C9.92,3.94 14,6.625 14,13.5 C11.688,8.438 9.25,7.5 6,7.5 L6,11 L0.5,5.5 L6,0 L6,3.5 Z" id="Shape"></path> </g> </g> </svg> | |
</span> | |
<span class="level-item">A post on</span> | |
<span class="level-item p-publication"> | |
<?php echo $site_name ?> | |
</span> | |
<span class="level-item"> | |
by<?php echo $author ?> | |
</span> | |
</p> | |
</div> | |
<cite class="h-cite u-in-reply-to"> | |
<?php | |
if ( $cite ) { | |
if ( $embed_html ) { | |
if ( ! get_the_title() ) { | |
echo '<div class="p-content">' . $embed_html . '</div>'; } else { | |
echo '<div class="p-content">' . $embed_html . '</div>'; | |
} | |
} elseif ( array_key_exists( 'summary', $cite ) ) { | |
echo sprintf( '<blockquote class="p-content">%1s</blockquote>', $cite['summary'] ); | |
} | |
} | |
// Close Response. | |
?> | |
</cite> | |
<?php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment