-
Notifications
You must be signed in to change notification settings - Fork 12
/
single-examples.php
102 lines (70 loc) · 3.29 KB
/
single-examples.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
// check if this is a syndicated external link
$the_real_permalink = get_post_meta( $post->ID, 'syndication_permalink', true );
if ( $the_real_permalink ) {
// let's go to the link instead of doing anything else
wp_redirect ( $the_real_permalink );
exit;
}
// We got a real thing to show, get some meta data first
$exampleURL = get_post_meta( $post->ID, 'example_url', true );
$exampleTwitter = get_post_meta( $post->ID, 'submitter_twitter', true );
$exampleCredit = ( get_post_meta( $post->ID, 'example_source', true ) ) ? ' (' . get_post_meta( $post->ID, 'example_source', true ) . ')' : '';
// get the assignment ID and permalink this example is a response to
$assignment_id = get_assignment_id_from_terms( $post->ID );
$assignment_link = get_permalink( $assignment_id );
get_header();
?>
<div id="content" class="clearfix row">
<div id="main" class="col-sm-12 clearfix" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post();
$exampleSource = bank106_get_display_name( $post->ID, 'syndication_source' );
?>
<article id="post-<?php the_ID(); ?>" role="article">
<div class="clearfix row">
<header>
<div class="col-sm-8">
<h1 class="single-title assignment-header" itemprop="headline"><?php the_title(); echo $exampleCredit; ?></h1>
<p class="meta">A response to the <a href="<?php echo $assignment_link?>"><?php echo get_the_title( $assignment_id );?></a> <?php echo bank106_option( 'thingname' )?><br />
<?php _e("created", "wpbootstrap"); ?> <strong><time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_date(); ?></time></strong> by <strong><?php echo $exampleSource?></strong> <?php echo bank106_user_credit_link( $post->ID, '(', ')', 'exampletags' )?><br /><br />
Number of views: <strong><?php echo get_post_meta( $post->ID, 'examples_visits', true);?></strong>
</p>
<p class="tags"><?php echo get_the_term_list( $post->ID, 'exampletags', 'Tags: ', ', ', '' ); ?></p>
<hr />
<?php the_content(); ?>
<?php bank106_twitter_button ( $post->ID, 'Response' )?>
</div>
<div class="col-sm-4" id="examplemedia">
<?php echo get_example_media( $post->ID, 'example_url' )?>
</div>
</header> <!-- end article header -->
</div> <!-- end row -->
</article> <!-- end article -->
<div id="content" class="row">
<div class="col-sm-8 ">
<!-- comments -->
<?php comments_template('',true); ?>
</div>
</div>
<?php endwhile; ?>
<?php
// let's update meta data for this assignment (count of exmaples done, bump visit count)
update_example_meta( $post->ID );
?>
<?php else : ?>
<div class="col-sm-8">
<article id="post-not-found">
<header>
<h1><?php _e("Uh oh", "wpbootstrap"); ?></h1>
</header>
<section class="post_content">
<p><?php _e("Egads, but the requested item was not found.", "wpbootstrap"); ?></p>
</section>
<footer>
</footer>
</article>
</div>
<?php endif; ?>
</div> <!-- end #main -->
</div> <!-- end #content -->
<?php get_footer(); ?>