-
Notifications
You must be signed in to change notification settings - Fork 0
/
content-archive-portfolio-full.php
256 lines (232 loc) · 9.11 KB
/
content-archive-portfolio-full.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
<?php
global $porto_settings, $post, $porto_portfolio_thumb_bg, $porto_portfolio_thumb_image, $porto_portfolio_ajax_load, $porto_portfolio_ajax_modal;
$portfolio_layout = 'full';
$post_class = array();
$post_class[] = 'portfolio';
$post_class[] = 'portfolio-' . $portfolio_layout;
$item_cats = get_the_terms( $post->ID, 'portfolio_cat' );
if ( $item_cats ) :
foreach ( $item_cats as $item_cat ) {
$post_class[] = urldecode( $item_cat->slug );
}
endif;
$archive_image = (int) get_post_meta( $post->ID, 'portfolio_archive_image', true );
if ( $archive_image ) {
$featured_images = array();
$featured_image = array(
'thumb' => wp_get_attachment_thumb_url( $archive_image ),
'full' => wp_get_attachment_url( $archive_image ),
'attachment_id' => $archive_image,
);
$featured_images[] = $featured_image;
} else {
$featured_images = porto_get_featured_images();
}
$portfolio_link = get_post_meta( $post->ID, 'portfolio_link', true );
$show_external_link = $porto_settings['portfolio-external-link'];
$portfolio_thumb_bg = $porto_portfolio_thumb_bg ? $porto_portfolio_thumb_bg : $porto_settings['portfolio-archive-thumb-bg'];
$portfolio_thumb_image = $porto_portfolio_thumb_image ? ( 'zoom' == $porto_portfolio_thumb_image ? '' : $porto_portfolio_thumb_image ) : $porto_settings['portfolio-archive-thumb-image'];
$portfolio_show_link = $porto_settings['portfolio-archive-link'];
$portfolio_show_all_images = $porto_settings['portfolio-archive-all-images'];
$portfolio_images_count = $porto_settings['portfolio-archive-images-count'];
$portfolio_show_zoom = $porto_settings['portfolio-archive-zoom'];
$portfolio_ajax = $porto_settings['portfolio-archive-ajax'];
$portfolio_ajax_modal = $porto_settings['portfolio-archive-ajax-modal'];
if ( 'yes' == $porto_portfolio_ajax_load ) {
$portfolio_ajax = true;
} elseif ( 'no' == $porto_portfolio_ajax_load ) {
$portfolio_ajax = false;
}
if ( 'yes' == $porto_portfolio_ajax_modal ) {
$portfolio_ajax_modal = true;
} elseif ( 'no' == $porto_portfolio_ajax_modal ) {
$portfolio_ajax_modal = false;
}
$options = array();
$options['margin'] = 10;
$options['animateOut'] = 'fadeOut';
$options['autoplay'] = true;
$options['autoplayTimeout'] = 3000;
$options = json_encode( $options );
$count = count( $featured_images );
$classes = array();
if ( $portfolio_thumb_bg ) {
$classes[] = 'thumb-info-' . $portfolio_thumb_bg;
}
if ( $count > 1 && $portfolio_show_all_images ) {
$classes[] = 'thumb-info-no-zoom';
} elseif ( $portfolio_thumb_image ) {
$classes[] = 'thumb-info-' . $portfolio_thumb_image;
}
$ajax_attr = '';
if ( ! ( $show_external_link && $portfolio_link ) && $portfolio_ajax ) {
$portfolio_show_zoom = false;
$portfolio_show_all_images = false;
if ( $portfolio_ajax_modal ) {
$ajax_attr = ' data-ajax-on-modal';
} else {
$ajax_attr = ' data-ajax-on-page';
}
}
if ( $portfolio_show_zoom ) {
$classes[] = 'thumb-info-centered-icons';
}
$class = implode( ' ', $classes );
$zoom_src = array();
$zoom_title = array();
$portfolio_show_link_zoom = false;
if ( $porto_settings['portfolio-archive-link-zoom'] ) {
$portfolio_show_link_zoom = true;
$portfolio_show_zoom = false;
$portfolio_show_link = false;
$portfolio_show_all_images = false;
}
if ( $ajax_attr ) {
$portfolio_show_link_zoom = false;
}
?>
<article <?php post_class( $post_class ); ?>>
<?php if ( $count ) : ?>
<a class="portfolio-link" href="<?php
if ( $portfolio_show_link_zoom ) {
foreach ( $featured_images as $featured_image ) {
$attachment_id = $featured_image['attachment_id'];
$attachment = porto_get_attachment( $attachment_id );
if ( $attachment ) {
echo esc_url( $attachment['src'] );
break;
}
}
} else {
if ( $show_external_link && $portfolio_link ) {
echo esc_url( $portfolio_link );
} else {
the_permalink();
}
}
?>"<?php echo porto_filter_output( $ajax_attr ); ?>>
<span class="thumb-info m-b-xl <?php echo esc_attr( $class ); ?>">
<span class="thumb-info-wrapper">
<?php
if ( $count > 1 && $portfolio_show_all_images ) :
?>
<div class="porto-carousel owl-carousel m-b-none nav-inside show-nav-hover" data-plugin-options="<?php echo esc_attr( $options ); ?>"><?php endif; ?>
<?php
$i = 0;
foreach ( $featured_images as $featured_image ) :
$attachment_id = $featured_image['attachment_id'];
if ( ! isset( $image_size ) ) {
$image_size = 'portfolio-full';
}
$attachment = porto_get_attachment( $attachment_id );
$attachment_full = porto_get_attachment( $attachment_id, $image_size );
$attachment_alternative = porto_get_attachment( $attachment_id, 'portfolio-large' );
if ( $attachment && $attachment_full ) :
$zoom_src[] = $attachment['src'];
$zoom_title[] = $attachment['caption'];
?>
<img class="img-responsive"<?php echo isset( $attachment_alternative ) ? ' srcset="' . esc_url( $attachment_alternative['src'] ) . ' 575w, ' . esc_url( $attachment_full['src'] ) . ' ' . esc_attr( $attachment_full['width'] ) . 'w" sizes="(max-width: 575px) ' . esc_attr( $attachment_alternative['width'] ) . 'px, ' . esc_attr( $attachment_full['width'] ) . 'px"' : ''; ?> src="<?php echo esc_url( $attachment_full['src'] ); ?>" alt="<?php echo esc_attr( $attachment_full['alt'] ); ?>" width="<?php echo esc_attr( $attachment_full['width'] ); ?>" height="<?php echo esc_attr( $attachment_full['height'] ); ?>" />
<?php
if ( ! $portfolio_show_all_images ) {
break;
}
$i++;
if ( $i >= $portfolio_images_count ) {
break;
}
endif;
endforeach;
?>
<?php
if ( 1 != $count && $portfolio_show_all_images ) :
?>
</div><?php endif; ?>
<?php if ( $portfolio_show_link || $portfolio_show_zoom ) : ?>
<span class="thumb-info-action">
<?php if ( $portfolio_show_link ) : ?>
<span class="thumb-info-action-icon thumb-info-action-icon-primary"><i class="fa <?php echo ! $ajax_attr ? 'fa-link' : 'fa-plus-square'; ?>"></i></span>
<?php endif; ?>
<?php if ( $portfolio_show_zoom ) : ?>
<span class="thumb-info-action-icon thumb-info-action-icon-light thumb-info-zoom" data-src="<?php echo esc_attr( json_encode( $zoom_src ) ); ?>" data-title="<?php echo esc_attr( json_encode( $zoom_title ) ); ?>"><i class="fa fa-search-plus"></i></span>
<?php endif; ?>
</span>
<?php endif; ?>
<?php
if ( $portfolio_show_link_zoom ) :
?>
<span class="thumb-info-zoom" data-src="<?php echo esc_attr( json_encode( $zoom_src ) ); ?>" data-title="<?php echo esc_attr( json_encode( $zoom_title ) ); ?>"></span><?php endif; ?>
</span>
</span>
</a>
<?php endif; ?>
<div class="portfolio-info">
<ul>
<?php if ( in_array( 'like', $porto_settings['portfolio-metas'] ) ) : ?>
<li>
<?php echo porto_portfolio_like(); ?>
</li>
<?php
endif;
if ( in_array( 'date', $porto_settings['portfolio-metas'] ) ) :
?>
<li>
<i class="fa fa-calendar"></i> <?php echo get_the_date(); ?>
</li>
<?php
endif;
$cat_list = get_the_term_list( $post->ID, 'portfolio_cat', '', ', ', '' );
if ( in_array( 'cats', $porto_settings['portfolio-metas'] ) && $cat_list ) :
?>
<li>
<i class="fa fa-tags"></i> <?php echo porto_filter_output( $cat_list ); ?>
</li>
<?php endif; ?>
<?php
if ( function_exists( 'Post_Views_Counter' ) && 'manual' == Post_Views_Counter()->options['display']['position'] && in_array( 'portfolio', (array) Post_Views_Counter()->options['general']['post_types_count'] ) ) {
$post_count = do_shortcode( '[post-views]' );
if ( $post_count ) :
?>
<li>
<?php echo wp_kses_post( $post_count ); ?>
</li>
<?php
endif;
}
?>
</ul>
</div>
<?php if ( $ajax_attr || $portfolio_show_link_zoom ) : ?>
<h4 class="entry-title"><?php the_title(); ?></h4>
<?php else : ?>
<h4 class="entry-title"><a href="<?php echo ! $show_external_link || ! $portfolio_link ? get_the_permalink() : esc_url( $portfolio_link ); ?>"><?php the_title(); ?></a></h4>
<?php endif; ?>
<?php if ( $porto_settings['portfolio-show-content'] ) : ?>
<div class="m-t-lg">
<?php
porto_render_rich_snippets( false );
if ( $porto_settings['portfolio-excerpt'] ) {
if ( has_excerpt() ) {
the_excerpt();
} else {
echo porto_get_excerpt( $porto_settings['portfolio-excerpt-length'], false );
}
} else {
echo '<div class="entry-content">';
porto_the_content();
wp_link_pages(
array(
'before' => '<div class="page-links"><span class="page-links-title">' . esc_html__( 'Pages:', 'porto' ) . '</span>',
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
'pagelink' => '<span class="screen-reader-text">' . esc_html__( 'Page', 'porto' ) . ' </span>%',
'separator' => '<span class="screen-reader-text">, </span>',
)
);
echo '</div>';
}
?>
</div>
<?php endif; ?>
<?php porto_get_template_part( 'views/portfolios/meta' ); ?>
</article>