forked from Dravenrip/avada
-
Notifications
You must be signed in to change notification settings - Fork 0
/
portfolio-grid.php
276 lines (254 loc) · 8.51 KB
/
portfolio-grid.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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<?php
// Template Name: Portfolio Grid
get_header();
$content_css = 'width:100%';
$sidebar_css = 'display:none';
$content_class = '';
$sidebar_exists = false;
$sidebar_left = '';
$double_sidebars = false;
$sidebar_1 = get_post_meta( $post->ID, 'sbg_selected_sidebar_replacement', true );
$sidebar_2 = get_post_meta( $post->ID, 'sbg_selected_sidebar_2_replacement', true );
if( $smof_data['pages_global_sidebar'] ) {
if( $smof_data['pages_sidebar'] != 'None' ) {
$sidebar_1 = array( $smof_data['pages_sidebar'] );
} else {
$sidebar_1 = '';
}
if( $smof_data['pages_sidebar_2'] != 'None' ) {
$sidebar_2 = array( $smof_data['pages_sidebar_2'] );
} else {
$sidebar_2 = '';
}
}
if( ( is_array( $sidebar_1 ) && ( $sidebar_1[0] || $sidebar_1[0] === '0' ) ) && ( is_array( $sidebar_2 ) && ( $sidebar_2[0] || $sidebar_2[0] === '0' ) ) ) {
$double_sidebars = true;
}
if( is_array( $sidebar_1 ) &&
( $sidebar_1[0] || $sidebar_1[0] === '0' )
) {
$sidebar_exists = true;
} else {
$sidebar_exists = false;
}
if( ! $sidebar_exists ) {
$content_css = 'width:100%';
$sidebar_css = 'display:none';
$sidebar_exists = false;
} elseif(get_post_meta($post->ID, 'pyre_sidebar_position', true) == 'left') {
$content_css = 'float:right;';
$sidebar_css = 'float:left;';
$sidebar_exists = true;
$sidebar_left = 1;
} elseif(get_post_meta($post->ID, 'pyre_sidebar_position', true) == 'right') {
$content_css = 'float:left;';
$sidebar_css = 'float:right;';
$sidebar_exists = true;
} elseif(get_post_meta($post->ID, 'pyre_sidebar_position', true) == 'default' || ! metadata_exists( 'post', $post->ID, 'pyre_sidebar_position' )) {
if($smof_data['default_sidebar_pos'] == 'Left') {
$content_css = 'float:right;';
$sidebar_css = 'float:left;';
$sidebar_exists = true;
$sidebar_left = 1;
} elseif($smof_data['default_sidebar_pos'] == 'Right') {
$content_css = 'float:left;';
$sidebar_css = 'float:right;';
$sidebar_exists = true;
$sidebar_left = 2;
}
}
if(get_post_meta($post->ID, 'pyre_sidebar_position', true) == 'right') {
$sidebar_left = 2;
}
if( $smof_data['pages_global_sidebar'] ) {
if( $smof_data['pages_sidebar'] != 'None' ) {
$sidebar_1 = $smof_data['pages_sidebar'];
if( $smof_data['default_sidebar_pos'] == 'Right' ) {
$content_css = 'float:left;';
$sidebar_css = 'float:right;';
$sidebar_left = 2;
} else {
$content_css = 'float:right;';
$sidebar_css = 'float:left;';
$sidebar_left = 1;
}
}
if( $smof_data['pages_sidebar_2'] != 'None' ) {
$sidebar_2 = $smof_data['pages_sidebar_2'];
}
if( $smof_data['pages_sidebar'] != 'None' && $smof_data['pages_sidebar_2'] != 'None' ) {
$double_sidebars = true;
}
} else {
$sidebar_1 = '0';
$sidebar_2 = '0';
}
if($double_sidebars == true) {
$content_css = 'float:left;';
$sidebar_css = 'float:left;';
$sidebar_2_css = 'float:left;';
} else {
$sidebar_left = 1;
}
$class = '';
if($smof_data['grid_pagination_type'] == 'Infinite Scroll') {
$class = 'portfolio-infinite';
}
if(get_post_meta($post->ID, 'pyre_portfolio_full_width', true) == 'no') {
$class .= ' portfolio-grid-2';
}
?>
<div id="content" class="portfolio portfolio-masonry <?php echo $class; ?>" style="<?php echo $content_css; ?>">
<?php while(have_posts()): the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php echo avada_render_rich_snippets_for_pages(); ?>
<div class="post-content">
<?php the_content(); ?>
<?php avada_link_pages(); ?>
</div>
</div>
<?php $current_page_id = $post->ID; ?>
<?php endwhile; ?>
<?php
if(is_front_page()) {
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
} else {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
}
$args = array(
'post_type' => 'avada_portfolio',
'paged' => $paged,
'posts_per_page' => $smof_data['portfolio_items'],
);
$pcats = get_post_meta(get_the_ID(), 'pyre_portfolio_category', true);
if($pcats && $pcats[0] == 0) {
unset($pcats[0]);
}
if($pcats){
$args['tax_query'][] = array(
'taxonomy' => 'portfolio_category',
'field' => 'term_id',
'terms' => $pcats
);
}
$gallery = new WP_Query($args);
$portfolio_taxs = array();
if(is_array($gallery->posts) && !empty($gallery->posts)) {
foreach($gallery->posts as $gallery_post) {
$post_taxs = wp_get_post_terms($gallery_post->ID, 'portfolio_category', array("fields" => "all"));
if(is_array($post_taxs) && !empty($post_taxs)) {
foreach($post_taxs as $post_tax) {
if(is_array($pcats) && !empty($pcats) && (in_array($post_tax->term_id, $pcats) || in_array($post_tax->parent, $pcats )) ) {
$portfolio_taxs[urldecode($post_tax->slug)] = $post_tax->name;
}
if(empty($pcats) || !isset($pcats)) {
$portfolio_taxs[urldecode($post_tax->slug)] = $post_tax->name;
}
}
}
}
}
$all_terms = get_terms('portfolio_category');
$sorted_taxs = array();
if( !empty( $all_terms ) && is_array( $all_terms ) ) {
foreach( $all_terms as $term ) {
if( array_key_exists ( urldecode($term->slug) , $portfolio_taxs ) ) {
$sorted_taxs[urldecode($term->slug)] = $term->name;
}
}
}
$portfolio_taxs = $sorted_taxs;
if($smof_data['grid_pagination_type'] == 'Infinite Scroll') {
$portfolio_category = get_terms('portfolio_category');
$portfolio_taxs = array();
if(empty($pcats) || !isset($pcats)) {
foreach($portfolio_category as $portfolio_cat) {
$portfolio_taxs[urldecode($portfolio_cat->slug)] = $portfolio_cat->name;
}
} else {
if( is_array($pcats) && !empty( $pcats ) ) {
foreach($pcats as $pcat) {
$term = get_term( $pcat, 'portfolio_category' );
$portfolio_taxs[urldecode($term->slug)] = $term->name;
}
}
}
if(is_array($portfolio_taxs)) {
asort($portfolio_taxs);
}
}
if( ! post_password_required($post->ID) ):
if(is_array($portfolio_taxs) && !empty($portfolio_taxs) && get_post_meta($post->ID, 'pyre_portfolio_filters', true) != 'no'):
?>
<ul class="portfolio-tabs clearfix">
<li class="active"><a data-filter="*" href="#"><?php echo __('All', 'Avada'); ?></a></li>
<?php foreach($portfolio_taxs as $portfolio_tax_slug => $portfolio_tax_name): ?>
<li><a data-filter=".<?php echo $portfolio_tax_slug; ?>" href="#"><?php echo $portfolio_tax_name; ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="portfolio-wrapper">
<?php
while($gallery->have_posts()): $gallery->the_post();
if($pcats) {
$permalink = tf_addUrlParameter(get_permalink(), 'portfolioID', $current_page_id);
} else {
$permalink = get_permalink();
}
if(has_post_thumbnail() || get_post_meta($post->ID, 'pyre_video', true)):
?>
<?php
$item_classes = '';
$item_cats = get_the_terms($post->ID, 'portfolio_category');
if($item_cats):
foreach($item_cats as $item_cat) {
$item_classes .= urldecode($item_cat->slug) . ' ';
}
endif;
$bgClass = '';
$featured_image_size = avada_set_portfolio_image_size( $current_page_id );
?>
<div class="portfolio-item <?php echo $item_classes; ?> <?php echo $bgClass; ?>">
<?php if( ! $smof_data['disable_date_rich_snippet_pages'] ): ?>
<span class="vcard" style="display: none;"><span class="fn"><?php the_author_posts_link(); ?></span></span>
<span class="updated" style="display: none;"><?php the_modified_time( 'c' ); ?></span>
<?php endif; ?>
<?php if(has_post_thumbnail()): ?>
<?php echo avada_image_rollover( get_the_ID(), $featured_image_size, $permalink ); ?>
<?php elseif(!has_post_thumbnail() && get_post_meta($post->ID, 'pyre_video', true)): ?>
<div class="image video full-video">
<?php echo get_post_meta($post->ID, 'pyre_video', true); ?>
</div>
<?php endif; ?>
</div>
<?php endif; endwhile; ?>
</div>
<?php themefusion_pagination($gallery->max_num_pages, $range = 2); ?>
<?php endif; ?>
</div>
<?php if( $sidebar_exists == true ): ?>
<?php wp_reset_query(); ?>
<div id="sidebar" class="sidebar" style="<?php echo $sidebar_css; ?>">
<?php
if($sidebar_left == 1) {
generated_dynamic_sidebar($sidebar_1);
}
if($sidebar_left == 2) {
generated_dynamic_sidebar_2($sidebar_2);
}
?>
</div>
<?php if( $double_sidebars == true ): ?>
<div id="sidebar-2" class="sidebar" style="<?php echo $sidebar_2_css; ?>">
<?php
if($sidebar_left == 1) {
generated_dynamic_sidebar_2($sidebar_2);
}
if($sidebar_left == 2) {
generated_dynamic_sidebar($sidebar_1);
}
?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php get_footer(); ?>