forked from vitathemes/notation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidebar.php
142 lines (132 loc) · 4.74 KB
/
sidebar.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
<?php
/**
* The sidebar containing the main widget area
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package Wp_notes
*/
if ( ! get_theme_mod( 'show_sidebar', true ) ) {
return;
}
global $post;
$current_post_id = $post->ID;
?>
<aside class="c-sidebar <?php if ( is_home() && get_theme_mods( 'blog_content', true ) || is_archive() ) {
echo "c-sidebar--archives";
} ?> js-sidebar">
<button class="c-sidebar__toggle js-sidebar-toggle" aria-label="<?php echo esc_attr_e( 'Toggle Sidebar', 'wp-notes' ); ?>">
<svg class="c-sidebar__toggle__icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" width="1em" height="1em" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256">
<path d="M160 216a7.975 7.975 0 0 1-5.657-2.343l-80-80a8 8 0 0 1 0-11.314l80-80a8 8 0 0 1 11.314 11.314L91.314 128l74.343 74.343A8 8 0 0 1 160 216z"/>
<rect x="0" y="0" width="256" height="256" fill="rgba(0, 0, 0, 0)"/>
</svg>
</button>
<?php
$sticky_posts_id = get_option( 'sticky_posts' );
if ($sticky_posts_id) {
$sticky_posts_args = array(
'posts_per_page' => get_option( 'posts_per_page' ),
'post__in' => $sticky_posts_id,
'ignore_sticky_posts' => 0,
);
$sticky_posts = new WP_Query( $sticky_posts_args );
if ( $sticky_posts->have_posts() ) :
echo "<span class='c-sidebar__title'>" . esc_html__( 'Pinned', 'wp-notes' ) . "</span>";
?>
<div class="c-sidebar__main">
<?php
/* Start the Loop */
while ( $sticky_posts->have_posts() ) :
$sticky_posts->the_post();
?>
<?php
$active_class = '';
if ( $current_post_id === get_the_ID() && is_single() ) {
$active_class = ' is-selected-post';
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'c-post c-post--archive' . $active_class ); ?>>
<a href="<?php echo esc_url( get_permalink() ); ?>" class="c-post__link" aria-label="<?php the_title(); ?>"></a>
<header class="c-post__header">
<?php
the_title( '<h3 class="c-post__title h3">', '</h2>' );
?>
</header><!-- .entry-header -->
<?php if ( get_theme_mod( 'show_post_excerpt_sidebar', true ) ): ?>
<div class="c-post__content">
<?php
echo esc_html(wp_notes_get_excerpt());
?>
</div><!-- .entry-content -->
<?php endif; ?>
<?php if ( get_theme_mod( 'show_date_sidebar', true ) ): ?>
<footer class="c-post__footer">
<div class="c-post__footer__meta">
<?php
wp_notes_posted_on();
?>
</div><!-- .entry-meta -->
</footer>
<?php endif; ?>
</article><!-- #post-<?php the_ID(); ?> -->
<?php
wp_reset_query();
endwhile; ?>
</div>
<?php
endif;
}
$args = array(
'posts_per_page' => get_option( 'posts_per_page' ),
'post__not_in' => $sticky_posts_id,
'ignore_sticky_posts' => 1,
);
$recent_posts = new WP_Query( $args );
?>
<?php
if ( $recent_posts->have_posts() ) :
if ($sticky_posts_id) {
echo "<span class='c-sidebar__title c-sidebar__title--other'>" . esc_html__( 'Other', 'wp-notes' ) . "</span>"; ?>
<?php } ?>
<div class="c-sidebar__main">
<?php
/* Start the Loop */
while ( $recent_posts->have_posts() ) :
$recent_posts->the_post();
$active_class = '';
if ( $current_post_id === get_the_ID() && is_single() ) {
$active_class = ' is-selected-post';
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'c-post c-post--archive' . $active_class ); ?>>
<a href="<?php echo esc_url( get_permalink() ); ?>" class="c-post__link" aria-label="<?php the_title(); ?>"></a>
<header class="c-post__header">
<?php
the_title( '<h3 class="c-post__title h3">', '</h2>' );
?>
</header><!-- .entry-header -->
<?php if ( get_theme_mod( 'show_post_excerpt_sidebar', true ) ): ?>
<div class="c-post__content">
<?php
echo esc_html(wp_notes_get_excerpt());
?>
</div><!-- .entry-content -->
<?php endif; ?>
<?php if ( get_theme_mod( 'show_date_sidebar', true ) ): ?>
<footer class="c-post__footer">
<div class="c-post__footer__meta">
<?php
wp_notes_posted_on();
?>
</div><!-- .entry-meta -->
</footer>
<?php endif; ?>
</article><!-- #post-<?php the_ID(); ?> -->
<?php
wp_reset_query();
endwhile; ?>
</div> <?php
endif;
wp_notes_get_sidebar_button();
?>
</aside>