1 | <?php |
||
2 | /** |
||
3 | * @package lsx-projects |
||
4 | */ |
||
5 | ?> |
||
6 | |||
7 | <?php |
||
8 | $client = get_post_meta( get_the_ID(), 'lsx_project_client', true ); |
||
9 | $client_logo = get_post_meta( get_the_ID(), 'lsx_project_client_logo', true ); |
||
10 | $url = get_post_meta( get_the_ID(), 'lsx_project_url', true ); |
||
11 | |||
12 | global $lsx_projects; |
||
13 | |||
14 | $button_label = ''; |
||
15 | $button_cf_id = ''; |
||
16 | |||
17 | if ( ! empty( projects_get_option( 'projects_modal_enable' ) ) ) { |
||
18 | if ( ! empty( projects_get_option( 'projects_modal_cta_label' ) ) && ! empty( projects_get_option( 'projects_modal_form_id' ) ) ) { |
||
19 | $button_label = projects_get_option( 'projects_modal_cta_label' ); |
||
20 | $button_cf_id = projects_get_option( 'projects_modal_form_id' ); |
||
21 | } |
||
22 | } |
||
23 | |||
24 | if ( ! empty( $client_logo ) ) { |
||
25 | $client_logo = '<img src="' . $client_logo . '">'; |
||
26 | } |
||
27 | |||
28 | $groups = ''; |
||
29 | $terms = get_the_terms( get_the_ID(), 'project-group' ); |
||
30 | |||
31 | if ( $terms && ! is_wp_error( $terms ) ) { |
||
32 | $groups = array(); |
||
33 | |||
34 | foreach ( $terms as $term ) { |
||
35 | $groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>'; |
||
36 | } |
||
37 | |||
38 | $groups = join( ', ', $groups ); |
||
39 | } |
||
40 | |||
41 | $product_groups = ''; |
||
42 | $product_terms = get_post_meta( get_the_ID(), 'lsx_project__alt_products', false ); |
||
43 | |||
44 | if ( $product_terms && ! is_wp_error( $product_terms ) ) { |
||
45 | $product_groups = array(); |
||
46 | foreach ( $product_terms[0] as $product_term ) { |
||
47 | $product_groups[] = '<a href="' . $product_term['lsx_project_alt_product_link'] . '">' . $product_term['lsx_project_alt_product_title'] . '</a>'; |
||
48 | } |
||
49 | |||
50 | $product_groups = join( ', ', $product_groups ); |
||
51 | } |
||
52 | |||
53 | |||
54 | $connections = array(); |
||
55 | // Connection Projects. |
||
56 | |||
57 | if ( post_type_exists( 'project' ) && $terms && ! is_wp_error( $terms ) ) { |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
58 | $groups_ = array(); |
||
59 | |||
60 | foreach ( $terms as $term ) { |
||
61 | $groups_[] = $term->term_id; |
||
62 | } |
||
63 | |||
64 | if ( count( $groups_ ) > 0 ) { |
||
65 | $connection_project['post_type'] = 'project'; |
||
66 | $connection_project['title'] = esc_html__( 'Related Projects', 'lsx-projects' ); |
||
67 | $connection_project['posts'] = array(); |
||
68 | |||
69 | $args = array( |
||
70 | 'post_type' => 'project', |
||
71 | 'post__not_in' => array( get_the_ID() ), |
||
72 | 'no_found_rows' => true, |
||
73 | 'ignore_sticky_posts' => 1, |
||
74 | 'update_post_meta_cache' => false, |
||
75 | 'tax_query' => array( |
||
76 | array( |
||
77 | 'taxonomy' => 'project-group', |
||
78 | 'terms' => $groups_, |
||
79 | ), |
||
80 | ), |
||
81 | ); |
||
82 | |||
83 | $projects_ = new \WP_Query( $args ); |
||
84 | |||
85 | if ( $projects_->have_posts() ) { |
||
86 | while ( $projects_->have_posts() ) { |
||
87 | $projects_->the_post(); |
||
88 | $connection_project['posts'][] = get_the_ID(); |
||
89 | wp_reset_postdata(); |
||
90 | } |
||
91 | } |
||
92 | |||
93 | if ( ! empty( $connection_project['posts'] ) ) { |
||
94 | $post_ids = join( ',', $connection_project['posts'] ); |
||
95 | $connection_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]'; |
||
96 | $connections[] = $connection_project; |
||
97 | } |
||
98 | } |
||
99 | } |
||
100 | |||
101 | // Connection Products. |
||
102 | if ( class_exists( 'WooCommerce' ) ) { |
||
103 | $connection_product['post_type'] = 'product'; |
||
104 | $connection_product['title'] = esc_html__( 'Related Products', 'lsx-projects' ) . ' <small>' . esc_html__( 'Products used to build this project', 'lsx-projects' ) . '</small>'; |
||
105 | $connection_product['posts'] = get_post_meta( get_the_ID(), 'product_to_project', false ); |
||
106 | |||
107 | if ( ! empty( $connection_product['posts'] ) ) { |
||
108 | $connection_product['small_list_html'] = ''; |
||
109 | |||
110 | $args = array( |
||
111 | 'post_type' => 'product', |
||
112 | 'post__in' => $connection_product['posts'][0], |
||
113 | 'orderby' => 'post__in', |
||
114 | 'no_found_rows' => true, |
||
115 | 'ignore_sticky_posts' => 1, |
||
116 | 'update_post_term_cache' => false, |
||
117 | 'update_post_meta_cache' => false, |
||
118 | ); |
||
119 | $connection_product['posts_obj'] = new \WP_Query( $args ); |
||
120 | |||
121 | if ( $connection_product['posts_obj']->have_posts() ) { |
||
122 | $connection_product['small_list_html'] = array(); |
||
123 | |||
124 | while ( $connection_product['posts_obj']->have_posts() ) { |
||
125 | $connection_product['posts_obj']->the_post(); |
||
126 | $connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>'; |
||
127 | wp_reset_postdata(); |
||
128 | } |
||
129 | |||
130 | $connection_product['posts_obj']->rewind_posts(); |
||
131 | $connection_product['small_list_html'] = join( ', ', $connection_product['small_list_html'] ); |
||
132 | } |
||
133 | $connections[] = $connection_product; |
||
134 | } |
||
135 | } |
||
136 | |||
137 | // Connection Services. |
||
138 | $connection_service['post_type'] = 'page'; |
||
139 | $connection_service['pages'] = get_post_meta( get_the_ID(), 'page_to_project', false ); |
||
140 | |||
141 | if ( ! empty( $connection_service['pages'] ) ) { |
||
142 | $post_ids = join( ',', $connection_service['pages'] ); |
||
143 | $connection_service['small_list_html'] = ''; |
||
144 | |||
145 | $args = array( |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
146 | 'post_type' => 'page', |
||
147 | 'post__in' => $connection_service['pages'], |
||
148 | 'orderby' => 'post__in', |
||
149 | 'no_found_rows' => true, |
||
150 | 'ignore_sticky_posts' => 1, |
||
151 | 'update_post_term_cache' => false, |
||
152 | 'update_post_meta_cache' => false, |
||
153 | ); |
||
154 | $services_ = new \WP_Query( $args ); |
||
155 | |||
156 | if ( $services_->have_posts() ) { |
||
157 | $connection_service['small_list_html'] = array(); |
||
158 | |||
159 | while ( $services_->have_posts() ) { |
||
160 | $services_->the_post(); |
||
161 | $connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>'; |
||
162 | wp_reset_postdata(); |
||
163 | } |
||
164 | |||
165 | $connection_service['small_list_html'] = join( ', ', $connection_service['small_list_html'] ); |
||
166 | } |
||
0 ignored issues
–
show
|
|||
167 | $connections[] = $connection_service; |
||
168 | } |
||
169 | |||
170 | // Connection Testimonials. |
||
171 | if ( post_type_exists( 'testimonial' ) ) { |
||
0 ignored issues
–
show
|
|||
172 | $connection_testimonial['post_type'] = 'testimonial'; |
||
173 | $connection_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_project', false ); |
||
174 | |||
175 | if ( ! empty( $connection_testimonial['posts'] ) ) { |
||
176 | $post_ids = join( ',', $connection_testimonial['posts'][0] ); |
||
177 | $connection_testimonial['shortcode'] = '[lsx_testimonials columns="1" include="' . $post_ids . '" orderby="date" order="DESC"]'; |
||
178 | $connections[] = $connection_testimonial; |
||
179 | } |
||
180 | } |
||
181 | |||
182 | // Connection Team. |
||
183 | if ( post_type_exists( 'team' ) ) { |
||
0 ignored issues
–
show
|
|||
184 | $connection_team['post_type'] = 'team'; |
||
185 | $connection_team['posts'] = get_post_meta( get_the_ID(), 'team_to_project', false ); |
||
186 | |||
187 | if ( ! empty( $connection_team['posts'] ) ) { |
||
188 | $post_ids = join( ',', $connection_team['posts'][0] ); |
||
189 | $connection_team['shortcode'] = '[lsx_team columns="4" include="' . $post_ids . '" show_social="false" show_desc="false" show_link="true"]'; |
||
190 | $connection_team['small_list_html'] = ''; |
||
191 | |||
192 | $args = array( |
||
193 | 'post_type' => 'team', |
||
194 | 'post__in' => $connection_team['posts'][0], |
||
195 | 'orderby' => 'post__in', |
||
196 | 'no_found_rows' => true, |
||
197 | 'ignore_sticky_posts' => 1, |
||
198 | 'update_post_term_cache' => false, |
||
199 | 'update_post_meta_cache' => false, |
||
200 | ); |
||
201 | $team_ = new \WP_Query( $args ); |
||
202 | |||
203 | if ( $team_->have_posts() ) { |
||
204 | global $lsx_team; |
||
205 | $connection_team['small_list_html'] = array(); |
||
206 | |||
207 | while ( $team_->have_posts() ) { |
||
208 | $team_->the_post(); |
||
209 | $connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ) . '</a>'; |
||
210 | wp_reset_postdata(); |
||
211 | } |
||
212 | |||
213 | $connection_team['small_list_html'] = join( ' ', $connection_team['small_list_html'] ); |
||
214 | } |
||
215 | $connections[] = $connection_team; |
||
216 | } |
||
217 | } |
||
218 | ?> |
||
219 | |||
220 | <?php lsx_entry_before(); ?> |
||
221 | |||
222 | <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> |
||
223 | |||
224 | <?php lsx_entry_top(); ?> |
||
225 | |||
226 | <div class="row"> |
||
227 | <div class="col-xs-12 col-sm-7 col-md-8"> |
||
228 | <div class="entry-content"><?php the_content(); ?></div> |
||
229 | |||
230 | <?php if ( count( $connections ) > 0 ) : ?> |
||
231 | <?php foreach ( $connections as $i => $connection ) : ?> |
||
232 | <?php |
||
233 | if ( 'testimonial' === $connection['post_type'] ) { |
||
234 | echo '<div class="tab-pane-fake">'; |
||
235 | echo do_shortcode( $connection['shortcode'] ); |
||
236 | echo '</div>'; |
||
237 | } |
||
238 | ?> |
||
239 | <?php endforeach; ?> |
||
240 | <?php endif; ?> |
||
241 | </div> |
||
242 | |||
243 | <div class="col-xs-12 col-sm-5 col-md-4"> |
||
244 | <div class="entry-fixed-sidebar-wrapper"> |
||
245 | <div class="entry-fixed-sidebar"> |
||
246 | <?php if ( ! empty( $client_logo ) ) : ?> |
||
247 | <div class="entry-meta-single"><?php echo wp_kses_post( $client_logo ); ?></div> |
||
248 | <?php elseif ( ! empty( $client ) ) : ?> |
||
249 | <div class="entry-meta-single"><?php echo esc_html( $client ); ?></div> |
||
250 | <?php endif; ?> |
||
251 | |||
252 | <?php if ( ! empty( $groups ) ) : ?> |
||
253 | <div class="entry-meta-key"><?php esc_html_e( 'Industry:', 'lsx-projects' ); ?></div> |
||
254 | <div class="entry-meta-value"><?php echo wp_kses_post( $groups ); ?></div> |
||
255 | <?php endif; ?> |
||
256 | |||
257 | <?php if ( ! empty( $product_groups ) ) : ?> |
||
258 | <div class="entry-meta-key"><?php esc_html_e( 'Products:', 'lsx-projects' ); ?></div> |
||
259 | <div class="entry-meta-value"><?php echo wp_kses_post( $product_groups ); ?></div> |
||
260 | <?php endif; ?> |
||
261 | |||
262 | <?php if ( ! empty( $connection_service['small_list_html'] ) ) : ?> |
||
263 | <div class="entry-meta-key"><?php esc_html_e( 'Services:', 'lsx-projects' ); ?></div> |
||
264 | <div class="entry-meta-value"><?php echo wp_kses_post( $connection_service['small_list_html'] ); ?></div> |
||
265 | <?php endif; ?> |
||
266 | |||
267 | <?php if ( ! empty( $connection_product['small_list_html'] ) ) : ?> |
||
268 | <!-- |
||
269 | <div class="entry-meta-key"><?php esc_html_e( 'Products used:', 'lsx-projects' ); ?></div> |
||
270 | <div class="entry-meta-value"><?php echo wp_kses_post( $connection_product['small_list_html'] ); ?></div> |
||
271 | --> |
||
272 | <?php endif; ?> |
||
273 | |||
274 | <?php if ( ! empty( $connection_team['small_list_html'] ) ) : ?> |
||
275 | <div class="entry-meta-key"><?php esc_html_e( 'Team members involved:', 'lsx-projects' ); ?></div> |
||
276 | <div class="entry-meta-value entry-meta-value-team"><?php echo wp_kses_post( $connection_team['small_list_html'] ); ?></div> |
||
277 | <?php endif; ?> |
||
278 | |||
279 | <?php if ( ! empty( $url ) ) : ?> |
||
280 | <div class="entry-meta-single"><a href="<?php echo esc_url( $url ); ?>" target="_blank" rel="nofollow" class="btn btn-block secondary-btn"><?php esc_html_e( 'See website', 'lsx-projects' ); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div> |
||
281 | <?php endif; ?> |
||
282 | |||
283 | <?php if ( ! empty( $button_label ) ) : ?> |
||
284 | <div class="entry-meta-single"><a href="#lsx-project-contact" data-toggle="modal" class="btn btn-block cta-btn"><?php echo esc_html( $button_label ); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div> |
||
285 | <?php endif; ?> |
||
286 | </div> |
||
287 | </div> |
||
288 | </div> |
||
289 | </div> |
||
290 | |||
291 | <?php if ( count( $connections ) > 0 ) : ?> |
||
292 | <?php foreach ( $connections as $i => $connection ) : ?> |
||
293 | <?php |
||
294 | // Team is now visible on detail box. |
||
295 | // Services is now visible on detail box. |
||
296 | // Testimonials is now visible below the content. |
||
297 | if ( in_array( $connection['post_type'], array( 'team', 'testimonial', 'service' ) ) ) { |
||
298 | continue; |
||
299 | } |
||
300 | ?> |
||
301 | <?php if ( 'page' !== $connection['post_type'] ) { ?> |
||
302 | <div class="lsx-projects-section lsx-full-width"> |
||
303 | <div class="row"> |
||
304 | <div class="col-xs-12"> |
||
305 | <h3 class="lsx-title"><?php echo wp_kses_post( $connection['title'] ); ?></h3> |
||
306 | |||
307 | <?php |
||
308 | if ( 'product' === $connection['post_type'] ) { |
||
309 | |||
310 | if ( $connection_product['posts_obj']->have_posts() ) { |
||
311 | // @codingStandardsIgnoreLine |
||
312 | echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ); |
||
313 | |||
314 | while ( $connection_product['posts_obj']->have_posts() ) { |
||
315 | $connection_product['posts_obj']->the_post(); |
||
316 | wc_get_template( 'content-widget-product.php', array( |
||
317 | 'show_rating' => false, |
||
318 | ) ); |
||
319 | |||
320 | wp_reset_postdata(); |
||
321 | } |
||
322 | |||
323 | // @codingStandardsIgnoreLine |
||
324 | echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' ); |
||
325 | } |
||
326 | } else { |
||
327 | echo do_shortcode( $connection['shortcode'] ); |
||
328 | } |
||
329 | ?> |
||
330 | </div> |
||
331 | </div> |
||
332 | </div> |
||
333 | <?php |
||
334 | } |
||
335 | ?> |
||
336 | <?php endforeach; ?> |
||
337 | <?php endif; ?> |
||
338 | |||
339 | <?php lsx_entry_bottom(); ?> |
||
340 | </article><!-- #post-## --> |
||
341 | |||
342 | <?php |
||
343 | lsx_entry_after(); |
||
344 |