-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthor.php
193 lines (159 loc) · 6.38 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
<?php get_header(); ?>
<section>
<div id="content" class="narrowcolumn">
<!-- This sets the $curauth variable -->
<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
?>
<h2>About: <?php echo $curauth->display_name; ?></h2>
<dl>
<dt>Website</dt>
<dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>
<dt>Profile</dt>
<dd><?php echo $curauth->user_description; ?></dd>
</dl>
<h2>:</h2>
<ul>
<!-- The Loop -->
<section class="section-border <?php if (is_dynamic_sidebar('sidebar-widgets')) :?>col-md-8<?php else :?>col-md-12<?php endif;?>"> <!-- the width of this section will vary if sidebar-widgets are active -->
<h1>VIDEOS BY <?php echo $curauth->display_name; ?></h1>
<ul class="row">
<div id="author-vids"> <!-- This id will be triggered by jquery to create an infinite scroll -->
<?php
if (isset($_POST['page_no'])){
$page_number = $_POST['page_no'];
} else {
$page_number = 1;
}
global $wp_query, $paged;
if( get_query_var('paged') ) {
$paged = get_query_var('paged');
}
else if ( get_query_var('page') ) {
$paged = get_query_var('page');
}
else{
$paged = 1;
}
$wp_query = null;
$content_layout = get_theme_mod('content_layout_setting'); //content layout settings - thumbs or compressed posts
if (is_dynamic_sidebar('sidebar-widgets')) { // the number of posts per page will vary if sidebar-widgets are active
$args = array(
'posts_per_page' => 6,
'posts_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'author' => $current_user->ID,
'paged' => $paged
);
}
else {
$args = array(
'posts_per_page' => 10,
'posts_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'author' => $current_user->ID,
'paged' => $paged
);
}
$wp_query = new WP_Query( $args ); /* for pagination to work this must be called wp_query for some reason */
$current_user = wp_get_current_user();
$x=1; // our x variable will be used to signal the first post on each page
while ($wp_query->have_posts()) : $wp_query->the_post();
$vid_link = get_post_meta( $post->ID, 'video_link', true );
$video_embed_code = wp_oembed_get( $vid_link, array( 'width' => 120, 'height' => 90, 'controls' => 2, 'showinfo' => 0) );
?>
<li id="page<?php if ($x==1) { echo $page_number; $x++;}?>" class="the-post col-md-4" style="width: <?php if (is_dynamic_sidebar('sidebar-widgets')) :?>33%<?php else :?>20%<?php endif;?>"><!-- using $x to signal our first post -->
<div class="vid-col">
<div class="zed<?php the_id(); ?> content-layout">
<div class="vid-thumb">
<?php echo $video_embed_code ?>
</div>
</div>
<div class="vid-title">
<h8>
<a href="<?php the_permalink(); ?>"><?php the_title();?></a>
<?php if ($content_layout == 'compressed'):?>
<button type = "button" class = "content-show" id = "show-nav<?php the_id(); ?>">
<span class = "glyphicon glyphicon-plus"> </span>
</button>
<button type = "button" class = "content-hide" id = "hide-nav<?php the_id(); ?>">
<span class = "glyphicon glyphicon-minus"> </span>
</button>
<?php endif;?>
</h8>
</div>
<div class="vid-desc">
<?php the_field('description'); ?> </p>
</div>
<div class="vid-meta-top">
<div class="vid-meta-auth">
Posted by <a><?php the_author_posts_link(); ?></a>
</div>
<div class="vid-meta-views">
<?php echo getPostViews(get_the_ID());?>
</div>
</div>
<div class="vid-meta-bottom">
<div class="vid-meta-date">
On <?php the_time('j F Y'); ?>
</div>
<div class="vid-meta-edit">
<a href="<?php the_permalink(); ?>"><?php if ($post->post_author == $current_user->ID || current_user_can( 'manage_options' )) : ?>Edit /<?php endif; ?> Comment</a></p>
</div>
</div>
</div>
</li>
<?php if ($content_layout == 'compressed') : ?>
<script>
jQuery("#show-nav<?php the_id(); ?>").click(function () {
jQuery(".zed<?php the_id(); ?>").toggle("slow");
jQuery("#show-nav<?php the_id(); ?>").hide();
jQuery("#hide-nav<?php the_id(); ?>").show();
});
jQuery("#hide-nav<?php the_id(); ?>").click(function () {
jQuery(".zed<?php the_id(); ?>").toggle("slow");
jQuery("#hide-nav<?php the_id(); ?>").hide();
jQuery("#show-nav<?php the_id(); ?>").show();
});
</script>
<?php
endif;
endwhile;
$total_posts = $wp_query->found_posts; //obtaining the total number of posts in our query
if (is_dynamic_sidebar('sidebar-widgets')) {
$total_pages = ceil($total_posts / 6); // calculating the number of pages based on the posts per page /// ADD COMPRESSED POSTS CONDITION
}
else {
$total_pages = ceil($total_posts / 10);
}
$pages_left = ($total_pages - 1) - ($page_number - 1);
if ($page_number < $total_pages && $total_pages > 1) : ?> <!-- disabling the 'more posts' button if there are no more pages or if there's only 1 page -->
<div class="col-md-12">
<button type="button" id="next-latest-btn" class="btn btn-primary pagination" value="<?php echo $total_pages;?>">
Load More (<?php echo $pages_left;?>)
</button>
<!-- ADD AN IF PAGE > 3 BACK TO TOP / COLLAPSE BUTTON -->
</div>
<?php
else :?>
<div>
</div>
<?php
endif;
wp_reset_query();
?>
<!-- End Loop -->
</ul>
</div>
</section>
<?php if (is_dynamic_sidebar('sidebar-widgets')) : ?>
<!-- our side widgets -->
<section class="sidebar-list col-md-4">
<div>
<?php dynamic_sidebar('sidebar-widgets');?>
</div>
</section>
<?php endif; ?>
<?php get_footer(); ?>