-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpage-licensed.php
215 lines (128 loc) · 4.53 KB
/
page-licensed.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
/*
Template Name: Licenses/Rights
*/
// ------------------------ check vars ------------------------
$page_id = $post->ID;
// all allowable licenses for this theme
$all_licenses = splotbox_get_licences();
if ( isset( $wp_query->query_vars['flavor'] ) ) {
$license_flavor = $wp_query->query_vars['flavor'];
// make sure we have something in the set of allowed ones; otherwise set to none
if ( ! array_key_exists ( $license_flavor, $all_licenses ) ) $license_flavor = 'none';
} else {
// no license in query string
$license_flavor = 'none';
}
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
?>
<?php get_header(); ?>
<div class="wrapper">
<div class="wrapper-inner section-inner groupthin">
<?php if ($license_flavor == 'none') :?>
<div class="content">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'post' ); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<figure class="featured-media">
<?php
the_post_thumbnail();
$image_caption = get_the_post_thumbnail_caption();
if ( $image_caption ) : ?>
<div class="media-caption-container">
<p class="media-caption"><?php echo $image_caption; ?></p>
</div>
<?php endif; ?>
</figure><!-- .featured-media -->
<?php endif; ?>
<div class="post-inner">
<div class="post-header">
<?php the_title( '<h1 class="post-title">', '</h1>' ); ?>
</div><!-- .post-header -->
<div class="post-content entry-content">
<?php the_content(); ?>
<?php if ( splotbox_option('use_license') > 0 ):?>
<ul>
<?php
foreach ( $all_licenses as $abbrev => $title) {
// get number of items with this license
$lcount = splotbox_get_license_count( $abbrev );
// show if we have some
if ( $lcount > 0 ) {
echo '<li><a href="' . site_url() . '/licensed/' . $abbrev . '">' . $title . '</a> (' . $lcount . ")</li>\n";
}
}
?>
</ul>
<?php else:?>
<p>The current settings for this site are to not use or display licenses; the site administration can enable this feature from the <code>SPLOTbox Options.</code> </p>
<?php endif?>
<?php edit_post_link( __( 'Edit', 'garfunkel' ) . ' →', '<div class="clear"></div>'); ?>
</div><!-- .post-content -->
<?php endwhile; else: ?>
<p><?php _e( "We couldn't find any content. Please try again.", "garfunkel" ); ?></p>
<?php endif; ?>
</div><!-- .post-inner -->
</article> <!-- .post -->
</div><!-- content -->
<?php else:?>
<?php
$args = array(
'meta_key' => 'license',
'meta_value' => $license_flavor,
'paged' => $paged,
);
$my_query = new WP_Query( $args );
// Pagination steps
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $my_query;
?>
<div class="page-title">
<h5><?php printf(
_n(
'%s Item Licensed %s',
'%s Items Licensed %s',
$my_query->found_posts,
'garfunkel'
),
number_format_i18n( $my_query->found_posts ),
$all_licenses[$license_flavor]
);?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if ( "1" < $my_query->max_num_pages ) : ?>
<span><?php printf( __('Page %s of %s', 'garfunkel'), $paged, $my_query->max_num_pages ); ?></span>
<div class="clear"></div>
<?php endif; ?></h5>
</div> <!-- /page-title -->
<div class="content">
<?php if ( $my_query->have_posts() ) : ?>
<div class="posts">
<?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
</div><!-- .posts -->
<?php if ( $my_query->max_num_pages > 1 ) : ?>
<div class="archive-nav">
<?php echo get_next_posts_link( '« ' . __( 'Older Items', 'garfunkel' ) ); ?>
<?php echo get_previous_posts_link( __( 'Newer Items', 'garfunkel' ) . ' »' ); ?>
<?php
// Reset postdata
wp_reset_postdata();
// Reset main query object
$wp_query = NULL;
$wp_query = $temp_query;
?>
<div class="clear"></div>
</div><!-- .post-nav archive-nav -->
<div class="clear"></div>
<?php endif; ?>
<?php endif; ?>
</div><!-- .post -->
<?php endif; ?>
<?php get_sidebar(); ?>
</div><!-- .content -->
</div><!-- .wrapper-inner -->
</div> <!-- .wrapper -->
<?php get_footer(); ?>