-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwcmke-employees.php
145 lines (130 loc) · 5.11 KB
/
wcmke-employees.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* @package WCMKE_Emplpyees
* @version 1.0
*/
/*
Plugin Name: WCMKE Employees
Description: Add custom post type and taxonomies for employees
Author: WCMKE
Version: 1.0
*/
if ( ! function_exists('wcmke_employee_cpt') ) {
// Register Custom Post Type
function wcmke_employee_cpt() {
$labels = array(
'name' => _x( 'Employees', 'Post Type General Name', 'wcmke' ),
'singular_name' => _x( 'Employee', 'Post Type Singular Name', 'wcmke' ),
'menu_name' => __( 'Employees', 'wcmke' ),
'name_admin_bar' => __( 'Employees', 'wcmke' ),
'parent_item_colon' => __( 'Parent Employee:', 'wcmke' ),
'all_items' => __( 'All Employees', 'wcmke' ),
'add_new_item' => __( 'Add New Employee', 'wcmke' ),
'add_new' => __( 'Add New Employee', 'wcmke' ),
'new_item' => __( 'New Employee', 'wcmke' ),
'edit_item' => __( 'Edit Employee', 'wcmke' ),
'update_item' => __( 'Update Employee', 'wcmke' ),
'view_item' => __( 'View Employee', 'wcmke' ),
'search_items' => __( 'Search Employees', 'wcmke' ),
'not_found' => __( 'Not found', 'wcmke' ),
'not_found_in_trash' => __( 'Not found in Trash', 'wcmke' ),
);
$rewrite = array(
'slug' => 'wcmke-employee',
'with_front' => true,
'pages' => false,
'feeds' => true,
);
$args = array(
'label' => __( 'wcmke_employee', 'wcmke' ),
'description' => __( 'Employees of WC MKE', 'wcmke' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'revisions', ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-users',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'wcmke-employees',
'exclude_from_search' => false,
'publicly_queryable' => true,
'query_var' => 'wcmke-employee',
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'wcmke_employee', $args );
}
// Hook into the 'init' action
add_action( 'init', 'wcmke_employee_cpt', 0 );
}
if ( ! function_exists( 'wcmke_departments' ) ) {
// Register Custom Taxonomy
function wcmke_departments() {
$labels = array(
'name' => _x( 'Departments', 'Taxonomy General Name', 'wcmke' ),
'singular_name' => _x( 'Department', 'Taxonomy Singular Name', 'wcmke' ),
'menu_name' => __( 'Departments', 'wcmke' ),
'all_items' => __( 'All Departments', 'wcmke' ),
'parent_item' => __( 'Parent Department', 'wcmke' ),
'parent_item_colon' => __( 'Parent Department:', 'wcmke' ),
'new_item_name' => __( 'New Item Department', 'wcmke' ),
'add_new_item' => __( 'Add New Department', 'wcmke' ),
'edit_item' => __( 'Edit Department', 'wcmke' ),
'update_item' => __( 'Update Department', 'wcmke' ),
'view_item' => __( 'View Department', 'wcmke' ),
'separate_items_with_commas' => __( 'Separate items with commas', 'wcmke' ),
'add_or_remove_items' => __( 'Add or remove Departments', 'wcmke' ),
'choose_from_most_used' => __( 'Choose from the most used', 'wcmke' ),
'popular_items' => __( 'Popular Departments', 'wcmke' ),
'search_items' => __( 'Search Departments', 'wcmke' ),
'not_found' => __( 'Not Found', 'wcmke' ),
);
$rewrite = array(
'slug' => 'wcmke-department',
'with_front' => true,
'hierarchical' => true,
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'query_var' => 'wcmke_departments',
'rewrite' => $rewrite,
);
register_taxonomy( 'wcmke_department', array( 'wcmke_employee' ), $args );
}
// Hook into the 'init' action
add_action( 'init', 'wcmke_departments', 0 );
}
add_action( 'cmb2_init', 'wcmke_custom_fields' );
function wcmke_custom_fields() {
$prefix = 'wcmke_';
$employee_data = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => __( 'Employee Data', 'cmb2' ),
'object_types' => array( 'wcmke_employee', ), // Post type
) );
$employee_data->add_field( array(
'name' => __( 'Job Title', 'cmb2' ),
'id' => $prefix . 'job_title',
'type' => 'text',
) );
$employee_data->add_field( array(
'name' => __( 'Email', 'cmb2' ),
'id' => $prefix . 'email',
'type' => 'text',
) );
$employee_data->add_field( array(
'name' => __( 'Phone Number', 'cmb2' ),
'id' => $prefix . 'phone_number',
'type' => 'text',
) );
}