Last active
March 16, 2016 14:53
-
-
Save bradyswenson/42ae5ebe576b97847313 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
#### AUTHOR GLOBAL ##### | |
if ( class_exists( 'coauthors_plus' ) ) { | |
$co_authors = get_coauthors(); | |
$author_bylines = ''; | |
$author_twitters = ''; | |
$authors_chartbeat = ''; | |
$twitter = ''; | |
foreach ( $co_authors as $key => $co_author ) { | |
render_userphoto($co_author->ID, array(height => '60', width => '60')); | |
if (get_the_author_meta('organization',$co_author->ID)) { | |
$author_org = ', ' . get_the_author_meta('organization',$co_author->ID); | |
} else { $author_org = ''; } | |
if ( $key == '0' ) { | |
$author_bylines .= '<p>by <a href="' . get_author_posts_url($co_author->ID) .'">' . $co_author->display_name . '</a>' . $author_org . '</p>'; | |
$authors_chartbeat .= $co_author->display_name; | |
} | |
else { | |
$author_bylines .= '<p>and <a href="' . get_author_posts_url($co_author->ID) .'">' . $co_author->display_name . '</a>' . $author_org . '</p>'; | |
$authors_chartbeat .= ', ' . $co_author->display_name; | |
} | |
$twitter = get_the_author_meta('twitter',$co_author->ID); | |
if ( $twitter != '' ) { | |
$author_twitters .= '<p class="author-twitter">Follow ' . $co_author->display_name . ' on twitter: <a href="http://twitter.com/' . $twitter . '">@' . $twitter . '</a></p>'; | |
} | |
} | |
} | |
$GLOBALS['authors_chartbeat'] = $authors_chartbeat; | |
##### SECTION GLOBAL ##### | |
$post_section_chartbeat = get_the_terms($post->ID, 'section', '', '', ''); | |
foreach ($post_section_chartbeat as $key => $section) { | |
if ($key == 0) { | |
$post_section_chartbeat = $section->name; | |
} else { | |
$post_section_chartbeat .= ", ". $section->name; | |
} | |
} | |
$post_section_chartbeat = str_replace("-", " ", $post_section_chartbeat); | |
$post_section_chartbeat = str_replace("&", "&", $post_section_chartbeat); | |
$GLOBALS['post_section_chartbeat'] = $post_section_chartbeat; | |
} | |
#### FOOTER CODE #### | |
<script type='text/javascript'> | |
var _sf_async_config = _sf_async_config || {}; | |
/** CONFIGURATION START **/ | |
_sf_async_config.uid = 62058; | |
_sf_async_config.domain = 'rewire.news'; | |
_sf_async_config.useCanonical = true; | |
_sf_async_config.sections = "<?php echo $GLOBALS['post_section_chartbeat'] ?>"; | |
_sf_async_config.authors = "<?php echo $GLOBALS['authors_chartbeat']; ?>"; | |
/** CONFIGURATION END **/ | |
(function() { | |
function loadChartbeat() { | |
window._sf_endpt = (new Date()).getTime(); | |
var e = document.createElement('script'); | |
e.setAttribute('language', 'javascript'); | |
e.setAttribute('type', 'text/javascript'); | |
e.setAttribute('src', '//static.chartbeat.com/js/chartbeat.js'); | |
document.body.appendChild(e); | |
} | |
var oldonload = window.onload; | |
window.onload = (typeof window.onload != 'function') ? | |
loadChartbeat : function() { | |
oldonload(); | |
loadChartbeat(); | |
}; | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment