@@ -11,448 +11,448 @@ |
||
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[] = array( |
|
135 | - 'name' => $user->nice_name, |
|
136 | - 'value' => $user->ID, |
|
137 | - ); |
|
138 | - } |
|
139 | - |
|
140 | - $cmb = new_cmb2_box( |
|
141 | - array( |
|
142 | - 'id' => $prefix . '_team', |
|
143 | - 'title' => esc_html__( 'Team Member Details', 'lsx-team' ), |
|
144 | - 'object_types' => 'team', |
|
145 | - 'context' => 'normal', |
|
146 | - 'priority' => 'low', |
|
147 | - 'show_names' => true, |
|
148 | - ) |
|
149 | - ); |
|
150 | - |
|
151 | - $cmb->add_field( |
|
152 | - array( |
|
153 | - 'name' => esc_html__( 'Featured:', 'lsx-team' ), |
|
154 | - 'id' => $prefix . 'featured', |
|
155 | - 'type' => 'checkbox', |
|
156 | - 'value' => 1, |
|
157 | - 'default' => 0, |
|
158 | - 'show_in_rest' => true, |
|
159 | - ) |
|
160 | - ); |
|
161 | - |
|
162 | - $cmb->add_field( |
|
163 | - array( |
|
164 | - 'name' => esc_html__( 'Site User', 'lsx-team' ), |
|
165 | - 'id' => $prefix . 'site_user', |
|
166 | - 'allow_none' => true, |
|
167 | - 'type' => 'select', |
|
168 | - 'options' => $user_array, |
|
169 | - 'show_in_rest' => true, |
|
170 | - ) |
|
171 | - ); |
|
172 | - |
|
173 | - $cmb->add_field( |
|
174 | - array( |
|
175 | - 'name' => esc_html__( 'Job Title:', 'lsx-team' ), |
|
176 | - 'id' => $prefix . 'job_title', |
|
177 | - 'type' => 'text', |
|
178 | - 'show_in_rest' => true, |
|
179 | - ) |
|
180 | - ); |
|
181 | - |
|
182 | - $cmb->add_field( |
|
183 | - array( |
|
184 | - 'name' => esc_html__( 'Location:', 'lsx-team' ), |
|
185 | - 'id' => $prefix . 'location', |
|
186 | - 'type' => 'text', |
|
187 | - 'show_in_rest' => true, |
|
188 | - ) |
|
189 | - ); |
|
190 | - |
|
191 | - $cmb->add_field( |
|
192 | - array( |
|
193 | - 'name' => esc_html__( 'Contact Email Address:', 'lsx-team' ), |
|
194 | - 'id' => $prefix . 'email_contact', |
|
195 | - 'type' => 'text', |
|
196 | - 'show_in_rest' => true, |
|
197 | - ) |
|
198 | - ); |
|
199 | - |
|
200 | - $cmb->add_field( |
|
201 | - array( |
|
202 | - 'name' => esc_html__( 'Gravatar Email Address:', 'lsx-team' ), |
|
203 | - 'desc' => esc_html__( 'Used for Gravatar if a featured image is not set', 'lsx-team' ), |
|
204 | - 'id' => $prefix . 'email_gravatar', |
|
205 | - 'type' => 'text', |
|
206 | - 'show_in_rest' => true, |
|
207 | - ) |
|
208 | - ); |
|
209 | - |
|
210 | - $cmb->add_field( |
|
211 | - array( |
|
212 | - 'name' => esc_html__( 'Telephone Number:', 'lsx-team' ), |
|
213 | - 'id' => $prefix . 'tel', |
|
214 | - 'type' => 'text', |
|
215 | - 'show_in_rest' => true, |
|
216 | - ) |
|
217 | - ); |
|
218 | - |
|
219 | - $cmb->add_field( |
|
220 | - array( |
|
221 | - 'name' => esc_html__( 'Skype Name:', 'lsx-team' ), |
|
222 | - 'id' => $prefix . 'skype', |
|
223 | - 'type' => 'text', |
|
224 | - 'show_in_rest' => true, |
|
225 | - ) |
|
226 | - ); |
|
227 | - |
|
228 | - $cmb->add_field( |
|
229 | - array( |
|
230 | - 'name' => esc_html__( 'Facebook URL', 'lsx-team' ), |
|
231 | - 'id' => $prefix . 'facebook', |
|
232 | - 'type' => 'text_url', |
|
233 | - 'show_in_rest' => true, |
|
234 | - ) |
|
235 | - ); |
|
236 | - |
|
237 | - $cmb->add_field( |
|
238 | - array( |
|
239 | - 'name' => esc_html__( 'Twitter URL', 'lsx-team' ), |
|
240 | - 'id' => $prefix . 'twitter', |
|
241 | - 'type' => 'text_url', |
|
242 | - 'show_in_rest' => true, |
|
243 | - ) |
|
244 | - ); |
|
245 | - |
|
246 | - $cmb->add_field( |
|
247 | - array( |
|
248 | - 'name' => esc_html__( 'LinkedIn URL', 'lsx-team' ), |
|
249 | - 'id' => $prefix . 'linkedin', |
|
250 | - 'type' => 'text_url', |
|
251 | - 'show_in_rest' => true, |
|
252 | - ) |
|
253 | - ); |
|
254 | - |
|
255 | - $cmb->add_field( |
|
256 | - array( |
|
257 | - 'name' => esc_html__( 'Github URL', 'lsx-team' ), |
|
258 | - 'id' => $prefix . 'github', |
|
259 | - 'type' => 'text_url', |
|
260 | - 'show_in_rest' => true, |
|
261 | - ) |
|
262 | - ); |
|
263 | - |
|
264 | - $cmb->add_field( |
|
265 | - array( |
|
266 | - 'name' => esc_html__( 'WordPress URL', 'lsx-team' ), |
|
267 | - 'id' => $prefix . 'wordpress', |
|
268 | - 'type' => 'text_url', |
|
269 | - 'show_in_rest' => true, |
|
270 | - ) |
|
271 | - ); |
|
272 | - } |
|
273 | - |
|
274 | - /** |
|
275 | - * Define the metabox and field configurations. |
|
276 | - */ |
|
277 | - public function projects_details_metabox() { |
|
278 | - |
|
279 | - if ( class_exists( 'LSX_Projects' ) ) { |
|
280 | - |
|
281 | - $prefix = 'lsx_'; |
|
282 | - |
|
283 | - $cmb = new_cmb2_box( |
|
284 | - array( |
|
285 | - 'id' => $prefix . '_team', |
|
286 | - 'context' => 'normal', |
|
287 | - 'priority' => 'low', |
|
288 | - 'show_names' => true, |
|
289 | - 'object_types' => array( 'team' ), |
|
290 | - ) |
|
291 | - ); |
|
292 | - $cmb->add_field( |
|
293 | - array( |
|
294 | - 'name' => __( 'Projects:', 'lsx-team' ), |
|
295 | - 'id' => 'project_to_team', |
|
296 | - 'type' => 'post_search_ajax', |
|
297 | - 'limit' => 15, |
|
298 | - 'sortable' => true, |
|
299 | - 'query_args' => array( |
|
300 | - 'post_type' => array( 'project' ), |
|
301 | - 'post_status' => array( 'publish' ), |
|
302 | - 'posts_per_page' => -1, |
|
303 | - ), |
|
304 | - ) |
|
305 | - ); |
|
306 | - } |
|
307 | - } |
|
308 | - |
|
309 | - /** |
|
310 | - * Define the metabox and field configurations. |
|
311 | - */ |
|
312 | - public function services_details_metabox() { |
|
313 | - |
|
314 | - if ( class_exists( 'LSX_Services' ) ) { |
|
315 | - |
|
316 | - $prefix = 'lsx_'; |
|
317 | - |
|
318 | - $cmb = new_cmb2_box( |
|
319 | - array( |
|
320 | - 'id' => $prefix . '_team', |
|
321 | - 'context' => 'normal', |
|
322 | - 'priority' => 'low', |
|
323 | - 'show_names' => true, |
|
324 | - 'object_types' => array( 'team' ), |
|
325 | - ) |
|
326 | - ); |
|
327 | - $cmb->add_field( |
|
328 | - array( |
|
329 | - 'name' => __( 'Services:', 'lsx-team' ), |
|
330 | - 'id' => 'service_to_team', |
|
331 | - 'type' => 'post_search_ajax', |
|
332 | - 'limit' => 15, |
|
333 | - 'sortable' => true, |
|
334 | - 'query_args' => array( |
|
335 | - 'post_type' => array( 'service' ), |
|
336 | - 'post_status' => array( 'publish' ), |
|
337 | - 'posts_per_page' => -1, |
|
338 | - ), |
|
339 | - ) |
|
340 | - ); |
|
341 | - } |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Define the metabox and field configurations. |
|
346 | - */ |
|
347 | - public function testimonials_details_metabox() { |
|
348 | - |
|
349 | - if ( class_exists( 'LSX_Testimonials' ) ) { |
|
350 | - |
|
351 | - $prefix = 'lsx_'; |
|
352 | - |
|
353 | - $cmb = new_cmb2_box( |
|
354 | - array( |
|
355 | - 'id' => $prefix . '_team', |
|
356 | - 'context' => 'normal', |
|
357 | - 'priority' => 'low', |
|
358 | - 'show_names' => true, |
|
359 | - 'object_types' => array( 'team' ), |
|
360 | - ) |
|
361 | - ); |
|
362 | - $cmb->add_field( |
|
363 | - array( |
|
364 | - 'name' => __( 'Testimonials:', 'lsx-team' ), |
|
365 | - 'id' => 'testimonial_to_team', |
|
366 | - 'type' => 'post_search_ajax', |
|
367 | - 'limit' => 15, |
|
368 | - 'sortable' => true, |
|
369 | - 'query_args' => array( |
|
370 | - 'post_type' => array( 'testimonial' ), |
|
371 | - 'post_status' => array( 'publish' ), |
|
372 | - 'posts_per_page' => -1, |
|
373 | - ), |
|
374 | - ) |
|
375 | - ); |
|
376 | - } |
|
377 | - |
|
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Sets up the "post relations". |
|
382 | - */ |
|
383 | - public function post_relations( $post_id, $field, $value ) { |
|
384 | - $connections = array( |
|
385 | - 'team_to_testimonial', |
|
386 | - 'testimonial_to_team', |
|
387 | - |
|
388 | - 'team_to_project', |
|
389 | - 'project_to_team', |
|
390 | - |
|
391 | - 'team_to_service', |
|
392 | - 'service_to_team', |
|
393 | - ); |
|
394 | - |
|
395 | - if ( in_array( $field['id'], $connections ) ) { |
|
396 | - $this->save_related_post( $connections, $post_id, $field, $value ); |
|
397 | - } |
|
398 | - } |
|
399 | - |
|
400 | - /** |
|
401 | - * Save the reverse post relation. |
|
402 | - */ |
|
403 | - public function save_related_post( $connections, $post_id, $field, $value ) { |
|
404 | - $ids = explode( '_to_', $field['id'] ); |
|
405 | - $relation = $ids[1] . '_to_' . $ids[0]; |
|
406 | - |
|
407 | - if ( in_array( $relation, $connections ) ) { |
|
408 | - $previous_values = get_post_meta( $post_id, $field['id'], false ); |
|
409 | - |
|
410 | - if ( ! empty( $previous_values ) ) { |
|
411 | - foreach ( $previous_values as $v ) { |
|
412 | - delete_post_meta( $v, $relation, $post_id ); |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - if ( is_array( $value ) ) { |
|
417 | - foreach ( $value as $v ) { |
|
418 | - if ( ! empty( $v ) ) { |
|
419 | - add_post_meta( $v, $relation, $post_id ); |
|
420 | - } |
|
421 | - } |
|
422 | - } |
|
423 | - } |
|
424 | - } |
|
425 | - |
|
426 | - public function assets() { |
|
427 | - //wp_enqueue_media(); |
|
428 | - wp_enqueue_script( 'media-upload' ); |
|
429 | - wp_enqueue_script( 'thickbox' ); |
|
430 | - wp_enqueue_style( 'thickbox' ); |
|
431 | - |
|
432 | - wp_enqueue_script( 'lsx-team-admin', LSX_TEAM_URL . 'assets/js/lsx-team-admin.min.js', array( 'jquery' ), LSX_TEAM_VER ); |
|
433 | - wp_enqueue_style( 'lsx-team-admin', LSX_TEAM_URL . 'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER ); |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * Change the "Insert into Post" button text when media modal is used for feature images |
|
438 | - */ |
|
439 | - public function change_attachment_field_button( $html ) { |
|
440 | - if ( isset( $_GET['feature_image_text_button'] ) ) { |
|
441 | - $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-team' ) ), $html ); |
|
442 | - } |
|
443 | - |
|
444 | - return $html; |
|
445 | - } |
|
446 | - |
|
447 | - public function change_title_text( $title ) { |
|
448 | - $screen = get_current_screen(); |
|
449 | - |
|
450 | - if ( 'team' === $screen->post_type ) { |
|
451 | - $title = esc_attr__( 'Enter team member name', 'lsx-team' ); |
|
452 | - } |
|
453 | - |
|
454 | - return $title; |
|
455 | - } |
|
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[] = array( |
|
135 | + 'name' => $user->nice_name, |
|
136 | + 'value' => $user->ID, |
|
137 | + ); |
|
138 | + } |
|
139 | + |
|
140 | + $cmb = new_cmb2_box( |
|
141 | + array( |
|
142 | + 'id' => $prefix . '_team', |
|
143 | + 'title' => esc_html__( 'Team Member Details', 'lsx-team' ), |
|
144 | + 'object_types' => 'team', |
|
145 | + 'context' => 'normal', |
|
146 | + 'priority' => 'low', |
|
147 | + 'show_names' => true, |
|
148 | + ) |
|
149 | + ); |
|
150 | + |
|
151 | + $cmb->add_field( |
|
152 | + array( |
|
153 | + 'name' => esc_html__( 'Featured:', 'lsx-team' ), |
|
154 | + 'id' => $prefix . 'featured', |
|
155 | + 'type' => 'checkbox', |
|
156 | + 'value' => 1, |
|
157 | + 'default' => 0, |
|
158 | + 'show_in_rest' => true, |
|
159 | + ) |
|
160 | + ); |
|
161 | + |
|
162 | + $cmb->add_field( |
|
163 | + array( |
|
164 | + 'name' => esc_html__( 'Site User', 'lsx-team' ), |
|
165 | + 'id' => $prefix . 'site_user', |
|
166 | + 'allow_none' => true, |
|
167 | + 'type' => 'select', |
|
168 | + 'options' => $user_array, |
|
169 | + 'show_in_rest' => true, |
|
170 | + ) |
|
171 | + ); |
|
172 | + |
|
173 | + $cmb->add_field( |
|
174 | + array( |
|
175 | + 'name' => esc_html__( 'Job Title:', 'lsx-team' ), |
|
176 | + 'id' => $prefix . 'job_title', |
|
177 | + 'type' => 'text', |
|
178 | + 'show_in_rest' => true, |
|
179 | + ) |
|
180 | + ); |
|
181 | + |
|
182 | + $cmb->add_field( |
|
183 | + array( |
|
184 | + 'name' => esc_html__( 'Location:', 'lsx-team' ), |
|
185 | + 'id' => $prefix . 'location', |
|
186 | + 'type' => 'text', |
|
187 | + 'show_in_rest' => true, |
|
188 | + ) |
|
189 | + ); |
|
190 | + |
|
191 | + $cmb->add_field( |
|
192 | + array( |
|
193 | + 'name' => esc_html__( 'Contact Email Address:', 'lsx-team' ), |
|
194 | + 'id' => $prefix . 'email_contact', |
|
195 | + 'type' => 'text', |
|
196 | + 'show_in_rest' => true, |
|
197 | + ) |
|
198 | + ); |
|
199 | + |
|
200 | + $cmb->add_field( |
|
201 | + array( |
|
202 | + 'name' => esc_html__( 'Gravatar Email Address:', 'lsx-team' ), |
|
203 | + 'desc' => esc_html__( 'Used for Gravatar if a featured image is not set', 'lsx-team' ), |
|
204 | + 'id' => $prefix . 'email_gravatar', |
|
205 | + 'type' => 'text', |
|
206 | + 'show_in_rest' => true, |
|
207 | + ) |
|
208 | + ); |
|
209 | + |
|
210 | + $cmb->add_field( |
|
211 | + array( |
|
212 | + 'name' => esc_html__( 'Telephone Number:', 'lsx-team' ), |
|
213 | + 'id' => $prefix . 'tel', |
|
214 | + 'type' => 'text', |
|
215 | + 'show_in_rest' => true, |
|
216 | + ) |
|
217 | + ); |
|
218 | + |
|
219 | + $cmb->add_field( |
|
220 | + array( |
|
221 | + 'name' => esc_html__( 'Skype Name:', 'lsx-team' ), |
|
222 | + 'id' => $prefix . 'skype', |
|
223 | + 'type' => 'text', |
|
224 | + 'show_in_rest' => true, |
|
225 | + ) |
|
226 | + ); |
|
227 | + |
|
228 | + $cmb->add_field( |
|
229 | + array( |
|
230 | + 'name' => esc_html__( 'Facebook URL', 'lsx-team' ), |
|
231 | + 'id' => $prefix . 'facebook', |
|
232 | + 'type' => 'text_url', |
|
233 | + 'show_in_rest' => true, |
|
234 | + ) |
|
235 | + ); |
|
236 | + |
|
237 | + $cmb->add_field( |
|
238 | + array( |
|
239 | + 'name' => esc_html__( 'Twitter URL', 'lsx-team' ), |
|
240 | + 'id' => $prefix . 'twitter', |
|
241 | + 'type' => 'text_url', |
|
242 | + 'show_in_rest' => true, |
|
243 | + ) |
|
244 | + ); |
|
245 | + |
|
246 | + $cmb->add_field( |
|
247 | + array( |
|
248 | + 'name' => esc_html__( 'LinkedIn URL', 'lsx-team' ), |
|
249 | + 'id' => $prefix . 'linkedin', |
|
250 | + 'type' => 'text_url', |
|
251 | + 'show_in_rest' => true, |
|
252 | + ) |
|
253 | + ); |
|
254 | + |
|
255 | + $cmb->add_field( |
|
256 | + array( |
|
257 | + 'name' => esc_html__( 'Github URL', 'lsx-team' ), |
|
258 | + 'id' => $prefix . 'github', |
|
259 | + 'type' => 'text_url', |
|
260 | + 'show_in_rest' => true, |
|
261 | + ) |
|
262 | + ); |
|
263 | + |
|
264 | + $cmb->add_field( |
|
265 | + array( |
|
266 | + 'name' => esc_html__( 'WordPress URL', 'lsx-team' ), |
|
267 | + 'id' => $prefix . 'wordpress', |
|
268 | + 'type' => 'text_url', |
|
269 | + 'show_in_rest' => true, |
|
270 | + ) |
|
271 | + ); |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Define the metabox and field configurations. |
|
276 | + */ |
|
277 | + public function projects_details_metabox() { |
|
278 | + |
|
279 | + if ( class_exists( 'LSX_Projects' ) ) { |
|
280 | + |
|
281 | + $prefix = 'lsx_'; |
|
282 | + |
|
283 | + $cmb = new_cmb2_box( |
|
284 | + array( |
|
285 | + 'id' => $prefix . '_team', |
|
286 | + 'context' => 'normal', |
|
287 | + 'priority' => 'low', |
|
288 | + 'show_names' => true, |
|
289 | + 'object_types' => array( 'team' ), |
|
290 | + ) |
|
291 | + ); |
|
292 | + $cmb->add_field( |
|
293 | + array( |
|
294 | + 'name' => __( 'Projects:', 'lsx-team' ), |
|
295 | + 'id' => 'project_to_team', |
|
296 | + 'type' => 'post_search_ajax', |
|
297 | + 'limit' => 15, |
|
298 | + 'sortable' => true, |
|
299 | + 'query_args' => array( |
|
300 | + 'post_type' => array( 'project' ), |
|
301 | + 'post_status' => array( 'publish' ), |
|
302 | + 'posts_per_page' => -1, |
|
303 | + ), |
|
304 | + ) |
|
305 | + ); |
|
306 | + } |
|
307 | + } |
|
308 | + |
|
309 | + /** |
|
310 | + * Define the metabox and field configurations. |
|
311 | + */ |
|
312 | + public function services_details_metabox() { |
|
313 | + |
|
314 | + if ( class_exists( 'LSX_Services' ) ) { |
|
315 | + |
|
316 | + $prefix = 'lsx_'; |
|
317 | + |
|
318 | + $cmb = new_cmb2_box( |
|
319 | + array( |
|
320 | + 'id' => $prefix . '_team', |
|
321 | + 'context' => 'normal', |
|
322 | + 'priority' => 'low', |
|
323 | + 'show_names' => true, |
|
324 | + 'object_types' => array( 'team' ), |
|
325 | + ) |
|
326 | + ); |
|
327 | + $cmb->add_field( |
|
328 | + array( |
|
329 | + 'name' => __( 'Services:', 'lsx-team' ), |
|
330 | + 'id' => 'service_to_team', |
|
331 | + 'type' => 'post_search_ajax', |
|
332 | + 'limit' => 15, |
|
333 | + 'sortable' => true, |
|
334 | + 'query_args' => array( |
|
335 | + 'post_type' => array( 'service' ), |
|
336 | + 'post_status' => array( 'publish' ), |
|
337 | + 'posts_per_page' => -1, |
|
338 | + ), |
|
339 | + ) |
|
340 | + ); |
|
341 | + } |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Define the metabox and field configurations. |
|
346 | + */ |
|
347 | + public function testimonials_details_metabox() { |
|
348 | + |
|
349 | + if ( class_exists( 'LSX_Testimonials' ) ) { |
|
350 | + |
|
351 | + $prefix = 'lsx_'; |
|
352 | + |
|
353 | + $cmb = new_cmb2_box( |
|
354 | + array( |
|
355 | + 'id' => $prefix . '_team', |
|
356 | + 'context' => 'normal', |
|
357 | + 'priority' => 'low', |
|
358 | + 'show_names' => true, |
|
359 | + 'object_types' => array( 'team' ), |
|
360 | + ) |
|
361 | + ); |
|
362 | + $cmb->add_field( |
|
363 | + array( |
|
364 | + 'name' => __( 'Testimonials:', 'lsx-team' ), |
|
365 | + 'id' => 'testimonial_to_team', |
|
366 | + 'type' => 'post_search_ajax', |
|
367 | + 'limit' => 15, |
|
368 | + 'sortable' => true, |
|
369 | + 'query_args' => array( |
|
370 | + 'post_type' => array( 'testimonial' ), |
|
371 | + 'post_status' => array( 'publish' ), |
|
372 | + 'posts_per_page' => -1, |
|
373 | + ), |
|
374 | + ) |
|
375 | + ); |
|
376 | + } |
|
377 | + |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Sets up the "post relations". |
|
382 | + */ |
|
383 | + public function post_relations( $post_id, $field, $value ) { |
|
384 | + $connections = array( |
|
385 | + 'team_to_testimonial', |
|
386 | + 'testimonial_to_team', |
|
387 | + |
|
388 | + 'team_to_project', |
|
389 | + 'project_to_team', |
|
390 | + |
|
391 | + 'team_to_service', |
|
392 | + 'service_to_team', |
|
393 | + ); |
|
394 | + |
|
395 | + if ( in_array( $field['id'], $connections ) ) { |
|
396 | + $this->save_related_post( $connections, $post_id, $field, $value ); |
|
397 | + } |
|
398 | + } |
|
399 | + |
|
400 | + /** |
|
401 | + * Save the reverse post relation. |
|
402 | + */ |
|
403 | + public function save_related_post( $connections, $post_id, $field, $value ) { |
|
404 | + $ids = explode( '_to_', $field['id'] ); |
|
405 | + $relation = $ids[1] . '_to_' . $ids[0]; |
|
406 | + |
|
407 | + if ( in_array( $relation, $connections ) ) { |
|
408 | + $previous_values = get_post_meta( $post_id, $field['id'], false ); |
|
409 | + |
|
410 | + if ( ! empty( $previous_values ) ) { |
|
411 | + foreach ( $previous_values as $v ) { |
|
412 | + delete_post_meta( $v, $relation, $post_id ); |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + if ( is_array( $value ) ) { |
|
417 | + foreach ( $value as $v ) { |
|
418 | + if ( ! empty( $v ) ) { |
|
419 | + add_post_meta( $v, $relation, $post_id ); |
|
420 | + } |
|
421 | + } |
|
422 | + } |
|
423 | + } |
|
424 | + } |
|
425 | + |
|
426 | + public function assets() { |
|
427 | + //wp_enqueue_media(); |
|
428 | + wp_enqueue_script( 'media-upload' ); |
|
429 | + wp_enqueue_script( 'thickbox' ); |
|
430 | + wp_enqueue_style( 'thickbox' ); |
|
431 | + |
|
432 | + wp_enqueue_script( 'lsx-team-admin', LSX_TEAM_URL . 'assets/js/lsx-team-admin.min.js', array( 'jquery' ), LSX_TEAM_VER ); |
|
433 | + wp_enqueue_style( 'lsx-team-admin', LSX_TEAM_URL . 'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER ); |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * Change the "Insert into Post" button text when media modal is used for feature images |
|
438 | + */ |
|
439 | + public function change_attachment_field_button( $html ) { |
|
440 | + if ( isset( $_GET['feature_image_text_button'] ) ) { |
|
441 | + $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-team' ) ), $html ); |
|
442 | + } |
|
443 | + |
|
444 | + return $html; |
|
445 | + } |
|
446 | + |
|
447 | + public function change_title_text( $title ) { |
|
448 | + $screen = get_current_screen(); |
|
449 | + |
|
450 | + if ( 'team' === $screen->post_type ) { |
|
451 | + $title = esc_attr__( 'Enter team member name', 'lsx-team' ); |
|
452 | + } |
|
453 | + |
|
454 | + return $title; |
|
455 | + } |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | $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,16 +121,16 @@ 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[] = array( |
135 | 135 | 'name' => $user->nice_name, |
136 | 136 | 'value' => $user->ID, |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | |
140 | 140 | $cmb = new_cmb2_box( |
141 | 141 | array( |
142 | - 'id' => $prefix . '_team', |
|
143 | - 'title' => esc_html__( 'Team Member Details', 'lsx-team' ), |
|
142 | + 'id' => $prefix.'_team', |
|
143 | + 'title' => esc_html__('Team Member Details', 'lsx-team'), |
|
144 | 144 | 'object_types' => 'team', |
145 | 145 | 'context' => 'normal', |
146 | 146 | 'priority' => 'low', |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | |
151 | 151 | $cmb->add_field( |
152 | 152 | array( |
153 | - 'name' => esc_html__( 'Featured:', 'lsx-team' ), |
|
154 | - 'id' => $prefix . 'featured', |
|
153 | + 'name' => esc_html__('Featured:', 'lsx-team'), |
|
154 | + 'id' => $prefix.'featured', |
|
155 | 155 | 'type' => 'checkbox', |
156 | 156 | 'value' => 1, |
157 | 157 | 'default' => 0, |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | |
162 | 162 | $cmb->add_field( |
163 | 163 | array( |
164 | - 'name' => esc_html__( 'Site User', 'lsx-team' ), |
|
165 | - 'id' => $prefix . 'site_user', |
|
164 | + 'name' => esc_html__('Site User', 'lsx-team'), |
|
165 | + 'id' => $prefix.'site_user', |
|
166 | 166 | 'allow_none' => true, |
167 | 167 | 'type' => 'select', |
168 | 168 | 'options' => $user_array, |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | |
173 | 173 | $cmb->add_field( |
174 | 174 | array( |
175 | - 'name' => esc_html__( 'Job Title:', 'lsx-team' ), |
|
176 | - 'id' => $prefix . 'job_title', |
|
175 | + 'name' => esc_html__('Job Title:', 'lsx-team'), |
|
176 | + 'id' => $prefix.'job_title', |
|
177 | 177 | 'type' => 'text', |
178 | 178 | 'show_in_rest' => true, |
179 | 179 | ) |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | |
182 | 182 | $cmb->add_field( |
183 | 183 | array( |
184 | - 'name' => esc_html__( 'Location:', 'lsx-team' ), |
|
185 | - 'id' => $prefix . 'location', |
|
184 | + 'name' => esc_html__('Location:', 'lsx-team'), |
|
185 | + 'id' => $prefix.'location', |
|
186 | 186 | 'type' => 'text', |
187 | 187 | 'show_in_rest' => true, |
188 | 188 | ) |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | |
191 | 191 | $cmb->add_field( |
192 | 192 | array( |
193 | - 'name' => esc_html__( 'Contact Email Address:', 'lsx-team' ), |
|
194 | - 'id' => $prefix . 'email_contact', |
|
193 | + 'name' => esc_html__('Contact Email Address:', 'lsx-team'), |
|
194 | + 'id' => $prefix.'email_contact', |
|
195 | 195 | 'type' => 'text', |
196 | 196 | 'show_in_rest' => true, |
197 | 197 | ) |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | |
200 | 200 | $cmb->add_field( |
201 | 201 | array( |
202 | - 'name' => esc_html__( 'Gravatar Email Address:', 'lsx-team' ), |
|
203 | - 'desc' => esc_html__( 'Used for Gravatar if a featured image is not set', 'lsx-team' ), |
|
204 | - 'id' => $prefix . 'email_gravatar', |
|
202 | + 'name' => esc_html__('Gravatar Email Address:', 'lsx-team'), |
|
203 | + 'desc' => esc_html__('Used for Gravatar if a featured image is not set', 'lsx-team'), |
|
204 | + 'id' => $prefix.'email_gravatar', |
|
205 | 205 | 'type' => 'text', |
206 | 206 | 'show_in_rest' => true, |
207 | 207 | ) |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | |
210 | 210 | $cmb->add_field( |
211 | 211 | array( |
212 | - 'name' => esc_html__( 'Telephone Number:', 'lsx-team' ), |
|
213 | - 'id' => $prefix . 'tel', |
|
212 | + 'name' => esc_html__('Telephone Number:', 'lsx-team'), |
|
213 | + 'id' => $prefix.'tel', |
|
214 | 214 | 'type' => 'text', |
215 | 215 | 'show_in_rest' => true, |
216 | 216 | ) |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | |
219 | 219 | $cmb->add_field( |
220 | 220 | array( |
221 | - 'name' => esc_html__( 'Skype Name:', 'lsx-team' ), |
|
222 | - 'id' => $prefix . 'skype', |
|
221 | + 'name' => esc_html__('Skype Name:', 'lsx-team'), |
|
222 | + 'id' => $prefix.'skype', |
|
223 | 223 | 'type' => 'text', |
224 | 224 | 'show_in_rest' => true, |
225 | 225 | ) |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | |
228 | 228 | $cmb->add_field( |
229 | 229 | array( |
230 | - 'name' => esc_html__( 'Facebook URL', 'lsx-team' ), |
|
231 | - 'id' => $prefix . 'facebook', |
|
230 | + 'name' => esc_html__('Facebook URL', 'lsx-team'), |
|
231 | + 'id' => $prefix.'facebook', |
|
232 | 232 | 'type' => 'text_url', |
233 | 233 | 'show_in_rest' => true, |
234 | 234 | ) |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | |
237 | 237 | $cmb->add_field( |
238 | 238 | array( |
239 | - 'name' => esc_html__( 'Twitter URL', 'lsx-team' ), |
|
240 | - 'id' => $prefix . 'twitter', |
|
239 | + 'name' => esc_html__('Twitter URL', 'lsx-team'), |
|
240 | + 'id' => $prefix.'twitter', |
|
241 | 241 | 'type' => 'text_url', |
242 | 242 | 'show_in_rest' => true, |
243 | 243 | ) |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | |
246 | 246 | $cmb->add_field( |
247 | 247 | array( |
248 | - 'name' => esc_html__( 'LinkedIn URL', 'lsx-team' ), |
|
249 | - 'id' => $prefix . 'linkedin', |
|
248 | + 'name' => esc_html__('LinkedIn URL', 'lsx-team'), |
|
249 | + 'id' => $prefix.'linkedin', |
|
250 | 250 | 'type' => 'text_url', |
251 | 251 | 'show_in_rest' => true, |
252 | 252 | ) |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | |
255 | 255 | $cmb->add_field( |
256 | 256 | array( |
257 | - 'name' => esc_html__( 'Github URL', 'lsx-team' ), |
|
258 | - 'id' => $prefix . 'github', |
|
257 | + 'name' => esc_html__('Github URL', 'lsx-team'), |
|
258 | + 'id' => $prefix.'github', |
|
259 | 259 | 'type' => 'text_url', |
260 | 260 | 'show_in_rest' => true, |
261 | 261 | ) |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | |
264 | 264 | $cmb->add_field( |
265 | 265 | array( |
266 | - 'name' => esc_html__( 'WordPress URL', 'lsx-team' ), |
|
267 | - 'id' => $prefix . 'wordpress', |
|
266 | + 'name' => esc_html__('WordPress URL', 'lsx-team'), |
|
267 | + 'id' => $prefix.'wordpress', |
|
268 | 268 | 'type' => 'text_url', |
269 | 269 | 'show_in_rest' => true, |
270 | 270 | ) |
@@ -276,29 +276,29 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function projects_details_metabox() { |
278 | 278 | |
279 | - if ( class_exists( 'LSX_Projects' ) ) { |
|
279 | + if (class_exists('LSX_Projects')) { |
|
280 | 280 | |
281 | 281 | $prefix = 'lsx_'; |
282 | 282 | |
283 | 283 | $cmb = new_cmb2_box( |
284 | 284 | array( |
285 | - 'id' => $prefix . '_team', |
|
285 | + 'id' => $prefix.'_team', |
|
286 | 286 | 'context' => 'normal', |
287 | 287 | 'priority' => 'low', |
288 | 288 | 'show_names' => true, |
289 | - 'object_types' => array( 'team' ), |
|
289 | + 'object_types' => array('team'), |
|
290 | 290 | ) |
291 | 291 | ); |
292 | 292 | $cmb->add_field( |
293 | 293 | array( |
294 | - 'name' => __( 'Projects:', 'lsx-team' ), |
|
294 | + 'name' => __('Projects:', 'lsx-team'), |
|
295 | 295 | 'id' => 'project_to_team', |
296 | 296 | 'type' => 'post_search_ajax', |
297 | 297 | 'limit' => 15, |
298 | 298 | 'sortable' => true, |
299 | 299 | 'query_args' => array( |
300 | - 'post_type' => array( 'project' ), |
|
301 | - 'post_status' => array( 'publish' ), |
|
300 | + 'post_type' => array('project'), |
|
301 | + 'post_status' => array('publish'), |
|
302 | 302 | 'posts_per_page' => -1, |
303 | 303 | ), |
304 | 304 | ) |
@@ -311,29 +311,29 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function services_details_metabox() { |
313 | 313 | |
314 | - if ( class_exists( 'LSX_Services' ) ) { |
|
314 | + if (class_exists('LSX_Services')) { |
|
315 | 315 | |
316 | 316 | $prefix = 'lsx_'; |
317 | 317 | |
318 | 318 | $cmb = new_cmb2_box( |
319 | 319 | array( |
320 | - 'id' => $prefix . '_team', |
|
320 | + 'id' => $prefix.'_team', |
|
321 | 321 | 'context' => 'normal', |
322 | 322 | 'priority' => 'low', |
323 | 323 | 'show_names' => true, |
324 | - 'object_types' => array( 'team' ), |
|
324 | + 'object_types' => array('team'), |
|
325 | 325 | ) |
326 | 326 | ); |
327 | 327 | $cmb->add_field( |
328 | 328 | array( |
329 | - 'name' => __( 'Services:', 'lsx-team' ), |
|
329 | + 'name' => __('Services:', 'lsx-team'), |
|
330 | 330 | 'id' => 'service_to_team', |
331 | 331 | 'type' => 'post_search_ajax', |
332 | 332 | 'limit' => 15, |
333 | 333 | 'sortable' => true, |
334 | 334 | 'query_args' => array( |
335 | - 'post_type' => array( 'service' ), |
|
336 | - 'post_status' => array( 'publish' ), |
|
335 | + 'post_type' => array('service'), |
|
336 | + 'post_status' => array('publish'), |
|
337 | 337 | 'posts_per_page' => -1, |
338 | 338 | ), |
339 | 339 | ) |
@@ -346,29 +346,29 @@ discard block |
||
346 | 346 | */ |
347 | 347 | public function testimonials_details_metabox() { |
348 | 348 | |
349 | - if ( class_exists( 'LSX_Testimonials' ) ) { |
|
349 | + if (class_exists('LSX_Testimonials')) { |
|
350 | 350 | |
351 | 351 | $prefix = 'lsx_'; |
352 | 352 | |
353 | 353 | $cmb = new_cmb2_box( |
354 | 354 | array( |
355 | - 'id' => $prefix . '_team', |
|
355 | + 'id' => $prefix.'_team', |
|
356 | 356 | 'context' => 'normal', |
357 | 357 | 'priority' => 'low', |
358 | 358 | 'show_names' => true, |
359 | - 'object_types' => array( 'team' ), |
|
359 | + 'object_types' => array('team'), |
|
360 | 360 | ) |
361 | 361 | ); |
362 | 362 | $cmb->add_field( |
363 | 363 | array( |
364 | - 'name' => __( 'Testimonials:', 'lsx-team' ), |
|
364 | + 'name' => __('Testimonials:', 'lsx-team'), |
|
365 | 365 | 'id' => 'testimonial_to_team', |
366 | 366 | 'type' => 'post_search_ajax', |
367 | 367 | 'limit' => 15, |
368 | 368 | 'sortable' => true, |
369 | 369 | 'query_args' => array( |
370 | - 'post_type' => array( 'testimonial' ), |
|
371 | - 'post_status' => array( 'publish' ), |
|
370 | + 'post_type' => array('testimonial'), |
|
371 | + 'post_status' => array('publish'), |
|
372 | 372 | 'posts_per_page' => -1, |
373 | 373 | ), |
374 | 374 | ) |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | /** |
381 | 381 | * Sets up the "post relations". |
382 | 382 | */ |
383 | - public function post_relations( $post_id, $field, $value ) { |
|
383 | + public function post_relations($post_id, $field, $value) { |
|
384 | 384 | $connections = array( |
385 | 385 | 'team_to_testimonial', |
386 | 386 | 'testimonial_to_team', |
@@ -392,31 +392,31 @@ discard block |
||
392 | 392 | 'service_to_team', |
393 | 393 | ); |
394 | 394 | |
395 | - if ( in_array( $field['id'], $connections ) ) { |
|
396 | - $this->save_related_post( $connections, $post_id, $field, $value ); |
|
395 | + if (in_array($field['id'], $connections)) { |
|
396 | + $this->save_related_post($connections, $post_id, $field, $value); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
401 | 401 | * Save the reverse post relation. |
402 | 402 | */ |
403 | - public function save_related_post( $connections, $post_id, $field, $value ) { |
|
404 | - $ids = explode( '_to_', $field['id'] ); |
|
405 | - $relation = $ids[1] . '_to_' . $ids[0]; |
|
403 | + public function save_related_post($connections, $post_id, $field, $value) { |
|
404 | + $ids = explode('_to_', $field['id']); |
|
405 | + $relation = $ids[1].'_to_'.$ids[0]; |
|
406 | 406 | |
407 | - if ( in_array( $relation, $connections ) ) { |
|
408 | - $previous_values = get_post_meta( $post_id, $field['id'], false ); |
|
407 | + if (in_array($relation, $connections)) { |
|
408 | + $previous_values = get_post_meta($post_id, $field['id'], false); |
|
409 | 409 | |
410 | - if ( ! empty( $previous_values ) ) { |
|
411 | - foreach ( $previous_values as $v ) { |
|
412 | - delete_post_meta( $v, $relation, $post_id ); |
|
410 | + if (!empty($previous_values)) { |
|
411 | + foreach ($previous_values as $v) { |
|
412 | + delete_post_meta($v, $relation, $post_id); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | - if ( is_array( $value ) ) { |
|
417 | - foreach ( $value as $v ) { |
|
418 | - if ( ! empty( $v ) ) { |
|
419 | - add_post_meta( $v, $relation, $post_id ); |
|
416 | + if (is_array($value)) { |
|
417 | + foreach ($value as $v) { |
|
418 | + if (!empty($v)) { |
|
419 | + add_post_meta($v, $relation, $post_id); |
|
420 | 420 | } |
421 | 421 | } |
422 | 422 | } |
@@ -425,30 +425,30 @@ discard block |
||
425 | 425 | |
426 | 426 | public function assets() { |
427 | 427 | //wp_enqueue_media(); |
428 | - wp_enqueue_script( 'media-upload' ); |
|
429 | - wp_enqueue_script( 'thickbox' ); |
|
430 | - wp_enqueue_style( 'thickbox' ); |
|
428 | + wp_enqueue_script('media-upload'); |
|
429 | + wp_enqueue_script('thickbox'); |
|
430 | + wp_enqueue_style('thickbox'); |
|
431 | 431 | |
432 | - wp_enqueue_script( 'lsx-team-admin', LSX_TEAM_URL . 'assets/js/lsx-team-admin.min.js', array( 'jquery' ), LSX_TEAM_VER ); |
|
433 | - wp_enqueue_style( 'lsx-team-admin', LSX_TEAM_URL . 'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER ); |
|
432 | + wp_enqueue_script('lsx-team-admin', LSX_TEAM_URL.'assets/js/lsx-team-admin.min.js', array('jquery'), LSX_TEAM_VER); |
|
433 | + wp_enqueue_style('lsx-team-admin', LSX_TEAM_URL.'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
437 | 437 | * Change the "Insert into Post" button text when media modal is used for feature images |
438 | 438 | */ |
439 | - public function change_attachment_field_button( $html ) { |
|
440 | - if ( isset( $_GET['feature_image_text_button'] ) ) { |
|
441 | - $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-team' ) ), $html ); |
|
439 | + public function change_attachment_field_button($html) { |
|
440 | + if (isset($_GET['feature_image_text_button'])) { |
|
441 | + $html = str_replace('value="Insert into Post"', sprintf('value="%s"', esc_html__('Select featured image', 'lsx-team')), $html); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | return $html; |
445 | 445 | } |
446 | 446 | |
447 | - public function change_title_text( $title ) { |
|
447 | + public function change_title_text($title) { |
|
448 | 448 | $screen = get_current_screen(); |
449 | 449 | |
450 | - if ( 'team' === $screen->post_type ) { |
|
451 | - $title = esc_attr__( 'Enter team member name', 'lsx-team' ); |
|
450 | + if ('team' === $screen->post_type) { |
|
451 | + $title = esc_attr__('Enter team member name', 'lsx-team'); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | return $title; |