-
Notifications
You must be signed in to change notification settings - Fork 2
/
navigation.php
62 lines (55 loc) · 1.91 KB
/
navigation.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
<?php
$history = flux_get_blog_history();
if ( empty( $history ) )
return;
$current_year = ( get_query_var( 'year' ) ) ? get_query_var( 'year' ) : date( 'Y' );
$current_month = ( get_query_var( 'monthnum' ) ) ? get_query_var( 'monthnum' ) : date( 'n' );
$years = array_unique( wp_list_pluck( $history, 'year' ) );
$year_months = array();
foreach( $years as $year ) {
$year_months[$year] = wp_filter_object_list( $history, array( 'year' => $year ), 'and', 'month' );
}
$all_months = array();
for( $i = 12; $i >= 1; $i-- ) {
$all_months[] = $i;
}
?>
<div id="flux-time-selectors">
<div class="flux-year-selector">
<ul>
<?php foreach( $years as $year ) {
$active_year = ( $year == $current_year ) ? true : false;
$classes = array(
'flux-year',
'flux-year-' . $year,
);
if ( $active_year )
$classes[] = 'flux-year-active';
$classes = apply_filters( 'flux_year_selector_classes', $classes );
$year_link = '<a class="' . implode( ' ', $classes ) . '" href="' . get_year_link( $year ) . '">' . $year . ' <span>•</span></a>';
echo '<li>' . $year_link . '</li>';
} ?>
</ul>
</div>
<?php foreach( $year_months as $year => $months ): ?>
<div class="flux-month-selector" id="<?php echo 'flux-month-selector-' . $year; ?>"<?php if ( $current_year != $year ) echo ' style="display:none"'; ?>>
<ul>
<?php foreach( $all_months as $month ) {
$active_month = ( $month == $current_month ) ? true : false;
$classes = array(
'flux-month',
'flux-month-' . $month,
);
if ( $active_month )
$classes[] = 'flux-month-active';
if ( in_array( $month, $months ) )
$month_link = '<a class="' . implode( ' ', $classes ) . '" href="' . get_month_link( $current_year, $month ) . '">' . $month . ' <span>•</span></a>';
else
$month_link = $month . ' <span>•</span>';
echo '<li>' . $month_link . '</li>';
} ?>
</ul>
</div>
<?php endforeach; ?>
</div>
</div>