-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthor.php
155 lines (127 loc) · 3.94 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
<?php
/**
* The template for displaying the author pages
*
* @link https://codex.wordpress.org/Author_Templates
*
* @package Wordtrap
* @since wordtrap 1.0.0
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
// View mode
$view_mode = wordtrap_get_view_mode();
// Pagination
$pagination = wordtrap_options( 'posts-pagination' );
get_header();
?>
<?php if ( have_posts() ) : ?>
<header class="author-header">
<?php
if ( get_query_var( 'author_name' ) ) {
$curauth = get_user_by( 'slug', get_query_var( 'author_name' ) );
} else {
$curauth = get_userdata( intval( $author ) );
}
if ( ! empty( $curauth->ID ) ) {
$alt = sprintf(
/* translators: %s: author name */
_x( 'Profile picture of %s', 'Avatar alt', 'wordtrap' ),
$curauth->display_name
);
echo get_avatar( $curauth->ID, 96, '', $alt );
}
if ( ! empty( $curauth->user_url ) || ! empty( $curauth->user_description ) ) {
?>
<dl>
<?php if ( ! empty( $curauth->user_url ) ) : ?>
<dt><?php esc_html_e( 'Website', 'wordtrap' ); ?></dt>
<dd>
<a href="<?php echo esc_url( $curauth->user_url ); ?>"><?php echo esc_html( $curauth->user_url ); ?></a>
</dd>
<?php endif; ?>
<?php if ( ! empty( $curauth->user_description ) ) : ?>
<dt>
<?php
printf(
/* translators: %s: author name */
esc_html__( 'About %s', 'wordtrap' ),
$curauth->display_name
);
?>
</dt>
<dd><?php echo esc_html( $curauth->user_description ); ?></dd>
<?php endif; ?>
</dl>
<?php
} else {
?>
<dl>
<dt><?php echo esc_html( $curauth->display_name ); ?></dt>
</dl>
<?php
}
if ( have_posts() ) {
printf(
/* translators: %s: author name */
'<h2 class="screen-reader-text">' . esc_html__( 'Posts by %s', 'wordtrap' ) . '</h2>',
$curauth->display_name
);
}
?>
</header><!-- .author-header -->
<?php
if ( $pagination ) : ?>
<div class="posts-pagination-container posts-pagination-<?php echo esc_attr( $pagination ) ?>">
<?php
endif;
wordtrap_posts_filter_navigation( 'posts-filter-above' );
if ( $view_mode === 'grid' ) : ?>
<div class="posts-grid posts-view-<?php echo esc_attr( wordtrap_options( 'posts-grid-view' ) ) ?> <?php echo esc_attr( wordtrap_grid_view_classes() ) ?>">
<?php
endif;
$prev_year = null;
$prev_month = null;
$count = 1;
$timeline_view = $view_mode === 'grid' && wordtrap_options( 'posts-grid-view' ) === 'timeline';
// Load posts loop.
while ( have_posts() ) :
the_post();
$timestamp = strtotime( get_the_date() );
$year = get_the_date( 'o' );
$month = date( 'n', $timestamp );
if ( $timeline_view && ( $prev_month != $month || ( $prev_month == $month && $prev_year != $year ) ) ) :
$post_count = 1;
$prev_year = $year;
$prev_month = $month;
?>
<div class="timeline-date"><span><?php echo get_the_date( 'F Y' ); ?></span></div>
<?php endif;
if ( $view_mode === 'grid' ) :
?>
<div class="post-wrap<?php echo $timeline_view ? ( ( 1 == $post_count++ % 2 ? ' left' : ' right' ) ) : '' ?>">
<?php
endif;
get_template_part( 'template-parts/content/content', get_post_format() );
if ( $view_mode === 'grid' ) :
?>
</div><!-- .post-wrap -->
<?php
endif;
endwhile;
if ( $view_mode === 'grid' ) : ?>
</div><!-- .posts-grid -->
<?php
endif;
wordtrap_posts_filter_navigation( 'posts-filter-below' );
if ( $pagination ) : ?>
</div><!-- .posts-pagination-container -->
<?php
endif;
else :
// If no content, include the "No posts found" template.
get_template_part( 'template-parts/content/content', 'none' );
endif;
?>
<?php
get_footer();