1 | <?php |
||||
2 | /** |
||||
3 | * LSX_TO_Team_Frontend |
||||
4 | * |
||||
5 | * @package LSX_TO_Team_Frontend |
||||
6 | * @author LightSpeed |
||||
7 | * @license GPL-2.0+ |
||||
8 | * @link |
||||
9 | * @copyright 2017 LightSpeedDevelopment |
||||
10 | */ |
||||
11 | |||||
12 | /** |
||||
13 | * Main plugin class. |
||||
14 | * |
||||
15 | * @package LSX_TO_Team_Frontend |
||||
16 | * @author LightSpeed |
||||
17 | */ |
||||
18 | class LSX_TO_Team_Frontend extends LSX_TO_Team { |
||||
19 | |||||
20 | /** |
||||
21 | * Holds the $page_links array while its being built on the single team page. |
||||
22 | * |
||||
23 | * @var array |
||||
24 | */ |
||||
25 | public $page_links = false; |
||||
26 | |||||
27 | /** |
||||
28 | * Holds the array of options. |
||||
29 | * |
||||
30 | * @var array |
||||
31 | */ |
||||
32 | public $options = false; |
||||
33 | |||||
34 | /** |
||||
35 | * Constructor |
||||
36 | */ |
||||
37 | public function __construct() { |
||||
38 | $this->options = get_option( '_lsx-to_settings', false ); |
||||
0 ignored issues
–
show
|
|||||
39 | |||||
40 | add_action( 'wp_head', array( $this, 'change_single_team_layout' ), 20, 1 ); |
||||
41 | |||||
42 | if ( ! is_admin() ) { |
||||
43 | add_filter( 'posts_orderby', array( $this, 'enable_role_taxonomy_order' ), 10, 2 ); |
||||
44 | } |
||||
45 | |||||
46 | add_filter( 'lsx_to_archive_class', array( $this, 'archive_class' ), 10, 3 ); |
||||
47 | add_filter( 'lsx_to_entry_class', array( $this, 'entry_class' ) ); |
||||
48 | add_action( 'lsx_to_settings_current_tab', array( $this, 'set_settings_current_tab' ) ); |
||||
49 | |||||
50 | if ( ! class_exists( 'LSX_TO_Template_Redirects' ) ) { |
||||
51 | require_once( LSX_TO_TEAM_PATH . 'classes/class-lsx-to-template-redirects.php' ); |
||||
52 | } |
||||
53 | |||||
54 | $this->redirects = new LSX_TO_Template_Redirects( LSX_TO_TEAM_PATH, array( 'team' ), array( 'role' ) ); |
||||
0 ignored issues
–
show
|
|||||
55 | |||||
56 | add_action( 'lsx_to_team_content', array( $this->redirects, 'content_part' ), 10, 2 ); |
||||
57 | |||||
58 | add_filter( 'lsx_to_page_navigation', array( $this, 'page_links' ) ); |
||||
59 | |||||
60 | add_action( 'lsx_entry_top', array( $this, 'archive_entry_top' ), 15 ); |
||||
61 | add_action( 'lsx_entry_bottom', array( $this, 'archive_entry_bottom' ) ); |
||||
62 | add_action( 'lsx_content_bottom', array( $this, 'single_content_bottom' ) ); |
||||
63 | |||||
64 | add_filter( 'lsx_to_maps_args', array( $this, 'lsx_to_maps_args' ), 10, 2 ); |
||||
65 | add_filter( 'lsx_to_has_maps_location', array( $this, 'lsx_to_has_maps_location' ), 50, 2 ); |
||||
66 | } |
||||
67 | |||||
68 | /** |
||||
69 | * Change single team layout. |
||||
70 | */ |
||||
71 | public function change_single_team_layout() { |
||||
72 | global $lsx_to_archive; |
||||
73 | |||||
74 | if ( is_singular( 'team' ) && 1 !== $lsx_to_archive ) { |
||||
75 | remove_action( 'lsx_entry_bottom', 'lsx_to_single_entry_bottom' ); |
||||
76 | add_action( 'lsx_entry_top', array( $this, 'lsx_to_single_entry_bottom' ) ); |
||||
77 | } |
||||
78 | } |
||||
79 | |||||
80 | /** |
||||
81 | * Change single team layout. |
||||
82 | */ |
||||
83 | public function lsx_to_single_entry_bottom() { |
||||
84 | if ( is_singular( 'team' ) ) { ?> |
||||
85 | <div class="col-xs-12 col-sm-5 col-md-4"> |
||||
86 | <figure class="lsx-to-team-thumb"> |
||||
87 | <?php lsx_thumbnail( 'lsx-thumbnail-square' ); ?> |
||||
88 | </figure> |
||||
89 | |||||
90 | <?php |
||||
91 | lsx_to_team_social_profiles( '<span class="lsx-to-team-socials-header">' . esc_html__( 'Follow', 'to-team' ) . ':</span><div class="lsx-to-team-socials">', '</div>' ); |
||||
92 | lsx_to_enquire_modal( esc_html__( 'Get in touch', 'to-team' ) ); |
||||
93 | ?> |
||||
94 | </div> |
||||
95 | <?php |
||||
96 | } |
||||
97 | } |
||||
98 | |||||
99 | /** |
||||
100 | * Enable role taxonomy order. |
||||
101 | */ |
||||
102 | public function enable_role_taxonomy_order( $orderby, $query ) { |
||||
103 | global $wpdb; |
||||
104 | |||||
105 | if ( $query->is_main_query() && $query->is_post_type_archive( 'team' ) ) { |
||||
106 | if ( isset( $this->options['team'] ) && isset( $this->options['team']['group_items_by_role'] ) ) { |
||||
107 | $new_orderby = "( |
||||
108 | SELECT GROUP_CONCAT(lsx_to_term_order ORDER BY lsx_to_term_order ASC) |
||||
109 | FROM $wpdb->term_relationships |
||||
110 | INNER JOIN $wpdb->term_taxonomy USING (term_taxonomy_id) |
||||
111 | INNER JOIN $wpdb->terms USING (term_id) |
||||
112 | WHERE $wpdb->posts.ID = object_id |
||||
113 | AND taxonomy = 'role' |
||||
114 | GROUP BY object_id |
||||
115 | ) "; |
||||
116 | |||||
117 | $new_orderby .= ( 'ASC' == strtoupper( $query->get( 'order' ) ) ) ? 'ASC' : 'DESC'; |
||||
118 | $orderby = $new_orderby . ', ' . $orderby; |
||||
119 | } |
||||
120 | } |
||||
121 | |||||
122 | return $orderby; |
||||
123 | } |
||||
124 | |||||
125 | /** |
||||
126 | * A filter to set the content area to a small column on single |
||||
127 | */ |
||||
128 | public function archive_class( $new_classes, $classes, $layout ) { |
||||
129 | if ( is_post_type_archive( 'team' ) ) { |
||||
130 | $new_classes = $classes; |
||||
131 | |||||
132 | if ( 'grid' === $layout ) { |
||||
133 | $new_classes[] = 'col-xs-12 col-sm-6 col-md-3'; |
||||
134 | } else { |
||||
135 | $new_classes[] = 'col-xs-12'; |
||||
136 | } |
||||
137 | } |
||||
138 | |||||
139 | return $new_classes; |
||||
140 | } |
||||
141 | |||||
142 | /** |
||||
143 | * A filter to set the content area to a small column on single |
||||
144 | */ |
||||
145 | public function entry_class( $classes ) { |
||||
146 | global $lsx_to_archive; |
||||
147 | |||||
148 | if ( 1 !== $lsx_to_archive ) { |
||||
149 | $lsx_to_archive = false; |
||||
150 | } |
||||
151 | |||||
152 | if ( is_main_query() && is_singular( 'team' ) && false === $lsx_to_archive ) { |
||||
153 | if ( lsx_to_has_enquiry_contact() ) { |
||||
154 | $classes[] = 'col-xs-12 col-sm-7 col-md-8'; |
||||
155 | } else { |
||||
156 | $classes[] = 'col-xs-12'; |
||||
157 | } |
||||
158 | } |
||||
159 | |||||
160 | return $classes; |
||||
161 | } |
||||
162 | |||||
163 | /** |
||||
164 | * Sets the current tab selected. |
||||
165 | */ |
||||
166 | public function set_settings_current_tab( $settings_tab ) { |
||||
167 | if ( is_tax( 'role' ) ) { |
||||
168 | $taxonomy = get_query_var( 'taxonomy' ); |
||||
169 | |||||
170 | if ( 'role' === $taxonomy ) { |
||||
171 | $settings_tab = 'team'; |
||||
172 | } |
||||
173 | } |
||||
174 | |||||
175 | return $settings_tab; |
||||
176 | } |
||||
177 | |||||
178 | /** |
||||
179 | * Adds our navigation links to the team single post |
||||
180 | * |
||||
181 | * @param $page_links array |
||||
182 | * @return $page_links array |
||||
0 ignored issues
–
show
|
|||||
183 | */ |
||||
184 | public function page_links( $page_links ) { |
||||
185 | if ( is_singular( 'team' ) ) { |
||||
186 | $this->page_links = $page_links; |
||||
187 | |||||
188 | $this->get_map_link(); |
||||
189 | |||||
190 | $this->get_related_posts_link(); |
||||
191 | $this->get_related_accommodation_link(); |
||||
192 | $this->get_related_destination_link(); |
||||
193 | $this->get_related_tours_link(); |
||||
194 | $this->get_related_reviews_link(); |
||||
195 | |||||
196 | $this->get_gallery_link(); |
||||
197 | $this->get_videos_link(); |
||||
198 | |||||
199 | $page_links = $this->page_links; |
||||
200 | } |
||||
201 | |||||
202 | return $page_links; |
||||
203 | } |
||||
204 | |||||
205 | /** |
||||
206 | * Tests for the Related Posts and returns a link for the section |
||||
207 | */ |
||||
208 | public function get_related_posts_link() { |
||||
209 | $site_user = get_post_meta( get_the_ID(), 'site_user', true ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
210 | |||||
211 | if ( ! empty( $site_user ) ) { |
||||
212 | if ( is_user_member_of_blog( $site_user ) ) { |
||||
0 ignored issues
–
show
It seems like
$site_user can also be of type string ; however, parameter $user_id of is_user_member_of_blog() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
213 | $user_posts = count_user_posts( $site_user, 'post' ); |
||||
0 ignored issues
–
show
It seems like
$site_user can also be of type string ; however, parameter $userid of count_user_posts() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
214 | |||||
215 | if ( $user_posts > 0 ) { |
||||
216 | $this->page_links['posts'] = esc_html__( 'Posts', 'to-team' ); |
||||
217 | } |
||||
218 | } |
||||
219 | } |
||||
220 | } |
||||
221 | |||||
222 | /** |
||||
223 | * Tests for the Google Map and returns a link for the section |
||||
224 | */ |
||||
225 | public function get_map_link() { |
||||
226 | if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) { |
||||
227 | $this->page_links['team-map'] = esc_html__( 'Map', 'tour-operator' ); |
||||
228 | } |
||||
229 | } |
||||
230 | |||||
231 | /** |
||||
232 | * Tests for the Related Accommodation and returns a link for the section |
||||
233 | */ |
||||
234 | public function get_related_accommodation_link() { |
||||
235 | $connected_accommodation = get_post_meta( get_the_ID(), 'accommodation_to_team', false ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
236 | |||||
237 | if ( post_type_exists( 'accommodation' ) && is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) { |
||||
238 | $connected_accommodation = new \WP_Query( array( |
||||
239 | 'post_type' => 'accommodation', |
||||
240 | 'post__in' => $connected_accommodation, |
||||
241 | 'post_status' => 'publish', |
||||
242 | 'nopagin' => true, |
||||
243 | 'posts_per_page' => '-1', |
||||
244 | 'fields' => 'ids', |
||||
245 | ) ); |
||||
246 | |||||
247 | $connected_accommodation = $connected_accommodation->posts; |
||||
248 | |||||
249 | if ( is_array( $connected_accommodation ) && ! empty( $connected_accommodation ) ) { |
||||
250 | $this->page_links['accommodation'] = esc_html__( 'Accommodation', 'to-team' ); |
||||
251 | } |
||||
252 | } |
||||
253 | } |
||||
254 | |||||
255 | /** |
||||
256 | * Tests for the Related Destinations and returns a link for the section |
||||
257 | */ |
||||
258 | public function get_related_destination_link() { |
||||
259 | $connected_destination = get_post_meta( get_the_ID(), 'destination_to_team', false ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
260 | |||||
261 | if ( post_type_exists( 'destination' ) && is_array( $connected_destination ) && ! empty( $connected_destination ) ) { |
||||
262 | $connected_destination = new \WP_Query( array( |
||||
263 | 'post_type' => 'destination', |
||||
264 | 'post__in' => $connected_destination, |
||||
265 | 'post_status' => 'publish', |
||||
266 | 'nopagin' => true, |
||||
267 | 'posts_per_page' => '-1', |
||||
268 | 'fields' => 'ids', |
||||
269 | ) ); |
||||
270 | |||||
271 | $connected_destination = $connected_destination->posts; |
||||
272 | |||||
273 | if ( is_array( $connected_destination ) && ! empty( $connected_destination ) ) { |
||||
274 | $this->page_links['destination'] = esc_html__( 'Destinations', 'to-team' ); |
||||
275 | } |
||||
276 | } |
||||
277 | } |
||||
278 | |||||
279 | /** |
||||
280 | * Tests for the Related Tours and returns a link for the section |
||||
281 | */ |
||||
282 | public function get_related_tours_link() { |
||||
283 | $connected_tours = get_post_meta( get_the_ID(), 'tour_to_team', false ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
284 | |||||
285 | if ( post_type_exists( 'tour' ) && is_array( $connected_tours ) && ! empty( $connected_tours ) ) { |
||||
286 | $connected_tours = new \WP_Query( array( |
||||
287 | 'post_type' => 'tour', |
||||
288 | 'post__in' => $connected_tours, |
||||
289 | 'post_status' => 'publish', |
||||
290 | 'nopagin' => true, |
||||
291 | 'posts_per_page' => '-1', |
||||
292 | 'fields' => 'ids', |
||||
293 | ) ); |
||||
294 | |||||
295 | $connected_tours = $connected_tours->posts; |
||||
296 | |||||
297 | if ( is_array( $connected_tours ) && ! empty( $connected_tours ) ) { |
||||
298 | $this->page_links['tours'] = esc_html__( 'Tours', 'to-team' ); |
||||
299 | } |
||||
300 | } |
||||
301 | } |
||||
302 | |||||
303 | /** |
||||
304 | * Tests for the Related Tours and returns a link for the section |
||||
305 | */ |
||||
306 | public function get_related_reviews_link() { |
||||
307 | $connected_reviews = get_post_meta( get_the_ID(), 'review_to_team', false ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
308 | |||||
309 | if ( post_type_exists( 'review' ) && is_array( $connected_reviews ) && ! empty( $connected_reviews ) ) { |
||||
310 | $connected_reviews = new \WP_Query( array( |
||||
311 | 'post_type' => 'review', |
||||
312 | 'post__in' => $connected_reviews, |
||||
313 | 'post_status' => 'publish', |
||||
314 | 'nopagin' => true, |
||||
315 | 'posts_per_page' => '-1', |
||||
316 | 'fields' => 'ids', |
||||
317 | ) ); |
||||
318 | |||||
319 | $connected_reviews = $connected_reviews->posts; |
||||
320 | |||||
321 | if ( is_array( $connected_reviews ) && ! empty( $connected_reviews ) ) { |
||||
322 | $this->page_links['reviews'] = esc_html__( 'Reviews', 'to-team' ); |
||||
323 | } |
||||
324 | } |
||||
325 | } |
||||
326 | |||||
327 | /** |
||||
328 | * Tests for the Gallery and returns a link for the section |
||||
329 | */ |
||||
330 | public function get_gallery_link() { |
||||
331 | $gallery_ids = get_post_meta( get_the_ID(), 'gallery', false ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
332 | $envira_gallery = get_post_meta( get_the_ID(), 'envira_gallery', true ); |
||||
333 | |||||
334 | if ( ( ! empty( $gallery_ids ) && is_array( $gallery_ids ) ) || ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) ) { |
||||
335 | if ( function_exists( 'envira_gallery' ) && ! empty( $envira_gallery ) && false === lsx_to_enable_envira_banner() ) { |
||||
336 | // Envira Gallery. |
||||
337 | $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-team' ); |
||||
338 | return; |
||||
339 | } else { |
||||
340 | if ( function_exists( 'envira_dynamic' ) ) { |
||||
341 | // Envira Gallery - Dynamic. |
||||
342 | $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-team' ); |
||||
343 | return; |
||||
344 | } else { |
||||
345 | // WordPress Gallery. |
||||
346 | $this->page_links['gallery'] = esc_html__( 'Gallery', 'to-team' ); |
||||
347 | return; |
||||
348 | } |
||||
349 | } |
||||
350 | } |
||||
351 | } |
||||
352 | |||||
353 | /** |
||||
354 | * Tests for the Videos and returns a link for the section |
||||
355 | */ |
||||
356 | public function get_videos_link() { |
||||
357 | $videos_id = false; |
||||
358 | |||||
359 | if ( class_exists( 'Envira_Videos' ) ) { |
||||
360 | $videos_id = get_post_meta( get_the_ID(), 'envira_video', true ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
361 | } |
||||
362 | |||||
363 | if ( empty( $videos_id ) && function_exists( 'lsx_to_videos' ) ) { |
||||
364 | $videos_id = get_post_meta( get_the_ID(), 'videos', true ); |
||||
365 | } |
||||
366 | |||||
367 | if ( ! empty( $videos_id ) ) { |
||||
368 | $this->page_links['videos'] = esc_html__( 'Videos', 'to-team' ); |
||||
369 | } |
||||
370 | } |
||||
371 | |||||
372 | /** |
||||
373 | * Adds the template tags to the top of the archive team |
||||
374 | */ |
||||
375 | public function archive_entry_top() { |
||||
376 | global $lsx_to_archive; |
||||
377 | |||||
378 | if ( 'team' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { |
||||
379 | ?> |
||||
380 | <?php if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?> |
||||
381 | <div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-grid-mode"> |
||||
382 | <?php |
||||
383 | $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
||||
384 | |||||
385 | lsx_to_team_role( '<span class="' . $meta_class . 'role"><span class="lsx-to-meta-data-key">' . __( 'Role', 'to-team' ) . ':</span> ', '</span>' ); |
||||
386 | lsx_to_team_contact_number( '<span class="' . $meta_class . 'phone">', '</span>' ); |
||||
387 | lsx_to_team_contact_email( '<span class="' . $meta_class . 'email">', '</span>' ); |
||||
388 | lsx_to_team_contact_skype( '<span class="' . $meta_class . 'skype">', '</span>' ); |
||||
389 | lsx_to_team_social_profiles( '<div class="' . $meta_class . 'socials">', '</div>' ); |
||||
390 | ?> |
||||
391 | </div> |
||||
392 | <?php } ?> |
||||
393 | <?php |
||||
394 | } |
||||
395 | } |
||||
396 | |||||
397 | /** |
||||
398 | * Adds the template tags to the bottom of the archive team |
||||
399 | */ |
||||
400 | public function archive_entry_bottom() { |
||||
401 | global $lsx_to_archive; |
||||
402 | |||||
403 | if ( 'team' === get_post_type() && ( is_archive() || $lsx_to_archive ) ) { |
||||
404 | ?> |
||||
405 | </div> |
||||
406 | |||||
407 | <?php if ( is_search() || empty( tour_operator()->options[ get_post_type() ]['disable_entry_metadata'] ) ) { ?> |
||||
408 | <div class="lsx-to-archive-meta-data lsx-to-archive-meta-data-list-mode"> |
||||
409 | <?php |
||||
410 | $meta_class = 'lsx-to-meta-data lsx-to-meta-data-'; |
||||
411 | |||||
412 | lsx_to_team_role( '<span class="' . $meta_class . 'role"><span class="lsx-to-meta-data-key">' . __( 'Role', 'to-team' ) . ':</span> ', '</span>' ); |
||||
413 | lsx_to_team_contact_number( '<span class="' . $meta_class . 'phone">', '</span>' ); |
||||
414 | lsx_to_team_contact_email( '<span class="' . $meta_class . 'email">', '</span>' ); |
||||
415 | lsx_to_team_contact_skype( '<span class="' . $meta_class . 'skype">', '</span>' ); |
||||
416 | lsx_to_team_social_profiles( '<div class="' . $meta_class . 'socials">', '</div>' ); |
||||
417 | ?> |
||||
418 | </div> |
||||
419 | <?php } ?> |
||||
420 | |||||
421 | <?php |
||||
422 | $member_name = get_the_title(); |
||||
423 | $has_single = ! lsx_to_is_single_disabled(); |
||||
424 | ?> |
||||
425 | |||||
426 | <?php if ( $has_single && 'grid' === tour_operator()->archive_layout ) : ?> |
||||
427 | <p class="text-center lsx-to-single-link"><a href="<?php the_permalink(); ?>"><?php echo esc_html__( 'More about', 'to-team' ) . ' ' . esc_html( strtok( $member_name, ' ' ) ); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></p> |
||||
428 | <?php endif; ?> |
||||
429 | </div> |
||||
430 | <?php |
||||
431 | } |
||||
432 | } |
||||
433 | |||||
434 | /** |
||||
435 | * Adds the template tags to the bottom of the single team |
||||
436 | */ |
||||
437 | public function single_content_bottom() { |
||||
438 | if ( is_singular( 'team' ) ) { |
||||
439 | if ( function_exists( 'lsx_to_has_map' ) && lsx_to_has_map() ) : |
||||
440 | global $post; |
||||
441 | $map_title = $post->post_title; |
||||
442 | $map_title = $map_title . __( "'s favourite places", 'to-team' ); |
||||
443 | ?> |
||||
444 | <section id="team-map" class="lsx-to-section lsx-to-collapse-section"> |
||||
445 | <h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-team-map"><?php echo esc_html( $map_title ); ?></h2> |
||||
446 | |||||
447 | <div id="collapse-team-map" class="collapse in"> |
||||
448 | <div class="collapse-inner"> |
||||
449 | <?php lsx_to_map(); ?> |
||||
450 | </div> |
||||
451 | </div> |
||||
452 | </section> |
||||
453 | <?php |
||||
454 | endif; |
||||
455 | |||||
456 | lsx_to_team_posts(); |
||||
457 | |||||
458 | lsx_to_team_accommodation(); |
||||
459 | |||||
460 | lsx_to_team_destination(); |
||||
461 | |||||
462 | lsx_to_team_tours(); |
||||
463 | |||||
464 | lsx_to_team_reviews(); |
||||
465 | |||||
466 | lsx_to_gallery( '<section id="gallery" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-gallery">' . esc_html__( 'Gallery', 'to-team' ) . '</h2><div id="collapse-gallery" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
||||
467 | |||||
468 | if ( function_exists( 'lsx_to_videos' ) ) { |
||||
469 | lsx_to_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-team' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
||||
470 | } elseif ( class_exists( 'Envira_Videos' ) ) { |
||||
471 | lsx_to_envira_videos( '<section id="videos" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-videos">' . esc_html__( 'Videos', 'to-team' ) . '</h2><div id="collapse-videos" class="collapse in"><div class="collapse-inner">', '</div></div></section>' ); |
||||
472 | } |
||||
473 | } |
||||
474 | } |
||||
475 | |||||
476 | public function lsx_to_maps_args( $args, $post_id ) { |
||||
477 | if ( is_singular( 'team' ) ) { |
||||
478 | $accommodation_connected = get_post_meta( get_the_ID(), 'accommodation_to_team' ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
479 | if ( is_array( $accommodation_connected ) && ! empty( $accommodation_connected ) ) { |
||||
480 | $args = array( |
||||
481 | 'lat' => true, |
||||
482 | 'long' => true, |
||||
483 | 'connections' => $accommodation_connected, |
||||
484 | 'content' => 'excerpt', |
||||
485 | 'type' => 'cluster', |
||||
486 | 'width' => '100%', |
||||
487 | 'height' => '500px', |
||||
488 | ); |
||||
489 | } |
||||
490 | } |
||||
491 | return $args; |
||||
492 | } |
||||
493 | |||||
494 | public function lsx_to_has_maps_location( $location, $id ) { |
||||
495 | if ( is_singular( 'team' ) ) { |
||||
496 | $accommodation_connected = get_post_meta( $id, 'accommodation_to_team' ); |
||||
497 | if ( is_array( $accommodation_connected ) && ! empty( $accommodation_connected ) ) { |
||||
498 | $location = array( |
||||
499 | 'lat' => true, |
||||
500 | 'connections' => $accommodation_connected, |
||||
501 | ); |
||||
502 | } |
||||
503 | } |
||||
504 | return $location; |
||||
505 | } |
||||
506 | } |
||||
507 | |||||
508 | global $lsx_to_team_frontend; |
||||
509 | $lsx_to_team_frontend = new LSX_TO_Team_Frontend(); |
||||
510 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.