-
Notifications
You must be signed in to change notification settings - Fork 3
/
page-whats-new.php
107 lines (90 loc) · 1.9 KB
/
page-whats-new.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
<?php
/**
* What's New Page
*
* @package KnowTheCode\WhatsNew
* @since 2.0.0
* @author hellofromTonya
* @link https://KnowTheCode.io
* @license GPL-2.0+
*/
namespace KnowTheCode\WhatsNew;
remove_all_actions( 'genesis_entry_content' );
add_action( 'genesis_entry_content', __NAMESPACE__ . '\do_the_whats_new_page' );
/**
* Let's build the What's New page.
*
* @since 1.0.0
*
* @return void
*/
function do_the_whats_new_page() {
$filterby = get_the_uri_filter();
render_filterby_navigation( $filterby );
render_new_content( $filterby );
}
/**
* Render the Filterby Navigation.
*
* @since 1.0.0
*
* @param string $filterby Filterby URI parameter
*
* @return void
*/
function render_filterby_navigation( $filterby ) {
$permalink = get_the_permalink();
$filters = array(
'' => __( 'All', 'ktc' ),
'labs' => __( 'Hands-On Labs', 'ktc' ),
'insights' => __( 'Insights & Tips', 'ktc' ),
'docx' => __( 'Docx', 'ktc' ),
'asktonya' => __( 'Ask Tonya', 'ktc' ),
);
require_once __DIR__ . '/lib/views/whats-new/nav.php';
}
/**
* Render the catalog index of titles.
*
* @since 1.4.0
*
* @return void
*/
function render_new_content( $filterby ) {
$query = get_whats_new_query( $filterby );
if ( ! $query->have_posts() ) {
_e( 'Whoopsie, something went wrong.', 'ktc' );
return;
}
require_once __DIR__ . '/lib/views/whats-new/page.php';
wp_reset_postdata();
}
/**
* Renders each catalog index item.
*
* @since 1.4.0
*
* @param \WP_Query $query
*
* @return void
*/
function render_new_item( $query ) {
while ( $query->have_posts() ) {
$query->the_post();
include __DIR__ . '/lib/views/whats-new/item.php';
}
}
/**
* Get the catalog filter from the URI.
*
* @since 1.4.0
*
* @return string
*/
function get_the_uri_filter() {
if ( ! isset( $_GET['filter'] ) ) {
return '';
}
return strip_tags( $_GET['filter'] );
}
genesis();