@@ -11,445 +11,445 @@ |
||
11 | 11 | |
12 | 12 | class LSX_Team_Admin { |
13 | 13 | |
14 | - public function __construct() { |
|
15 | - $this->load_classes(); |
|
16 | - |
|
17 | - add_action( 'init', array( $this, 'post_type_setup' ) ); |
|
18 | - add_action( 'init', array( $this, 'taxonomy_setup' ) ); |
|
19 | - |
|
20 | - add_action( 'cmb2_admin_init', array( $this, 'details_metabox' ) ); |
|
21 | - add_action( 'cmb2_admin_init', array( $this, 'projects_details_metabox' ) ); |
|
22 | - add_action( 'cmb2_admin_init', array( $this, 'services_details_metabox' ) ); |
|
23 | - add_action( 'cmb2_admin_init', array( $this, 'testimonials_details_metabox' ) ); |
|
24 | - |
|
25 | - add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
26 | - |
|
27 | - add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 ); |
|
28 | - add_filter( 'enter_title_here', array( $this, 'change_title_text' ) ); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Loads the admin subclasses |
|
33 | - */ |
|
34 | - private function load_classes() { |
|
35 | - require_once LSX_TEAM_PATH . 'classes/admin/class-settings.php'; |
|
36 | - $this->settings = \lsx\team\classes\admin\Settings::get_instance(); |
|
37 | - |
|
38 | - require_once LSX_TEAM_PATH . 'classes/admin/class-settings-theme.php'; |
|
39 | - $this->settings_theme = \lsx\team\classes\admin\Settings_Theme::get_instance(); |
|
40 | - } |
|
41 | - |
|
42 | - public function post_type_setup() { |
|
43 | - $labels = array( |
|
44 | - 'name' => esc_html_x( 'Team Members', 'post type general name', 'lsx-team' ), |
|
45 | - 'singular_name' => esc_html_x( 'Team Member', 'post type singular name', 'lsx-team' ), |
|
46 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-team' ), |
|
47 | - 'add_new_item' => esc_html__( 'Add New Team Member', 'lsx-team' ), |
|
48 | - 'edit_item' => esc_html__( 'Edit Team Member', 'lsx-team' ), |
|
49 | - 'new_item' => esc_html__( 'New Team Member', 'lsx-team' ), |
|
50 | - 'all_items' => esc_html__( 'All Team Members', 'lsx-team' ), |
|
51 | - 'view_item' => esc_html__( 'View Team Member', 'lsx-team' ), |
|
52 | - 'search_items' => esc_html__( 'Search Team Members', 'lsx-team' ), |
|
53 | - 'not_found' => esc_html__( 'No team members found', 'lsx-team' ), |
|
54 | - 'not_found_in_trash' => esc_html__( 'No team members found in Trash', 'lsx-team' ), |
|
55 | - 'parent_item_colon' => '', |
|
56 | - 'menu_name' => esc_html_x( 'Team Members', 'admin menu', 'lsx-team' ), |
|
57 | - ); |
|
58 | - |
|
59 | - $args = array( |
|
60 | - 'labels' => $labels, |
|
61 | - 'public' => true, |
|
62 | - 'publicly_queryable' => true, |
|
63 | - 'show_ui' => true, |
|
64 | - 'show_in_menu' => true, |
|
65 | - 'menu_icon' => 'dashicons-groups', |
|
66 | - 'query_var' => true, |
|
67 | - 'rewrite' => array( |
|
68 | - 'slug' => 'team', |
|
69 | - ), |
|
70 | - 'capability_type' => 'post', |
|
71 | - 'has_archive' => 'team', |
|
72 | - 'hierarchical' => false, |
|
73 | - 'menu_position' => null, |
|
74 | - 'supports' => array( |
|
75 | - 'title', |
|
76 | - 'editor', |
|
77 | - 'excerpt', |
|
78 | - 'thumbnail', |
|
79 | - 'custom-fields', |
|
80 | - ), |
|
81 | - 'show_in_rest' => true, |
|
82 | - ); |
|
83 | - |
|
84 | - register_post_type( 'team', $args ); |
|
85 | - } |
|
86 | - |
|
87 | - public function taxonomy_setup() { |
|
88 | - $labels = array( |
|
89 | - 'name' => esc_html_x( 'Roles', 'taxonomy general name', 'lsx-team' ), |
|
90 | - 'singular_name' => esc_html_x( 'Role', 'taxonomy singular name', 'lsx-team' ), |
|
91 | - 'search_items' => esc_html__( 'Search Roles', 'lsx-team' ), |
|
92 | - 'all_items' => esc_html__( 'All Roles', 'lsx-team' ), |
|
93 | - 'parent_item' => esc_html__( 'Parent Role', 'lsx-team' ), |
|
94 | - 'parent_item_colon' => esc_html__( 'Parent Role:', 'lsx-team' ), |
|
95 | - 'edit_item' => esc_html__( 'Edit Role', 'lsx-team' ), |
|
96 | - 'update_item' => esc_html__( 'Update Role', 'lsx-team' ), |
|
97 | - 'add_new_item' => esc_html__( 'Add New Role', 'lsx-team' ), |
|
98 | - 'new_item_name' => esc_html__( 'New Role Name', 'lsx-team' ), |
|
99 | - 'menu_name' => esc_html__( 'Roles', 'lsx-team' ), |
|
100 | - ); |
|
101 | - |
|
102 | - $args = array( |
|
103 | - 'hierarchical' => true, |
|
104 | - 'labels' => $labels, |
|
105 | - 'show_ui' => true, |
|
106 | - 'show_admin_column' => true, |
|
107 | - 'query_var' => true, |
|
108 | - 'rewrite' => array( |
|
109 | - 'slug' => 'team-role', |
|
110 | - ), |
|
111 | - 'show_in_rest' => true, |
|
112 | - ); |
|
113 | - |
|
114 | - register_taxonomy( 'team_role', array( 'team' ), $args ); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * Define the metabox and field configurations. |
|
119 | - */ |
|
120 | - public function details_metabox() { |
|
121 | - |
|
122 | - $prefix = 'lsx_'; |
|
123 | - |
|
124 | - $users = get_transient( 'lsx_team_users' ); |
|
125 | - |
|
126 | - if ( false === $users || '' === $users ) { |
|
127 | - $users = get_users( array( |
|
128 | - 'role__in' => array( 'administrator', 'editor', 'author' ), |
|
129 | - ) ); |
|
130 | - set_transient( 'lsx_team_users', $users, 5 * 60 ); |
|
131 | - } |
|
132 | - |
|
133 | - foreach ( $users as $user ) { |
|
134 | - $user_array[$user->ID] = $user->user_login; |
|
135 | - } |
|
136 | - |
|
137 | - $cmb = new_cmb2_box( |
|
138 | - array( |
|
139 | - 'id' => $prefix . '_team', |
|
140 | - 'title' => esc_html__( 'Team Member Details', 'lsx-team' ), |
|
141 | - 'object_types' => 'team', |
|
142 | - 'context' => 'normal', |
|
143 | - 'priority' => 'low', |
|
144 | - 'show_names' => true, |
|
145 | - ) |
|
146 | - ); |
|
147 | - |
|
148 | - $cmb->add_field( |
|
149 | - array( |
|
150 | - 'name' => esc_html__( 'Featured:', 'lsx-team' ), |
|
151 | - 'id' => $prefix . 'featured', |
|
152 | - 'type' => 'checkbox', |
|
153 | - 'value' => 1, |
|
154 | - 'default' => 0, |
|
155 | - 'show_in_rest' => true, |
|
156 | - ) |
|
157 | - ); |
|
158 | - |
|
159 | - $cmb->add_field( |
|
160 | - array( |
|
161 | - 'name' => esc_html__( 'Site User', 'lsx-team' ), |
|
162 | - 'id' => $prefix . 'site_user', |
|
163 | - 'allow_none' => true, |
|
164 | - 'type' => 'select', |
|
165 | - 'options' => $user_array, |
|
166 | - 'show_in_rest' => true, |
|
167 | - ) |
|
168 | - ); |
|
169 | - |
|
170 | - $cmb->add_field( |
|
171 | - array( |
|
172 | - 'name' => esc_html__( 'Job Title:', 'lsx-team' ), |
|
173 | - 'id' => $prefix . 'job_title', |
|
174 | - 'type' => 'text', |
|
175 | - 'show_in_rest' => true, |
|
176 | - ) |
|
177 | - ); |
|
178 | - |
|
179 | - $cmb->add_field( |
|
180 | - array( |
|
181 | - 'name' => esc_html__( 'Location:', 'lsx-team' ), |
|
182 | - 'id' => $prefix . 'location', |
|
183 | - 'type' => 'text', |
|
184 | - 'show_in_rest' => true, |
|
185 | - ) |
|
186 | - ); |
|
187 | - |
|
188 | - $cmb->add_field( |
|
189 | - array( |
|
190 | - 'name' => esc_html__( 'Contact Email Address:', 'lsx-team' ), |
|
191 | - 'id' => $prefix . 'email_contact', |
|
192 | - 'type' => 'text', |
|
193 | - 'show_in_rest' => true, |
|
194 | - ) |
|
195 | - ); |
|
196 | - |
|
197 | - $cmb->add_field( |
|
198 | - array( |
|
199 | - 'name' => esc_html__( 'Gravatar Email Address:', 'lsx-team' ), |
|
200 | - 'desc' => esc_html__( 'Used for Gravatar if a featured image is not set', 'lsx-team' ), |
|
201 | - 'id' => $prefix . 'email_gravatar', |
|
202 | - 'type' => 'text', |
|
203 | - 'show_in_rest' => true, |
|
204 | - ) |
|
205 | - ); |
|
206 | - |
|
207 | - $cmb->add_field( |
|
208 | - array( |
|
209 | - 'name' => esc_html__( 'Telephone Number:', 'lsx-team' ), |
|
210 | - 'id' => $prefix . 'tel', |
|
211 | - 'type' => 'text', |
|
212 | - 'show_in_rest' => true, |
|
213 | - ) |
|
214 | - ); |
|
215 | - |
|
216 | - $cmb->add_field( |
|
217 | - array( |
|
218 | - 'name' => esc_html__( 'Skype Name:', 'lsx-team' ), |
|
219 | - 'id' => $prefix . 'skype', |
|
220 | - 'type' => 'text', |
|
221 | - 'show_in_rest' => true, |
|
222 | - ) |
|
223 | - ); |
|
224 | - |
|
225 | - $cmb->add_field( |
|
226 | - array( |
|
227 | - 'name' => esc_html__( 'Facebook URL', 'lsx-team' ), |
|
228 | - 'id' => $prefix . 'facebook', |
|
229 | - 'type' => 'text_url', |
|
230 | - 'show_in_rest' => true, |
|
231 | - ) |
|
232 | - ); |
|
233 | - |
|
234 | - $cmb->add_field( |
|
235 | - array( |
|
236 | - 'name' => esc_html__( 'Twitter URL', 'lsx-team' ), |
|
237 | - 'id' => $prefix . 'twitter', |
|
238 | - 'type' => 'text_url', |
|
239 | - 'show_in_rest' => true, |
|
240 | - ) |
|
241 | - ); |
|
242 | - |
|
243 | - $cmb->add_field( |
|
244 | - array( |
|
245 | - 'name' => esc_html__( 'LinkedIn URL', 'lsx-team' ), |
|
246 | - 'id' => $prefix . 'linkedin', |
|
247 | - 'type' => 'text_url', |
|
248 | - 'show_in_rest' => true, |
|
249 | - ) |
|
250 | - ); |
|
251 | - |
|
252 | - $cmb->add_field( |
|
253 | - array( |
|
254 | - 'name' => esc_html__( 'Github URL', 'lsx-team' ), |
|
255 | - 'id' => $prefix . 'github', |
|
256 | - 'type' => 'text_url', |
|
257 | - 'show_in_rest' => true, |
|
258 | - ) |
|
259 | - ); |
|
260 | - |
|
261 | - $cmb->add_field( |
|
262 | - array( |
|
263 | - 'name' => esc_html__( 'WordPress URL', 'lsx-team' ), |
|
264 | - 'id' => $prefix . 'wordpress', |
|
265 | - 'type' => 'text_url', |
|
266 | - 'show_in_rest' => true, |
|
267 | - ) |
|
268 | - ); |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Define the metabox and field configurations. |
|
273 | - */ |
|
274 | - public function projects_details_metabox() { |
|
275 | - |
|
276 | - if ( class_exists( 'LSX_Projects' ) ) { |
|
277 | - |
|
278 | - $prefix = 'lsx_'; |
|
279 | - |
|
280 | - $cmb = new_cmb2_box( |
|
281 | - array( |
|
282 | - 'id' => $prefix . '_team', |
|
283 | - 'context' => 'normal', |
|
284 | - 'priority' => 'low', |
|
285 | - 'show_names' => true, |
|
286 | - 'object_types' => array( 'team' ), |
|
287 | - ) |
|
288 | - ); |
|
289 | - $cmb->add_field( |
|
290 | - array( |
|
291 | - 'name' => __( 'Projects:', 'lsx-team' ), |
|
292 | - 'id' => 'project_to_team', |
|
293 | - 'type' => 'post_search_ajax', |
|
294 | - 'limit' => 15, |
|
295 | - 'sortable' => true, |
|
296 | - 'query_args' => array( |
|
297 | - 'post_type' => array( 'project' ), |
|
298 | - 'post_status' => array( 'publish' ), |
|
299 | - 'posts_per_page' => -1, |
|
300 | - ), |
|
301 | - ) |
|
302 | - ); |
|
303 | - } |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Define the metabox and field configurations. |
|
308 | - */ |
|
309 | - public function services_details_metabox() { |
|
310 | - |
|
311 | - if ( class_exists( 'LSX_Services' ) ) { |
|
312 | - |
|
313 | - $prefix = 'lsx_'; |
|
314 | - |
|
315 | - $cmb = new_cmb2_box( |
|
316 | - array( |
|
317 | - 'id' => $prefix . '_team', |
|
318 | - 'context' => 'normal', |
|
319 | - 'priority' => 'low', |
|
320 | - 'show_names' => true, |
|
321 | - 'object_types' => array( 'team' ), |
|
322 | - ) |
|
323 | - ); |
|
324 | - $cmb->add_field( |
|
325 | - array( |
|
326 | - 'name' => __( 'Services:', 'lsx-team' ), |
|
327 | - 'id' => 'service_to_team', |
|
328 | - 'type' => 'post_search_ajax', |
|
329 | - 'limit' => 15, |
|
330 | - 'sortable' => true, |
|
331 | - 'query_args' => array( |
|
332 | - 'post_type' => array( 'service' ), |
|
333 | - 'post_status' => array( 'publish' ), |
|
334 | - 'posts_per_page' => -1, |
|
335 | - ), |
|
336 | - ) |
|
337 | - ); |
|
338 | - } |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Define the metabox and field configurations. |
|
343 | - */ |
|
344 | - public function testimonials_details_metabox() { |
|
345 | - |
|
346 | - if ( class_exists( 'LSX_Testimonials' ) ) { |
|
347 | - |
|
348 | - $prefix = 'lsx_'; |
|
349 | - |
|
350 | - $cmb = new_cmb2_box( |
|
351 | - array( |
|
352 | - 'id' => $prefix . '_team', |
|
353 | - 'context' => 'normal', |
|
354 | - 'priority' => 'low', |
|
355 | - 'show_names' => true, |
|
356 | - 'object_types' => array( 'team' ), |
|
357 | - ) |
|
358 | - ); |
|
359 | - $cmb->add_field( |
|
360 | - array( |
|
361 | - 'name' => __( 'Testimonials:', 'lsx-team' ), |
|
362 | - 'id' => 'testimonial_to_team', |
|
363 | - 'type' => 'post_search_ajax', |
|
364 | - 'limit' => 15, |
|
365 | - 'sortable' => true, |
|
366 | - 'query_args' => array( |
|
367 | - 'post_type' => array( 'testimonial' ), |
|
368 | - 'post_status' => array( 'publish' ), |
|
369 | - 'posts_per_page' => -1, |
|
370 | - ), |
|
371 | - ) |
|
372 | - ); |
|
373 | - } |
|
374 | - |
|
375 | - } |
|
376 | - |
|
377 | - /** |
|
378 | - * Sets up the "post relations". |
|
379 | - */ |
|
380 | - public function post_relations( $post_id, $field, $value ) { |
|
381 | - $connections = array( |
|
382 | - 'team_to_testimonial', |
|
383 | - 'testimonial_to_team', |
|
384 | - |
|
385 | - 'team_to_project', |
|
386 | - 'project_to_team', |
|
387 | - |
|
388 | - 'team_to_service', |
|
389 | - 'service_to_team', |
|
390 | - ); |
|
391 | - |
|
392 | - if ( in_array( $field['id'], $connections ) ) { |
|
393 | - $this->save_related_post( $connections, $post_id, $field, $value ); |
|
394 | - } |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Save the reverse post relation. |
|
399 | - */ |
|
400 | - public function save_related_post( $connections, $post_id, $field, $value ) { |
|
401 | - $ids = explode( '_to_', $field['id'] ); |
|
402 | - $relation = $ids[1] . '_to_' . $ids[0]; |
|
403 | - |
|
404 | - if ( in_array( $relation, $connections ) ) { |
|
405 | - $previous_values = get_post_meta( $post_id, $field['id'], false ); |
|
406 | - |
|
407 | - if ( ! empty( $previous_values ) ) { |
|
408 | - foreach ( $previous_values as $v ) { |
|
409 | - delete_post_meta( $v, $relation, $post_id ); |
|
410 | - } |
|
411 | - } |
|
412 | - |
|
413 | - if ( is_array( $value ) ) { |
|
414 | - foreach ( $value as $v ) { |
|
415 | - if ( ! empty( $v ) ) { |
|
416 | - add_post_meta( $v, $relation, $post_id ); |
|
417 | - } |
|
418 | - } |
|
419 | - } |
|
420 | - } |
|
421 | - } |
|
422 | - |
|
423 | - public function assets() { |
|
424 | - //wp_enqueue_media(); |
|
425 | - wp_enqueue_script( 'media-upload' ); |
|
426 | - wp_enqueue_script( 'thickbox' ); |
|
427 | - wp_enqueue_style( 'thickbox' ); |
|
428 | - |
|
429 | - wp_enqueue_script( 'lsx-team-admin', LSX_TEAM_URL . 'assets/js/lsx-team-admin.min.js', array( 'jquery' ), LSX_TEAM_VER ); |
|
430 | - wp_enqueue_style( 'lsx-team-admin', LSX_TEAM_URL . 'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER ); |
|
431 | - } |
|
432 | - |
|
433 | - /** |
|
434 | - * Change the "Insert into Post" button text when media modal is used for feature images |
|
435 | - */ |
|
436 | - public function change_attachment_field_button( $html ) { |
|
437 | - if ( isset( $_GET['feature_image_text_button'] ) ) { |
|
438 | - $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-team' ) ), $html ); |
|
439 | - } |
|
440 | - |
|
441 | - return $html; |
|
442 | - } |
|
443 | - |
|
444 | - public function change_title_text( $title ) { |
|
445 | - $screen = get_current_screen(); |
|
446 | - |
|
447 | - if ( 'team' === $screen->post_type ) { |
|
448 | - $title = esc_attr__( 'Enter team member name', 'lsx-team' ); |
|
449 | - } |
|
450 | - |
|
451 | - return $title; |
|
452 | - } |
|
14 | + public function __construct() { |
|
15 | + $this->load_classes(); |
|
16 | + |
|
17 | + add_action( 'init', array( $this, 'post_type_setup' ) ); |
|
18 | + add_action( 'init', array( $this, 'taxonomy_setup' ) ); |
|
19 | + |
|
20 | + add_action( 'cmb2_admin_init', array( $this, 'details_metabox' ) ); |
|
21 | + add_action( 'cmb2_admin_init', array( $this, 'projects_details_metabox' ) ); |
|
22 | + add_action( 'cmb2_admin_init', array( $this, 'services_details_metabox' ) ); |
|
23 | + add_action( 'cmb2_admin_init', array( $this, 'testimonials_details_metabox' ) ); |
|
24 | + |
|
25 | + add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
26 | + |
|
27 | + add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 ); |
|
28 | + add_filter( 'enter_title_here', array( $this, 'change_title_text' ) ); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Loads the admin subclasses |
|
33 | + */ |
|
34 | + private function load_classes() { |
|
35 | + require_once LSX_TEAM_PATH . 'classes/admin/class-settings.php'; |
|
36 | + $this->settings = \lsx\team\classes\admin\Settings::get_instance(); |
|
37 | + |
|
38 | + require_once LSX_TEAM_PATH . 'classes/admin/class-settings-theme.php'; |
|
39 | + $this->settings_theme = \lsx\team\classes\admin\Settings_Theme::get_instance(); |
|
40 | + } |
|
41 | + |
|
42 | + public function post_type_setup() { |
|
43 | + $labels = array( |
|
44 | + 'name' => esc_html_x( 'Team Members', 'post type general name', 'lsx-team' ), |
|
45 | + 'singular_name' => esc_html_x( 'Team Member', 'post type singular name', 'lsx-team' ), |
|
46 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-team' ), |
|
47 | + 'add_new_item' => esc_html__( 'Add New Team Member', 'lsx-team' ), |
|
48 | + 'edit_item' => esc_html__( 'Edit Team Member', 'lsx-team' ), |
|
49 | + 'new_item' => esc_html__( 'New Team Member', 'lsx-team' ), |
|
50 | + 'all_items' => esc_html__( 'All Team Members', 'lsx-team' ), |
|
51 | + 'view_item' => esc_html__( 'View Team Member', 'lsx-team' ), |
|
52 | + 'search_items' => esc_html__( 'Search Team Members', 'lsx-team' ), |
|
53 | + 'not_found' => esc_html__( 'No team members found', 'lsx-team' ), |
|
54 | + 'not_found_in_trash' => esc_html__( 'No team members found in Trash', 'lsx-team' ), |
|
55 | + 'parent_item_colon' => '', |
|
56 | + 'menu_name' => esc_html_x( 'Team Members', 'admin menu', 'lsx-team' ), |
|
57 | + ); |
|
58 | + |
|
59 | + $args = array( |
|
60 | + 'labels' => $labels, |
|
61 | + 'public' => true, |
|
62 | + 'publicly_queryable' => true, |
|
63 | + 'show_ui' => true, |
|
64 | + 'show_in_menu' => true, |
|
65 | + 'menu_icon' => 'dashicons-groups', |
|
66 | + 'query_var' => true, |
|
67 | + 'rewrite' => array( |
|
68 | + 'slug' => 'team', |
|
69 | + ), |
|
70 | + 'capability_type' => 'post', |
|
71 | + 'has_archive' => 'team', |
|
72 | + 'hierarchical' => false, |
|
73 | + 'menu_position' => null, |
|
74 | + 'supports' => array( |
|
75 | + 'title', |
|
76 | + 'editor', |
|
77 | + 'excerpt', |
|
78 | + 'thumbnail', |
|
79 | + 'custom-fields', |
|
80 | + ), |
|
81 | + 'show_in_rest' => true, |
|
82 | + ); |
|
83 | + |
|
84 | + register_post_type( 'team', $args ); |
|
85 | + } |
|
86 | + |
|
87 | + public function taxonomy_setup() { |
|
88 | + $labels = array( |
|
89 | + 'name' => esc_html_x( 'Roles', 'taxonomy general name', 'lsx-team' ), |
|
90 | + 'singular_name' => esc_html_x( 'Role', 'taxonomy singular name', 'lsx-team' ), |
|
91 | + 'search_items' => esc_html__( 'Search Roles', 'lsx-team' ), |
|
92 | + 'all_items' => esc_html__( 'All Roles', 'lsx-team' ), |
|
93 | + 'parent_item' => esc_html__( 'Parent Role', 'lsx-team' ), |
|
94 | + 'parent_item_colon' => esc_html__( 'Parent Role:', 'lsx-team' ), |
|
95 | + 'edit_item' => esc_html__( 'Edit Role', 'lsx-team' ), |
|
96 | + 'update_item' => esc_html__( 'Update Role', 'lsx-team' ), |
|
97 | + 'add_new_item' => esc_html__( 'Add New Role', 'lsx-team' ), |
|
98 | + 'new_item_name' => esc_html__( 'New Role Name', 'lsx-team' ), |
|
99 | + 'menu_name' => esc_html__( 'Roles', 'lsx-team' ), |
|
100 | + ); |
|
101 | + |
|
102 | + $args = array( |
|
103 | + 'hierarchical' => true, |
|
104 | + 'labels' => $labels, |
|
105 | + 'show_ui' => true, |
|
106 | + 'show_admin_column' => true, |
|
107 | + 'query_var' => true, |
|
108 | + 'rewrite' => array( |
|
109 | + 'slug' => 'team-role', |
|
110 | + ), |
|
111 | + 'show_in_rest' => true, |
|
112 | + ); |
|
113 | + |
|
114 | + register_taxonomy( 'team_role', array( 'team' ), $args ); |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * Define the metabox and field configurations. |
|
119 | + */ |
|
120 | + public function details_metabox() { |
|
121 | + |
|
122 | + $prefix = 'lsx_'; |
|
123 | + |
|
124 | + $users = get_transient( 'lsx_team_users' ); |
|
125 | + |
|
126 | + if ( false === $users || '' === $users ) { |
|
127 | + $users = get_users( array( |
|
128 | + 'role__in' => array( 'administrator', 'editor', 'author' ), |
|
129 | + ) ); |
|
130 | + set_transient( 'lsx_team_users', $users, 5 * 60 ); |
|
131 | + } |
|
132 | + |
|
133 | + foreach ( $users as $user ) { |
|
134 | + $user_array[$user->ID] = $user->user_login; |
|
135 | + } |
|
136 | + |
|
137 | + $cmb = new_cmb2_box( |
|
138 | + array( |
|
139 | + 'id' => $prefix . '_team', |
|
140 | + 'title' => esc_html__( 'Team Member Details', 'lsx-team' ), |
|
141 | + 'object_types' => 'team', |
|
142 | + 'context' => 'normal', |
|
143 | + 'priority' => 'low', |
|
144 | + 'show_names' => true, |
|
145 | + ) |
|
146 | + ); |
|
147 | + |
|
148 | + $cmb->add_field( |
|
149 | + array( |
|
150 | + 'name' => esc_html__( 'Featured:', 'lsx-team' ), |
|
151 | + 'id' => $prefix . 'featured', |
|
152 | + 'type' => 'checkbox', |
|
153 | + 'value' => 1, |
|
154 | + 'default' => 0, |
|
155 | + 'show_in_rest' => true, |
|
156 | + ) |
|
157 | + ); |
|
158 | + |
|
159 | + $cmb->add_field( |
|
160 | + array( |
|
161 | + 'name' => esc_html__( 'Site User', 'lsx-team' ), |
|
162 | + 'id' => $prefix . 'site_user', |
|
163 | + 'allow_none' => true, |
|
164 | + 'type' => 'select', |
|
165 | + 'options' => $user_array, |
|
166 | + 'show_in_rest' => true, |
|
167 | + ) |
|
168 | + ); |
|
169 | + |
|
170 | + $cmb->add_field( |
|
171 | + array( |
|
172 | + 'name' => esc_html__( 'Job Title:', 'lsx-team' ), |
|
173 | + 'id' => $prefix . 'job_title', |
|
174 | + 'type' => 'text', |
|
175 | + 'show_in_rest' => true, |
|
176 | + ) |
|
177 | + ); |
|
178 | + |
|
179 | + $cmb->add_field( |
|
180 | + array( |
|
181 | + 'name' => esc_html__( 'Location:', 'lsx-team' ), |
|
182 | + 'id' => $prefix . 'location', |
|
183 | + 'type' => 'text', |
|
184 | + 'show_in_rest' => true, |
|
185 | + ) |
|
186 | + ); |
|
187 | + |
|
188 | + $cmb->add_field( |
|
189 | + array( |
|
190 | + 'name' => esc_html__( 'Contact Email Address:', 'lsx-team' ), |
|
191 | + 'id' => $prefix . 'email_contact', |
|
192 | + 'type' => 'text', |
|
193 | + 'show_in_rest' => true, |
|
194 | + ) |
|
195 | + ); |
|
196 | + |
|
197 | + $cmb->add_field( |
|
198 | + array( |
|
199 | + 'name' => esc_html__( 'Gravatar Email Address:', 'lsx-team' ), |
|
200 | + 'desc' => esc_html__( 'Used for Gravatar if a featured image is not set', 'lsx-team' ), |
|
201 | + 'id' => $prefix . 'email_gravatar', |
|
202 | + 'type' => 'text', |
|
203 | + 'show_in_rest' => true, |
|
204 | + ) |
|
205 | + ); |
|
206 | + |
|
207 | + $cmb->add_field( |
|
208 | + array( |
|
209 | + 'name' => esc_html__( 'Telephone Number:', 'lsx-team' ), |
|
210 | + 'id' => $prefix . 'tel', |
|
211 | + 'type' => 'text', |
|
212 | + 'show_in_rest' => true, |
|
213 | + ) |
|
214 | + ); |
|
215 | + |
|
216 | + $cmb->add_field( |
|
217 | + array( |
|
218 | + 'name' => esc_html__( 'Skype Name:', 'lsx-team' ), |
|
219 | + 'id' => $prefix . 'skype', |
|
220 | + 'type' => 'text', |
|
221 | + 'show_in_rest' => true, |
|
222 | + ) |
|
223 | + ); |
|
224 | + |
|
225 | + $cmb->add_field( |
|
226 | + array( |
|
227 | + 'name' => esc_html__( 'Facebook URL', 'lsx-team' ), |
|
228 | + 'id' => $prefix . 'facebook', |
|
229 | + 'type' => 'text_url', |
|
230 | + 'show_in_rest' => true, |
|
231 | + ) |
|
232 | + ); |
|
233 | + |
|
234 | + $cmb->add_field( |
|
235 | + array( |
|
236 | + 'name' => esc_html__( 'Twitter URL', 'lsx-team' ), |
|
237 | + 'id' => $prefix . 'twitter', |
|
238 | + 'type' => 'text_url', |
|
239 | + 'show_in_rest' => true, |
|
240 | + ) |
|
241 | + ); |
|
242 | + |
|
243 | + $cmb->add_field( |
|
244 | + array( |
|
245 | + 'name' => esc_html__( 'LinkedIn URL', 'lsx-team' ), |
|
246 | + 'id' => $prefix . 'linkedin', |
|
247 | + 'type' => 'text_url', |
|
248 | + 'show_in_rest' => true, |
|
249 | + ) |
|
250 | + ); |
|
251 | + |
|
252 | + $cmb->add_field( |
|
253 | + array( |
|
254 | + 'name' => esc_html__( 'Github URL', 'lsx-team' ), |
|
255 | + 'id' => $prefix . 'github', |
|
256 | + 'type' => 'text_url', |
|
257 | + 'show_in_rest' => true, |
|
258 | + ) |
|
259 | + ); |
|
260 | + |
|
261 | + $cmb->add_field( |
|
262 | + array( |
|
263 | + 'name' => esc_html__( 'WordPress URL', 'lsx-team' ), |
|
264 | + 'id' => $prefix . 'wordpress', |
|
265 | + 'type' => 'text_url', |
|
266 | + 'show_in_rest' => true, |
|
267 | + ) |
|
268 | + ); |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Define the metabox and field configurations. |
|
273 | + */ |
|
274 | + public function projects_details_metabox() { |
|
275 | + |
|
276 | + if ( class_exists( 'LSX_Projects' ) ) { |
|
277 | + |
|
278 | + $prefix = 'lsx_'; |
|
279 | + |
|
280 | + $cmb = new_cmb2_box( |
|
281 | + array( |
|
282 | + 'id' => $prefix . '_team', |
|
283 | + 'context' => 'normal', |
|
284 | + 'priority' => 'low', |
|
285 | + 'show_names' => true, |
|
286 | + 'object_types' => array( 'team' ), |
|
287 | + ) |
|
288 | + ); |
|
289 | + $cmb->add_field( |
|
290 | + array( |
|
291 | + 'name' => __( 'Projects:', 'lsx-team' ), |
|
292 | + 'id' => 'project_to_team', |
|
293 | + 'type' => 'post_search_ajax', |
|
294 | + 'limit' => 15, |
|
295 | + 'sortable' => true, |
|
296 | + 'query_args' => array( |
|
297 | + 'post_type' => array( 'project' ), |
|
298 | + 'post_status' => array( 'publish' ), |
|
299 | + 'posts_per_page' => -1, |
|
300 | + ), |
|
301 | + ) |
|
302 | + ); |
|
303 | + } |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Define the metabox and field configurations. |
|
308 | + */ |
|
309 | + public function services_details_metabox() { |
|
310 | + |
|
311 | + if ( class_exists( 'LSX_Services' ) ) { |
|
312 | + |
|
313 | + $prefix = 'lsx_'; |
|
314 | + |
|
315 | + $cmb = new_cmb2_box( |
|
316 | + array( |
|
317 | + 'id' => $prefix . '_team', |
|
318 | + 'context' => 'normal', |
|
319 | + 'priority' => 'low', |
|
320 | + 'show_names' => true, |
|
321 | + 'object_types' => array( 'team' ), |
|
322 | + ) |
|
323 | + ); |
|
324 | + $cmb->add_field( |
|
325 | + array( |
|
326 | + 'name' => __( 'Services:', 'lsx-team' ), |
|
327 | + 'id' => 'service_to_team', |
|
328 | + 'type' => 'post_search_ajax', |
|
329 | + 'limit' => 15, |
|
330 | + 'sortable' => true, |
|
331 | + 'query_args' => array( |
|
332 | + 'post_type' => array( 'service' ), |
|
333 | + 'post_status' => array( 'publish' ), |
|
334 | + 'posts_per_page' => -1, |
|
335 | + ), |
|
336 | + ) |
|
337 | + ); |
|
338 | + } |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Define the metabox and field configurations. |
|
343 | + */ |
|
344 | + public function testimonials_details_metabox() { |
|
345 | + |
|
346 | + if ( class_exists( 'LSX_Testimonials' ) ) { |
|
347 | + |
|
348 | + $prefix = 'lsx_'; |
|
349 | + |
|
350 | + $cmb = new_cmb2_box( |
|
351 | + array( |
|
352 | + 'id' => $prefix . '_team', |
|
353 | + 'context' => 'normal', |
|
354 | + 'priority' => 'low', |
|
355 | + 'show_names' => true, |
|
356 | + 'object_types' => array( 'team' ), |
|
357 | + ) |
|
358 | + ); |
|
359 | + $cmb->add_field( |
|
360 | + array( |
|
361 | + 'name' => __( 'Testimonials:', 'lsx-team' ), |
|
362 | + 'id' => 'testimonial_to_team', |
|
363 | + 'type' => 'post_search_ajax', |
|
364 | + 'limit' => 15, |
|
365 | + 'sortable' => true, |
|
366 | + 'query_args' => array( |
|
367 | + 'post_type' => array( 'testimonial' ), |
|
368 | + 'post_status' => array( 'publish' ), |
|
369 | + 'posts_per_page' => -1, |
|
370 | + ), |
|
371 | + ) |
|
372 | + ); |
|
373 | + } |
|
374 | + |
|
375 | + } |
|
376 | + |
|
377 | + /** |
|
378 | + * Sets up the "post relations". |
|
379 | + */ |
|
380 | + public function post_relations( $post_id, $field, $value ) { |
|
381 | + $connections = array( |
|
382 | + 'team_to_testimonial', |
|
383 | + 'testimonial_to_team', |
|
384 | + |
|
385 | + 'team_to_project', |
|
386 | + 'project_to_team', |
|
387 | + |
|
388 | + 'team_to_service', |
|
389 | + 'service_to_team', |
|
390 | + ); |
|
391 | + |
|
392 | + if ( in_array( $field['id'], $connections ) ) { |
|
393 | + $this->save_related_post( $connections, $post_id, $field, $value ); |
|
394 | + } |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | + * Save the reverse post relation. |
|
399 | + */ |
|
400 | + public function save_related_post( $connections, $post_id, $field, $value ) { |
|
401 | + $ids = explode( '_to_', $field['id'] ); |
|
402 | + $relation = $ids[1] . '_to_' . $ids[0]; |
|
403 | + |
|
404 | + if ( in_array( $relation, $connections ) ) { |
|
405 | + $previous_values = get_post_meta( $post_id, $field['id'], false ); |
|
406 | + |
|
407 | + if ( ! empty( $previous_values ) ) { |
|
408 | + foreach ( $previous_values as $v ) { |
|
409 | + delete_post_meta( $v, $relation, $post_id ); |
|
410 | + } |
|
411 | + } |
|
412 | + |
|
413 | + if ( is_array( $value ) ) { |
|
414 | + foreach ( $value as $v ) { |
|
415 | + if ( ! empty( $v ) ) { |
|
416 | + add_post_meta( $v, $relation, $post_id ); |
|
417 | + } |
|
418 | + } |
|
419 | + } |
|
420 | + } |
|
421 | + } |
|
422 | + |
|
423 | + public function assets() { |
|
424 | + //wp_enqueue_media(); |
|
425 | + wp_enqueue_script( 'media-upload' ); |
|
426 | + wp_enqueue_script( 'thickbox' ); |
|
427 | + wp_enqueue_style( 'thickbox' ); |
|
428 | + |
|
429 | + wp_enqueue_script( 'lsx-team-admin', LSX_TEAM_URL . 'assets/js/lsx-team-admin.min.js', array( 'jquery' ), LSX_TEAM_VER ); |
|
430 | + wp_enqueue_style( 'lsx-team-admin', LSX_TEAM_URL . 'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER ); |
|
431 | + } |
|
432 | + |
|
433 | + /** |
|
434 | + * Change the "Insert into Post" button text when media modal is used for feature images |
|
435 | + */ |
|
436 | + public function change_attachment_field_button( $html ) { |
|
437 | + if ( isset( $_GET['feature_image_text_button'] ) ) { |
|
438 | + $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-team' ) ), $html ); |
|
439 | + } |
|
440 | + |
|
441 | + return $html; |
|
442 | + } |
|
443 | + |
|
444 | + public function change_title_text( $title ) { |
|
445 | + $screen = get_current_screen(); |
|
446 | + |
|
447 | + if ( 'team' === $screen->post_type ) { |
|
448 | + $title = esc_attr__( 'Enter team member name', 'lsx-team' ); |
|
449 | + } |
|
450 | + |
|
451 | + return $title; |
|
452 | + } |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | $lsx_team_admin = new LSX_Team_Admin(); |
@@ -14,46 +14,46 @@ discard block |
||
14 | 14 | public function __construct() { |
15 | 15 | $this->load_classes(); |
16 | 16 | |
17 | - add_action( 'init', array( $this, 'post_type_setup' ) ); |
|
18 | - add_action( 'init', array( $this, 'taxonomy_setup' ) ); |
|
17 | + add_action('init', array($this, 'post_type_setup')); |
|
18 | + add_action('init', array($this, 'taxonomy_setup')); |
|
19 | 19 | |
20 | - add_action( 'cmb2_admin_init', array( $this, 'details_metabox' ) ); |
|
21 | - add_action( 'cmb2_admin_init', array( $this, 'projects_details_metabox' ) ); |
|
22 | - add_action( 'cmb2_admin_init', array( $this, 'services_details_metabox' ) ); |
|
23 | - add_action( 'cmb2_admin_init', array( $this, 'testimonials_details_metabox' ) ); |
|
20 | + add_action('cmb2_admin_init', array($this, 'details_metabox')); |
|
21 | + add_action('cmb2_admin_init', array($this, 'projects_details_metabox')); |
|
22 | + add_action('cmb2_admin_init', array($this, 'services_details_metabox')); |
|
23 | + add_action('cmb2_admin_init', array($this, 'testimonials_details_metabox')); |
|
24 | 24 | |
25 | - add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
25 | + add_action('admin_enqueue_scripts', array($this, 'assets')); |
|
26 | 26 | |
27 | - add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 ); |
|
28 | - add_filter( 'enter_title_here', array( $this, 'change_title_text' ) ); |
|
27 | + add_filter('type_url_form_media', array($this, 'change_attachment_field_button'), 20, 1); |
|
28 | + add_filter('enter_title_here', array($this, 'change_title_text')); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Loads the admin subclasses |
33 | 33 | */ |
34 | 34 | private function load_classes() { |
35 | - require_once LSX_TEAM_PATH . 'classes/admin/class-settings.php'; |
|
35 | + require_once LSX_TEAM_PATH.'classes/admin/class-settings.php'; |
|
36 | 36 | $this->settings = \lsx\team\classes\admin\Settings::get_instance(); |
37 | 37 | |
38 | - require_once LSX_TEAM_PATH . 'classes/admin/class-settings-theme.php'; |
|
38 | + require_once LSX_TEAM_PATH.'classes/admin/class-settings-theme.php'; |
|
39 | 39 | $this->settings_theme = \lsx\team\classes\admin\Settings_Theme::get_instance(); |
40 | 40 | } |
41 | 41 | |
42 | 42 | public function post_type_setup() { |
43 | 43 | $labels = array( |
44 | - 'name' => esc_html_x( 'Team Members', 'post type general name', 'lsx-team' ), |
|
45 | - 'singular_name' => esc_html_x( 'Team Member', 'post type singular name', 'lsx-team' ), |
|
46 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-team' ), |
|
47 | - 'add_new_item' => esc_html__( 'Add New Team Member', 'lsx-team' ), |
|
48 | - 'edit_item' => esc_html__( 'Edit Team Member', 'lsx-team' ), |
|
49 | - 'new_item' => esc_html__( 'New Team Member', 'lsx-team' ), |
|
50 | - 'all_items' => esc_html__( 'All Team Members', 'lsx-team' ), |
|
51 | - 'view_item' => esc_html__( 'View Team Member', 'lsx-team' ), |
|
52 | - 'search_items' => esc_html__( 'Search Team Members', 'lsx-team' ), |
|
53 | - 'not_found' => esc_html__( 'No team members found', 'lsx-team' ), |
|
54 | - 'not_found_in_trash' => esc_html__( 'No team members found in Trash', 'lsx-team' ), |
|
44 | + 'name' => esc_html_x('Team Members', 'post type general name', 'lsx-team'), |
|
45 | + 'singular_name' => esc_html_x('Team Member', 'post type singular name', 'lsx-team'), |
|
46 | + 'add_new' => esc_html_x('Add New', 'post type general name', 'lsx-team'), |
|
47 | + 'add_new_item' => esc_html__('Add New Team Member', 'lsx-team'), |
|
48 | + 'edit_item' => esc_html__('Edit Team Member', 'lsx-team'), |
|
49 | + 'new_item' => esc_html__('New Team Member', 'lsx-team'), |
|
50 | + 'all_items' => esc_html__('All Team Members', 'lsx-team'), |
|
51 | + 'view_item' => esc_html__('View Team Member', 'lsx-team'), |
|
52 | + 'search_items' => esc_html__('Search Team Members', 'lsx-team'), |
|
53 | + 'not_found' => esc_html__('No team members found', 'lsx-team'), |
|
54 | + 'not_found_in_trash' => esc_html__('No team members found in Trash', 'lsx-team'), |
|
55 | 55 | 'parent_item_colon' => '', |
56 | - 'menu_name' => esc_html_x( 'Team Members', 'admin menu', 'lsx-team' ), |
|
56 | + 'menu_name' => esc_html_x('Team Members', 'admin menu', 'lsx-team'), |
|
57 | 57 | ); |
58 | 58 | |
59 | 59 | $args = array( |
@@ -81,22 +81,22 @@ discard block |
||
81 | 81 | 'show_in_rest' => true, |
82 | 82 | ); |
83 | 83 | |
84 | - register_post_type( 'team', $args ); |
|
84 | + register_post_type('team', $args); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public function taxonomy_setup() { |
88 | 88 | $labels = array( |
89 | - 'name' => esc_html_x( 'Roles', 'taxonomy general name', 'lsx-team' ), |
|
90 | - 'singular_name' => esc_html_x( 'Role', 'taxonomy singular name', 'lsx-team' ), |
|
91 | - 'search_items' => esc_html__( 'Search Roles', 'lsx-team' ), |
|
92 | - 'all_items' => esc_html__( 'All Roles', 'lsx-team' ), |
|
93 | - 'parent_item' => esc_html__( 'Parent Role', 'lsx-team' ), |
|
94 | - 'parent_item_colon' => esc_html__( 'Parent Role:', 'lsx-team' ), |
|
95 | - 'edit_item' => esc_html__( 'Edit Role', 'lsx-team' ), |
|
96 | - 'update_item' => esc_html__( 'Update Role', 'lsx-team' ), |
|
97 | - 'add_new_item' => esc_html__( 'Add New Role', 'lsx-team' ), |
|
98 | - 'new_item_name' => esc_html__( 'New Role Name', 'lsx-team' ), |
|
99 | - 'menu_name' => esc_html__( 'Roles', 'lsx-team' ), |
|
89 | + 'name' => esc_html_x('Roles', 'taxonomy general name', 'lsx-team'), |
|
90 | + 'singular_name' => esc_html_x('Role', 'taxonomy singular name', 'lsx-team'), |
|
91 | + 'search_items' => esc_html__('Search Roles', 'lsx-team'), |
|
92 | + 'all_items' => esc_html__('All Roles', 'lsx-team'), |
|
93 | + 'parent_item' => esc_html__('Parent Role', 'lsx-team'), |
|
94 | + 'parent_item_colon' => esc_html__('Parent Role:', 'lsx-team'), |
|
95 | + 'edit_item' => esc_html__('Edit Role', 'lsx-team'), |
|
96 | + 'update_item' => esc_html__('Update Role', 'lsx-team'), |
|
97 | + 'add_new_item' => esc_html__('Add New Role', 'lsx-team'), |
|
98 | + 'new_item_name' => esc_html__('New Role Name', 'lsx-team'), |
|
99 | + 'menu_name' => esc_html__('Roles', 'lsx-team'), |
|
100 | 100 | ); |
101 | 101 | |
102 | 102 | $args = array( |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'show_in_rest' => true, |
112 | 112 | ); |
113 | 113 | |
114 | - register_taxonomy( 'team_role', array( 'team' ), $args ); |
|
114 | + register_taxonomy('team_role', array('team'), $args); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -121,23 +121,23 @@ discard block |
||
121 | 121 | |
122 | 122 | $prefix = 'lsx_'; |
123 | 123 | |
124 | - $users = get_transient( 'lsx_team_users' ); |
|
124 | + $users = get_transient('lsx_team_users'); |
|
125 | 125 | |
126 | - if ( false === $users || '' === $users ) { |
|
127 | - $users = get_users( array( |
|
128 | - 'role__in' => array( 'administrator', 'editor', 'author' ), |
|
129 | - ) ); |
|
130 | - set_transient( 'lsx_team_users', $users, 5 * 60 ); |
|
126 | + if (false === $users || '' === $users) { |
|
127 | + $users = get_users(array( |
|
128 | + 'role__in' => array('administrator', 'editor', 'author'), |
|
129 | + )); |
|
130 | + set_transient('lsx_team_users', $users, 5 * 60); |
|
131 | 131 | } |
132 | 132 | |
133 | - foreach ( $users as $user ) { |
|
133 | + foreach ($users as $user) { |
|
134 | 134 | $user_array[$user->ID] = $user->user_login; |
135 | 135 | } |
136 | 136 | |
137 | 137 | $cmb = new_cmb2_box( |
138 | 138 | array( |
139 | - 'id' => $prefix . '_team', |
|
140 | - 'title' => esc_html__( 'Team Member Details', 'lsx-team' ), |
|
139 | + 'id' => $prefix.'_team', |
|
140 | + 'title' => esc_html__('Team Member Details', 'lsx-team'), |
|
141 | 141 | 'object_types' => 'team', |
142 | 142 | 'context' => 'normal', |
143 | 143 | 'priority' => 'low', |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | |
148 | 148 | $cmb->add_field( |
149 | 149 | array( |
150 | - 'name' => esc_html__( 'Featured:', 'lsx-team' ), |
|
151 | - 'id' => $prefix . 'featured', |
|
150 | + 'name' => esc_html__('Featured:', 'lsx-team'), |
|
151 | + 'id' => $prefix.'featured', |
|
152 | 152 | 'type' => 'checkbox', |
153 | 153 | 'value' => 1, |
154 | 154 | 'default' => 0, |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | |
159 | 159 | $cmb->add_field( |
160 | 160 | array( |
161 | - 'name' => esc_html__( 'Site User', 'lsx-team' ), |
|
162 | - 'id' => $prefix . 'site_user', |
|
161 | + 'name' => esc_html__('Site User', 'lsx-team'), |
|
162 | + 'id' => $prefix.'site_user', |
|
163 | 163 | 'allow_none' => true, |
164 | 164 | 'type' => 'select', |
165 | 165 | 'options' => $user_array, |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | |
170 | 170 | $cmb->add_field( |
171 | 171 | array( |
172 | - 'name' => esc_html__( 'Job Title:', 'lsx-team' ), |
|
173 | - 'id' => $prefix . 'job_title', |
|
172 | + 'name' => esc_html__('Job Title:', 'lsx-team'), |
|
173 | + 'id' => $prefix.'job_title', |
|
174 | 174 | 'type' => 'text', |
175 | 175 | 'show_in_rest' => true, |
176 | 176 | ) |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | |
179 | 179 | $cmb->add_field( |
180 | 180 | array( |
181 | - 'name' => esc_html__( 'Location:', 'lsx-team' ), |
|
182 | - 'id' => $prefix . 'location', |
|
181 | + 'name' => esc_html__('Location:', 'lsx-team'), |
|
182 | + 'id' => $prefix.'location', |
|
183 | 183 | 'type' => 'text', |
184 | 184 | 'show_in_rest' => true, |
185 | 185 | ) |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | |
188 | 188 | $cmb->add_field( |
189 | 189 | array( |
190 | - 'name' => esc_html__( 'Contact Email Address:', 'lsx-team' ), |
|
191 | - 'id' => $prefix . 'email_contact', |
|
190 | + 'name' => esc_html__('Contact Email Address:', 'lsx-team'), |
|
191 | + 'id' => $prefix.'email_contact', |
|
192 | 192 | 'type' => 'text', |
193 | 193 | 'show_in_rest' => true, |
194 | 194 | ) |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | |
197 | 197 | $cmb->add_field( |
198 | 198 | array( |
199 | - 'name' => esc_html__( 'Gravatar Email Address:', 'lsx-team' ), |
|
200 | - 'desc' => esc_html__( 'Used for Gravatar if a featured image is not set', 'lsx-team' ), |
|
201 | - 'id' => $prefix . 'email_gravatar', |
|
199 | + 'name' => esc_html__('Gravatar Email Address:', 'lsx-team'), |
|
200 | + 'desc' => esc_html__('Used for Gravatar if a featured image is not set', 'lsx-team'), |
|
201 | + 'id' => $prefix.'email_gravatar', |
|
202 | 202 | 'type' => 'text', |
203 | 203 | 'show_in_rest' => true, |
204 | 204 | ) |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | |
207 | 207 | $cmb->add_field( |
208 | 208 | array( |
209 | - 'name' => esc_html__( 'Telephone Number:', 'lsx-team' ), |
|
210 | - 'id' => $prefix . 'tel', |
|
209 | + 'name' => esc_html__('Telephone Number:', 'lsx-team'), |
|
210 | + 'id' => $prefix.'tel', |
|
211 | 211 | 'type' => 'text', |
212 | 212 | 'show_in_rest' => true, |
213 | 213 | ) |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | |
216 | 216 | $cmb->add_field( |
217 | 217 | array( |
218 | - 'name' => esc_html__( 'Skype Name:', 'lsx-team' ), |
|
219 | - 'id' => $prefix . 'skype', |
|
218 | + 'name' => esc_html__('Skype Name:', 'lsx-team'), |
|
219 | + 'id' => $prefix.'skype', |
|
220 | 220 | 'type' => 'text', |
221 | 221 | 'show_in_rest' => true, |
222 | 222 | ) |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | |
225 | 225 | $cmb->add_field( |
226 | 226 | array( |
227 | - 'name' => esc_html__( 'Facebook URL', 'lsx-team' ), |
|
228 | - 'id' => $prefix . 'facebook', |
|
227 | + 'name' => esc_html__('Facebook URL', 'lsx-team'), |
|
228 | + 'id' => $prefix.'facebook', |
|
229 | 229 | 'type' => 'text_url', |
230 | 230 | 'show_in_rest' => true, |
231 | 231 | ) |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | |
234 | 234 | $cmb->add_field( |
235 | 235 | array( |
236 | - 'name' => esc_html__( 'Twitter URL', 'lsx-team' ), |
|
237 | - 'id' => $prefix . 'twitter', |
|
236 | + 'name' => esc_html__('Twitter URL', 'lsx-team'), |
|
237 | + 'id' => $prefix.'twitter', |
|
238 | 238 | 'type' => 'text_url', |
239 | 239 | 'show_in_rest' => true, |
240 | 240 | ) |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | |
243 | 243 | $cmb->add_field( |
244 | 244 | array( |
245 | - 'name' => esc_html__( 'LinkedIn URL', 'lsx-team' ), |
|
246 | - 'id' => $prefix . 'linkedin', |
|
245 | + 'name' => esc_html__('LinkedIn URL', 'lsx-team'), |
|
246 | + 'id' => $prefix.'linkedin', |
|
247 | 247 | 'type' => 'text_url', |
248 | 248 | 'show_in_rest' => true, |
249 | 249 | ) |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | |
252 | 252 | $cmb->add_field( |
253 | 253 | array( |
254 | - 'name' => esc_html__( 'Github URL', 'lsx-team' ), |
|
255 | - 'id' => $prefix . 'github', |
|
254 | + 'name' => esc_html__('Github URL', 'lsx-team'), |
|
255 | + 'id' => $prefix.'github', |
|
256 | 256 | 'type' => 'text_url', |
257 | 257 | 'show_in_rest' => true, |
258 | 258 | ) |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | |
261 | 261 | $cmb->add_field( |
262 | 262 | array( |
263 | - 'name' => esc_html__( 'WordPress URL', 'lsx-team' ), |
|
264 | - 'id' => $prefix . 'wordpress', |
|
263 | + 'name' => esc_html__('WordPress URL', 'lsx-team'), |
|
264 | + 'id' => $prefix.'wordpress', |
|
265 | 265 | 'type' => 'text_url', |
266 | 266 | 'show_in_rest' => true, |
267 | 267 | ) |
@@ -273,29 +273,29 @@ discard block |
||
273 | 273 | */ |
274 | 274 | public function projects_details_metabox() { |
275 | 275 | |
276 | - if ( class_exists( 'LSX_Projects' ) ) { |
|
276 | + if (class_exists('LSX_Projects')) { |
|
277 | 277 | |
278 | 278 | $prefix = 'lsx_'; |
279 | 279 | |
280 | 280 | $cmb = new_cmb2_box( |
281 | 281 | array( |
282 | - 'id' => $prefix . '_team', |
|
282 | + 'id' => $prefix.'_team', |
|
283 | 283 | 'context' => 'normal', |
284 | 284 | 'priority' => 'low', |
285 | 285 | 'show_names' => true, |
286 | - 'object_types' => array( 'team' ), |
|
286 | + 'object_types' => array('team'), |
|
287 | 287 | ) |
288 | 288 | ); |
289 | 289 | $cmb->add_field( |
290 | 290 | array( |
291 | - 'name' => __( 'Projects:', 'lsx-team' ), |
|
291 | + 'name' => __('Projects:', 'lsx-team'), |
|
292 | 292 | 'id' => 'project_to_team', |
293 | 293 | 'type' => 'post_search_ajax', |
294 | 294 | 'limit' => 15, |
295 | 295 | 'sortable' => true, |
296 | 296 | 'query_args' => array( |
297 | - 'post_type' => array( 'project' ), |
|
298 | - 'post_status' => array( 'publish' ), |
|
297 | + 'post_type' => array('project'), |
|
298 | + 'post_status' => array('publish'), |
|
299 | 299 | 'posts_per_page' => -1, |
300 | 300 | ), |
301 | 301 | ) |
@@ -308,29 +308,29 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function services_details_metabox() { |
310 | 310 | |
311 | - if ( class_exists( 'LSX_Services' ) ) { |
|
311 | + if (class_exists('LSX_Services')) { |
|
312 | 312 | |
313 | 313 | $prefix = 'lsx_'; |
314 | 314 | |
315 | 315 | $cmb = new_cmb2_box( |
316 | 316 | array( |
317 | - 'id' => $prefix . '_team', |
|
317 | + 'id' => $prefix.'_team', |
|
318 | 318 | 'context' => 'normal', |
319 | 319 | 'priority' => 'low', |
320 | 320 | 'show_names' => true, |
321 | - 'object_types' => array( 'team' ), |
|
321 | + 'object_types' => array('team'), |
|
322 | 322 | ) |
323 | 323 | ); |
324 | 324 | $cmb->add_field( |
325 | 325 | array( |
326 | - 'name' => __( 'Services:', 'lsx-team' ), |
|
326 | + 'name' => __('Services:', 'lsx-team'), |
|
327 | 327 | 'id' => 'service_to_team', |
328 | 328 | 'type' => 'post_search_ajax', |
329 | 329 | 'limit' => 15, |
330 | 330 | 'sortable' => true, |
331 | 331 | 'query_args' => array( |
332 | - 'post_type' => array( 'service' ), |
|
333 | - 'post_status' => array( 'publish' ), |
|
332 | + 'post_type' => array('service'), |
|
333 | + 'post_status' => array('publish'), |
|
334 | 334 | 'posts_per_page' => -1, |
335 | 335 | ), |
336 | 336 | ) |
@@ -343,29 +343,29 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function testimonials_details_metabox() { |
345 | 345 | |
346 | - if ( class_exists( 'LSX_Testimonials' ) ) { |
|
346 | + if (class_exists('LSX_Testimonials')) { |
|
347 | 347 | |
348 | 348 | $prefix = 'lsx_'; |
349 | 349 | |
350 | 350 | $cmb = new_cmb2_box( |
351 | 351 | array( |
352 | - 'id' => $prefix . '_team', |
|
352 | + 'id' => $prefix.'_team', |
|
353 | 353 | 'context' => 'normal', |
354 | 354 | 'priority' => 'low', |
355 | 355 | 'show_names' => true, |
356 | - 'object_types' => array( 'team' ), |
|
356 | + 'object_types' => array('team'), |
|
357 | 357 | ) |
358 | 358 | ); |
359 | 359 | $cmb->add_field( |
360 | 360 | array( |
361 | - 'name' => __( 'Testimonials:', 'lsx-team' ), |
|
361 | + 'name' => __('Testimonials:', 'lsx-team'), |
|
362 | 362 | 'id' => 'testimonial_to_team', |
363 | 363 | 'type' => 'post_search_ajax', |
364 | 364 | 'limit' => 15, |
365 | 365 | 'sortable' => true, |
366 | 366 | 'query_args' => array( |
367 | - 'post_type' => array( 'testimonial' ), |
|
368 | - 'post_status' => array( 'publish' ), |
|
367 | + 'post_type' => array('testimonial'), |
|
368 | + 'post_status' => array('publish'), |
|
369 | 369 | 'posts_per_page' => -1, |
370 | 370 | ), |
371 | 371 | ) |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | /** |
378 | 378 | * Sets up the "post relations". |
379 | 379 | */ |
380 | - public function post_relations( $post_id, $field, $value ) { |
|
380 | + public function post_relations($post_id, $field, $value) { |
|
381 | 381 | $connections = array( |
382 | 382 | 'team_to_testimonial', |
383 | 383 | 'testimonial_to_team', |
@@ -389,31 +389,31 @@ discard block |
||
389 | 389 | 'service_to_team', |
390 | 390 | ); |
391 | 391 | |
392 | - if ( in_array( $field['id'], $connections ) ) { |
|
393 | - $this->save_related_post( $connections, $post_id, $field, $value ); |
|
392 | + if (in_array($field['id'], $connections)) { |
|
393 | + $this->save_related_post($connections, $post_id, $field, $value); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
398 | 398 | * Save the reverse post relation. |
399 | 399 | */ |
400 | - public function save_related_post( $connections, $post_id, $field, $value ) { |
|
401 | - $ids = explode( '_to_', $field['id'] ); |
|
402 | - $relation = $ids[1] . '_to_' . $ids[0]; |
|
400 | + public function save_related_post($connections, $post_id, $field, $value) { |
|
401 | + $ids = explode('_to_', $field['id']); |
|
402 | + $relation = $ids[1].'_to_'.$ids[0]; |
|
403 | 403 | |
404 | - if ( in_array( $relation, $connections ) ) { |
|
405 | - $previous_values = get_post_meta( $post_id, $field['id'], false ); |
|
404 | + if (in_array($relation, $connections)) { |
|
405 | + $previous_values = get_post_meta($post_id, $field['id'], false); |
|
406 | 406 | |
407 | - if ( ! empty( $previous_values ) ) { |
|
408 | - foreach ( $previous_values as $v ) { |
|
409 | - delete_post_meta( $v, $relation, $post_id ); |
|
407 | + if (!empty($previous_values)) { |
|
408 | + foreach ($previous_values as $v) { |
|
409 | + delete_post_meta($v, $relation, $post_id); |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | |
413 | - if ( is_array( $value ) ) { |
|
414 | - foreach ( $value as $v ) { |
|
415 | - if ( ! empty( $v ) ) { |
|
416 | - add_post_meta( $v, $relation, $post_id ); |
|
413 | + if (is_array($value)) { |
|
414 | + foreach ($value as $v) { |
|
415 | + if (!empty($v)) { |
|
416 | + add_post_meta($v, $relation, $post_id); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | } |
@@ -422,30 +422,30 @@ discard block |
||
422 | 422 | |
423 | 423 | public function assets() { |
424 | 424 | //wp_enqueue_media(); |
425 | - wp_enqueue_script( 'media-upload' ); |
|
426 | - wp_enqueue_script( 'thickbox' ); |
|
427 | - wp_enqueue_style( 'thickbox' ); |
|
425 | + wp_enqueue_script('media-upload'); |
|
426 | + wp_enqueue_script('thickbox'); |
|
427 | + wp_enqueue_style('thickbox'); |
|
428 | 428 | |
429 | - wp_enqueue_script( 'lsx-team-admin', LSX_TEAM_URL . 'assets/js/lsx-team-admin.min.js', array( 'jquery' ), LSX_TEAM_VER ); |
|
430 | - wp_enqueue_style( 'lsx-team-admin', LSX_TEAM_URL . 'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER ); |
|
429 | + wp_enqueue_script('lsx-team-admin', LSX_TEAM_URL.'assets/js/lsx-team-admin.min.js', array('jquery'), LSX_TEAM_VER); |
|
430 | + wp_enqueue_style('lsx-team-admin', LSX_TEAM_URL.'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
434 | 434 | * Change the "Insert into Post" button text when media modal is used for feature images |
435 | 435 | */ |
436 | - public function change_attachment_field_button( $html ) { |
|
437 | - if ( isset( $_GET['feature_image_text_button'] ) ) { |
|
438 | - $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-team' ) ), $html ); |
|
436 | + public function change_attachment_field_button($html) { |
|
437 | + if (isset($_GET['feature_image_text_button'])) { |
|
438 | + $html = str_replace('value="Insert into Post"', sprintf('value="%s"', esc_html__('Select featured image', 'lsx-team')), $html); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | return $html; |
442 | 442 | } |
443 | 443 | |
444 | - public function change_title_text( $title ) { |
|
444 | + public function change_title_text($title) { |
|
445 | 445 | $screen = get_current_screen(); |
446 | 446 | |
447 | - if ( 'team' === $screen->post_type ) { |
|
448 | - $title = esc_attr__( 'Enter team member name', 'lsx-team' ); |
|
447 | + if ('team' === $screen->post_type) { |
|
448 | + $title = esc_attr__('Enter team member name', 'lsx-team'); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | return $title; |