-
Notifications
You must be signed in to change notification settings - Fork 0
/
posttypes.php
312 lines (277 loc) · 11.4 KB
/
posttypes.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php
/**
* Plugin Name: Project/Feature Manager
* Description: A simple plugin to publish projects with the project name, client, agency, and role(s) performed.
* Version: 0.1
* Author: Preston Edmands
* License: GPL2
*/
/* Copyright 2015 Preston Edmands (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
function custom_posttypes() {
$labels = array(
'name' => 'Projects',
'singular_name' => 'Project',
'menu_name' => 'Projects',
'name_admin_bar' => 'Project',
'add_new' => 'Add New',
'add_new_item' => 'Add New Project',
'new_item' => 'New Project',
'edit_item' => 'Edit Project',
'view_item' => 'View Project',
'all_items' => 'All Projects',
'search_items' => 'Search Projects',
'parent_item_colon' => 'Parent Projects:',
'not_found' => 'No Projects found.',
'not_found_in_trash' => 'No Projects found in Trash.',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-format-video',
'query_var' => true,
'rewrite' => array( 'slug' => 'projects' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'taxonomies' => array('clients', 'agencies', 'year','director','editor')
);
register_post_type('projects', $args );
$labels = array(
'name' => 'Features',
'singular_name' => 'Feature',
'menu_name' => 'Features',
'name_admin_bar' => 'Feature',
'add_new' => 'Add New',
'add_new_item' => 'Add New Feature',
'new_item' => 'New Feature',
'edit_item' => 'Edit Feature',
'view_item' => 'View Feature',
'all_items' => 'All Features',
'search_items' => 'Search Features',
'parent_item_colon' => 'Parent Features:',
'not_found' => 'No Features found.',
'not_found_in_trash' => 'No Features found in Trash.',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-video-alt',
'query_var' => true,
'rewrite' => array( 'slug' => 'features' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'taxonomies' => array('year','length','director','editor','studios')
);
register_post_type('features', $args );
}
add_action( 'init', 'custom_posttypes' );
function my_rewrite_flush() {
// First, we "add" the custom post type via the above written function.
// Note: "add" is wr
// They are only referenced in the post_type column with a post entry,
// when you add a post of this CPT.
custom_posttypes();
// ATTENTION: This is *only* done during plugin activation hook in this example!
// You should *NEVER EVER* do this on every page load!!
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'my_rewrite_flush' );
// Custom Taxonomies
function custom_taxonomies() {
// Client
$labels = array(
'name' => 'Client',
'singular_name' => 'Client',
'search_items' => 'Search Clients',
'all_items' => 'All Clients',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit Client',
'update_item' => 'Update Client',
'add_new_item' => 'Add New Client',
'new_item_name' => 'New Client',
'menu_name' => 'Clients',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'clients' ),
);
register_taxonomy('clients', array('projects'), $args);
// Agency
$labels = array(
'name' => 'Agency',
'singular_name' => 'Agency',
'search_items' => 'Search Agencies',
'popular_items' => 'Popular Agencies',
'all_items' => 'All Agencies',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit Agency',
'update_item' => 'Update Agency',
'add_new_item' => 'Add New Agency',
'new_item_name' => 'New Agency Name',
'separate_items_with_commas' => 'Separate Agencies with commas',
'add_or_remove_items' => 'Add or remove Agencies',
'choose_from_most_used' => 'Choose from the most used Agency',
'not_found' => 'No Agency found.',
'menu_name' => 'Agencies',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'agencies' ),
);
register_taxonomy('agencies', array('projects'), $args);
// Year
$labels = array(
'name' => 'Year',
'singular_name' => 'Year',
'search_items' => 'Search Years',
'all_items' => 'All Years',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit Year',
'update_item' => 'Update Year',
'add_new_item' => 'Add New Year',
'new_item_name' => 'New Year',
'menu_name' => 'Year',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => false,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'year' ),
);
register_taxonomy('year', array('projects', 'features'), $args);
// Length
$labels = array(
'name' => 'Length',
'singular_name' => 'Length',
'search_items' => 'Search Lengths',
'all_items' => 'All Lengths',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit Length',
'update_item' => 'Update Length',
'add_new_item' => 'Add New Length',
'new_item_name' => 'New Length',
'menu_name' => 'Length',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => false,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'length' ),
);
register_taxonomy('length', array('features'), $args);
// Director
$labels = array(
'name' => 'Director',
'singular_name' => 'Director',
'search_items' => 'Search Directors',
'all_items' => 'All Directors',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit Director',
'update_item' => 'Update Director',
'add_new_item' => 'Add New Director',
'new_item_name' => 'New Director',
'menu_name' => 'Directors',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => false,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'director' ),
);
register_taxonomy('director', array('projects', 'features'), $args);
// Editor
$labels = array(
'name' => 'Editor',
'singular_name' => 'Editor',
'search_items' => 'Search Editors',
'all_items' => 'All Editors',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit Editor',
'update_item' => 'Update Editor',
'add_new_item' => 'Add New Editor',
'new_item_name' => 'New Editor',
'menu_name' => 'Editors',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => false,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'editor' ),
);
register_taxonomy('editor', array('projects', 'features'), $args);
// Studio
$labels = array(
'name' => 'Studio',
'singular_name' => 'Studio',
'search_items' => 'Search Studios',
'all_items' => 'All Studios',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Edit Studio',
'update_item' => 'Update Studio',
'add_new_item' => 'Add New Studio',
'new_item_name' => 'New Studio',
'menu_name' => 'Studios',
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => false,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'studios' ),
);
register_taxonomy('studios', array('features'), $args);
}
add_action('init', 'custom_taxonomies');