Skip to content

Instantly share code, notes, and snippets.

@mfenner
Created June 25, 2011 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfenner/1046450 to your computer and use it in GitHub Desktop.
Save mfenner/1046450 to your computer and use it in GitHub Desktop.
Changes to Annotum Wordpress theme to support ePub Export Plugin
/**
* Get the ePub download link for a post
*
* @param int $id
* @return string
*/
function anno_epub_download_url($id = null) {
# Requires ePub Export Plugin, returns "" if ePub Export Plugin didn't create ePub file
$article_id = get_the_ID();
$uploads = wp_upload_dir();
$fname = $uploads[path] . "/" . $article_id . ".epub";
// Use link if ePub exists
if (file_exists($fname)) {
$url = $uploads[url] . "/" . $article_id . ".epub";
} else {
$url = "";
}
return $url;
}
// Set a default ePub Link
$epub_link = '';
if (function_exists('anno_epub_download_url')) {
$epub_url = anno_epub_download_url(get_the_ID());
if (!empty($epub_url)) {
$epub_link = '<a href="'.esc_url($epub_url).'">'.__('ePub', 'anno').'</a>';
}
}
?>
<div class="tools-bar supplement clearfix">
<div class="cell print">
<a href="#" onclick="window.print(); return false;"><?php _e('Print Article', 'anno'); ?></a>
</div>
<div class="cell citation">
<a><?php _e('Citation', 'anno'); ?></a>
<div class="citation-container">
<textarea class="entry-summary" readonly><?php anno_the_citation(); ?></textarea>
</div><!--/.citation-container -->
</div>
<div class="cell download">
<?php echo implode(', ', array($pdf_link, $xml_link, $epub_link)); ?>
</div>
<div class="cell share clearfix">
<div class="social-nav">
<ul class="nav">
<li><?php anno_email_link(); ?></li>
<li><?php anno_twitter_button(); ?></li>
<li><?php anno_facebook_button(); ?></li>
</ul>
</div>
</div>
</div><!-- .action-bar -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment