-
Notifications
You must be signed in to change notification settings - Fork 9
/
author.php
executable file
·298 lines (205 loc) · 10.2 KB
/
author.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?php get_header(); ?>
<div id="content" class="clearfix row">
<div id="main" class="col-sm-12 clearfix" role="main">
<div class="page-header">
<h1 class="archive_title h2">
<span><?php _e( get_bloginfo() . " • ", "wpbootstrap"); ?></span>
<?php
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
$author_display_name = get_the_author_meta('display_name', $curauth->ID);
echo $author_display_name;
?>
</h1>
</div> <!-- page-header -->
<?php if ( bank106_option( 'show_ex' ) == 'both' OR bank106_option( 'show_ex' ) == 'ex' ): // show response types?>
<div class="row exlist">
<div class="col-sm-10">
<?php
// count of items found
$found_things = $wp_query->found_posts;
$title_str = $found_things . ' ' . bank106_option( 'thingname' ) . ' Response';
//because grammar
$title_str .= ( $found_things == 1 ) ? '' : 's';
// array to hold results
$author_results = [];
?>
<h2><?php echo $title_str?></h2>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
/* to group the responses by Type, we need to load all results
in an array, then sort and display
*/
// get the ID for the assignment this belongs to
$aid = get_assignment_id_from_terms( get_the_ID() );
// get the assignment types for this thing
$terms = get_the_terms( $aid, 'assignmenttypes' );
// make a link string for the thing/assignment this is response to
$assignment_str = ($aid) ? '<a href="' . get_permalink($aid) . '">' . get_the_title($aid) . '</a>' : '';
// get link for item
$the_real_permalink = bank106_get_response_link( $post->ID );
$more_link = '<a href="' . $the_real_permalink . '" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-link"></span> ' . $the_real_permalink . '</a>';
$byline = bank106_user_credit_link( $aid, '', '', 'exampletags' );
// build the output
$example_str = '';
$example_str .= '<article class="clearfix" role="article"><header><h4><a href="' . $the_real_permalink . '">' . get_the_title() . '</a>' ;
$example_str .= '</h4><p class="meta"><time datetime="' . get_the_time('Y-m-j') . '" pubdate>' . get_the_date() . '</time> • Response for ' . $assignment_str . ' ' . bank106_option( 'thingname' ) . '</p></header><section class="post_content">' . get_the_excerpt() . ' <p class="more-link">' . $more_link . '</p></section></article>';
// now iterate over the assignment terms
if ($terms) {
foreach ($terms as $term) {
if (array_key_exists( $term->slug, $author_results ) ) {
// see if we have used this term, if so append to results
$author_results[$term->slug]["results"][] = $example_str;
} else {
$author_results[$term->slug] = array(
'name' => $term->name,
'results' => array($example_str)
);
}
}
}
?>
<?php endwhile; ?>
<?php
foreach ($author_results as $key => $value) {
echo '<h3>' . $value['name'] . ' ' . ucfirst( bank106_option('type_name') ) . '</h3><ul>' . implode("\n", $value['results']) . '</ul>';
}
?>
<?php else : ?>
<p><?php _e('No responses to' . bank106_option( 'pluralthings' ) . ' have been made by ' . $author_display_name . '.', "wpbootstrap"); ?></p>
<?php endif; ?>
</div><!--col -->
</div><!-- row -->
<?php if ( bank106_option( 'show_ex' ) == 'both' OR bank106_option( 'show_ex' ) == 'tut' ): // show tutorial types?>
<div class="row tutlist">
<div class="col-sm-10">
<?php
// Fix the examples to add new post meta
$example_query = new WP_Query(
array(
'posts_per_page' =>'-1',
'post_type' => 'examples',
'meta_key' => 'example_type',
'meta_value' => 'tut'
)
);
if ( $example_query->have_posts() ) {
// count of items found
$found_things = $example_query->found_posts;
$title_str = $found_things . ' ' . bank106_option( 'thingname' ) . ' ' . bank106_option('helpthingname');
//because grammar
$title_str .= ( $found_things == 1 ) ? '' : 's';
// array to hold results
$author_results = [];
echo '<h2>' . $title_str . '</h2>';
while ($example_query->have_posts()) : $example_query->the_post();
/* to group the responses by Type, we need to load all results
in an array, then sort and display
*/
// get the ID for the assignment this belongs to
$aid = get_assignment_id_from_terms( get_the_ID() );
// get the assignment types for this thing
$terms = get_the_terms( $aid, 'assignmenttypes' );
// make a link string for the thing/assignment this is response to
$assignment_str = ($aid) ? '<a href="' . get_permalink($aid) . '">' . get_the_title($aid) . '</a>' : '';
// get link for item
$the_real_permalink = bank106_get_response_link( $post->ID );
$more_link = '<a href="' . $the_real_permalink . '" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-link"></span> ' . $the_real_permalink . '</a>';
$byline = bank106_user_credit_link( $aid, '', '', 'exampletags' );
// build the output
$example_str = '';
$example_str .= '<article class="clearfix" role="article"><header><h4><a href="' . $the_real_permalink . '">' . get_the_title() . '</a>' ;
$example_str .= '</h4><p class="meta"><time datetime="' . get_the_time('Y-m-j') . '" pubdate>' . get_the_date() . '</time> • ' . bank106_option( 'helpthingname' ) . ' for ' . $assignment_str . ' ' . bank106_option( 'thingname' ) . '</p></header><section class="post_content">' . get_the_excerpt() . ' <p class="more-link">' . $more_link . '</p></section></article>';
// now iterate over the assignment terms
if ($terms) {
foreach ($terms as $term) {
if (array_key_exists( $term->slug, $author_results ) ) {
// see if we have used this term, if so append to results
$author_results[$term->slug]["results"][] = $example_str;
} else {
$author_results[$term->slug] = array(
'name' => $term->name,
'results' => array($example_str)
);
}
}
}
endwhile;
foreach ($author_results as $key => $value) {
echo '<h3>' . $value['name'] . ' ' . ucfirst( bank106_option('type_name') ) . '</h3><ul>' . implode("\n", $value['results']) . '</ul>';
}
} else {
echo '<p>No ' . bank106_option( 'thingname' ) . 's to' . bank106_option( 'pluralthings' ) . ' have been made by ' . $author_display_name . '.</p>';
}
?>
</div><!--col -->
</div><!-- row -->
<?php endif?>
<?php
// find all things created by this user
$things_query = new WP_Query(
array(
'posts_per_page' =>'-1',
'post_type' => 'assignments',
'author' => $curauth->ID
)
);
?>
<?php if ($things_query->have_posts()) :?>
<div class="row">
<div class="col-sm-10">
<?php
// count of items found
$found_things = $things_query->found_posts;
// Because grammar
$plural = ( $found_things == 1 ) ? bank106_option( 'thingname' ) : bank106_option( 'pluralthings' );
$use_public_ratings = function_exists('the_ratings');
?>
<h2><?php echo $found_things . ' ' . $plural?> Created</h2>
</div><!--col -->
</div><!-- row -->
<?php endif?>
<div id="assignmentmenu" class="clearfix row"> <!-- thing menu -->
<?php
$odd = false; // flag to start a new row
while ($things_query->have_posts()) : $things_query->the_post();
if ( $odd ) {
echo '<div class="col-sm-offset-1 col-sm-5">';
} else {
echo '<div class="clearfix row"><div class="col-sm-5">';
}
$odd = !$odd;
?>
<article id="post-<?php the_ID(); ?>" role="article" class="thing-archive">
<!-- thing header -->
<header>
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<?php
// insert ratings if enabled
if ( $use_public_ratings ) { the_ratings(); }
// author name either from WP user or from meta data (uses old FWP meta)
$assignmentAuthor = bank106_get_display_name( $post->ID, 'fwp_name' );
?>
<p class="meta">
Created <strong><time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_date(); ?></time></strong> by <strong><?php echo $assignmentAuthor?></strong> <?php echo bank106_user_credit_link( $post->ID, '(', ')' )?> <?php echo get_assignment_meta_string( $post->ID );?>
</p>
</header>
<!-- end thing header -->
<!-- thing icon or embedded media -->
<div class="thing-icon">
<a href="<?php the_permalink(); ?>"><?php echo get_thing_icon ($post->ID, 'thumbnail', 'thing-archive') ?></a>
</div>
<!-- end icon or media -->
<!-- thing content -->
<section class="post_content">
<?php the_excerpt(); ?><p class="more-link"><a href="<?php the_permalink(); ?>" class="btn btn-primary"><?php echo bank106_option( 'thingname' )?> Details</a><?php edit_post_link( __( 'Edit', 'wpbootstrap' ), '<br /><span class="edit-link">', '</span>' ); ?></p>
</section> <!-- end article section -->
<!-- end thing content -->
</article> <!-- end article -->
</div> <!-- end assignment listing -->
<?php if ( !$odd ) echo '</div> <!-- end row -->';?>
<?php endwhile; ?>
</div> <!-- end assignment menu -->
<?php endif; ?>
</div> <!-- end #main -->
</div> <!-- end #content -->
<?php get_footer(); ?>