-
Notifications
You must be signed in to change notification settings - Fork 0
/
template-knowledgebase.php
255 lines (237 loc) · 9.42 KB
/
template-knowledgebase.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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?php
/*
Template Name: Knowledge Base Page
*/
/**
* Page Template for the Knowledge Base Page
*
* Publish a page and put this as a static front-page
*
* @package iPanelThemes Knowledgebase
*/
get_header();
$main_categories = get_categories( array(
'taxonomy' => 'category',
'parent' => 0,
'hide_empty' => 0,
) );
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( of_get_option( 'reklam_3' ) ) { ?>
<div class="reklamnet">
<?php echo of_get_option( 'reklam_3', '' ); ?>
</div>
<?php } ?>
<div class="row kb-home-cat-row">
<?php $cat_iterator = 0; foreach ( $main_categories as $cat ) : ?>
<?php $term_meta = get_option( 'ipt_kb_category_meta_' . $cat->term_id, array() ); ?>
<?php $term_link = esc_url( get_term_link( $cat ) ); ?>
<?php $pcat_totals = ipt_kb_total_cat_post_count( $cat->term_id ); ?>
<div class="col-md-6">
<div class="col-sm-4 hidden-xs">
<?php if ( isset( $term_meta['image_url'] ) && '' != $term_meta['image_url'] ) : ?>
<p class="text-center">
<a href="<?php echo $term_link; ?>">
<img class="img-circle" src="<?php echo esc_attr( $term_meta['image_url'] ); ?>" alt="<?php echo esc_attr( $cat->name ); ?>" />
</a>
</p>
<?php endif; ?>
<div class="caption">
<?php if ( isset( $term_meta['support_forum'] ) && '' != $term_meta['support_forum'] ) : ?>
<p class="text-center"><a class="btn btn-default btn-block" href="<?php echo esc_url( $term_meta['support_forum'] ); ?>">
<i class="glyphicon ipt-icomoon-support"></i> <?php _e( 'Get support', 'ipt_kb' ); ?>
</a></p>
<?php endif; ?>
</div>
</div>
<div class="col-sm-8">
<h2 class="knowledgebase-title"><a data-placement="bottom" data-popt="kb-homepage-popover-<?php echo $cat->term_id; ?>" title="<?php echo esc_attr( $cat->name ); ?>" href="#" class="btn btn-default btn-sm text-muted ipt-kb-popover"><i class="glyphicon ipt-icomoon-paragraph-justify"></i></a> <?php echo $cat->name; ?></h2>
<div class="ipt-kb-popover-target" id="kb-homepage-popover-<?php echo $cat->term_id; ?>">
<?php echo wpautop( $cat->description ); ?>
<p class="text-right">
<?php if ( isset( $term_meta['support_forum'] ) && '' != $term_meta['support_forum'] ) : ?>
<a class="btn btn-default" href="<?php echo esc_url( $term_meta['support_forum'] ); ?>">
<i class="glyphicon ipt-icomoon-support"></i> <?php _e( 'Get support', 'ipt_kb' ); ?>
</a>
<?php endif; ?>
<a href="<?php echo $term_link; ?>" class="btn btn-info">
<i class="glyphicon ipt-icomoon-link"></i> <?php _e( 'Browse all', 'ipt_kb' ); ?>
</a>
</p>
</div>
<div class="visible-xs">
<?php if ( isset( $term_meta['image_url'] ) && '' != $term_meta['image_url'] ) : ?>
<p class="text-center">
<a href="<?php echo $term_link; ?>">
<img class="img-circle" src="<?php echo esc_attr( $term_meta['image_url'] ); ?>" alt="<?php echo esc_attr( $cat->name ); ?>" />
</a>
</p>
<?php endif; ?>
<div class="caption">
<?php if ( isset( $term_meta['support_forum'] ) && '' != $term_meta['support_forum'] ) : ?>
<p class="text-center"><a class="btn btn-default btn-block" href="<?php echo esc_url( $term_meta['support_forum'] ); ?>">
<i class="glyphicon ipt-icomoon-support"></i> <?php _e( 'Get support', 'ipt_kb' ); ?>
</a></p>
<?php endif; ?>
</div>
</div>
<?php $sub_categories = get_categories( array(
'taxonomy' => 'category',
'parent' => $cat->term_id,
'hide_empty' => 0,
'number' => '5',
) ); ?>
<div class="list-group">
<?php if ( ! empty( $sub_categories ) ) : ?>
<?php foreach ( $sub_categories as $scat ) : ?>
<?php $sterm_meta = get_option( 'ipt_kb_category_meta_' . $scat->term_id, array() ); ?>
<a href="<?php echo esc_url( get_term_link( $scat, 'category' ) ); ?>" class="list-group-item" target="_blank" rel="nofollow">
<span class="badge"><?php echo $scat->count; ?></span>
<?php if ( isset( $sterm_meta['icon_class'] ) && '' != $sterm_meta['icon_class'] ) : ?>
<i class="glyphicon <?php echo esc_attr( $sterm_meta['icon_class'] ); ?>"></i>
<?php else : ?>
<i class="glyphicon ipt-icomoon-books"></i>
<?php endif; ?>
<?php echo $scat->name; ?>
</a>
<?php endforeach; ?>
<?php else : ?>
<?php $cat_posts = new WP_Query( array(
'posts_per_page' => get_option( 'posts_per_page', 5 ),
'cat' => $cat->term_id,
) ); ?>
<?php if ( $cat_posts->have_posts() ) : ?>
<?php while ( $cat_posts->have_posts() ) : $cat_posts->the_post(); ?>
<?php get_template_part( 'category-templates/content', 'popular' ); ?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'category-templates/no-result' ); ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
<?php endif; ?>
</div>
<p class="text-right">
<a href="<?php echo $term_link; ?>" class="btn btn-default">
<i class="glyphicon ipt-icomoon-link"></i> <?php printf( _n( 'Browse %d article', 'Browse all %d articles', $pcat_totals, 'ipt_kb' ), $pcat_totals ); ?>
</a>
</p>
</div>
</div>
<?php $cat_iterator++; if ( $cat_iterator % 2 == 0 ) echo '<div class="clearfix"></div>'; ?>
<?php endforeach; ?>
<div class="clearfix"></div>
</div>
<?php if ( of_get_option( 'reklam_4' ) ) { ?>
<div class="reklamnet">
<?php echo of_get_option( 'reklam_4', '' ); ?>
</div>
<?php } ?>
<div class="row kb-home-panels">
<?php
// Remove the filter from the Posts Order By Plugin
if ( function_exists( 'CPTOrderPosts' ) ) {
remove_filter( 'posts_orderby', 'CPTOrderPosts', 99, 2 );
}
// Recent posts
$recent_posts = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => get_option( 'posts_per_page', 5 ),
'order' => 'DESC',
'orderby' => 'date',
) );
?>
<div class="col-md-6">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title"><i class="glyphicon glyphicon-calendar"></i> <?php _e( 'Recent articles', 'ipt_kb' ); ?></h3>
</div>
<div class="panel-body">
<div class="list-group">
<?php if ( $recent_posts->have_posts() ) : ?>
<?php while ( $recent_posts->have_posts() ) : $recent_posts->the_post(); ?>
<?php get_template_part( 'category-templates/content', 'date' ); ?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'category-templates/no-result' ); ?>
<?php endif; ?>
</div>
</div>
<?php if ( of_get_option( 'reklam_10' ) ) { ?>
<div class="reklamnet" style="margin:0 !important; margin-top:-20px !important;">
<?php echo of_get_option( 'reklam_10', '' ); ?>
</div>
<?php } ?>
</div>
</div>
<?php wp_reset_query(); ?>
<?php
// Popular posts
// Prep the arguments
$args = array(
'post_type' => 'post',
'posts_per_page' => get_option( 'posts_per_page', 5 ),
'order' => 'DESC',
'meta_key' => 'ipt_kb_like_article',
'orderby' => 'meta_value_num',
);
// Filter it for further customizability
$args = apply_filters( 'ipt_kb_popular_posts_args', $args );
// Build our custom query
$popular_query = new WP_Query( $args );
?>
<div class="col-md-6">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title"><i class="glyphicon glyphicon-fire"></i> <?php _e( 'Popular articles', 'ipt_kb' ); ?></h3>
</div>
<div class="panel-body">
<div class="list-group">
<?php if ( $popular_query->have_posts() ) : ?>
<?php while ( $popular_query->have_posts() ) : $popular_query->the_post(); ?>
<?php get_template_part( 'category-templates/content', 'popular' ); ?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'category-templates/no-result' ); ?>
<?php endif; ?>
</div>
</div>
<?php if ( of_get_option( 'reklam_11' ) ) { ?>
<div class="reklamnet" style="margin:0 !important; margin-top:-20px !important;">
<?php echo of_get_option( 'reklam_11', '' ); ?>
</div>
<?php } ?>
</div>
</div>
</div>
<?php if ( of_get_option( 'reklam_5' ) ) { ?>
<div class="reklamnet">
<?php echo of_get_option( 'reklam_5', '' ); ?>
</div>
<?php } ?>
<?php wp_reset_query(); ?>
<?php
// Add the filter from the Posts Order By Plugin
if ( function_exists( 'CPTOrderPosts' ) ) {
add_filter( 'posts_orderby', 'CPTOrderPosts', 99, 2 );
}
?>
<?php // Finally add the actual page content ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<?php the_content(); ?>
<?php
wp_link_pages( array(
'before' => __( '<p class="pagination-p">Pages:</p>', 'ipt_kb' ) . '<ul class="pagination">',
'after' => '</ul><div class="clearfix"></div>',
) );
?>
</div><!-- .entry-content -->
</article>
<?php endwhile; ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_footer(); ?>