0
|
1 |
<?php |
|
2 |
/* |
|
3 |
Template Name: Portfolio template |
6
|
4 |
* Version: 1.3 |
0
|
5 |
*/ |
|
6 |
get_header(); ?> |
6
|
7 |
<div class="content-area"> |
|
8 |
<div id="container" class="site-content site-main"> |
0
|
9 |
<div id="content" class="hentry"> |
|
10 |
<div class="breadcrumbs home_page_title entry-header"> |
6
|
11 |
<?php global $post, $wpdb, $wp_query, $request; |
|
12 |
$portfolio_options = get_option( 'prtfl_options' ); |
|
13 |
|
|
14 |
if ( isset( $wp_query->query_vars["technologies"] ) ) { |
|
15 |
$term = get_term_by( 'slug', $wp_query->query_vars["technologies"], 'portfolio_technologies' ); |
|
16 |
echo $portfolio_options['prtfl_technologies_text_field'] . " " . ( $term->name ); |
|
17 |
} elseif ( isset( $wp_query->query_vars["portfolio_executor_profile"] ) ) { |
|
18 |
$term = get_term_by('slug', $wp_query->query_vars["portfolio_executor_profile"], 'portfolio_executor_profile'); |
|
19 |
echo __( 'Executor Profile', 'portfolio' ) . ": <h1>" . ( $term->name ) . "</h1>"; |
|
20 |
$_SESSION['prtfl_page_name'] = __( 'Executor Profile', 'portfolio' ) . ": " . ( $term->name ); |
|
21 |
$_SESSION['prtfl_page_url'] = get_pagenum_link( $wp_query->query_vars['paged'] ); |
|
22 |
} else { |
|
23 |
the_title(); |
|
24 |
} ?> |
|
25 |
</div> |
|
26 |
<?php $count = 0; |
|
27 |
if ( get_query_var( 'paged' ) ) { |
|
28 |
$paged = get_query_var( 'paged' ); |
|
29 |
} elseif ( get_query_var( 'page' ) ) { |
|
30 |
$paged = get_query_var( 'page' ); |
0
|
31 |
} else { |
6
|
32 |
$paged = 1; |
|
33 |
} |
|
34 |
$per_page = $showitems = get_option( 'posts_per_page' ); |
0
|
35 |
$technologies = isset( $wp_query->query_vars["technologies"] ) ? $wp_query->query_vars["technologies"] : ""; |
6
|
36 |
$executor_profile = isset( $wp_query->query_vars["portfolio_executor_profile"] ) ? $wp_query->query_vars["portfolio_executor_profile"] : ""; |
|
37 |
if ( "" != $technologies ) { |
0
|
38 |
$args = array( |
6
|
39 |
'post_type' => 'portfolio', |
|
40 |
'post_status' => 'publish', |
|
41 |
'orderby' => $portfolio_options['prtfl_order_by'], |
|
42 |
'order' => $portfolio_options['prtfl_order'], |
|
43 |
'posts_per_page' => $per_page, |
|
44 |
'paged' => $paged, |
|
45 |
'tax_query' => array( |
|
46 |
array( |
|
47 |
'taxonomy' => 'portfolio_technologies', |
|
48 |
'field' => 'slug', |
|
49 |
'terms' => $technologies |
0
|
50 |
) |
6
|
51 |
) |
|
52 |
); |
|
53 |
} else if ( "" != $executor_profile ) { |
|
54 |
$args = array( |
|
55 |
'post_type' => 'portfolio', |
|
56 |
'post_status' => 'publish', |
|
57 |
'orderby' => $portfolio_options['prtfl_order_by'], |
|
58 |
'order' => $portfolio_options['prtfl_order'], |
|
59 |
'posts_per_page' => $per_page, |
|
60 |
'paged' => $paged, |
|
61 |
'tax_query' => array( |
|
62 |
array( |
|
63 |
'taxonomy' => 'portfolio_executor_profile', |
|
64 |
'field' => 'slug', |
|
65 |
'terms' => $executor_profile |
|
66 |
) |
|
67 |
) |
|
68 |
); |
0
|
69 |
} else { |
|
70 |
$args = array( |
6
|
71 |
'post_type' => 'portfolio', |
|
72 |
'post_status' => 'publish', |
|
73 |
'orderby' => $portfolio_options['prtfl_order_by'], |
|
74 |
'order' => $portfolio_options['prtfl_order'], |
|
75 |
'posts_per_page' => $per_page, |
|
76 |
'paged' => $paged |
|
77 |
); |
0
|
78 |
} |
|
79 |
|
6
|
80 |
$second_query = new WP_Query( $args ); |
|
81 |
|
|
82 |
$pdfprnt_options = get_option('pdfprnt_options_array'); |
|
83 |
if ( empty( $pdfprnt_options ) ) |
|
84 |
$pdfprnt_options = get_option('pdfprntpr_options_array'); |
|
85 |
if ( isset( $pdfprnt_options ) && is_array( $pdfprnt_options ) && true === in_array( 'portfolio', $pdfprnt_options['use_types_posts'] ) ) { |
|
86 |
if ( function_exists( 'pdfprnt_show_buttons_for_bws_portfolio_post' ) ) |
|
87 |
echo pdfprnt_show_buttons_for_bws_portfolio_post(); |
|
88 |
elseif ( function_exists( 'pdfprntpr_show_buttons_for_bws_portfolio_post' ) ) |
|
89 |
echo pdfprntpr_show_buttons_for_bws_portfolio_post(); |
|
90 |
} |
0
|
91 |
|
6
|
92 |
$request = $second_query->request; |
|
93 |
|
|
94 |
if ( $second_query->have_posts() ) : |
|
95 |
while ( $second_query->have_posts() ) : $second_query->the_post(); ?> |
|
96 |
<div class="portfolio_content entry-content"> |
|
97 |
<div class="entry"> |
|
98 |
<?php $meta_values = get_post_custom( $post->ID ); |
|
99 |
$post_thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
100 |
if ( empty ( $post_thumbnail_id ) ) { |
|
101 |
$args = array( |
|
102 |
'post_parent' => $post->ID, |
|
103 |
'post_type' => 'attachment', |
|
104 |
'post_mime_type' => 'image', |
|
105 |
'numberposts' => 1 |
|
106 |
); |
|
107 |
$attachments = get_children( $args ); |
|
108 |
$post_thumbnail_id = key( $attachments ); |
|
109 |
} |
|
110 |
$image = wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' ); |
|
111 |
$image_large = wp_get_attachment_image_src( $post_thumbnail_id, 'large' ); |
|
112 |
$image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); |
|
113 |
$image_desc = get_post($post_thumbnail_id); |
|
114 |
$image_desc = $image_desc->post_content; |
|
115 |
$post_meta = get_post_meta( $post->ID, 'prtfl_information', true); |
|
116 |
$date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
|
117 |
if ( ! empty( $date_compl ) && 'in progress' != $date_compl) { |
0
|
118 |
$date_compl = explode( "/", $date_compl ); |
6
|
119 |
$date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1] . "-" . $date_compl[0] . '-' . $date_compl[2] ) ); |
0
|
120 |
} |
6
|
121 |
$link = isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : ''; |
|
122 |
$short_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : ''; |
|
123 |
if ( empty( $short_descr ) ) |
|
124 |
$short_descr = get_the_excerpt(); |
|
125 |
$title = get_the_title(); |
|
126 |
if ( empty( $title ) ) |
|
127 |
$title = '(' . __( 'No title', 'portfolio-pro' ) . ')'; |
|
128 |
$permalink = get_permalink(); |
|
129 |
if ( ! empty( $image[0] ) ) { ?> |
|
130 |
<div class="portfolio_thumb"> |
|
131 |
<a rel="bookmark" href="<?php echo $permalink; ?>" title="<?php echo $title; ?>"> |
|
132 |
<img src="<?php echo $image[0]; ?>" width="<?php echo $portfolio_options['prtfl_custom_size_px'][0][0]; ?>" height="<?php echo $portfolio_options['prtfl_custom_size_px'][0][1]; ?>" alt="<?php echo $image_alt; ?>" /> |
|
133 |
</a> |
|
134 |
</div><!-- .portfolio_thumb --> |
|
135 |
<?php } ?> |
|
136 |
<div class="portfolio_short_content"> |
|
137 |
<div class="item_title"> |
|
138 |
<p> |
|
139 |
<a href="<?php echo $permalink; ?>" rel="bookmark"><?php echo $title; ?></a> |
|
140 |
</p> |
|
141 |
</div><!-- .item_title --> |
|
142 |
<?php if ( 1 == $portfolio_options['prtfl_date_additional_field'] ) { ?> |
0
|
143 |
<p> |
|
144 |
<span class="lable"><?php echo $portfolio_options['prtfl_date_text_field']; ?></span> <?php echo $date_compl; ?> |
|
145 |
</p> |
6
|
146 |
<?php } |
|
147 |
$user_id = get_current_user_id(); |
|
148 |
if ( 1 == $portfolio_options['prtfl_link_additional_field'] ) { |
|
149 |
if ( false !== parse_url( $link ) ) { ?> |
|
150 |
<?php if ( ( 0 == $user_id && 0 == $portfolio_options['prtfl_link_additional_field_for_non_registered'] ) || 0 != $user_id ) { ?> |
|
151 |
<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <a href="<?php echo $link; ?>"><?php echo $link; ?></a></p> |
|
152 |
<?php } else { ?> |
|
153 |
<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <?php echo $link; ?></p> |
|
154 |
<?php } |
|
155 |
} else { ?> |
0
|
156 |
<p><span class="lable"><?php echo $portfolio_options['prtfl_link_text_field']; ?></span> <?php echo $link; ?></p> |
6
|
157 |
<?php } |
|
158 |
} |
|
159 |
if ( 1 == $portfolio_options['prtfl_shrdescription_additional_field'] ) { ?> |
|
160 |
<p><span class="lable"><?php echo $portfolio_options['prtfl_shrdescription_text_field']; ?></span> <?php echo $short_descr; ?></p> |
0
|
161 |
<?php } ?> |
6
|
162 |
</div><!-- .portfolio_short_content --> |
|
163 |
</div><!-- .entry --> |
|
164 |
<div class="entry_footer"> |
|
165 |
<div class="read_more"> |
|
166 |
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php _e( 'Read more', 'portfolio' ); ?></a> |
|
167 |
</div><!-- .read_more --> |
|
168 |
<?php $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ); |
|
169 |
if ( is_array( $terms ) && 0 < count( $terms ) ) { ?> |
|
170 |
<div class="portfolio_terms"> |
|
171 |
<?php echo $portfolio_options['prtfl_technologies_text_field']; |
|
172 |
$count = 0; |
|
173 |
foreach ( $terms as $term ) { |
|
174 |
if ( 0 < $count ) |
|
175 |
echo ', '; |
|
176 |
echo '<a href="' . get_term_link( $term->slug, 'portfolio_technologies') . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name . '</a>'; |
|
177 |
$count++; |
|
178 |
} ?> |
|
179 |
</div><!-- .portfolio_terms --> |
0
|
180 |
<?php } ?> |
6
|
181 |
</div><!-- .entry_footer --> |
|
182 |
</div><!-- .portfolio_content --> |
|
183 |
<?php endwhile; |
|
184 |
endif; ?> |
|
185 |
</div><!-- #content --> |
|
186 |
<?php $count_all_albums = $second_query->found_posts; |
|
187 |
wp_reset_query(); |
|
188 |
$request = $wp_query->request; |
|
189 |
$pages = intval( $count_all_albums / $per_page ); |
|
190 |
if ( $count_all_albums % $per_page > 0 ) |
|
191 |
$pages += 1; |
|
192 |
|
|
193 |
$range = 2; |
|
194 |
|
|
195 |
if ( ! $pages ) |
|
196 |
$pages = 1; |
|
197 |
|
|
198 |
if ( 1 != $pages ) { ?> |
|
199 |
<div class='clear'></div> |
|
200 |
<div id="portfolio_pagenation"> |
|
201 |
<div class='pagination'> |
|
202 |
<?php if ( 2 < $paged && $paged > $range + 1 && $showitems < $pages ) |
|
203 |
echo "<a href='" . get_pagenum_link( 1 ) . "'>«</a>"; |
|
204 |
if ( 1 < $paged && $showitems < $pages ) |
|
205 |
echo "<a href='" . get_pagenum_link( $paged - 1 ) . "'>‹</a>"; |
|
206 |
|
|
207 |
for ( $i = 1; $i <= $pages; $i++ ) { |
|
208 |
if ( 1 != $pages && ( ! ( $i >= $paged + $range + 1 || $i <= $paged - $range - 1 ) || $pages <= $showitems ) ) { |
|
209 |
echo ( $paged == $i ) ? "<span class='current'>" . $i . "</span>":"<a href='" . get_pagenum_link( $i ) . "' class='inactive' >" . $i . "</a>"; |
0
|
210 |
} |
6
|
211 |
} |
|
212 |
if ( $paged < $pages && $showitems < $pages ) |
|
213 |
echo "<a href='" . get_pagenum_link( $paged + 1 ) . "'>›</a>"; |
|
214 |
if ( $paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages ) |
|
215 |
echo "<a href='" . get_pagenum_link( $pages ) . "'>»</a>"; ?> |
|
216 |
<div class='clear'></div> |
|
217 |
</div><!-- .pagination --> |
|
218 |
</div><!-- #portfolio_pagenation --> |
|
219 |
<?php } ?> |
|
220 |
<?php comments_template(); ?> |
0
|
221 |
</div><!-- #container --> |
6
|
222 |
</div><!-- .content-area --> |
0
|
223 |
<?php get_sidebar(); ?> |
|
224 |
<?php get_footer(); ?> |