Created
October 22, 2011 18:23
-
-
Save jayj/1306314 to your computer and use it in GitHub Desktop.
Part of tutorial on Jayj.dk
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
/** | |
* Format: box | |
*/ | |
if ( 'box' == $format ) : | |
$meta = get_post_meta( $id, 'download', true ); | |
$count_meta = get_post_meta( $id, 'download_count', true ); | |
// Start content | |
ob_start(); | |
?> | |
<div class="single-download" id="single-download-<?php echo intval( $id ); ?>"> | |
<?php | |
// Get the title, either from shortcode or the title of the download | |
$title = ( $title ) ? $title : 'Download ' . $download->post_title; | |
// Append count to title | |
if ( $show_count === true ) | |
$title .= ' (Downloaded ' . number_format( $count_meta ) . ' times)'; | |
?> | |
<!-- Thumbnail --> | |
<?php if ( $thumbnail !== false && has_post_thumbnail( $id ) ) { ?> | |
<a href="<?php echo get_permalink( $id ); ?>" title="<?php echo esc_attr( $title ); ?>"><?php echo get_the_post_thumbnail( $id, 'thumbnail' ); ?></a> | |
<?php } ?> | |
<?php if ( ! empty( $content ) ) { ?> | |
<div class="download-text"><?php echo $content; ?></div> | |
<?php } ?> | |
<a href="<?php echo get_permalink( $id ); ?>" title="<?php echo esc_attr( $title ); ?>" class="download-link">Download</a> | |
<?php | |
// Show count | |
if ( $show_count === true ) | |
echo '<span class="download-count">' . sprintf( __( 'Downloaded %s times', 'twentyeleven' ), number_format( $count_meta ) ) . '</span>'; | |
?> | |
</div> <!-- .single-download --> | |
<?php | |
// Return the content | |
return ob_get_clean(); | |
endif; // 'box' == $format |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment