@@ -10,268 +10,268 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class LSX_Team { |
12 | 12 | |
13 | - public $options; |
|
14 | - |
|
15 | - public function __construct() { |
|
16 | - $this->options = team_get_options(); |
|
17 | - |
|
18 | - add_action( 'init', array( $this, 'custom_image_sizes' ) ); |
|
19 | - add_filter( 'lsx_banner_allowed_post_types', array( $this, 'lsx_banner_allowed_post_types' ) ); |
|
20 | - |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * Enable project custom post type on LSX Banners. |
|
25 | - */ |
|
26 | - public function custom_image_sizes( $post_types ) { |
|
27 | - add_image_size( 'lsx-team-archive', 170, 170, true ); |
|
28 | - add_image_size( 'lsx-team-single', 320, 320, true ); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Enable project custom post type on LSX Banners. |
|
33 | - */ |
|
34 | - public function lsx_banner_allowed_post_types( $post_types ) { |
|
35 | - $post_types[] = 'team'; |
|
36 | - return $post_types; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * Return the team thumbnail. |
|
41 | - */ |
|
42 | - public function get_thumbnail( $post_id, $size ) { |
|
43 | - add_filter( 'lsx_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
44 | - add_filter( 'lsx_to_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
45 | - |
|
46 | - if ( is_numeric( $size ) ) { |
|
47 | - $thumb_size = array( $size, $size ); |
|
48 | - } else { |
|
49 | - $thumb_size = $size; |
|
50 | - } |
|
51 | - |
|
52 | - $thumbnail_class = 'img-responsive'; |
|
53 | - |
|
54 | - if ( ! empty( get_the_post_thumbnail( $post_id ) ) || ! empty( get_post_meta( $post_id, 'lsx_email_gravatar', true ) ) ) { |
|
55 | - if ( ! empty( get_the_post_thumbnail( $post_id ) ) ) { |
|
56 | - $thumbnail = get_the_post_thumbnail( $post_id, $thumb_size, array( |
|
57 | - 'class' => $thumbnail_class, |
|
58 | - ) ); |
|
59 | - } else { |
|
60 | - $thumbnail = get_avatar( get_post_meta( $post_id, 'lsx_email_gravatar', true ), $size, $this->options['display']['team_placeholder'], false, array( |
|
61 | - 'class' => $thumbnail_class, |
|
62 | - ) ); |
|
63 | - } |
|
64 | - } |
|
65 | - if ( empty( $thumbnail ) ) { |
|
66 | - if ( $this->options['display'] && ! empty( $this->options['display']['team_placeholder'] ) ) { |
|
67 | - $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="' . $this->options['display']['team_placeholder'] . '" width="' . $size . '" />'; |
|
68 | - } else { |
|
69 | - $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="https://www.gravatar.com/avatar/none?d=mm&s=' . $size . '" width="' . $size . '" />'; |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - remove_filter( 'lsx_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
74 | - remove_filter( 'lsx_to_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
75 | - |
|
76 | - return $thumbnail; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * Replaces the widget with Mystery Man |
|
81 | - */ |
|
82 | - public function placeholder( $image ) { |
|
83 | - $image = array( |
|
84 | - LSX_TEAM_URL . 'assets/img/mystery-man-square.png', |
|
85 | - 512, |
|
86 | - 512, |
|
87 | - true, |
|
88 | - ); |
|
89 | - |
|
90 | - return $image; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Returns the shortcode output markup |
|
95 | - */ |
|
96 | - public function output( $atts ) { |
|
97 | - extract( shortcode_atts(array( |
|
98 | - 'columns' => 4, |
|
99 | - 'orderby' => 'name', |
|
100 | - 'order' => 'ASC', |
|
101 | - 'role' => '', |
|
102 | - 'limit' => '99', |
|
103 | - 'include' => '', |
|
104 | - 'display' => 'excerpt', |
|
105 | - 'size' => 'lsx-team-archive', |
|
106 | - 'show_link' => false, |
|
107 | - 'show_email' => false, |
|
108 | - 'show_image' => true, |
|
109 | - 'show_roles' => false, |
|
110 | - 'show_job_title' => true, |
|
111 | - 'show_desc' => true, |
|
112 | - 'show_social' => true, |
|
113 | - 'carousel' => true, |
|
114 | - 'featured' => false, |
|
115 | - ), $atts ) ); |
|
116 | - |
|
117 | - $output = ''; |
|
118 | - |
|
119 | - if ( ! empty( $include ) ) { |
|
120 | - $include = explode( ',', $include ); |
|
121 | - |
|
122 | - $args = array( |
|
123 | - 'post_type' => 'team', |
|
124 | - 'posts_per_page' => $limit, |
|
125 | - 'post__in' => $include, |
|
126 | - 'orderby' => 'post__in', |
|
127 | - 'order' => $order, |
|
128 | - ); |
|
129 | - } else { |
|
130 | - $args = array( |
|
131 | - 'post_type' => 'team', |
|
132 | - 'posts_per_page' => $limit, |
|
133 | - 'orderby' => $orderby, |
|
134 | - 'order' => $order, |
|
135 | - ); |
|
136 | - |
|
137 | - if ( 'true' === $featured || true === $featured ) { |
|
138 | - $args['meta_key'] = 'lsx_featured'; |
|
139 | - $args['meta_value'] = 1; |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - if ( ! empty( $role ) ) { |
|
144 | - $args['tax_query'] = array( |
|
145 | - array( |
|
146 | - 'taxonomy' => 'team_role', |
|
147 | - 'field' => 'id', |
|
148 | - 'terms' => $role, |
|
149 | - ), |
|
150 | - ); |
|
151 | - } |
|
152 | - |
|
153 | - $team = new \WP_Query( $args ); |
|
154 | - |
|
155 | - if ( $team->have_posts() ) { |
|
156 | - global $post; |
|
157 | - |
|
158 | - $count = 0; |
|
159 | - $count_global = 0; |
|
160 | - |
|
161 | - $column_size = intval( 12 / $columns ); |
|
162 | - |
|
163 | - $carousel = true === $carousel || 'true' === $carousel ? true : false; |
|
164 | - |
|
165 | - if ( $carousel ) { |
|
166 | - $output .= "<div class='lsx-team-shortcode lsx-team-block' id='lsx-team-slider' data-slick='{\"slidesToShow\": $columns, \"slidesToScroll\": $columns }'>"; |
|
167 | - } else { |
|
168 | - $output .= "<div class='lsx-team-shortcode'><div class='row'>"; |
|
169 | - } |
|
170 | - |
|
171 | - while ( $team->have_posts() ) { |
|
172 | - $team->the_post(); |
|
173 | - |
|
174 | - // Count |
|
175 | - $count++; |
|
176 | - $count_global++; |
|
177 | - |
|
178 | - $member_name = apply_filters( 'the_title', $post->post_title ); |
|
179 | - $member_roles = ''; |
|
180 | - $member_description = ''; |
|
181 | - $member_avatar = ''; |
|
182 | - $member_socials = ''; |
|
183 | - $member_job_title = ''; |
|
184 | - $member_email = ''; |
|
185 | - $bottom_link = ''; |
|
186 | - $facebook = get_post_meta( $post->ID, 'lsx_facebook', true ); |
|
187 | - $twitter = get_post_meta( $post->ID, 'lsx_twitter', true ); |
|
188 | - $linkedin = get_post_meta( $post->ID, 'lsx_linkedin', true ); |
|
189 | - |
|
190 | - // Link to single |
|
191 | - if ( ( true === $show_link || 'true' === $show_link ) && ( empty( team_get_option( 'team_disable_single' ) ) ) ) { |
|
192 | - $bottom_link = '<a href="' . get_permalink( $post->ID ) . '" class="lsx-team-show-more">More about ' . strtok( $member_name, ' ' ) . '<i class="fa fa-long-arrow-right" aria-hidden="true"></i></a>'; |
|
193 | - } |
|
194 | - |
|
195 | - if ( true === $show_email || 'true' === $show_email ) { |
|
196 | - $email = get_post_meta( $post->ID, 'lsx_email_contact', true ); |
|
197 | - |
|
198 | - $member_email = '<a href="mailto:' . sanitize_email( $email ) . '" class="lsx-team-email">' . sanitize_email( $email ) . '</a>'; |
|
199 | - } |
|
200 | - |
|
201 | - if ( ( true === $show_link || 'true' === $show_link ) && ( empty( team_get_option( 'team_disable_single' ) ) ) ) { |
|
202 | - $member_name = '<h5 class="lsx-team-name"><a href="' . get_permalink() . '">' . $member_name . '</a></h5>'; |
|
203 | - } else { |
|
204 | - $member_name = '<h5 class="lsx-team-name">' . $member_name . '</h5>'; |
|
205 | - } |
|
206 | - |
|
207 | - // Member roles |
|
208 | - if ( true === $show_roles || 'true' === $show_roles ) { |
|
209 | - $roles = ''; |
|
210 | - $terms = get_the_terms( $post->ID, 'team_role' ); |
|
211 | - |
|
212 | - if ( $terms && ! is_wp_error( $terms ) ) { |
|
213 | - $roles = array(); |
|
214 | - |
|
215 | - foreach ( $terms as $term ) { |
|
216 | - $roles[] = $term->name; |
|
217 | - } |
|
218 | - |
|
219 | - $roles = join( ', ', $roles ); |
|
220 | - } |
|
221 | - |
|
222 | - $member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : ''; |
|
223 | - } |
|
224 | - |
|
225 | - if ( true === $show_job_title || 'true' === $show_job_title ) { |
|
226 | - $job_title = get_post_meta( $post->ID, 'lsx_job_title', true ); |
|
227 | - $member_job_title = ! empty( $job_title ) ? "<small class='lsx-team-job-title'>$job_title</small>" : ''; |
|
228 | - } |
|
229 | - |
|
230 | - // Member description |
|
231 | - if ( true === $show_desc || 'true' === $show_desc ) { |
|
232 | - if ( 'full' === $display ) { |
|
233 | - $member_description = apply_filters( 'the_content', get_the_content( esc_html__( 'Read More', 'lsx-team' ) ) ); |
|
234 | - $member_description = str_replace( ']]>', ']]>', $member_description ); |
|
235 | - } elseif ( 'excerpt' === $display ) { |
|
236 | - $member_description = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
237 | - } |
|
238 | - |
|
239 | - $member_description = ! empty( $member_description ) ? "<div class='lsx-team-description'>$member_description</div>" : ''; |
|
240 | - } |
|
241 | - |
|
242 | - // Member avatar |
|
243 | - if ( true === $show_image || 'true' === $show_image ) { |
|
244 | - $member_avatar = $this->get_thumbnail( $post->ID, $size ); |
|
245 | - |
|
246 | - if ( ( true === $show_link || 'true' === $show_link ) && ( empty( $this->options['display'] ) || empty( team_get_option( 'team_disable_single' ) ) ) ) { |
|
247 | - $member_avatar = "<figure class='lsx-team-avatar'><a href='" . get_permalink() . "'>$member_avatar</a></figure>"; |
|
248 | - } else { |
|
249 | - $member_avatar = "<figure class='lsx-team-avatar'>$member_avatar</figure>"; |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - // Member socials |
|
254 | - if ( true === $show_social || 'true' === $show_social ) { |
|
255 | - $links = array( |
|
256 | - 'facebook' => $facebook, |
|
257 | - 'twitter' => $twitter, |
|
258 | - 'linkedin' => $linkedin, |
|
259 | - ); |
|
260 | - |
|
261 | - foreach ( $links as $sm => $sm_link ) { |
|
262 | - if ( ! empty( $sm_link ) ) { |
|
263 | - $member_socials .= "<li><a href='$sm_link' target='_blank'><i class='fa fa-$sm' aria-hidden='true'></i></a></li>"; |
|
264 | - } |
|
265 | - } |
|
266 | - |
|
267 | - $member_socials = ! empty( $member_socials ) ? "<ul class='lsx-team-socials list-inline'>$member_socials</ul>" : ''; |
|
268 | - } |
|
269 | - |
|
270 | - if ( ! $carousel ) { |
|
271 | - $output .= "<div class='col-xs-12 col-md-$column_size'>"; |
|
272 | - } |
|
273 | - |
|
274 | - $output .= " |
|
13 | + public $options; |
|
14 | + |
|
15 | + public function __construct() { |
|
16 | + $this->options = team_get_options(); |
|
17 | + |
|
18 | + add_action( 'init', array( $this, 'custom_image_sizes' ) ); |
|
19 | + add_filter( 'lsx_banner_allowed_post_types', array( $this, 'lsx_banner_allowed_post_types' ) ); |
|
20 | + |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * Enable project custom post type on LSX Banners. |
|
25 | + */ |
|
26 | + public function custom_image_sizes( $post_types ) { |
|
27 | + add_image_size( 'lsx-team-archive', 170, 170, true ); |
|
28 | + add_image_size( 'lsx-team-single', 320, 320, true ); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Enable project custom post type on LSX Banners. |
|
33 | + */ |
|
34 | + public function lsx_banner_allowed_post_types( $post_types ) { |
|
35 | + $post_types[] = 'team'; |
|
36 | + return $post_types; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * Return the team thumbnail. |
|
41 | + */ |
|
42 | + public function get_thumbnail( $post_id, $size ) { |
|
43 | + add_filter( 'lsx_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
44 | + add_filter( 'lsx_to_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
45 | + |
|
46 | + if ( is_numeric( $size ) ) { |
|
47 | + $thumb_size = array( $size, $size ); |
|
48 | + } else { |
|
49 | + $thumb_size = $size; |
|
50 | + } |
|
51 | + |
|
52 | + $thumbnail_class = 'img-responsive'; |
|
53 | + |
|
54 | + if ( ! empty( get_the_post_thumbnail( $post_id ) ) || ! empty( get_post_meta( $post_id, 'lsx_email_gravatar', true ) ) ) { |
|
55 | + if ( ! empty( get_the_post_thumbnail( $post_id ) ) ) { |
|
56 | + $thumbnail = get_the_post_thumbnail( $post_id, $thumb_size, array( |
|
57 | + 'class' => $thumbnail_class, |
|
58 | + ) ); |
|
59 | + } else { |
|
60 | + $thumbnail = get_avatar( get_post_meta( $post_id, 'lsx_email_gravatar', true ), $size, $this->options['display']['team_placeholder'], false, array( |
|
61 | + 'class' => $thumbnail_class, |
|
62 | + ) ); |
|
63 | + } |
|
64 | + } |
|
65 | + if ( empty( $thumbnail ) ) { |
|
66 | + if ( $this->options['display'] && ! empty( $this->options['display']['team_placeholder'] ) ) { |
|
67 | + $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="' . $this->options['display']['team_placeholder'] . '" width="' . $size . '" />'; |
|
68 | + } else { |
|
69 | + $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="https://www.gravatar.com/avatar/none?d=mm&s=' . $size . '" width="' . $size . '" />'; |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + remove_filter( 'lsx_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
74 | + remove_filter( 'lsx_to_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
75 | + |
|
76 | + return $thumbnail; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * Replaces the widget with Mystery Man |
|
81 | + */ |
|
82 | + public function placeholder( $image ) { |
|
83 | + $image = array( |
|
84 | + LSX_TEAM_URL . 'assets/img/mystery-man-square.png', |
|
85 | + 512, |
|
86 | + 512, |
|
87 | + true, |
|
88 | + ); |
|
89 | + |
|
90 | + return $image; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Returns the shortcode output markup |
|
95 | + */ |
|
96 | + public function output( $atts ) { |
|
97 | + extract( shortcode_atts(array( |
|
98 | + 'columns' => 4, |
|
99 | + 'orderby' => 'name', |
|
100 | + 'order' => 'ASC', |
|
101 | + 'role' => '', |
|
102 | + 'limit' => '99', |
|
103 | + 'include' => '', |
|
104 | + 'display' => 'excerpt', |
|
105 | + 'size' => 'lsx-team-archive', |
|
106 | + 'show_link' => false, |
|
107 | + 'show_email' => false, |
|
108 | + 'show_image' => true, |
|
109 | + 'show_roles' => false, |
|
110 | + 'show_job_title' => true, |
|
111 | + 'show_desc' => true, |
|
112 | + 'show_social' => true, |
|
113 | + 'carousel' => true, |
|
114 | + 'featured' => false, |
|
115 | + ), $atts ) ); |
|
116 | + |
|
117 | + $output = ''; |
|
118 | + |
|
119 | + if ( ! empty( $include ) ) { |
|
120 | + $include = explode( ',', $include ); |
|
121 | + |
|
122 | + $args = array( |
|
123 | + 'post_type' => 'team', |
|
124 | + 'posts_per_page' => $limit, |
|
125 | + 'post__in' => $include, |
|
126 | + 'orderby' => 'post__in', |
|
127 | + 'order' => $order, |
|
128 | + ); |
|
129 | + } else { |
|
130 | + $args = array( |
|
131 | + 'post_type' => 'team', |
|
132 | + 'posts_per_page' => $limit, |
|
133 | + 'orderby' => $orderby, |
|
134 | + 'order' => $order, |
|
135 | + ); |
|
136 | + |
|
137 | + if ( 'true' === $featured || true === $featured ) { |
|
138 | + $args['meta_key'] = 'lsx_featured'; |
|
139 | + $args['meta_value'] = 1; |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + if ( ! empty( $role ) ) { |
|
144 | + $args['tax_query'] = array( |
|
145 | + array( |
|
146 | + 'taxonomy' => 'team_role', |
|
147 | + 'field' => 'id', |
|
148 | + 'terms' => $role, |
|
149 | + ), |
|
150 | + ); |
|
151 | + } |
|
152 | + |
|
153 | + $team = new \WP_Query( $args ); |
|
154 | + |
|
155 | + if ( $team->have_posts() ) { |
|
156 | + global $post; |
|
157 | + |
|
158 | + $count = 0; |
|
159 | + $count_global = 0; |
|
160 | + |
|
161 | + $column_size = intval( 12 / $columns ); |
|
162 | + |
|
163 | + $carousel = true === $carousel || 'true' === $carousel ? true : false; |
|
164 | + |
|
165 | + if ( $carousel ) { |
|
166 | + $output .= "<div class='lsx-team-shortcode lsx-team-block' id='lsx-team-slider' data-slick='{\"slidesToShow\": $columns, \"slidesToScroll\": $columns }'>"; |
|
167 | + } else { |
|
168 | + $output .= "<div class='lsx-team-shortcode'><div class='row'>"; |
|
169 | + } |
|
170 | + |
|
171 | + while ( $team->have_posts() ) { |
|
172 | + $team->the_post(); |
|
173 | + |
|
174 | + // Count |
|
175 | + $count++; |
|
176 | + $count_global++; |
|
177 | + |
|
178 | + $member_name = apply_filters( 'the_title', $post->post_title ); |
|
179 | + $member_roles = ''; |
|
180 | + $member_description = ''; |
|
181 | + $member_avatar = ''; |
|
182 | + $member_socials = ''; |
|
183 | + $member_job_title = ''; |
|
184 | + $member_email = ''; |
|
185 | + $bottom_link = ''; |
|
186 | + $facebook = get_post_meta( $post->ID, 'lsx_facebook', true ); |
|
187 | + $twitter = get_post_meta( $post->ID, 'lsx_twitter', true ); |
|
188 | + $linkedin = get_post_meta( $post->ID, 'lsx_linkedin', true ); |
|
189 | + |
|
190 | + // Link to single |
|
191 | + if ( ( true === $show_link || 'true' === $show_link ) && ( empty( team_get_option( 'team_disable_single' ) ) ) ) { |
|
192 | + $bottom_link = '<a href="' . get_permalink( $post->ID ) . '" class="lsx-team-show-more">More about ' . strtok( $member_name, ' ' ) . '<i class="fa fa-long-arrow-right" aria-hidden="true"></i></a>'; |
|
193 | + } |
|
194 | + |
|
195 | + if ( true === $show_email || 'true' === $show_email ) { |
|
196 | + $email = get_post_meta( $post->ID, 'lsx_email_contact', true ); |
|
197 | + |
|
198 | + $member_email = '<a href="mailto:' . sanitize_email( $email ) . '" class="lsx-team-email">' . sanitize_email( $email ) . '</a>'; |
|
199 | + } |
|
200 | + |
|
201 | + if ( ( true === $show_link || 'true' === $show_link ) && ( empty( team_get_option( 'team_disable_single' ) ) ) ) { |
|
202 | + $member_name = '<h5 class="lsx-team-name"><a href="' . get_permalink() . '">' . $member_name . '</a></h5>'; |
|
203 | + } else { |
|
204 | + $member_name = '<h5 class="lsx-team-name">' . $member_name . '</h5>'; |
|
205 | + } |
|
206 | + |
|
207 | + // Member roles |
|
208 | + if ( true === $show_roles || 'true' === $show_roles ) { |
|
209 | + $roles = ''; |
|
210 | + $terms = get_the_terms( $post->ID, 'team_role' ); |
|
211 | + |
|
212 | + if ( $terms && ! is_wp_error( $terms ) ) { |
|
213 | + $roles = array(); |
|
214 | + |
|
215 | + foreach ( $terms as $term ) { |
|
216 | + $roles[] = $term->name; |
|
217 | + } |
|
218 | + |
|
219 | + $roles = join( ', ', $roles ); |
|
220 | + } |
|
221 | + |
|
222 | + $member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : ''; |
|
223 | + } |
|
224 | + |
|
225 | + if ( true === $show_job_title || 'true' === $show_job_title ) { |
|
226 | + $job_title = get_post_meta( $post->ID, 'lsx_job_title', true ); |
|
227 | + $member_job_title = ! empty( $job_title ) ? "<small class='lsx-team-job-title'>$job_title</small>" : ''; |
|
228 | + } |
|
229 | + |
|
230 | + // Member description |
|
231 | + if ( true === $show_desc || 'true' === $show_desc ) { |
|
232 | + if ( 'full' === $display ) { |
|
233 | + $member_description = apply_filters( 'the_content', get_the_content( esc_html__( 'Read More', 'lsx-team' ) ) ); |
|
234 | + $member_description = str_replace( ']]>', ']]>', $member_description ); |
|
235 | + } elseif ( 'excerpt' === $display ) { |
|
236 | + $member_description = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
237 | + } |
|
238 | + |
|
239 | + $member_description = ! empty( $member_description ) ? "<div class='lsx-team-description'>$member_description</div>" : ''; |
|
240 | + } |
|
241 | + |
|
242 | + // Member avatar |
|
243 | + if ( true === $show_image || 'true' === $show_image ) { |
|
244 | + $member_avatar = $this->get_thumbnail( $post->ID, $size ); |
|
245 | + |
|
246 | + if ( ( true === $show_link || 'true' === $show_link ) && ( empty( $this->options['display'] ) || empty( team_get_option( 'team_disable_single' ) ) ) ) { |
|
247 | + $member_avatar = "<figure class='lsx-team-avatar'><a href='" . get_permalink() . "'>$member_avatar</a></figure>"; |
|
248 | + } else { |
|
249 | + $member_avatar = "<figure class='lsx-team-avatar'>$member_avatar</figure>"; |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + // Member socials |
|
254 | + if ( true === $show_social || 'true' === $show_social ) { |
|
255 | + $links = array( |
|
256 | + 'facebook' => $facebook, |
|
257 | + 'twitter' => $twitter, |
|
258 | + 'linkedin' => $linkedin, |
|
259 | + ); |
|
260 | + |
|
261 | + foreach ( $links as $sm => $sm_link ) { |
|
262 | + if ( ! empty( $sm_link ) ) { |
|
263 | + $member_socials .= "<li><a href='$sm_link' target='_blank'><i class='fa fa-$sm' aria-hidden='true'></i></a></li>"; |
|
264 | + } |
|
265 | + } |
|
266 | + |
|
267 | + $member_socials = ! empty( $member_socials ) ? "<ul class='lsx-team-socials list-inline'>$member_socials</ul>" : ''; |
|
268 | + } |
|
269 | + |
|
270 | + if ( ! $carousel ) { |
|
271 | + $output .= "<div class='col-xs-12 col-md-$column_size'>"; |
|
272 | + } |
|
273 | + |
|
274 | + $output .= " |
|
275 | 275 | <div class='lsx-team-slot'> |
276 | 276 | $member_avatar |
277 | 277 | $member_name |
@@ -284,28 +284,28 @@ discard block |
||
284 | 284 | </div> |
285 | 285 | "; |
286 | 286 | |
287 | - if ( ! $carousel ) { |
|
288 | - $output .= '</div>'; |
|
287 | + if ( ! $carousel ) { |
|
288 | + $output .= '</div>'; |
|
289 | 289 | |
290 | - if ( $count == $columns && $team->post_count > $count_global ) { |
|
291 | - $output .= '</div>'; |
|
292 | - $output .= '<div class="row">'; |
|
293 | - $count = 0; |
|
294 | - } |
|
295 | - } |
|
290 | + if ( $count == $columns && $team->post_count > $count_global ) { |
|
291 | + $output .= '</div>'; |
|
292 | + $output .= '<div class="row">'; |
|
293 | + $count = 0; |
|
294 | + } |
|
295 | + } |
|
296 | 296 | |
297 | - wp_reset_postdata(); |
|
298 | - } |
|
297 | + wp_reset_postdata(); |
|
298 | + } |
|
299 | 299 | |
300 | - if ( ! $carousel ) { |
|
301 | - $output .= '</div>'; |
|
302 | - } |
|
300 | + if ( ! $carousel ) { |
|
301 | + $output .= '</div>'; |
|
302 | + } |
|
303 | 303 | |
304 | - $output .= '</div>'; |
|
304 | + $output .= '</div>'; |
|
305 | 305 | |
306 | - return $output; |
|
307 | - } |
|
308 | - } |
|
306 | + return $output; |
|
307 | + } |
|
308 | + } |
|
309 | 309 | |
310 | 310 | } |
311 | 311 |
@@ -15,23 +15,23 @@ discard block |
||
15 | 15 | public function __construct() { |
16 | 16 | $this->options = team_get_options(); |
17 | 17 | |
18 | - add_action( 'init', array( $this, 'custom_image_sizes' ) ); |
|
19 | - add_filter( 'lsx_banner_allowed_post_types', array( $this, 'lsx_banner_allowed_post_types' ) ); |
|
18 | + add_action('init', array($this, 'custom_image_sizes')); |
|
19 | + add_filter('lsx_banner_allowed_post_types', array($this, 'lsx_banner_allowed_post_types')); |
|
20 | 20 | |
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Enable project custom post type on LSX Banners. |
25 | 25 | */ |
26 | - public function custom_image_sizes( $post_types ) { |
|
27 | - add_image_size( 'lsx-team-archive', 170, 170, true ); |
|
28 | - add_image_size( 'lsx-team-single', 320, 320, true ); |
|
26 | + public function custom_image_sizes($post_types) { |
|
27 | + add_image_size('lsx-team-archive', 170, 170, true); |
|
28 | + add_image_size('lsx-team-single', 320, 320, true); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Enable project custom post type on LSX Banners. |
33 | 33 | */ |
34 | - public function lsx_banner_allowed_post_types( $post_types ) { |
|
34 | + public function lsx_banner_allowed_post_types($post_types) { |
|
35 | 35 | $post_types[] = 'team'; |
36 | 36 | return $post_types; |
37 | 37 | } |
@@ -39,39 +39,39 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * Return the team thumbnail. |
41 | 41 | */ |
42 | - public function get_thumbnail( $post_id, $size ) { |
|
43 | - add_filter( 'lsx_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
44 | - add_filter( 'lsx_to_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
42 | + public function get_thumbnail($post_id, $size) { |
|
43 | + add_filter('lsx_placeholder_url', array($this, 'placeholder'), 10, 1); |
|
44 | + add_filter('lsx_to_placeholder_url', array($this, 'placeholder'), 10, 1); |
|
45 | 45 | |
46 | - if ( is_numeric( $size ) ) { |
|
47 | - $thumb_size = array( $size, $size ); |
|
46 | + if (is_numeric($size)) { |
|
47 | + $thumb_size = array($size, $size); |
|
48 | 48 | } else { |
49 | 49 | $thumb_size = $size; |
50 | 50 | } |
51 | 51 | |
52 | 52 | $thumbnail_class = 'img-responsive'; |
53 | 53 | |
54 | - if ( ! empty( get_the_post_thumbnail( $post_id ) ) || ! empty( get_post_meta( $post_id, 'lsx_email_gravatar', true ) ) ) { |
|
55 | - if ( ! empty( get_the_post_thumbnail( $post_id ) ) ) { |
|
56 | - $thumbnail = get_the_post_thumbnail( $post_id, $thumb_size, array( |
|
54 | + if (!empty(get_the_post_thumbnail($post_id)) || !empty(get_post_meta($post_id, 'lsx_email_gravatar', true))) { |
|
55 | + if (!empty(get_the_post_thumbnail($post_id))) { |
|
56 | + $thumbnail = get_the_post_thumbnail($post_id, $thumb_size, array( |
|
57 | 57 | 'class' => $thumbnail_class, |
58 | - ) ); |
|
58 | + )); |
|
59 | 59 | } else { |
60 | - $thumbnail = get_avatar( get_post_meta( $post_id, 'lsx_email_gravatar', true ), $size, $this->options['display']['team_placeholder'], false, array( |
|
60 | + $thumbnail = get_avatar(get_post_meta($post_id, 'lsx_email_gravatar', true), $size, $this->options['display']['team_placeholder'], false, array( |
|
61 | 61 | 'class' => $thumbnail_class, |
62 | - ) ); |
|
62 | + )); |
|
63 | 63 | } |
64 | 64 | } |
65 | - if ( empty( $thumbnail ) ) { |
|
66 | - if ( $this->options['display'] && ! empty( $this->options['display']['team_placeholder'] ) ) { |
|
67 | - $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="' . $this->options['display']['team_placeholder'] . '" width="' . $size . '" />'; |
|
65 | + if (empty($thumbnail)) { |
|
66 | + if ($this->options['display'] && !empty($this->options['display']['team_placeholder'])) { |
|
67 | + $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="'.$this->options['display']['team_placeholder'].'" width="'.$size.'" />'; |
|
68 | 68 | } else { |
69 | - $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="https://www.gravatar.com/avatar/none?d=mm&s=' . $size . '" width="' . $size . '" />'; |
|
69 | + $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="https://www.gravatar.com/avatar/none?d=mm&s='.$size.'" width="'.$size.'" />'; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - remove_filter( 'lsx_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
74 | - remove_filter( 'lsx_to_placeholder_url', array( $this, 'placeholder' ), 10, 1 ); |
|
73 | + remove_filter('lsx_placeholder_url', array($this, 'placeholder'), 10, 1); |
|
74 | + remove_filter('lsx_to_placeholder_url', array($this, 'placeholder'), 10, 1); |
|
75 | 75 | |
76 | 76 | return $thumbnail; |
77 | 77 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * Replaces the widget with Mystery Man |
81 | 81 | */ |
82 | - public function placeholder( $image ) { |
|
82 | + public function placeholder($image) { |
|
83 | 83 | $image = array( |
84 | - LSX_TEAM_URL . 'assets/img/mystery-man-square.png', |
|
84 | + LSX_TEAM_URL.'assets/img/mystery-man-square.png', |
|
85 | 85 | 512, |
86 | 86 | 512, |
87 | 87 | true, |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * Returns the shortcode output markup |
95 | 95 | */ |
96 | - public function output( $atts ) { |
|
97 | - extract( shortcode_atts(array( |
|
96 | + public function output($atts) { |
|
97 | + extract(shortcode_atts(array( |
|
98 | 98 | 'columns' => 4, |
99 | 99 | 'orderby' => 'name', |
100 | 100 | 'order' => 'ASC', |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | 'show_social' => true, |
113 | 113 | 'carousel' => true, |
114 | 114 | 'featured' => false, |
115 | - ), $atts ) ); |
|
115 | + ), $atts)); |
|
116 | 116 | |
117 | 117 | $output = ''; |
118 | 118 | |
119 | - if ( ! empty( $include ) ) { |
|
120 | - $include = explode( ',', $include ); |
|
119 | + if (!empty($include)) { |
|
120 | + $include = explode(',', $include); |
|
121 | 121 | |
122 | 122 | $args = array( |
123 | 123 | 'post_type' => 'team', |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | 'order' => $order, |
135 | 135 | ); |
136 | 136 | |
137 | - if ( 'true' === $featured || true === $featured ) { |
|
137 | + if ('true' === $featured || true === $featured) { |
|
138 | 138 | $args['meta_key'] = 'lsx_featured'; |
139 | 139 | $args['meta_value'] = 1; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - if ( ! empty( $role ) ) { |
|
143 | + if (!empty($role)) { |
|
144 | 144 | $args['tax_query'] = array( |
145 | 145 | array( |
146 | 146 | 'taxonomy' => 'team_role', |
@@ -150,32 +150,32 @@ discard block |
||
150 | 150 | ); |
151 | 151 | } |
152 | 152 | |
153 | - $team = new \WP_Query( $args ); |
|
153 | + $team = new \WP_Query($args); |
|
154 | 154 | |
155 | - if ( $team->have_posts() ) { |
|
155 | + if ($team->have_posts()) { |
|
156 | 156 | global $post; |
157 | 157 | |
158 | 158 | $count = 0; |
159 | 159 | $count_global = 0; |
160 | 160 | |
161 | - $column_size = intval( 12 / $columns ); |
|
161 | + $column_size = intval(12 / $columns); |
|
162 | 162 | |
163 | 163 | $carousel = true === $carousel || 'true' === $carousel ? true : false; |
164 | 164 | |
165 | - if ( $carousel ) { |
|
165 | + if ($carousel) { |
|
166 | 166 | $output .= "<div class='lsx-team-shortcode lsx-team-block' id='lsx-team-slider' data-slick='{\"slidesToShow\": $columns, \"slidesToScroll\": $columns }'>"; |
167 | 167 | } else { |
168 | 168 | $output .= "<div class='lsx-team-shortcode'><div class='row'>"; |
169 | 169 | } |
170 | 170 | |
171 | - while ( $team->have_posts() ) { |
|
171 | + while ($team->have_posts()) { |
|
172 | 172 | $team->the_post(); |
173 | 173 | |
174 | 174 | // Count |
175 | 175 | $count++; |
176 | 176 | $count_global++; |
177 | 177 | |
178 | - $member_name = apply_filters( 'the_title', $post->post_title ); |
|
178 | + $member_name = apply_filters('the_title', $post->post_title); |
|
179 | 179 | $member_roles = ''; |
180 | 180 | $member_description = ''; |
181 | 181 | $member_avatar = ''; |
@@ -183,91 +183,91 @@ discard block |
||
183 | 183 | $member_job_title = ''; |
184 | 184 | $member_email = ''; |
185 | 185 | $bottom_link = ''; |
186 | - $facebook = get_post_meta( $post->ID, 'lsx_facebook', true ); |
|
187 | - $twitter = get_post_meta( $post->ID, 'lsx_twitter', true ); |
|
188 | - $linkedin = get_post_meta( $post->ID, 'lsx_linkedin', true ); |
|
186 | + $facebook = get_post_meta($post->ID, 'lsx_facebook', true); |
|
187 | + $twitter = get_post_meta($post->ID, 'lsx_twitter', true); |
|
188 | + $linkedin = get_post_meta($post->ID, 'lsx_linkedin', true); |
|
189 | 189 | |
190 | 190 | // Link to single |
191 | - if ( ( true === $show_link || 'true' === $show_link ) && ( empty( team_get_option( 'team_disable_single' ) ) ) ) { |
|
192 | - $bottom_link = '<a href="' . get_permalink( $post->ID ) . '" class="lsx-team-show-more">More about ' . strtok( $member_name, ' ' ) . '<i class="fa fa-long-arrow-right" aria-hidden="true"></i></a>'; |
|
191 | + if ((true === $show_link || 'true' === $show_link) && (empty(team_get_option('team_disable_single')))) { |
|
192 | + $bottom_link = '<a href="'.get_permalink($post->ID).'" class="lsx-team-show-more">More about '.strtok($member_name, ' ').'<i class="fa fa-long-arrow-right" aria-hidden="true"></i></a>'; |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( true === $show_email || 'true' === $show_email ) { |
|
196 | - $email = get_post_meta( $post->ID, 'lsx_email_contact', true ); |
|
195 | + if (true === $show_email || 'true' === $show_email) { |
|
196 | + $email = get_post_meta($post->ID, 'lsx_email_contact', true); |
|
197 | 197 | |
198 | - $member_email = '<a href="mailto:' . sanitize_email( $email ) . '" class="lsx-team-email">' . sanitize_email( $email ) . '</a>'; |
|
198 | + $member_email = '<a href="mailto:'.sanitize_email($email).'" class="lsx-team-email">'.sanitize_email($email).'</a>'; |
|
199 | 199 | } |
200 | 200 | |
201 | - if ( ( true === $show_link || 'true' === $show_link ) && ( empty( team_get_option( 'team_disable_single' ) ) ) ) { |
|
202 | - $member_name = '<h5 class="lsx-team-name"><a href="' . get_permalink() . '">' . $member_name . '</a></h5>'; |
|
201 | + if ((true === $show_link || 'true' === $show_link) && (empty(team_get_option('team_disable_single')))) { |
|
202 | + $member_name = '<h5 class="lsx-team-name"><a href="'.get_permalink().'">'.$member_name.'</a></h5>'; |
|
203 | 203 | } else { |
204 | - $member_name = '<h5 class="lsx-team-name">' . $member_name . '</h5>'; |
|
204 | + $member_name = '<h5 class="lsx-team-name">'.$member_name.'</h5>'; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | // Member roles |
208 | - if ( true === $show_roles || 'true' === $show_roles ) { |
|
208 | + if (true === $show_roles || 'true' === $show_roles) { |
|
209 | 209 | $roles = ''; |
210 | - $terms = get_the_terms( $post->ID, 'team_role' ); |
|
210 | + $terms = get_the_terms($post->ID, 'team_role'); |
|
211 | 211 | |
212 | - if ( $terms && ! is_wp_error( $terms ) ) { |
|
212 | + if ($terms && !is_wp_error($terms)) { |
|
213 | 213 | $roles = array(); |
214 | 214 | |
215 | - foreach ( $terms as $term ) { |
|
215 | + foreach ($terms as $term) { |
|
216 | 216 | $roles[] = $term->name; |
217 | 217 | } |
218 | 218 | |
219 | - $roles = join( ', ', $roles ); |
|
219 | + $roles = join(', ', $roles); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | $member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : ''; |
223 | 223 | } |
224 | 224 | |
225 | - if ( true === $show_job_title || 'true' === $show_job_title ) { |
|
226 | - $job_title = get_post_meta( $post->ID, 'lsx_job_title', true ); |
|
227 | - $member_job_title = ! empty( $job_title ) ? "<small class='lsx-team-job-title'>$job_title</small>" : ''; |
|
225 | + if (true === $show_job_title || 'true' === $show_job_title) { |
|
226 | + $job_title = get_post_meta($post->ID, 'lsx_job_title', true); |
|
227 | + $member_job_title = !empty($job_title) ? "<small class='lsx-team-job-title'>$job_title</small>" : ''; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | // Member description |
231 | - if ( true === $show_desc || 'true' === $show_desc ) { |
|
232 | - if ( 'full' === $display ) { |
|
233 | - $member_description = apply_filters( 'the_content', get_the_content( esc_html__( 'Read More', 'lsx-team' ) ) ); |
|
234 | - $member_description = str_replace( ']]>', ']]>', $member_description ); |
|
235 | - } elseif ( 'excerpt' === $display ) { |
|
236 | - $member_description = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
231 | + if (true === $show_desc || 'true' === $show_desc) { |
|
232 | + if ('full' === $display) { |
|
233 | + $member_description = apply_filters('the_content', get_the_content(esc_html__('Read More', 'lsx-team'))); |
|
234 | + $member_description = str_replace(']]>', ']]>', $member_description); |
|
235 | + } elseif ('excerpt' === $display) { |
|
236 | + $member_description = apply_filters('the_excerpt', get_the_excerpt()); |
|
237 | 237 | } |
238 | 238 | |
239 | - $member_description = ! empty( $member_description ) ? "<div class='lsx-team-description'>$member_description</div>" : ''; |
|
239 | + $member_description = !empty($member_description) ? "<div class='lsx-team-description'>$member_description</div>" : ''; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // Member avatar |
243 | - if ( true === $show_image || 'true' === $show_image ) { |
|
244 | - $member_avatar = $this->get_thumbnail( $post->ID, $size ); |
|
243 | + if (true === $show_image || 'true' === $show_image) { |
|
244 | + $member_avatar = $this->get_thumbnail($post->ID, $size); |
|
245 | 245 | |
246 | - if ( ( true === $show_link || 'true' === $show_link ) && ( empty( $this->options['display'] ) || empty( team_get_option( 'team_disable_single' ) ) ) ) { |
|
247 | - $member_avatar = "<figure class='lsx-team-avatar'><a href='" . get_permalink() . "'>$member_avatar</a></figure>"; |
|
246 | + if ((true === $show_link || 'true' === $show_link) && (empty($this->options['display']) || empty(team_get_option('team_disable_single')))) { |
|
247 | + $member_avatar = "<figure class='lsx-team-avatar'><a href='".get_permalink()."'>$member_avatar</a></figure>"; |
|
248 | 248 | } else { |
249 | 249 | $member_avatar = "<figure class='lsx-team-avatar'>$member_avatar</figure>"; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | // Member socials |
254 | - if ( true === $show_social || 'true' === $show_social ) { |
|
254 | + if (true === $show_social || 'true' === $show_social) { |
|
255 | 255 | $links = array( |
256 | 256 | 'facebook' => $facebook, |
257 | 257 | 'twitter' => $twitter, |
258 | 258 | 'linkedin' => $linkedin, |
259 | 259 | ); |
260 | 260 | |
261 | - foreach ( $links as $sm => $sm_link ) { |
|
262 | - if ( ! empty( $sm_link ) ) { |
|
261 | + foreach ($links as $sm => $sm_link) { |
|
262 | + if (!empty($sm_link)) { |
|
263 | 263 | $member_socials .= "<li><a href='$sm_link' target='_blank'><i class='fa fa-$sm' aria-hidden='true'></i></a></li>"; |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | - $member_socials = ! empty( $member_socials ) ? "<ul class='lsx-team-socials list-inline'>$member_socials</ul>" : ''; |
|
267 | + $member_socials = !empty($member_socials) ? "<ul class='lsx-team-socials list-inline'>$member_socials</ul>" : ''; |
|
268 | 268 | } |
269 | 269 | |
270 | - if ( ! $carousel ) { |
|
270 | + if (!$carousel) { |
|
271 | 271 | $output .= "<div class='col-xs-12 col-md-$column_size'>"; |
272 | 272 | } |
273 | 273 | |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | </div> |
285 | 285 | "; |
286 | 286 | |
287 | - if ( ! $carousel ) { |
|
287 | + if (!$carousel) { |
|
288 | 288 | $output .= '</div>'; |
289 | 289 | |
290 | - if ( $count == $columns && $team->post_count > $count_global ) { |
|
290 | + if ($count == $columns && $team->post_count > $count_global) { |
|
291 | 291 | $output .= '</div>'; |
292 | 292 | $output .= '<div class="row">'; |
293 | 293 | $count = 0; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | wp_reset_postdata(); |
298 | 298 | } |
299 | 299 | |
300 | - if ( ! $carousel ) { |
|
300 | + if (!$carousel) { |
|
301 | 301 | $output .= '</div>'; |
302 | 302 | } |
303 | 303 |