PluginProbe ʕ •ᴥ•ʔ
Custom Post Type UI / 0.7.1.0
Custom Post Type UI v0.7.1.0
1.19.2 1.19.1 1.19.0 trunk 0.7.0.0 0.7.1.0 0.7.2.0 0.8.0.0 0.8.1 0.8.2 0.8.3 0.8.4 0.8.5 0.9.0 0.9.5 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.10.1 1.10.2 1.11.0 1.11.1 1.11.2 1.12.0 1.12.1 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.13.5 1.13.6 1.13.7 1.14.0 1.15.0 1.15.1 1.16.0 1.17.0 1.17.1 1.17.2 1.17.3 1.18.0 1.18.1 1.18.2 1.18.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.8.0 1.8.1 1.8.2 1.9.0 1.9.1 1.9.2
custom-post-type-ui / custom-post-type-ui.php
custom-post-type-ui Last commit date
images 15 years ago languages 15 years ago custom-post-type-ui.php 14 years ago readme.txt 14 years ago screenshot-1.png 15 years ago screenshot-2.png 15 years ago screenshot-3.png 16 years ago screenshot-4.png 15 years ago screenshot-5.png 16 years ago
custom-post-type-ui.php
1493 lines
1 <?php
2 /*
3 Plugin Name: Custom Post Type UI
4 Plugin URI: http://webdevstudios.com/support/wordpress-plugins/
5 Description: Admin panel for creating custom post types and custom taxonomies in WordPress
6 Author: WebDevStudios.com
7 Version: 0.7.1
8 Author URI: http://webdevstudios.com/
9 */
10
11 // Define current version constant
12 define( 'CPT_VERSION', '0.7.1' );
13
14 // Define plugin URL constant
15 $CPT_URL = cpt_check_return( 'add' );
16
17 //load translated strings
18 load_plugin_textdomain( 'cpt-plugin', false, 'custom-post-type-ui/languages' );
19
20 // create custom plugin settings menu
21 add_action('admin_menu', 'cpt_plugin_menu');
22
23 //call delete post function
24 add_action( 'admin_init', 'cpt_delete_post_type' );
25
26 //call register settings function
27 add_action( 'admin_init', 'cpt_register_settings' );
28
29 //process custom taxonomies if they exist
30 add_action( 'init', 'cpt_create_custom_taxonomies', 0 );
31
32 //process custom taxonomies if they exist
33 add_action( 'init', 'cpt_create_custom_post_types', 0 );
34
35 function cpt_plugin_menu() {
36 //create custom post type menu
37 add_menu_page('Custom Post Types', 'Custom Post Types', 'administrator', 'cpt_main_menu', 'cpt_settings');
38
39 //create submenu items
40 add_submenu_page('cpt_main_menu', 'Add New', 'Add New', 'administrator', 'cpt_sub_add_new', 'cpt_add_new');
41 add_submenu_page('cpt_main_menu', 'Manage Post Types', 'Manage Post Types', 'administrator', 'cpt_sub_manage_cpt', 'cpt_manage_cpt');
42 add_submenu_page('cpt_main_menu', 'Manage Taxonomies', 'Manage Taxonomies', 'administrator', 'cpt_sub_manage_taxonomies', 'cpt_manage_taxonomies');
43 }
44
45 //temp fix, should do: http://planetozh.com/blog/2008/04/how-to-load-javascript-with-your-wordpress-plugin/
46 //only load JS if on a CPT page
47 If ( strpos($_SERVER['REQUEST_URI'], 'cpt')>0 ) {
48 add_action( 'admin_head', 'cpt_wp_add_styles' );
49 }
50 // Add JS Scripts
51 function cpt_wp_add_styles() {
52 ?>
53 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js">
54 </script>
55 <script type="text/javascript" >
56 jQuery(document).ready(function()
57 {
58 jQuery(".comment_button").click(function(){
59
60 var element = jQuery(this);
61 var I = element.attr("id");
62
63 jQuery("#slidepanel"+I).slideToggle(300);
64 jQuery(this).toggleClass("active");
65
66 return false;
67 });
68 });
69 </script>
70 <?php
71 }
72
73 function cpt_create_custom_post_types() {
74 //register custom post types
75 $cpt_post_types = get_option('cpt_custom_post_types');
76
77 //check if option value is an Array before proceeding
78 if ( is_array( $cpt_post_types ) ) {
79 foreach ($cpt_post_types as $cpt_post_type) {
80
81 //set post type values
82 $cpt_label = ( !$cpt_post_type["label"] ) ? esc_html($cpt_post_type["name"]) : esc_html($cpt_post_type["label"]);
83 $cpt_singular = ( !$cpt_post_type["singular_label"] ) ? $cpt_label : esc_html($cpt_post_type["singular_label"]);
84 $cpt_rewrite_slug = ( !$cpt_post_type["rewrite_slug"] ) ? esc_html($cpt_post_type["name"]) : esc_html($cpt_post_type["rewrite_slug"]);
85 $cpt_menu_position = ( !$cpt_post_type["menu_position"] ) ? null : intval($cpt_post_type["menu_position"]);
86 $cpt_taxonomies = ( !$cpt_post_type[1] ) ? array() : $cpt_post_type[1];
87 $cpt_supports = ( !$cpt_post_type[0] ) ? array() : $cpt_post_type[0];
88 //$cpt_show_in_menu = ( !$cpt_post_type["show_in_menu_string"] ) ? null : $cpt_post_type["show_in_menu_string"];
89
90 if ( isset ( $cpt_post_type["show_in_menu"] ) ) {
91 $cpt_show_in_menu = ( $cpt_post_type["show_in_menu"] == 1 ) ? true : false;
92 $cpt_show_in_menu = ( $cpt_post_type["show_in_menu_string"] ) ? $cpt_post_type["show_in_menu_string"] : $cpt_show_in_menu;
93 }else{
94 $cpt_show_in_menu = true;
95 }
96 //set custom label values
97 $cpt_labels['name'] = $cpt_label;
98 $cpt_labels['singular_name'] = $cpt_post_type["singular_label"];
99
100 if ( isset ( $cpt_post_type[2]["menu_name"] ) ) {
101 $cpt_labels['menu_name'] = ( $cpt_post_type[2]["menu_name"] ) ? $cpt_post_type[2]["menu_name"] : $cpt_label;
102 }
103
104 $cpt_has_archive = ( isset ( $cpt_post_type["has_archive"] ) ) ? get_disp_boolean( $cpt_post_type["has_archive"] ) : null;
105
106 $cpt_labels['add_new'] = ( $cpt_post_type[2]["add_new"] ) ? $cpt_post_type[2]["add_new"] : 'Add ' .$cpt_singular;
107 $cpt_labels['add_new_item'] = ( $cpt_post_type[2]["add_new_item"] ) ? $cpt_post_type[2]["add_new_item"] : 'Add New ' .$cpt_singular;
108 $cpt_labels['edit'] = ( $cpt_post_type[2]["edit"] ) ? $cpt_post_type[2]["edit"] : 'Edit';
109 $cpt_labels['edit_item'] = ( $cpt_post_type[2]["edit_item"] ) ? $cpt_post_type[2]["edit_item"] : 'Edit ' .$cpt_singular;
110 $cpt_labels['new_item'] = ( $cpt_post_type[2]["new_item"] ) ? $cpt_post_type[2]["new_item"] : 'New ' .$cpt_singular;
111 $cpt_labels['view'] = ( $cpt_post_type[2]["view"] ) ? $cpt_post_type[2]["view"] : 'View ' .$cpt_singular;
112 $cpt_labels['view_item'] = ( $cpt_post_type[2]["view_item"] ) ? $cpt_post_type[2]["view_item"] : 'View ' .$cpt_singular;
113 $cpt_labels['search_items'] = ( $cpt_post_type[2]["search_items"] ) ? $cpt_post_type[2]["search_items"] : 'Search ' .$cpt_label;
114 $cpt_labels['not_found'] = ( $cpt_post_type[2]["not_found"] ) ? $cpt_post_type[2]["not_found"] : 'No ' .$cpt_label. ' Found';
115 $cpt_labels['not_found_in_trash'] = ( $cpt_post_type[2]["not_found_in_trash"] ) ? $cpt_post_type[2]["not_found_in_trash"] : 'No ' .$cpt_label. ' Found in Trash';
116 $cpt_labels['parent'] = ( $cpt_post_type[2]["parent"] ) ? $cpt_post_type[2]["parent"] : 'Parent ' .$cpt_singular;
117
118 register_post_type( $cpt_post_type["name"], array( 'label' => __($cpt_label),
119 'public' => get_disp_boolean($cpt_post_type["public"]),
120 'singular_label' => $cpt_post_type["singular_label"],
121 'show_ui' => get_disp_boolean($cpt_post_type["show_ui"]),
122 'has_archive' => $cpt_has_archive,
123 'show_in_menu' => $cpt_show_in_menu,
124 'capability_type' => $cpt_post_type["capability_type"],
125 'hierarchical' => get_disp_boolean($cpt_post_type["hierarchical"]),
126 'rewrite' => array('slug' => $cpt_rewrite_slug),
127 'query_var' => get_disp_boolean($cpt_post_type["query_var"]),
128 'description' => esc_html($cpt_post_type["description"]),
129 'menu_position' => $cpt_menu_position,
130 'supports' => $cpt_supports,
131 'taxonomies' => $cpt_taxonomies,
132 'labels' => $cpt_labels
133 ) );
134 }
135 }
136 }
137
138
139 function cpt_create_custom_taxonomies() {
140 //register custom taxonomies
141 $cpt_tax_types = get_option('cpt_custom_tax_types');
142
143 //check if option value is an array before proceeding
144 if ( is_array( $cpt_tax_types ) ) {
145 foreach ($cpt_tax_types as $cpt_tax_type) {
146
147 //set custom taxonomy values
148 $cpt_label = ( !$cpt_tax_type["label"] ) ? esc_html($cpt_tax_type["name"]) : esc_html($cpt_tax_type["label"]);
149 $cpt_singular_label = ( !$cpt_tax_type["singular_label"] ) ? esc_html($cpt_tax_type["name"]) : esc_html($cpt_tax_type["singular_label"]);
150 $cpt_rewrite_slug = ( !$cpt_tax_type["rewrite_slug"] ) ? esc_html($cpt_tax_type["name"]) : esc_html($cpt_tax_type["rewrite_slug"]);
151 $cpt_post_types = ( !$cpt_tax_type[1] ) ? $cpt_tax_type["cpt_name"] : $cpt_tax_type[1];
152
153 //set custom label values
154 $cpt_labels['name'] = $cpt_label;
155 $cpt_labels['singular_name'] = $cpt_tax_type["singular_label"];
156 $cpt_labels['search_items'] = ( $cpt_tax_type[0]["search_items"] ) ? $cpt_tax_type[0]["search_items"] : 'Search ' .$cpt_label;
157 $cpt_labels['popular_items'] = ( $cpt_tax_type[0]["popular_items"] ) ? $cpt_tax_type[0]["popular_items"] : 'Popular ' .$cpt_label;
158 $cpt_labels['all_items'] = ( $cpt_tax_type[0]["all_items"] ) ? $cpt_tax_type[0]["all_items"] : 'All ' .$cpt_label;
159 $cpt_labels['parent_item'] = ( $cpt_tax_type[0]["parent_item"] ) ? $cpt_tax_type[0]["parent_item"] : 'Parent ' .$cpt_singular_label;
160 $cpt_labels['parent_item_colon'] = ( $cpt_tax_type[0]["parent_item_colon"] ) ? $cpt_tax_type[0]["parent_item_colon"] : 'Parent ' .$cpt_singular_label. ':';
161 $cpt_labels['edit_item'] = ( $cpt_tax_type[0]["edit_item"] ) ? $cpt_tax_type[0]["edit_item"] : 'Edit ' .$cpt_singular_label;
162 $cpt_labels['update_item'] = ( $cpt_tax_type[0]["update_item"] ) ? $cpt_tax_type[0]["update_item"] : 'Update ' .$cpt_singular_label;
163 $cpt_labels['add_new_item'] = ( $cpt_tax_type[0]["add_new_item"] ) ? $cpt_tax_type[0]["add_new_item"] : 'Add New ' .$cpt_singular_label;
164 $cpt_labels['new_item_name'] = ( $cpt_tax_type[0]["new_item_name"] ) ? $cpt_tax_type[0]["new_item_name"] : 'New ' .$cpt_singular_label. ' Name';
165 $cpt_labels['separate_items_with_commas'] = ( $cpt_tax_type[0]["separate_items_with_commas"] ) ? $cpt_tax_type[0]["separate_items_with_commas"] : 'Separate ' .$cpt_label. ' with commas';
166 $cpt_labels['add_or_remove_items'] = ( $cpt_tax_type[0]["add_or_remove_items"] ) ? $cpt_tax_type[0]["add_or_remove_items"] : 'Add or remove ' .$cpt_label;
167 $cpt_labels['choose_from_most_used'] = ( $cpt_tax_type[0]["choose_from_most_used"] ) ? $cpt_tax_type[0]["choose_from_most_used"] : 'Choose from the most used ' .$cpt_label;
168
169 //register our custom taxonomies
170 register_taxonomy( $cpt_tax_type["name"],
171 $cpt_post_types,
172 array( 'hierarchical' => get_disp_boolean($cpt_tax_type["hierarchical"]),
173 'label' => $cpt_label,
174 'show_ui' => get_disp_boolean($cpt_tax_type["show_ui"]),
175 'query_var' => get_disp_boolean($cpt_tax_type["query_var"]),
176 'rewrite' => array('slug' => $cpt_rewrite_slug),
177 'singular_label' => $cpt_singular_label,
178 'labels' => $cpt_labels
179 ) );
180
181 }
182 }
183 }
184
185 //delete custom post type or custom taxonomy
186 function cpt_delete_post_type() {
187 global $CPT_URL;
188
189 //check if we are deleting a custom post type
190 If(isset($_GET['deltype'])) {
191 check_admin_referer('cpt_delete_post_type');
192 $delType = intval($_GET['deltype']);
193 $cpt_post_types = get_option('cpt_custom_post_types');
194
195 unset($cpt_post_types[$delType]);
196
197 $cpt_post_types = array_values($cpt_post_types);
198
199 update_option('cpt_custom_post_types', $cpt_post_types);
200
201 If (isset($_GET['return'])) {
202 $RETURN_URL = cpt_check_return(esc_attr($_GET['return']));
203 }Else{
204 $RETURN_URL = $CPT_URL;
205 }
206
207 wp_redirect($RETURN_URL .'&cpt_msg=del');
208 }
209
210 //check if we are deleting a custom taxonomy
211 If(isset($_GET['deltax'])) {
212 check_admin_referer('cpt_delete_tax');
213
214 $delType = intval($_GET['deltax']);
215 $cpt_taxonomies = get_option('cpt_custom_tax_types');
216
217 unset($cpt_taxonomies[$delType]);
218
219 $cpt_taxonomies = array_values($cpt_taxonomies);
220
221 update_option('cpt_custom_tax_types', $cpt_taxonomies);
222
223 If (isset($_GET['return'])) {
224 $RETURN_URL = cpt_check_return(esc_attr($_GET['return']));
225 }Else{
226 $RETURN_URL = $CPT_URL;
227 }
228
229 wp_redirect($RETURN_URL .'&cpt_msg=del');
230 }
231
232 }
233
234 function cpt_register_settings() {
235 global $cpt_error, $CPT_URL;
236
237 If (isset($_POST['cpt_edit'])) {
238 //edit a custom post type
239 check_admin_referer('cpt_add_custom_post_type');
240
241 //custom post type to edit
242 $cpt_edit = intval($_POST['cpt_edit']);
243
244 //edit the custom post type
245 $cpt_form_fields = $_POST['cpt_custom_post_type'];
246
247 //add support checkbox values to array
248 $cpt_supports = ( isset( $_POST['cpt_supports'] ) ) ? $_POST['cpt_supports'] : null;
249 array_push($cpt_form_fields, $cpt_supports);
250
251 //add taxonomies support checkbox values to array
252 $cpt_addon_taxes = ( isset( $_POST['cpt_addon_taxes'] ) ) ? $_POST['cpt_addon_taxes'] : null;
253 array_push($cpt_form_fields, $cpt_addon_taxes);
254
255 //add label values to array
256 array_push($cpt_form_fields, $_POST['cpt_labels']);
257
258 //load custom posts saved in WP
259 $cpt_options = get_option('cpt_custom_post_types');
260
261 If (is_array($cpt_options)) {
262
263 unset($cpt_options[$cpt_edit]);
264
265 //insert new custom post type into the array
266 array_push($cpt_options, $cpt_form_fields);
267
268 $cpt_options = array_values($cpt_options);
269
270 //save custom post types
271 update_option('cpt_custom_post_types', $cpt_options);
272
273 If (isset($_GET['return'])) {
274 $RETURN_URL = cpt_check_return(esc_attr($_GET['return']));
275 }Else{
276 $RETURN_URL = $CPT_URL;
277 }
278
279 wp_redirect($RETURN_URL);
280
281 }
282
283 }ElseIf(isset($_POST['cpt_submit'])) {
284 //create a new custom post type
285 check_admin_referer('cpt_add_custom_post_type');
286
287 //retrieve new custom post type values
288 $cpt_form_fields = $_POST['cpt_custom_post_type'];
289
290 If (empty($cpt_form_fields["name"])) {
291 If (isset($_GET['return'])) {
292 $RETURN_URL = cpt_check_return(esc_attr($_GET['return']));
293 }Else{
294 $RETURN_URL = $CPT_URL;
295 }
296
297 wp_redirect($RETURN_URL .'&cpt_error=1');
298 exit();
299 }
300
301 //add support checkbox values to array
302 $cpt_supports = ( isset( $_POST['cpt_supports'] ) ) ? $_POST['cpt_supports'] : null;
303 array_push($cpt_form_fields, $cpt_supports);
304
305 //add taxonomies support checkbox values to array
306 $cpt_addon_taxes = ( isset( $_POST['cpt_addon_taxes'] ) ) ? $_POST['cpt_addon_taxes'] : null;
307 array_push($cpt_form_fields, $cpt_addon_taxes);
308
309 //add label values to array
310 array_push($cpt_form_fields, $_POST['cpt_labels']);
311
312 //load custom posts saved in WP
313 $cpt_options = get_option('cpt_custom_post_types');
314
315 //check if option exists, if not create an array for it
316 If (!is_array($cpt_options)) {
317 $cpt_options = array();
318 }
319
320 //insert new custom post type into the array
321 array_push($cpt_options, $cpt_form_fields);
322
323 //save new custom post type array in the CPT option
324 update_option('cpt_custom_post_types', $cpt_options);
325
326 If (isset($_GET['return'])) {
327 $RETURN_URL = cpt_check_return(esc_attr($_GET['return']));
328 }Else{
329 $RETURN_URL = $CPT_URL;
330 }
331
332 wp_redirect($RETURN_URL .'&cpt_msg=1');
333 }
334
335 If (isset($_POST['cpt_edit_tax'])) {
336 //edit a custom taxonomy
337 check_admin_referer('cpt_add_custom_taxonomy');
338
339 //custom taxonomy to edit
340 $cpt_edit = intval($_POST['cpt_edit_tax']);
341
342 //edit the custom taxonomy
343 $cpt_form_fields = $_POST['cpt_custom_tax'];
344
345 //add label values to array
346 array_push($cpt_form_fields, $_POST['cpt_tax_labels']);
347
348 //add attached post type values to array
349 array_push($cpt_form_fields, $_POST['cpt_post_types']);
350
351 //load custom posts saved in WP
352 $cpt_options = get_option('cpt_custom_tax_types');
353
354 If (is_array($cpt_options)) {
355
356 unset($cpt_options[$cpt_edit]);
357
358 //insert new custom post type into the array
359 array_push($cpt_options, $cpt_form_fields);
360
361 $cpt_options = array_values($cpt_options);
362
363 //save custom post types
364 update_option('cpt_custom_tax_types', $cpt_options);
365
366 If (isset($_GET['return'])) {
367 $RETURN_URL = cpt_check_return(esc_attr($_GET['return']));
368 }Else{
369 $RETURN_URL = $CPT_URL;
370 }
371
372 wp_redirect($RETURN_URL);
373
374 }
375
376 }ElseIf(isset($_POST['cpt_add_tax'])) {
377 //create new custom taxonomy
378 check_admin_referer('cpt_add_custom_taxonomy');
379
380 //retrieve new custom taxonomy values
381 $cpt_form_fields = $_POST['cpt_custom_tax'];
382
383 //verify required fields are filled out
384 If (empty($cpt_form_fields["name"])) {
385 If (isset($_GET['return'])) {
386 $RETURN_URL = cpt_check_return(esc_attr($_GET['return']));
387 }Else{
388 $RETURN_URL = $CPT_URL;
389 }
390
391 wp_redirect($RETURN_URL .'&cpt_error=2');
392 exit();
393 }elseif ( empty( $_POST['cpt_post_types'] ) ) {
394 If (isset($_GET['return'])) {
395 $RETURN_URL = cpt_check_return(esc_attr($_GET['return']));
396 }Else{
397 $RETURN_URL = $CPT_URL;
398 }
399
400 wp_redirect($RETURN_URL .'&cpt_error=3');
401 exit();
402 }
403
404 //add label values to array
405 array_push($cpt_form_fields, $_POST['cpt_tax_labels']);
406
407 //add attached post type values to array
408 array_push($cpt_form_fields, $_POST['cpt_post_types']);
409
410 //load custom taxonomies saved in WP
411 $cpt_options = get_option('cpt_custom_tax_types');
412
413 //check if option exists, if not create an array for it
414 If (!is_array($cpt_options)) {
415 $cpt_options = array();
416 }
417
418 //insert new custom taxonomy into the array
419 array_push($cpt_options, $cpt_form_fields);
420
421 //save new custom taxonomy array in the CPT option
422 update_option('cpt_custom_tax_types', $cpt_options);
423
424 If (isset($_GET['return'])) {
425 $RETURN_URL = cpt_check_return(esc_attr($_GET['return']));
426 }Else{
427 $RETURN_URL = $CPT_URL;
428 }
429
430 wp_redirect($RETURN_URL .'&cpt_msg=2');
431
432 }
433 }
434
435 //main welcome/settings page
436 function cpt_settings() {
437 global $CPT_URL, $wp_post_types;
438
439 //flush rewrite rules
440 flush_rewrite_rules();
441 ?>
442 <div class="wrap">
443 <?php screen_icon( 'plugins' ); ?>
444 <h2><?php _e('Custom Post Type UI', 'cpt-plugin'); ?></h2>
445 <p><?php _e('Plugin version', 'cpt-plugin'); ?>: <?php echo CPT_VERSION; ?></p>
446 <p><?php _e('WordPress version', 'cpt-plugin'); ?>: <?php echo get_bloginfo('version'); ?></p>
447 <table border="0" width="60%">
448 <tr>
449 <td colspan="3"><h2><?php _e( 'Help Support This Plugin!', 'cpt-plugin' ); ?></h2></td>
450 </tr>
451 <tr>
452 <td width="33%"><h3><?php _e( 'PayPal Donation', 'cpt-plugin' ); ?></h3></td>
453 <td width="33%"><h3><?php _e( 'Professional WordPress', 'cpt-plugin' ); ?></h3></td>
454 <td width="33%"><h3><?php _e( 'Professional WordPress<br />Plugin Development', 'cpt-plugin' ); ?></h3></td>
455 </tr>
456 <tr>
457 <td valign="top" width="33%">
458 <p>Please donate to the development<br />of Custom Post Type UI:
459 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
460 <input type="hidden" name="cmd" value="_s-xclick">
461 <input type="hidden" name="hosted_button_id" value="YJEDXPHE49Q3U">
462 <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
463 <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
464 </form>
465 </p>
466 </td>
467 <td valign="top" width="33%"><a href="http://bit.ly/pro-wp" target="_blank"><img src="<?php echo plugins_url( '/images/professional-wordpress.jpg', __FILE__ ); ?>" width="200"></a><br />The leading book on WordPress design and development!</td>
468 <td valign="top" width="33%"><a href="http://amzn.to/plugindevbook" target="_blank"><img src="<?php echo plugins_url( '/images/professional-wordpress-plugin-development.png', __FILE__ ); ?>" width="200"></a><br />Check out my new book all about plugin development!</td>
469 </tr>
470 </table>
471
472 <h3><?php _e('Frequently Asked Questions', 'cpt-plugin'); ?></h3>
473 <p>Q: <strong>How can I display content from a custom post type on my website?</strong></p>
474 <p>
475 A: Justin Tadlock has written some great posts on the topic:<br />
476 <a href="http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page" target="_blank">Showing Custom Post Types on your Home Page</a><br />
477 <a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress" target="_blank">Custom Post Types in WordPress</a>
478 </p>
479 <p>Q: <strong>How can I add custom meta boxes to my custom post types?</strong></p>
480 <p>A: The More Fields plugin does a great job at creating custom meta boxes and fully supports custom post types: <a href="http://wordpress.org/extend/plugins/more-fields/" target="_blank">http://wordpress.org/extend/plugins/more-fields/</a></p>
481 <p>Q: <strong>I changed my custom post type name and now I can't get to my posts</strong></p>
482 <p>A: You can either change the custom post type name back to the original name or try the Post Type Switcher plugin: <a href="http://wordpress.org/extend/plugins/post-type-switcher/" target="_blank">http://wordpress.org/extend/plugins/post-type-switcher/</a></p>
483 <h3><?php _e('Slightly Outdated Demo Video', 'cpt-plugin'); ?></h3>
484 <object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=10187055&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=10187055&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
485 <h3><?php _e( 'Latest WebDevStudios.com News', 'cpt-plugin' ); ?></h3>
486 <?php
487 echo '<div class="cp-rss-widget">';
488
489 wp_widget_rss_output( array(
490 'url' => esc_url( 'http://webdevstudios.com/feed/' ),
491 'title' => __( 'WebDevStudios.com News', 'cpt-plugin' ),
492 'items' => 5,
493 'show_summary' => 1,
494 'show_author' => 0,
495 'show_date' => 1
496 ) );
497
498 echo '</div>';
499 ?>
500 </div>
501 <?php
502 //load footer
503 cpt_footer();
504 }
505
506 //manage custom post types page
507 function cpt_manage_cpt() {
508 global $CPT_URL;
509
510 $MANAGE_URL = cpt_check_return( 'add' );
511
512 ?>
513 <div class="wrap">
514 <?php
515 //check for success/error messages
516 If (isset($_GET['cpt_msg']) && $_GET['cpt_msg']=='del') { ?>
517 <div id="message" class="updated">
518 <?php _e('Custom post type deleted successfully', 'cpt-plugin'); ?>
519 </div>
520 <?php
521 }
522 ?>
523 <?php screen_icon( 'plugins' ); ?>
524 <h2><?php _e('Manage Custom Post Types', 'cpt-plugin') ?></h2>
525 <p><?php _e('Deleting custom post types does <strong>NOT</strong> delete any content added to those post types. You can easily recreate your post types and the content will still exist.', 'cpt-plugin') ?></p>
526 <?php
527 $cpt_post_types = get_option('cpt_custom_post_types');
528 If (is_array($cpt_post_types)) {
529 ?>
530 <table width="100%" class="widefat">
531 <thead>
532 <tr>
533 <th><?php _e('Action', 'cpt-plugin');?></th>
534 <th><?php _e('Name', 'cpt-plugin');?></th>
535 <th><?php _e('Label', 'cpt-plugin');?></th>
536 <th><?php _e('Public', 'cpt-plugin');?></th>
537 <th><?php _e('Show UI', 'cpt-plugin');?></th>
538 <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
539 <th><?php _e('Rewrite', 'cpt-plugin');?></th>
540 <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
541 <th><?php _e('Total Published', 'cpt-plugin');?></th>
542 <th><?php _e('Total Drafts', 'cpt-plugin');?></th>
543 <th><?php _e('Supports', 'cpt-plugin');?></th>
544 </tr>
545 </thead>
546 <tfoot>
547 <tr>
548 <th><?php _e('Action', 'cpt-plugin');?></th>
549 <th><?php _e('Name', 'cpt-plugin');?></th>
550 <th><?php _e('Label', 'cpt-plugin');?></th>
551 <th><?php _e('Public', 'cpt-plugin');?></th>
552 <th><?php _e('Show UI', 'cpt-plugin');?></th>
553 <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
554 <th><?php _e('Rewrite', 'cpt-plugin');?></th>
555 <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
556 <th><?php _e('Total Published', 'cpt-plugin');?></th>
557 <th><?php _e('Total Drafts', 'cpt-plugin');?></th>
558 <th><?php _e('Supports', 'cpt-plugin');?></th>
559 </tr>
560 </tfoot>
561 <?php
562 $thecounter=0;
563 $cpt_names = array();
564 foreach ($cpt_post_types as $cpt_post_type) {
565
566 $del_url = cpt_check_return( 'cpt' ) .'&deltype=' .$thecounter .'&return=cpt';
567 $del_url = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($del_url, 'cpt_delete_post_type') : $del_url;
568
569 $edit_url = $MANAGE_URL .'&edittype=' .$thecounter .'&return=cpt';
570 $edit_url = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($edit_url, 'cpt_edit_post_type') : $edit_url;
571
572 $cpt_counts = wp_count_posts($cpt_post_type["name"]);
573
574 $rewrite_slug = ( $cpt_post_type["rewrite_slug"] ) ? $cpt_post_type["rewrite_slug"] : $cpt_post_type["name"];
575 ?>
576 <tr>
577 <td valign="top"><a href="<?php echo $del_url; ?>">Delete</a> / <a href="<?php echo $edit_url; ?>">Edit</a> / <a href="#" class="comment_button" id="<?php echo $thecounter; ?>">Get Code</a></td>
578 <td valign="top"><?php echo stripslashes($cpt_post_type["name"]); ?></td>
579 <td valign="top"><?php echo stripslashes($cpt_post_type["label"]); ?></td>
580 <td valign="top"><?php echo disp_boolean($cpt_post_type["public"]); ?></td>
581 <td valign="top"><?php echo disp_boolean($cpt_post_type["show_ui"]); ?></td>
582 <td valign="top"><?php echo disp_boolean($cpt_post_type["hierarchical"]); ?></td>
583 <td valign="top"><?php echo disp_boolean($cpt_post_type["rewrite"]); ?></td>
584 <td valign="top"><?php echo $rewrite_slug; ?></td>
585 <td valign="top"><?php echo $cpt_counts->publish; ?></td>
586 <td valign="top"><?php echo $cpt_counts->draft; ?></td>
587 <td>
588 <?php
589 If (is_array($cpt_post_type[0])) {
590 foreach ($cpt_post_type[0] as $cpt_supports) {
591 echo $cpt_supports .'<br />';
592 }
593 }
594 ?>
595 </td>
596 </tr>
597 <tr>
598 <td colspan="12">
599 <div style="display:none;" id="slidepanel<?php echo $thecounter; ?>">
600 <?php
601 //display register_post_type code
602 $custom_post_type='';
603 $cpt_support_array='';
604 $cpt_tax_array='';
605
606 $cpt_label = ( !$cpt_post_type["label"] ) ? esc_html($cpt_post_type["name"]) : esc_html($cpt_post_type["label"]);
607 $cpt_singular = ( !$cpt_post_type["singular_label"] ) ? $cpt_label : esc_html($cpt_post_type["singular_label"]);
608 $cpt_rewrite_slug = ( !$cpt_post_type["rewrite_slug"] ) ? esc_html($cpt_post_type["name"]) : esc_html($cpt_post_type["rewrite_slug"]);
609 $cpt_menu_position = ( !$cpt_post_type["menu_position"] ) ? null : intval($cpt_post_type["menu_position"]);
610 $cpt_show_in_menu = ( $cpt_post_type["show_in_menu"] == 1 ) ? 'true' : 'false';
611 $cpt_show_in_menu = ( $cpt_post_type["show_in_menu_string"] ) ? '\''.$cpt_post_type["show_in_menu_string"].'\'' : $cpt_show_in_menu;
612
613 //set custom label values
614 $cpt_labels['name'] = $cpt_label;
615 $cpt_labels['singular_name'] = $cpt_post_type["singular_label"];
616 $cpt_labels['menu_name'] = ( $cpt_post_type[2]["menu_name"] ) ? $cpt_post_type[2]["menu_name"] : $cpt_label;
617 $cpt_labels['add_new'] = ( $cpt_post_type[2]["add_new"] ) ? $cpt_post_type[2]["add_new"] : 'Add ' .$cpt_singular;
618 $cpt_labels['add_new_item'] = ( $cpt_post_type[2]["add_new_item"] ) ? $cpt_post_type[2]["add_new_item"] : 'Add New ' .$cpt_singular;
619 $cpt_labels['edit'] = ( $cpt_post_type[2]["edit"] ) ? $cpt_post_type[2]["edit"] : 'Edit';
620 $cpt_labels['edit_item'] = ( $cpt_post_type[2]["edit_item"] ) ? $cpt_post_type[2]["edit_item"] : 'Edit ' .$cpt_singular;
621 $cpt_labels['new_item'] = ( $cpt_post_type[2]["new_item"] ) ? $cpt_post_type[2]["new_item"] : 'New ' .$cpt_singular;
622 $cpt_labels['view'] = ( $cpt_post_type[2]["view"] ) ? $cpt_post_type[2]["view"] : 'View ' .$cpt_singular;
623 $cpt_labels['view_item'] = ( $cpt_post_type[2]["view_item"] ) ? $cpt_post_type[2]["view_item"] : 'View ' .$cpt_singular;
624 $cpt_labels['search_items'] = ( $cpt_post_type[2]["search_items"] ) ? $cpt_post_type[2]["search_items"] : 'Search ' .$cpt_label;
625 $cpt_labels['not_found'] = ( $cpt_post_type[2]["not_found"] ) ? $cpt_post_type[2]["not_found"] : 'No ' .$cpt_label. ' Found';
626 $cpt_labels['not_found_in_trash'] = ( $cpt_post_type[2]["not_found_in_trash"] ) ? $cpt_post_type[2]["not_found_in_trash"] : 'No ' .$cpt_label. ' Found in Trash';
627 $cpt_labels['parent'] = ( $cpt_post_type[2]["parent"] ) ? $cpt_post_type[2]["parent"] : 'Parent ' .$cpt_singular;
628
629 if( is_array( $cpt_post_type[0] ) ) {
630 foreach ( $cpt_post_type[0] as $cpt_supports ) {
631 //build supports variable
632 $cpt_support_array .= '\''.$cpt_supports.'\',';
633 }
634 }
635
636 if( is_array( $cpt_post_type[1] ) ) {
637 foreach ( $cpt_post_type[1] as $cpt_taxes ) {
638 //build taxonomies variable
639 $cpt_tax_array .= '\''.$cpt_taxes.'\',';
640 }
641 }
642
643 $custom_post_type = 'register_post_type(\'' .$cpt_post_type["name"]. '\', array( \'label\' => \''.__($cpt_label).'\',';
644 $custom_post_type .= '\'description\' => \''. $cpt_post_type["description"].'\',';
645 $custom_post_type .= '\'public\' => '.disp_boolean($cpt_post_type["public"]).',';
646 $custom_post_type .= '\'show_ui\' => '.disp_boolean($cpt_post_type["show_ui"]).',';
647 $custom_post_type .= '\'show_in_menu\' => ' .$cpt_show_in_menu .',';
648 $custom_post_type .= '\'capability_type\' => \''.$cpt_post_type["capability_type"].'\',';
649 $custom_post_type .= '\'hierarchical\' => '.disp_boolean($cpt_post_type["hierarchical"]).',';
650 $custom_post_type .= '\'rewrite\' => array(\'slug\' => \'' .$cpt_post_type["rewrite_slug"]. '\'),';
651 $custom_post_type .= '\'query_var\' => '. disp_boolean($cpt_post_type["query_var"]).',';
652
653 if ( $cpt_post_type["has_archive"] ) {
654 $custom_post_type .= '\'has_archive\' => '. disp_boolean( $cpt_post_type["has_archive"] ).',';
655 }
656
657 if ( $cpt_post_type["menu_position"] ) {
658 $custom_post_type .= '\'menu_position\' => '. $cpt_post_type["menu_position"].',';
659 }
660
661 $custom_post_type .= '\'supports\' => array(' .$cpt_support_array.'),';
662
663 if ( $cpt_tax_array ) {
664 $custom_post_type .= '\'taxonomies\' => array(' .$cpt_tax_array.'),';
665 }
666
667 if ( $cpt_labels ) {
668 $custom_post_type .= '\'labels\' => '.var_export( $cpt_labels, true ).',';
669 }
670
671 $custom_post_type .= ') );';
672
673 echo _e('Place the below code in your themes functions.php file to manually create this custom post type','cpt-plugin').'<br>';
674 echo _e('This is a <strong>BETA</strong> feature. Please <a href="http://webdevstudios.com/support/forum/custom-post-type-ui/">report bugs</a>.','cpt-plugin').'<br>';
675 echo '<textarea rows="5" cols="100">' .$custom_post_type .'</textarea>';
676
677 ?>
678 </div>
679 </td>
680 </tr>
681 <?php
682 $thecounter++;
683 $cpt_names[] = strtolower( $cpt_post_type["name"] );
684 }
685
686 $args=array(
687 'public' => true,
688 '_builtin' => false
689 );
690 $output = 'objects'; // or objects
691 $post_types=get_post_types($args,$output);
692 if ( $post_types ) {
693
694 ?></table>
695 <?php screen_icon( 'plugins' ); ?>
696 <h2><?php _e('Additional Custom Post Types', 'cpt-plugin') ?></h2>
697 <p><?php _e('The custom post types below are registered in WordPress but were not created by the Custom Post Type UI Plugin.', 'cpt-plugin') ?></p>
698 <?php
699 foreach ($post_types as $post_type ) {
700
701 if ( !in_array( strtolower( $post_type->name ), $cpt_names ) ) {
702 if ( isset( $cpt_first ) && !$cpt_first ) {
703 ?>
704 <table width="100%" class="widefat">
705 <thead>
706 <tr>
707 <th><?php _e('Name', 'cpt-plugin');?></th>
708 <th><?php _e('Label', 'cpt-plugin');?></th>
709 <th><?php _e('Singular Label', 'cpt-plugin');?></th>
710 <th><?php _e('Public', 'cpt-plugin');?></th>
711 <th><?php _e('Show UI', 'cpt-plugin');?></th>
712 <th><?php _e('Capability Type', 'cpt-plugin');?></th>
713 <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
714 <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
715 <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
716 <th><?php _e('Query Var', 'cpt-plugin');?></th>
717 </tr>
718 </thead>
719 <tfoot>
720 <tr>
721 <th><?php _e('Name', 'cpt-plugin');?></th>
722 <th><?php _e('Label', 'cpt-plugin');?></th>
723 <th><?php _e('Singular Label', 'cpt-plugin');?></th>
724 <th><?php _e('Public', 'cpt-plugin');?></th>
725 <th><?php _e('Show UI', 'cpt-plugin');?></th>
726 <th><?php _e('Capability Type', 'cpt-plugin');?></th>
727 <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
728 <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
729 <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
730 <th><?php _e('Query Var', 'cpt-plugin');?></th>
731 </tr>
732 </tfoot>
733 <?php
734 $cpt_first = true;
735 }
736 $rewrite_slug = ( isset( $post_type->rewrite_slug ) ) ? $post_type->rewrite_slug : $post_type->name;
737 ?>
738 <tr>
739 <td valign="top"><?php echo $post_type->name; ?></td>
740 <td valign="top"><?php echo $post_type->label; ?></td>
741 <td valign="top"><?php echo $post_type->singular_label; ?></td>
742 <td valign="top"><?php echo disp_boolean($post_type->public); ?></td>
743 <td valign="top"><?php echo disp_boolean($post_type->show_ui); ?></td>
744 <td valign="top"><?php echo $post_type->capability_type; ?></td>
745 <td valign="top"><?php echo disp_boolean($post_type->hierarchical); ?></td>
746 <td valign="top"><?php echo disp_boolean($post_type->rewrite); ?></td>
747 <td valign="top"><?php echo $rewrite_slug; ?></td>
748 <td valign="top"><?php echo disp_boolean($post_type->query_var); ?></td>
749 </tr>
750 <?php
751 }
752 }
753 }
754
755 if ( isset($cpt_first) && !$cpt_first ) {
756 echo '<tr><td><strong>';
757 _e( 'No additional post types found', 'cpt-plugin' );
758 echo '</strong></td></tr>';
759 }
760 ?>
761 </table>
762
763 </div><?php
764 //load footer
765 cpt_footer();
766 }
767 }
768
769 //manage custom taxonomies page
770 function cpt_manage_taxonomies() {
771 global $CPT_URL;
772
773 $MANAGE_URL = cpt_check_return( 'add' );
774
775 ?>
776 <div class="wrap">
777 <?php
778 //check for success/error messages
779 If (isset($_GET['cpt_msg']) && $_GET['cpt_msg']=='del') { ?>
780 <div id="message" class="updated">
781 <?php _e('Custom taxonomy deleted successfully', 'cpt-plugin'); ?>
782 </div>
783 <?php
784 }
785 ?>
786 <?php screen_icon( 'plugins' ); ?>
787 <h2><?php _e('Manage Custom Taxonomies', 'cpt-plugin') ?></h2>
788 <p><?php _e('Deleting custom taxonomies does <strong>NOT</strong> delete any content added to those taxonomies. You can easily recreate your taxonomies and the content will still exist.', 'cpt-plugin') ?></p>
789 <?php
790 $cpt_tax_types = get_option('cpt_custom_tax_types');
791
792 If (is_array($cpt_tax_types)) {
793 ?>
794 <table width="100%" class="widefat">
795 <thead>
796 <tr>
797 <th><?php _e('Action', 'cpt-plugin');?></th>
798 <th><?php _e('Name', 'cpt-plugin');?></th>
799 <th><?php _e('Label', 'cpt-plugin');?></th>
800 <th><?php _e('Singular Label', 'cpt-plugin');?></th>
801 <th><?php _e('Attached Post Types', 'cpt-plugin');?></th>
802 <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
803 <th><?php _e('Show UI', 'cpt-plugin');?></th>
804 <th><?php _e('Rewrite', 'cpt-plugin');?></th>
805 <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
806 </tr>
807 </thead>
808 <tfoot>
809 <tr>
810 <th><?php _e('Action', 'cpt-plugin');?></th>
811 <th><?php _e('Name', 'cpt-plugin');?></th>
812 <th><?php _e('Label', 'cpt-plugin');?></th>
813 <th><?php _e('Singular Label', 'cpt-plugin');?></th>
814 <th><?php _e('Attached Post Types', 'cpt-plugin');?></th>
815 <th><?php _e('Hierarchical', 'cpt-plugin');?></th>
816 <th><?php _e('Show UI', 'cpt-plugin');?></th>
817 <th><?php _e('Rewrite', 'cpt-plugin');?></th>
818 <th><?php _e('Rewrite Slug', 'cpt-plugin');?></th>
819 </tr>
820 </tfoot>
821 <?php
822 $thecounter=0;
823 foreach ($cpt_tax_types as $cpt_tax_type) {
824
825 $del_url = cpt_check_return( 'cpt' ) .'&deltax=' .$thecounter .'&return=tax';
826 $del_url = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($del_url, 'cpt_delete_tax') : $del_url;
827
828 $edit_url = $MANAGE_URL .'&edittax=' .$thecounter .'&return=tax';
829 $edit_url = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($edit_url, 'cpt_edit_tax') : $edit_url;
830
831 $rewrite_slug = ( $cpt_tax_type["rewrite_slug"] ) ? $cpt_tax_type["rewrite_slug"] : $cpt_tax_type["name"];
832 ?>
833 <tr>
834 <td valign="top"><a href="<?php echo $del_url; ?>">Delete</a> / <a href="<?php echo $edit_url; ?>">Edit</a> / <a href="#" class="comment_button" id="<?php echo $thecounter; ?>">Get Code</a></td>
835 <td valign="top"><?php echo stripslashes($cpt_tax_type["name"]); ?></td>
836 <td valign="top"><?php echo stripslashes($cpt_tax_type["label"]); ?></td>
837 <td valign="top"><?php echo stripslashes($cpt_tax_type["singular_label"]); ?></td>
838 <td valign="top">
839 <?php
840 if ( isset( $cpt_tax_type["cpt_name"] ) ) {
841 echo stripslashes($cpt_tax_type["cpt_name"]);
842 }elseif ( is_array( $cpt_tax_type[1] ) ) {
843 foreach ($cpt_tax_type[1] as $cpt_post_types) {
844 echo $cpt_post_types .'<br />';
845 }
846 }
847 ?>
848 </td>
849 <td valign="top"><?php echo disp_boolean($cpt_tax_type["hierarchical"]); ?></td>
850 <td valign="top"><?php echo disp_boolean($cpt_tax_type["show_ui"]); ?></td>
851 <td valign="top"><?php echo disp_boolean($cpt_tax_type["rewrite"]); ?></td>
852 <td valign="top"><?php echo $rewrite_slug; ?></td>
853 </tr>
854 <tr>
855 <td colspan="10">
856 <div style="display:none;" id="slidepanel<?php echo $thecounter; ?>">
857 <?php
858 //display register_taxonomy code
859 $cpt_tax_types = get_option('cpt_custom_tax_types');
860 $custom_tax = '';
861
862 //check if option value is an Array before proceeding
863 If (is_array($cpt_tax_types)) {
864 //foreach ($cpt_tax_types as $cpt_tax_type) {
865
866 If (!$cpt_tax_type["label"]) {
867 $cpt_label = esc_html($cpt_tax_type["name"]);
868 }Else{
869 $cpt_label = esc_html($cpt_tax_type["label"]);
870 }
871
872 //check if singular label was filled out
873 If (!$cpt_tax_type["singular_label"]) {
874 $cpt_singular_label = esc_html($cpt_tax_type["name"]);
875 }Else{
876 $cpt_singular_label = esc_html($cpt_tax_type["singular_label"]);
877 }
878
879 $cpt_post_types = ( !$cpt_tax_type[1] ) ? $cpt_tax_type["cpt_name"] : var_export( $cpt_tax_type[1], true );
880
881 //register our custom taxonomies
882 $custom_tax = 'register_taxonomy(\'' .$cpt_tax_type["name"]. '\',';
883 $custom_tax .= $cpt_post_types .',';
884 $custom_tax .= 'array( \'hierarchical\' => '.disp_boolean($cpt_tax_type["hierarchical"]).', ';
885 $custom_tax .= '\'label\' => \''.$cpt_label.'\',';
886 $custom_tax .= '\'show_ui\' => '.disp_boolean($cpt_tax_type["show_ui"]).',';
887 $custom_tax .= '\'query_var\' => '. disp_boolean($cpt_tax_type["query_var"]).',';
888 $custom_tax .= '\'rewrite\' => array(\'slug\' => \'' .$cpt_tax_type["rewrite_slug"]. '\'),';
889 $custom_tax .= '\'singular_label\' => \''.$cpt_singular_label.'\'';
890 $custom_tax .= ') );';
891
892 echo '<br>';
893 echo _e('Place the below code in your themes functions.php file to manually create this custom taxonomy','cpt-plugin').'<br>';
894 echo _e('This is a <strong>BETA</strong> feature. Please <a href="http://webdevstudios.com/support/forum/custom-post-type-ui/">report bugs</a>.','cpt-plugin').'<br>';
895 echo '<textarea rows="5" cols="100">' .$custom_tax .'</textarea>';
896
897 //}
898 }
899 ?>
900 </div>
901 </td>
902 </tr>
903 <?php
904 $thecounter++;
905 }
906 ?></table>
907 </div>
908 <?php
909 //load footer
910 cpt_footer();
911 }
912 }
913
914 //add new custom post type / taxonomy page
915 function cpt_add_new() {
916 global $cpt_error, $CPT_URL;
917
918 If (isset($_GET['return'])) {
919 $RETURN_URL = 'action="' .cpt_check_return(esc_attr($_GET['return'])). '"';
920 }Else{
921 $RETURN_URL = '';
922 }
923
924
925 //check if we are editing a custom post type or creating a new one
926 If (isset($_GET['edittype']) && !isset($_GET['cpt_edit'])) {
927 check_admin_referer('cpt_edit_post_type');
928
929 //get post type to edit
930 $editType = intval($_GET['edittype']);
931
932 //load custom posts saved in WP
933 $cpt_options = get_option('cpt_custom_post_types');
934
935 //load custom post type values to edit
936 $cpt_post_type_name = $cpt_options[$editType]["name"];
937 $cpt_label = $cpt_options[$editType]["label"];
938 $cpt_singular_label = $cpt_options[$editType]["singular_label"];
939 $cpt_public = $cpt_options[$editType]["public"];
940 $cpt_showui = $cpt_options[$editType]["show_ui"];
941 $cpt_capability = $cpt_options[$editType]["capability_type"];
942 $cpt_hierarchical = $cpt_options[$editType]["hierarchical"];
943 $cpt_rewrite = $cpt_options[$editType]["rewrite"];
944 $cpt_rewrite_slug = $cpt_options[$editType]["rewrite_slug"];
945 $cpt_query_var = $cpt_options[$editType]["query_var"];
946 $cpt_description = $cpt_options[$editType]["description"];
947 $cpt_menu_position = $cpt_options[$editType]["menu_position"];
948 $cpt_supports = $cpt_options[$editType][0];
949 $cpt_taxes = $cpt_options[$editType][1];
950 $cpt_labels = $cpt_options[$editType][2];
951 $cpt_has_archive = ( isset( $cpt_options[$editType]["has_archive"] ) ) ? $cpt_options[$editType]["has_archive"] : null;
952 $cpt_show_in_menu = ( isset( $cpt_options[$editType]["show_in_menu"] ) ) ? $cpt_options[$editType]["show_in_menu"] : null;
953 $cpt_show_in_menu_string = ( isset( $cpt_options[$editType]["show_in_menu_string"] ) ) ? $cpt_options[$editType]["show_in_menu_string"] : null;
954
955 $cpt_submit_name = 'Save Custom Post Type';
956 }Else{
957 $cpt_submit_name = 'Create Custom Post Type';
958 }
959
960 If (isset($_GET['edittax']) && !isset($_GET['cpt_edit'])) {
961 check_admin_referer('cpt_edit_tax');
962
963 //get post type to edit
964 $editTax = intval($_GET['edittax']);
965
966 //load custom posts saved in WP
967 $cpt_options = get_option('cpt_custom_tax_types');
968
969 //load custom post type values to edit
970 $cpt_tax_name = $cpt_options[$editTax]["name"];
971 $cpt_tax_label = $cpt_options[$editTax]["label"];
972 $cpt_singular_label = $cpt_options[$editTax]["singular_label"];
973 $cpt_tax_object_type = ( isset( $cpt_options[$editTax]["cpt_name"] ) ) ? $cpt_options[$editTax]["cpt_name"] : null;
974 $cpt_tax_hierarchical = $cpt_options[$editTax]["hierarchical"];
975 $cpt_tax_showui = $cpt_options[$editTax]["show_ui"];
976 $cpt_tax_query_var = $cpt_options[$editTax]["query_var"];
977 $cpt_tax_rewrite = $cpt_options[$editTax]["rewrite"];
978 $cpt_tax_rewrite_slug = $cpt_options[$editTax]["rewrite_slug"];
979 $cpt_tax_labels = $cpt_options[$editTax][0];
980 $cpt_post_types = $cpt_options[$editTax][1];
981
982 $cpt_tax_submit_name = 'Save Custom Taxonomy';
983 }Else{
984 $cpt_tax_submit_name = 'Create Custom Taxonomy';
985 }
986
987 //flush rewrite rules
988 flush_rewrite_rules();
989
990 ?><div class="wrap"><?php
991 //check for success/error messages
992 If (isset($_GET['cpt_msg']) && $_GET['cpt_msg']==1) { ?>
993 <div id="message" class="updated">
994 <?php _e('Custom post type created successfully. You may need to refresh to view the new post type. <a href="' .cpt_check_return( 'cpt' ) .'">Manage custom post types</a>', 'cpt-plugin'); ?>
995 </div>
996 <?php
997 }elseIf (isset($_GET['cpt_msg']) && $_GET['cpt_msg']==2) { ?>
998 <div id="message" class="updated">
999 <?php _e('Custom taxonomy created successfully. You may need to refresh to view the new taxonomy. <a href="' .cpt_check_return( 'tax' ) .'">Manage custom taxonomies</a>', 'cpt-plugin'); ?>
1000 </div>
1001 <?php
1002 }else{
1003 If (isset($_GET['cpt_error']) && $_GET['cpt_error']==1) { ?>
1004 <div class="error">
1005 <?php _e('Post type name is a required field.', 'cpt-plugin'); ?>
1006 </div>
1007 <?php }ElseIf (isset($_GET['cpt_error']) && $_GET['cpt_error']==2) { ?>
1008 <div class="error">
1009 <?php _e('Taxonomy name is a required field.', 'cpt-plugin'); ?>
1010 </div>
1011 <?php }ElseIf (isset($_GET['cpt_error']) && $_GET['cpt_error']==3) { ?>
1012 <div class="error">
1013 <?php _e('You must assign your custom taxonomy to at least one post type.', 'cpt-plugin'); ?>
1014 </div>
1015 <?php }
1016 }
1017 ?>
1018 <?php screen_icon( 'plugins' ); ?>
1019 <?php If ( isset( $_GET['edittype'] ) || isset( $_GET['edittax'] ) ) { ?>
1020 <h2><?php _e('Edit Custom Post Type or Taxonomy', 'cpt-plugin') ?> &middot; <a href="<?php echo cpt_check_return( 'add' ); ?>"><?php _e('Reset', 'cpt-plugin');?></a></h2>
1021 <?php }Else{ ?>
1022 <h2><?php _e('Create New Custom Post Type or Taxonomy', 'cpt-plugin') ?> &middot; <a href="<?php echo cpt_check_return( 'add' ); ?>"><?php _e('Reset', 'cpt-plugin');?></a></h2>
1023 <?php } ?>
1024 <table border="0" cellspacing="10" class="widefat">
1025 <tr>
1026 <td width="50%" valign="top">
1027 <p><?php _e('If you are unfamiliar with the options below only fill out the <strong>Post Type Name</strong> and <strong>Label</strong> fields and check which meta boxes to support. The other settings are set to the most common defaults for custom post types.', 'cpt-plugin'); ?></p>
1028 <form method="post" <?php echo $RETURN_URL; ?>>
1029 <?php if ( function_exists('wp_nonce_field') )
1030 wp_nonce_field('cpt_add_custom_post_type'); ?>
1031 <?php If (isset($_GET['edittype'])) { ?>
1032 <input type="hidden" name="cpt_edit" value="<?php echo $editType; ?>" />
1033 <?php } ?>
1034 <table class="form-table">
1035 <tr valign="top">
1036 <th scope="row"><?php _e('Post Type Name', 'cpt-plugin') ?> <span style="color:red;">*</span></th>
1037 <td><input type="text" name="cpt_custom_post_type[name]" tabindex="1" value="<?php If (isset($cpt_post_type_name)) { echo esc_attr($cpt_post_type_name); } ?>" /> <a href="#" title="The post type name. Used to retrieve custom post type content. Should be short and sweet" style="cursor: help;">?</a> (e.g. movies)</td>
1038 </tr>
1039
1040 <tr valign="top">
1041 <th scope="row"><?php _e('Label', 'cpt-plugin') ?></th>
1042 <td><input type="text" name="cpt_custom_post_type[label]" tabindex="2" value="<?php If (isset($cpt_label)) { echo esc_attr($cpt_label); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. Movies)</td>
1043 </tr>
1044
1045 <tr valign="top">
1046 <th scope="row"><?php _e('Singular Label', 'cpt-plugin') ?></th>
1047 <td><input type="text" name="cpt_custom_post_type[singular_label]" tabindex="3" value="<?php If (isset($cpt_singular_label)) { echo esc_attr($cpt_singular_label); } ?>" /> <a href="#" title="Custom Post Type Singular label. Used in WordPress when a singular label is needed." style="cursor: help;">?</a> (e.g. Movie)</td>
1048
1049 </tr>
1050
1051 <tr valign="top">
1052 <th scope="row"><?php _e('Description', 'cpt-plugin') ?></th>
1053 <td><textarea name="cpt_custom_post_type[description]" tabindex="4" rows="4" cols="40"><?php If (isset($cpt_description)) { echo esc_attr($cpt_description); } ?></textarea><a href="#" title="Custom Post Type Description. Describe what your custom post type is used for." style="cursor: help;">?</a></td>
1054 </tr>
1055
1056 <tr valign="top">
1057 <td colspan="2">
1058 <p align="center">
1059 <?php echo '<a href="#" class="comment_button" id="1">' . __('Advanced Label Options', 'cpt-plugin') . '</a>'; ?> &middot;
1060 <?php echo '<a href="#" class="comment_button" id="2">' . __('Advanced Options', 'cpt-plugin') . '</a>'; ?>
1061 </p>
1062 </td>
1063 </tr>
1064
1065 </table>
1066
1067 <div style="display:none;" id="slidepanel1">
1068 <p><?php _e('Below are the advanced label options for custom post types. If you are unfamiliar with these labels the plugin will automatically create labels based off of your custom post type name', 'cpt-plugin'); ?></p>
1069 <table class="form-table">
1070
1071 <tr valign="top">
1072 <th scope="row"><?php _e('Menu Name', 'cpt-plugin') ?></th>
1073 <td><input type="text" name="cpt_labels[menu_name]" tabindex="2" value="<?php If (isset($cpt_labels["menu_name"])) { echo esc_attr($cpt_labels["menu_name"]); } ?>" /> <a href="#" title="Custom menu name for your custom post type." style="cursor: help;">?</a> (e.g. My Movies)</td>
1074 </tr>
1075
1076 <tr valign="top">
1077 <th scope="row"><?php _e('Add New', 'cpt-plugin') ?></th>
1078 <td><input type="text" name="cpt_labels[add_new]" tabindex="2" value="<?php If (isset($cpt_labels["add_new"])) { echo esc_attr($cpt_labels["add_new"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. Add New)</td>
1079 </tr>
1080
1081 <tr valign="top">
1082 <th scope="row"><?php _e('Add New Item', 'cpt-plugin') ?></th>
1083 <td><input type="text" name="cpt_labels[add_new_item]" tabindex="2" value="<?php If (isset($cpt_labels["add_new_item"])) { echo esc_attr($cpt_labels["add_new_item"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. Add New Movie)</td>
1084 </tr>
1085
1086 <tr valign="top">
1087 <th scope="row"><?php _e('Edit', 'cpt-plugin') ?></th>
1088 <td><input type="text" name="cpt_labels[edit]" tabindex="2" value="<?php If (isset($cpt_labels["edit"])) { echo esc_attr($cpt_labels["edit"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. Edit)</td>
1089 </tr>
1090
1091 <tr valign="top">
1092 <th scope="row"><?php _e('Edit Item', 'cpt-plugin') ?></th>
1093 <td><input type="text" name="cpt_labels[edit_item]" tabindex="2" value="<?php If (isset($cpt_labels["edit_item"])) { echo esc_attr($cpt_labels["edit_item"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. Edit Movie)</td>
1094 </tr>
1095
1096 <tr valign="top">
1097 <th scope="row"><?php _e('New Item', 'cpt-plugin') ?></th>
1098 <td><input type="text" name="cpt_labels[new_item]" tabindex="2" value="<?php If (isset($cpt_labels["new_item"])) { echo esc_attr($cpt_labels["new_item"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. New Movie)</td>
1099 </tr>
1100
1101 <tr valign="top">
1102 <th scope="row"><?php _e('View', 'cpt-plugin') ?></th>
1103 <td><input type="text" name="cpt_labels[view]" tabindex="2" value="<?php If (isset($cpt_labels["view"])) { echo esc_attr($cpt_labels["view"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. View Movie)</td>
1104 </tr>
1105
1106 <tr valign="top">
1107 <th scope="row"><?php _e('View Item', 'cpt-plugin') ?></th>
1108 <td><input type="text" name="cpt_labels[view_item]" tabindex="2" value="<?php If (isset($cpt_labels["view_item"])) { echo esc_attr($cpt_labels["view_item"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. View Movie)</td>
1109 </tr>
1110
1111 <tr valign="top">
1112 <th scope="row"><?php _e('Search Items', 'cpt-plugin') ?></th>
1113 <td><input type="text" name="cpt_labels[search_items]" tabindex="2" value="<?php If (isset($cpt_labels["search_items"])) { echo esc_attr($cpt_labels["search_items"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. Search Movies)</td>
1114 </tr>
1115
1116 <tr valign="top">
1117 <th scope="row"><?php _e('Not Found', 'cpt-plugin') ?></th>
1118 <td><input type="text" name="cpt_labels[not_found]" tabindex="2" value="<?php If (isset($cpt_labels["not_found"])) { echo esc_attr($cpt_labels["not_found"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. No Movies Found)</td>
1119 </tr>
1120
1121 <tr valign="top">
1122 <th scope="row"><?php _e('Not Found in Trash', 'cpt-plugin') ?></th>
1123 <td><input type="text" name="cpt_labels[not_found_in_trash]" tabindex="2" value="<?php If (isset($cpt_labels["not_found_in_trash"])) { echo esc_attr($cpt_labels["not_found_in_trash"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. No Movies found in Trash)</td>
1124 </tr>
1125
1126 <tr valign="top">
1127 <th scope="row"><?php _e('Parent', 'cpt-plugin') ?></th>
1128 <td><input type="text" name="cpt_labels[parent]" tabindex="2" value="<?php If (isset($cpt_labels["parent"])) { echo esc_attr($cpt_labels["parent"]); } ?>" /> <a href="#" title="Post type label. Used in the admin menu for displaying post types." style="cursor: help;">?</a> (e.g. Parent Movie)</td>
1129 </tr>
1130
1131 </table>
1132 </div>
1133
1134 <div style="display:none;" id="slidepanel2">
1135 <table class="form-table">
1136 <tr valign="top">
1137 <th scope="row"><?php _e('Public', 'cpt-plugin') ?></th>
1138 <td>
1139 <SELECT name="cpt_custom_post_type[public]" tabindex="4">
1140 <OPTION value="0" <?php If (isset($cpt_public)) { If ($cpt_public == 0 && $cpt_public != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
1141 <OPTION value="1" <?php If (isset($cpt_public)) { If ($cpt_public == 1 || is_null($cpt_public)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
1142 </SELECT> <a href="#" title="Whether posts of this type should be shown in the admin UI" style="cursor: help;">?</a> (default: True)
1143 </td>
1144 </tr>
1145
1146 <tr valign="top">
1147 <th scope="row"><?php _e('Show UI', 'cpt-plugin') ?></th>
1148 <td>
1149 <SELECT name="cpt_custom_post_type[show_ui]" tabindex="5">
1150 <OPTION value="0" <?php If (isset($cpt_showui)) { If ($cpt_showui == 0 && $cpt_showui != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
1151 <OPTION value="1" <?php If (isset($cpt_showui)) { If ($cpt_showui == 1 || is_null($cpt_showui)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
1152 </SELECT> <a href="#" title="Whether to generate a default UI for managing this post type" style="cursor: help;">?</a> (default: True)
1153 </td>
1154 </tr>
1155
1156 <tr valign="top">
1157 <th scope="row"><?php _e('Has Archive', 'cpt-plugin') ?></th>
1158 <td>
1159 <SELECT name="cpt_custom_post_type[has_archive]" tabindex="6">
1160 <OPTION value="0" <?php If (isset($cpt_has_archive)) { If ($cpt_has_archive == 0) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>False</OPTION>
1161 <OPTION value="1" <?php If (isset($cpt_has_archive)) { If ($cpt_has_archive == 1) { echo 'selected="selected"'; } } ?>>True</OPTION>
1162 </SELECT> <a href="#" title="Whether the post type will have a post type archive page" style="cursor: help;">?</a> (default: False)
1163 </td>
1164 </tr>
1165
1166 <tr valign="top">
1167 <th scope="row"><?php _e('Capability Type', 'cpt-plugin') ?></th>
1168 <td><input type="text" name="cpt_custom_post_type[capability_type]" tabindex="6" value="post" value="<?php echo esc_attr($cpt_capability); ?>" /> <a href="#" title="The post type to use for checking read, edit, and delete capabilities" style="cursor: help;">?</a></td>
1169 </tr>
1170
1171 <tr valign="top">
1172 <th scope="row"><?php _e('Hierarchical', 'cpt-plugin') ?></th>
1173 <td>
1174 <SELECT name="cpt_custom_post_type[hierarchical]" tabindex="7">
1175 <OPTION value="0" <?php If (isset($cpt_hierarchical)) { If ($cpt_hierarchical == 0) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>False</OPTION>
1176 <OPTION value="1" <?php If (isset($cpt_hierarchical)) { If ($cpt_hierarchical == 1) { echo 'selected="selected"'; } } ?>>True</OPTION>
1177 </SELECT> <a href="#" title="Whether the post type is hierarchical" style="cursor: help;">?</a> (default: False)
1178 </td>
1179 </tr>
1180
1181 <tr valign="top">
1182 <th scope="row"><?php _e('Rewrite', 'cpt-plugin') ?></th>
1183 <td>
1184 <SELECT name="cpt_custom_post_type[rewrite]" tabindex="8">
1185 <OPTION value="0" <?php If (isset($cpt_rewrite)) { If ($cpt_rewrite == 0 && $cpt_rewrite != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
1186 <OPTION value="1" <?php If (isset($cpt_rewrite)) { If ($cpt_rewrite == 1 || is_null($cpt_rewrite)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
1187 </SELECT> <a href="#" title="" style="cursor: help;">?</a> (default: True)
1188 </td>
1189 </tr>
1190
1191 <tr valign="top">
1192 <th scope="row"><?php _e('Custom Rewrite Slug', 'cpt-plugin') ?></th>
1193 <td><input type="text" name="cpt_custom_post_type[rewrite_slug]" tabindex="9" value="<?php If (isset($cpt_rewrite_slug)) { echo esc_attr($cpt_rewrite_slug); } ?>" /> <a href="#" title="Custom Post Type Rewrite Slug" style="cursor: help;">?</a> (default: post type name)</td>
1194 </tr>
1195
1196 <tr valign="top">
1197 <th scope="row"><?php _e('Query Var', 'cpt-plugin') ?></th>
1198 <td>
1199 <SELECT name="cpt_custom_post_type[query_var]" tabindex="10">
1200 <OPTION value="0" <?php If (isset($cpt_query_var)) { If ($cpt_query_var == 0 && $cpt_query_var != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
1201 <OPTION value="1" <?php If (isset($cpt_query_var)) { If ($cpt_query_var == 1 || is_null($cpt_query_var)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
1202 </SELECT> <a href="#" title="" style="cursor: help;">?</a> (default: True)
1203 </td>
1204 </tr>
1205
1206 <tr valign="top">
1207 <th scope="row"><?php _e('Menu Position', 'cpt-plugin') ?></th>
1208 <td><input type="text" name="cpt_custom_post_type[menu_position]" tabindex="11" size="5" value="<?php If (isset($cpt_menu_position)) { echo esc_attr($cpt_menu_position); } ?>" /> <a href="#" title="The menu position of the custom post type" style="cursor: help;">?</a></td>
1209 </tr>
1210
1211 <tr valign="top">
1212 <th scope="row"><?php _e('Show in Menu', 'cpt-plugin') ?></th>
1213 <td>
1214 <SELECT name="cpt_custom_post_type[show_in_menu]" tabindex="10">
1215 <OPTION value="0" <?php If (isset($cpt_show_in_menu)) { If ($cpt_show_in_menu == 0 && $cpt_show_in_menu != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
1216 <OPTION value="1" <?php If (isset($cpt_show_in_menu)) { If ($cpt_show_in_menu == 1 || is_null($cpt_show_in_menu)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
1217 </SELECT> <a href="#" title="" style="cursor: help;">?</a> Top level page (e.g. 'plugins.php')
1218 <input type="text" name="cpt_custom_post_type[show_in_menu_string]" tabindex="12" size="5" value="<?php If (isset($cpt_show_in_menu_string)) { echo esc_attr($cpt_show_in_menu_string); } ?>" /> <a href="#" title="Whether to show the post type in the admin menu and where to show that menu. Note that show_ui must be true" style="cursor: help;">?</a></td>
1219 </tr>
1220
1221 <tr valign="top">
1222 <th scope="row"><?php _e('Supports', 'cpt-plugin') ?></th>
1223 <td>
1224 <input type="checkbox" name="cpt_supports[]" tabindex="11" value="title" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('title', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Title <a href="#" title="Adds the title meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1225 <input type="checkbox" name="cpt_supports[]" tabindex="12" value="editor" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('editor', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Editor <a href="#" title="Adds the content editor meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1226 <input type="checkbox" name="cpt_supports[]" tabindex="13" value="excerpt" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('excerpt', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Excerpt <a href="#" title="Adds the excerpt meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1227 <input type="checkbox" name="cpt_supports[]" tabindex="14" value="trackbacks" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('trackbacks', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Trackbacks <a href="#" title="Adds the trackbacks meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1228 <input type="checkbox" name="cpt_supports[]" tabindex="15" value="custom-fields" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('custom-fields', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Custom Fields <a href="#" title="Adds the custom fields meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1229 <input type="checkbox" name="cpt_supports[]" tabindex="16" value="comments" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('comments', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Comments <a href="#" title="Adds the comments meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1230 <input type="checkbox" name="cpt_supports[]" tabindex="17" value="revisions" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('revisions', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Revisions <a href="#" title="Adds the revisions meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1231 <input type="checkbox" name="cpt_supports[]" tabindex="18" value="thumbnail" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('thumbnail', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Featured Image <a href="#" title="Adds the featured image meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1232 <input type="checkbox" name="cpt_supports[]" tabindex="19" value="author" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('author', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Author <a href="#" title="Adds the author meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1233 <input type="checkbox" name="cpt_supports[]" tabindex="20" value="page-attributes" <?php If (isset($cpt_supports) && is_array($cpt_supports)) { If (in_array('page-attributes', $cpt_supports)) { echo 'checked="checked"'; } }Elseif (!isset($_GET['edittype'])) { echo 'checked="checked"'; } ?> />&nbsp;Page Attributes <a href="#" title="Adds the page attribute meta box when creating content for this custom post type" style="cursor: help;">?</a> <br/ >
1234 </td>
1235 </tr>
1236
1237 <tr valign="top">
1238 <th scope="row"><?php _e('Built-in Taxonomies', 'cpt-plugin') ?></th>
1239 <td>
1240 <?php
1241 //load built-in WP Taxonomies
1242 $args=array( 'public' => true );
1243 $output = 'objects';
1244 $add_taxes = get_taxonomies($args,$output);
1245 foreach ($add_taxes as $add_tax ) {
1246 if ( $add_tax->name != 'nav_menu' && $add_tax->name != 'post_format') {
1247 ?>
1248 <input type="checkbox" name="cpt_addon_taxes[]" tabindex="20" value="<?php echo $add_tax->name; ?>" <?php If (isset($cpt_taxes) && is_array($cpt_taxes)) { If (in_array($add_tax->name, $cpt_taxes)) { echo 'checked="checked"'; } } ?> />&nbsp;<?php echo $add_tax->label; ?><br />
1249 <?php
1250 }
1251 }
1252 ?>
1253 </td>
1254 </tr>
1255
1256 </table>
1257 </div>
1258
1259 <p class="submit">
1260 <input type="submit" class="button-primary" tabindex="21" name="cpt_submit" value="<?php _e($cpt_submit_name, 'cpt-plugin') ?>" />
1261 </p>
1262
1263 </form>
1264 </td>
1265 <td width="50%" valign="top">
1266 <?php
1267 //debug area
1268 $cpt_options = get_option('cpt_custom_tax_types');
1269 ?>
1270 <p><?php _e('If you are unfamiliar with the options below only fill out the <strong>Taxonomy Name</strong> and <strong>Post Type Name</strong> fields. The other settings are set to the most common defaults for custom taxonomies.', 'cpt-plugin');?></p>
1271 <form method="post" <?php echo $RETURN_URL; ?>>
1272 <?php if ( function_exists('wp_nonce_field') )
1273 wp_nonce_field('cpt_add_custom_taxonomy'); ?>
1274 <?php If (isset($_GET['edittax'])) { ?>
1275 <input type="hidden" name="cpt_edit_tax" value="<?php echo $editTax; ?>" />
1276 <?php } ?>
1277 <table class="form-table">
1278 <tr valign="top">
1279 <th scope="row"><?php _e('Taxonomy Name', 'cpt-plugin') ?> <span style="color:red;">*</span></th>
1280 <td><input type="text" name="cpt_custom_tax[name]" tabindex="21" value="<?php If (isset($cpt_tax_name)) { echo esc_attr($cpt_tax_name); } ?>" /> <a href="#" title="The taxonomy name. Used to retrieve custom taxonomy content. Should be short and sweet" style="cursor: help;">?</a> (e.g. actors)</td>
1281 </tr>
1282
1283 <tr valign="top">
1284 <th scope="row"><?php _e('Label', 'cpt-plugin') ?></th>
1285 <td><input type="text" name="cpt_custom_tax[label]" tabindex="22" value="<?php If (isset($cpt_tax_label)) { echo esc_attr($cpt_tax_label); } ?>" /> <a href="#" title="Taxonomy label. Used in the admin menu for displaying custom taxonomy." style="cursor: help;">?</a> (e.g. Actors)</td>
1286 </tr>
1287
1288 <tr valign="top">
1289 <th scope="row"><?php _e('Singular Label', 'cpt-plugin') ?></th>
1290 <td><input type="text" name="cpt_custom_tax[singular_label]" tabindex="23" value="<?php If (isset($cpt_singular_label)) { echo esc_attr($cpt_singular_label); } ?>" /> <a href="#" title="Taxonomy Singular label. Used in WordPress when a singular label is needed." style="cursor: help;">?</a> (e.g. Actor)</td>
1291 </tr>
1292
1293 <tr valign="top">
1294 <th scope="row"><?php _e('Attach to Post Type', 'cpt-plugin') ?> <span style="color:red;">*</span></th>
1295 <td>
1296 <?php if ( isset( $cpt_tax_object_type ) ) { ?>
1297 <strong>This is the old method. Delete the post type from the textbox and check which post type to attach this taxonomy to</strong>
1298 <input type="text" name="cpt_custom_tax[cpt_name]" tabindex="24" value="<?php If (isset($cpt_tax_object_type)) { echo esc_attr($cpt_tax_object_type); } ?>" /> <a href="#" title="What object to attach the custom taxonomy to. Can be post, page, or link by default. Can also be any custom post type name." style="cursor: help;">?</a> (e.g. movies)
1299 <?php } ?>
1300 <?php
1301 $args=array(
1302 'public' => true
1303 );
1304 $output = 'objects'; // or objects
1305 $post_types=get_post_types($args,$output);
1306 foreach ($post_types as $post_type ) {
1307 if ( $post_type->name != 'attachment' ) {
1308 ?>
1309 <input type="checkbox" name="cpt_post_types[]" tabindex="20" value="<?php echo $post_type->name; ?>" <?php If (isset($cpt_post_types) && is_array($cpt_post_types)) { If (in_array($post_type->name, $cpt_post_types)) { echo 'checked="checked"'; } } ?> />&nbsp;<?php echo $post_type->label; ?><br />
1310 <?php
1311 }
1312 }
1313 ?>
1314 </td>
1315 </tr>
1316
1317 <tr valign="top">
1318 <td colspan="2">
1319 <p align="center">
1320 <?php echo '<a href="#" class="comment_button" id="3">' . __('Advanced Label Options', 'cpt-plugin') . '</a>'; ?> &middot;
1321 <?php echo '<a href="#" class="comment_button" id="4">' . __('Advanced Options', 'cpt-plugin') . '</a>'; ?>
1322 </p>
1323 </td>
1324 </tr>
1325
1326 </table>
1327
1328 <div style="display:none;" id="slidepanel3">
1329 <p><?php _e('Below are the advanced label options for custom taxonomies. If you are unfamiliar with these labels the plugin will automatically create labels based off of your custom taxonomy name', 'cpt-plugin'); ?></p>
1330 <table class="form-table">
1331 <tr valign="top">
1332 <th scope="row"><?php _e('Search Items', 'cpt-plugin') ?></th>
1333 <td><input type="text" name="cpt_tax_labels[search_items]" tabindex="2" value="<?php If (isset($cpt_tax_labels["search_items"])) { echo esc_attr($cpt_tax_labels["search_items"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Search Actors)</td>
1334 </tr>
1335
1336 <tr valign="top">
1337 <th scope="row"><?php _e('Popular Items', 'cpt-plugin') ?></th>
1338 <td><input type="text" name="cpt_tax_labels[popular_items]" tabindex="2" value="<?php If (isset($cpt_tax_labels["popular_items"])) { echo esc_attr($cpt_tax_labels["popular_items"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Popular Actors)</td>
1339 </tr>
1340
1341 <tr valign="top">
1342 <th scope="row"><?php _e('All Items', 'cpt-plugin') ?></th>
1343 <td><input type="text" name="cpt_tax_labels[all_items]" tabindex="2" value="<?php If (isset($cpt_tax_labels["all_items"])) { echo esc_attr($cpt_tax_labels["all_items"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. All Actors)</td>
1344 </tr>
1345
1346 <tr valign="top">
1347 <th scope="row"><?php _e('Parent Item', 'cpt-plugin') ?></th>
1348 <td><input type="text" name="cpt_tax_labels[parent_item]" tabindex="2" value="<?php If (isset($cpt_tax_labels["parent_item"])) { echo esc_attr($cpt_tax_labels["parent_item"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Parent Actor)</td>
1349 </tr>
1350
1351 <tr valign="top">
1352 <th scope="row"><?php _e('Parent Item Colon', 'cpt-plugin') ?></th>
1353 <td><input type="text" name="cpt_tax_labels[parent_item_colon]" tabindex="2" value="<?php If (isset($cpt_tax_labels["parent_item_colon"])) { echo esc_attr($cpt_tax_labels["parent_item_colon"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Parent Actor:)</td>
1354 </tr>
1355
1356 <tr valign="top">
1357 <th scope="row"><?php _e('Edit Item', 'cpt-plugin') ?></th>
1358 <td><input type="text" name="cpt_tax_labels[edit_item]" tabindex="2" value="<?php If (isset($cpt_tax_labels["edit_item"])) { echo esc_attr($cpt_tax_labels["edit_item"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Edit Actor)</td>
1359 </tr>
1360
1361 <tr valign="top">
1362 <th scope="row"><?php _e('Update Item', 'cpt-plugin') ?></th>
1363 <td><input type="text" name="cpt_tax_labels[update_item]" tabindex="2" value="<?php If (isset($cpt_tax_labels["update_item"])) { echo esc_attr($cpt_tax_labels["update_item"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Update Actor)</td>
1364 </tr>
1365
1366 <tr valign="top">
1367 <th scope="row"><?php _e('Add New Item', 'cpt-plugin') ?></th>
1368 <td><input type="text" name="cpt_tax_labels[add_new_item]" tabindex="2" value="<?php If (isset($cpt_tax_labels["add_new_item"])) { echo esc_attr($cpt_tax_labels["add_new_item"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Add New Actor)</td>
1369 </tr>
1370
1371 <tr valign="top">
1372 <th scope="row"><?php _e('New Item Name', 'cpt-plugin') ?></th>
1373 <td><input type="text" name="cpt_tax_labels[new_item_name]" tabindex="2" value="<?php If (isset($cpt_tax_labels["new_item_name"])) { echo esc_attr($cpt_tax_labels["new_item_name"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. New Actor Name)</td>
1374 </tr>
1375
1376 <tr valign="top">
1377 <th scope="row"><?php _e('Separate Items with Commas', 'cpt-plugin') ?></th>
1378 <td><input type="text" name="cpt_tax_labels[separate_items_with_commas]" tabindex="2" value="<?php If (isset($cpt_tax_labels["separate_items_with_commas"])) { echo esc_attr($cpt_tax_labels["separate_items_with_commas"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Separate actors with commas)</td>
1379 </tr>
1380
1381 <tr valign="top">
1382 <th scope="row"><?php _e('Add or Remove Items', 'cpt-plugin') ?></th>
1383 <td><input type="text" name="cpt_tax_labels[add_or_remove_items]" tabindex="2" value="<?php If (isset($cpt_tax_labels["add_or_remove_items"])) { echo esc_attr($cpt_tax_labels["add_or_remove_items"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Add or remove actors)</td>
1384 </tr>
1385
1386 <tr valign="top">
1387 <th scope="row"><?php _e('Choose From Most Used', 'cpt-plugin') ?></th>
1388 <td><input type="text" name="cpt_tax_labels[choose_from_most_used]" tabindex="2" value="<?php If (isset($cpt_tax_labels["choose_from_most_used"])) { echo esc_attr($cpt_tax_labels["choose_from_most_used"]); } ?>" /> <a href="#" title="Custom taxonomy label. Used in the admin menu for displaying taxonomies." style="cursor: help;">?</a> (e.g. Choose from the most used actors)</td>
1389 </tr>
1390 </table>
1391 </div>
1392
1393 <div style="display:none;" id="slidepanel4">
1394 <table class="form-table">
1395 <tr valign="top">
1396 <th scope="row"><?php _e('Hierarchical', 'cpt-plugin') ?></th>
1397 <td>
1398 <SELECT name="cpt_custom_tax[hierarchical]" tabindex="25">
1399 <OPTION value="0" <?php If (isset($cpt_tax_hierarchical)) { If ($cpt_tax_hierarchical == 0) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>False</OPTION>
1400 <OPTION value="1" <?php If (isset($cpt_tax_hierarchical)) { If ($cpt_tax_hierarchical == 1) { echo 'selected="selected"'; } } ?>>True</OPTION>
1401 </SELECT> <a href="#" title="Whether the taxonomy is hierarchical" style="cursor: help;">?</a> (default: False)
1402 </td>
1403 </tr>
1404
1405 <tr valign="top">
1406 <th scope="row"><?php _e('Show UI', 'cpt-plugin') ?></th>
1407 <td>
1408 <SELECT name="cpt_custom_tax[show_ui]" tabindex="26">
1409 <OPTION value="0" <?php If (isset($cpt_tax_showui)) { If ($cpt_tax_showui == 0 && $cpt_tax_showui != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
1410 <OPTION value="1" <?php If (isset($cpt_tax_showui)) { If ($cpt_tax_showui == 1 || is_null($cpt_tax_showui)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
1411 </SELECT> <a href="#" title="Whether to generate a default UI for managing this custom taxonomy" style="cursor: help;">?</a> (default: True)
1412 </td>
1413 </tr>
1414
1415 <tr valign="top">
1416 <th scope="row"><?php _e('Query Var', 'cpt-plugin') ?></th>
1417 <td>
1418 <SELECT name="cpt_custom_tax[query_var]" tabindex="27">
1419 <OPTION value="0" <?php If (isset($cpt_tax_query_var)) { If ($cpt_tax_query_var == 0 && $cpt_tax_query_var != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
1420 <OPTION value="1" <?php If (isset($cpt_tax_query_var)) { If ($cpt_tax_query_var == 1 || is_null($cpt_tax_query_var)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
1421 </SELECT> <a href="#" title="" style="cursor: help;">?</a> (default: True)
1422 </td>
1423 </tr>
1424
1425 <tr valign="top">
1426 <th scope="row"><?php _e('Rewrite', 'cpt-plugin') ?></th>
1427 <td>
1428 <SELECT name="cpt_custom_tax[rewrite]" tabindex="28">
1429 <OPTION value="0" <?php If (isset($cpt_tax_rewrite)) { If ($cpt_tax_rewrite == 0 && $cpt_tax_rewrite != '') { echo 'selected="selected"'; } } ?>>False</OPTION>
1430 <OPTION value="1" <?php If (isset($cpt_tax_rewrite)) { If ($cpt_tax_rewrite == 1 || is_null($cpt_tax_rewrite)) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>True</OPTION>
1431 </SELECT> <a href="#" title="" style="cursor: help;">?</a> (default: True)
1432 </td>
1433 </tr>
1434
1435 <tr valign="top">
1436 <th scope="row"><?php _e('Custom Rewrite Slug', 'cpt-plugin') ?></th>
1437 <td><input type="text" name="cpt_custom_tax[rewrite_slug]" tabindex="9" value="<?php If (isset($cpt_tax_rewrite_slug)) { echo esc_attr($cpt_tax_rewrite_slug); } ?>" /> <a href="#" title="Custom Taxonomy Rewrite Slug" style="cursor: help;">?</a> (default: taxonomy name)</td>
1438 </tr>
1439
1440 </table>
1441 </div>
1442
1443 <p class="submit">
1444 <input type="submit" class="button-primary" tabindex="29" name="cpt_add_tax" value="<?php _e($cpt_tax_submit_name, 'cpt-plugin') ?>" />
1445 </p>
1446 </form>
1447 </td>
1448 </tr>
1449 </table>
1450 </div>
1451 <?php
1452 //load footer
1453 cpt_footer();
1454
1455 }
1456
1457 function cpt_footer() {
1458 ?>
1459 <hr />
1460 <p class="cp_about"><a target="_blank" href="http://webdevstudios.com/support/forum/custom-post-type-ui/">Custom Post Type UI</a> v<?php echo CPT_VERSION; ?> - <a href="http://webdevstudios.com/support/forum/custom-post-type-ui/" target="_blank">Please Report Bugs</a> &middot; Follow on Twitter: <a href="http://twitter.com/williamsba" target="_blank">Brad</a> &middot; <a href="http://twitter.com/pluginize" target="_blank">Pluginize</a> &middot; <a href="http://twitter.com/webdevstudios" target="_blank">WDS</a></p>
1461 <?php
1462 }
1463
1464 function cpt_check_return($return) {
1465 global $CPT_URL;
1466
1467 If( $return=='cpt' ) {
1468 return ( isset( $_GET['return'] ) ) ? admin_url( 'admin.php?page=cpt_sub_manage_cpt&return=cpt' ) : admin_url( 'admin.php?page=cpt_sub_manage_cpt' );
1469 }Elseif( $return=='tax' ){
1470 return ( isset( $_GET['return'] ) ) ? admin_url( 'admin.php?page=cpt_sub_manage_taxonomies&return=tax' ) : admin_url( 'admin.php?page=cpt_sub_manage_taxonomies' );
1471 }Elseif( $return=='add' ) {
1472 return admin_url( 'admin.php?page=cpt_sub_add_new' );
1473 }Else{
1474 return admin_url( 'admin.php?page=cpt_sub_add_new' );
1475 }
1476 }
1477
1478 function get_disp_boolean($booText) {
1479 If ($booText == '0') {
1480 return false;
1481 }Else{
1482 return true;
1483 }
1484 }
1485
1486 function disp_boolean($booText) {
1487 If ($booText == '0') {
1488 return 'false';
1489 }Else{
1490 return 'true';
1491 }
1492 }
1493 ?>