Custom Post Type UI - Version 0.7.2.0

Version Description

= 0.7.2 = * Added exclude_from_search support * Fixed display bug with capability type * Fixed JavaScript bug * Strict CPT name check * Code cleanup

= 0.7.1 = * XSS security bug patched

= 0.7 = * WordPress 3.1 support * Added has_archive and show_in_menu support * Added label for custom menu name * Updated plugin UI to be consistent with WordPress styles * Added "Get Code" feature to easily copy code used for post types and taxonomies (BETA)

= 0.6.2 = * Added support for assigning custom taxonomies to post types when creating/editing * Fixed bug when setting hierarchy on a post type (props @JohnPBloch) * Fixed an error when registering a post type with no supported meta boxes * Fixed "Undefined index" error when determining return URLs * Added Chinese translation

= 0.6.1 = * Added translation functionality and .pot file * Added Japanese translation * Reworked entire path structure fixing "page not found" errors * Fixed "First argument is expected to be a valid callback" error * Random bug fixes

= 0.6 = * Added support for custom labels with custom post types and taxonomies * Added ability to assign built-in taxonomies to custom post types * Added ability to assign custom taxonomies to multiple post types * Fixed jQuery conflict with other plugins (props shadyvb) * Managing post types now displays total published/draft per type * Code optimization and cleanup

= 0.5.2 = * Updated excerpts to excerpt in CPT Support field (props vlad27aug)

= 0.5.1 = * Added flush_rewrite_rules() to reset rules when using custom rewrite slugs

= 0.5 = * Fixed multiple bugs * If upgrading from pre 0.5 version you will need to recreate your custom post types

= 0.4.1 = * Fixed bug with REWRITE and QUERY_VAR values not executing correctly

= 0.4 = * Default view now hides advanced options * Get Code link to easily copy/paste code used to create custom post types and taxonomies * Added support for 'author' and 'page-attributes' in CPT Supports field

= 0.3.1 = * Fixed multiple warnings and errors

= 0.3 = * added new menu/submenus for individual sections * added support for 'title' and 'editor' in CPT Supports field * added Singular Label for custom taxonomies (props sleary)

= 0.2.1 = * Set default Query Var setting to False

= 0.2 = * Fixed the siteurl bug * Added support for creating custom taxonomies

= 0.1.2 = * Fixed a bug where default values were incorrect

= 0.1.1 = * Fixed a bunch of warnings

= 0.1 = * First beta release

Download this release

Release Info

Developer williamsba1
Plugin Icon 128x128 Custom Post Type UI
Version 0.7.2.0
Comparing to
See all releases

Code changes from version 0.7.1.0 to 0.7.2.0

Files changed (3) hide show
  1. custom-post-type-ui.php +153 -117
  2. readme.txt +17 -11
  3. screenshot-1.png +0 -0
custom-post-type-ui.php CHANGED
@@ -4,12 +4,12 @@ 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' );
@@ -44,28 +44,31 @@ function cpt_plugin_menu() {
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
  }
@@ -102,6 +105,7 @@ function cpt_create_custom_post_types() {
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;
@@ -123,6 +127,7 @@ function cpt_create_custom_post_types() {
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"]),
@@ -187,46 +192,49 @@ 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
  }
@@ -234,12 +242,12 @@ function cpt_delete_post_type() {
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'];
@@ -250,184 +258,192 @@ function cpt_register_settings() {
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
  }
@@ -464,7 +480,7 @@ function cpt_settings() {
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>
@@ -654,6 +670,10 @@ If (isset($_GET['cpt_msg']) && $_GET['cpt_msg']=='del') { ?>
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
  }
@@ -949,6 +969,7 @@ If (isset($_GET['edittype']) && !isset($_GET['cpt_edit'])) {
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
 
@@ -1016,9 +1037,9 @@ If (isset($_GET['cpt_msg']) && $_GET['cpt_msg']==1) { ?>
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">
@@ -1026,17 +1047,22 @@ If (isset($_GET['cpt_msg']) && $_GET['cpt_msg']==1) { ?>
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>
@@ -1163,9 +1189,19 @@ If (isset($_GET['cpt_msg']) && $_GET['cpt_msg']==1) { ?>
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">
@@ -1215,7 +1251,7 @@ If (isset($_GET['cpt_msg']) && $_GET['cpt_msg']==1) { ?>
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">
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.2
8
  Author URI: http://webdevstudios.com/
9
  */
10
 
11
  // Define current version constant
12
+ define( 'CPT_VERSION', '0.7.2' );
13
 
14
  // Define plugin URL constant
15
  $CPT_URL = cpt_check_return( 'add' );
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
+
51
  // Add JS Scripts
52
  function cpt_wp_add_styles() {
53
+
54
+ wp_enqueue_script( 'jquery' );
55
  ?>
56
+
 
57
  <script type="text/javascript" >
58
+ jQuery(document).ready(function()
59
+ {
60
+ jQuery(".comment_button").click(function(){
61
 
62
+ var element = jQuery(this);
63
+ var I = element.attr("id");
64
 
65
+ jQuery("#slidepanel"+I).slideToggle(300);
66
+ jQuery(this).toggleClass("active");
67
 
68
+ return false;
69
+
70
+ });
71
+ });
72
  </script>
73
  <?php
74
  }
105
  }
106
 
107
  $cpt_has_archive = ( isset ( $cpt_post_type["has_archive"] ) ) ? get_disp_boolean( $cpt_post_type["has_archive"] ) : null;
108
+ $cpt_exclude_from_search = ( isset ( $cpt_post_type["exclude_from_search"] ) ) ? get_disp_boolean( $cpt_post_type["exclude_from_search"] ) : null;
109
 
110
  $cpt_labels['add_new'] = ( $cpt_post_type[2]["add_new"] ) ? $cpt_post_type[2]["add_new"] : 'Add ' .$cpt_singular;
111
  $cpt_labels['add_new_item'] = ( $cpt_post_type[2]["add_new_item"] ) ? $cpt_post_type[2]["add_new_item"] : 'Add New ' .$cpt_singular;
127
  'show_in_menu' => $cpt_show_in_menu,
128
  'capability_type' => $cpt_post_type["capability_type"],
129
  'hierarchical' => get_disp_boolean($cpt_post_type["hierarchical"]),
130
+ 'exclude_from_search' => $cpt_exclude_from_search,
131
  'rewrite' => array('slug' => $cpt_rewrite_slug),
132
  'query_var' => get_disp_boolean($cpt_post_type["query_var"]),
133
  'description' => esc_html($cpt_post_type["description"]),
192
  global $CPT_URL;
193
 
194
  //check if we are deleting a custom post type
195
+ if( isset( $_GET['deltype'] ) ) {
196
+
197
+ //nonce security check
198
+ check_admin_referer( 'cpt_delete_post_type' );
199
+
200
+ $delType = intval( $_GET['deltype'] );
201
+ $cpt_post_types = get_option( 'cpt_custom_post_types' );
202
 
203
+ unset( $cpt_post_types[$delType] );
204
 
205
+ $cpt_post_types = array_values( $cpt_post_types );
206
 
207
+ update_option( 'cpt_custom_post_types', $cpt_post_types );
208
 
209
+ if ( isset( $_GET['return'] ) ) {
210
+ $RETURN_URL = cpt_check_return( esc_attr( $_GET['return'] ) );
211
+ }else{
212
  $RETURN_URL = $CPT_URL;
213
  }
214
 
215
+ wp_redirect( $RETURN_URL .'&cpt_msg=del' );
216
  }
217
 
218
  //check if we are deleting a custom taxonomy
219
+ if( isset( $_GET['deltax'] ) ) {
220
+ check_admin_referer( 'cpt_delete_tax' );
221
 
222
+ $delType = intval( $_GET['deltax'] );
223
+ $cpt_taxonomies = get_option( 'cpt_custom_tax_types' );
224
 
225
+ unset( $cpt_taxonomies[$delType] );
226
 
227
+ $cpt_taxonomies = array_values( $cpt_taxonomies );
228
 
229
+ update_option( 'cpt_custom_tax_types', $cpt_taxonomies );
230
 
231
+ if ( isset( $_GET['return'] ) ) {
232
+ $RETURN_URL = cpt_check_return( esc_attr( $_GET['return'] ) );
233
+ }else{
234
  $RETURN_URL = $CPT_URL;
235
  }
236
 
237
+ wp_redirect( $RETURN_URL .'&cpt_msg=del' );
238
  }
239
 
240
  }
242
  function cpt_register_settings() {
243
  global $cpt_error, $CPT_URL;
244
 
245
+ if ( isset( $_POST['cpt_edit'] ) ) {
246
  //edit a custom post type
247
+ check_admin_referer( 'cpt_add_custom_post_type' );
248
 
249
  //custom post type to edit
250
+ $cpt_edit = intval( $_POST['cpt_edit'] );
251
 
252
  //edit the custom post type
253
  $cpt_form_fields = $_POST['cpt_custom_post_type'];
258
 
259
  //add taxonomies support checkbox values to array
260
  $cpt_addon_taxes = ( isset( $_POST['cpt_addon_taxes'] ) ) ? $_POST['cpt_addon_taxes'] : null;
261
+ array_push( $cpt_form_fields, $cpt_addon_taxes );
262
 
263
  //add label values to array
264
+ array_push( $cpt_form_fields, $_POST['cpt_labels'] );
265
 
266
  //load custom posts saved in WP
267
+ $cpt_options = get_option( 'cpt_custom_post_types' );
268
 
269
+ if ( is_array( $cpt_options ) ) {
270
 
271
+ unset( $cpt_options[$cpt_edit] );
272
 
273
  //insert new custom post type into the array
274
+ array_push( $cpt_options, $cpt_form_fields );
275
 
276
+ $cpt_options = array_values( $cpt_options );
277
 
278
  //save custom post types
279
+ update_option( 'cpt_custom_post_types', $cpt_options );
280
 
281
+ if ( isset( $_GET['return'] ) ) {
282
+ $RETURN_URL = cpt_check_return( esc_attr( $_GET['return'] ) );
283
+ }else{
284
  $RETURN_URL = $CPT_URL;
285
  }
286
 
287
+ wp_redirect( $RETURN_URL );
288
 
289
  }
290
 
291
+ }elseif( isset( $_POST['cpt_submit'] ) ) {
292
  //create a new custom post type
293
+
294
+ //nonce security check
295
+ check_admin_referer( 'cpt_add_custom_post_type' );
296
 
297
  //retrieve new custom post type values
298
  $cpt_form_fields = $_POST['cpt_custom_post_type'];
299
 
300
+ if ( empty( $cpt_form_fields["name"] ) ) {
301
+ if ( isset( $_GET['return'] ) ) {
302
+ $RETURN_URL = cpt_check_return( esc_attr( $_GET['return'] ) );
303
+ }else{
304
  $RETURN_URL = $CPT_URL;
305
  }
306
 
307
+ wp_redirect( $RETURN_URL .'&cpt_error=1' );
308
  exit();
309
  }
310
 
311
  //add support checkbox values to array
312
  $cpt_supports = ( isset( $_POST['cpt_supports'] ) ) ? $_POST['cpt_supports'] : null;
313
+ array_push( $cpt_form_fields, $cpt_supports );
314
 
315
  //add taxonomies support checkbox values to array
316
  $cpt_addon_taxes = ( isset( $_POST['cpt_addon_taxes'] ) ) ? $_POST['cpt_addon_taxes'] : null;
317
+ array_push( $cpt_form_fields, $cpt_addon_taxes );
318
 
319
  //add label values to array
320
+ array_push( $cpt_form_fields, $_POST['cpt_labels'] );
321
 
322
  //load custom posts saved in WP
323
+ $cpt_options = get_option( 'cpt_custom_post_types' );
324
 
325
  //check if option exists, if not create an array for it
326
+ if ( !is_array( $cpt_options ) ) {
327
  $cpt_options = array();
328
  }
329
 
330
  //insert new custom post type into the array
331
+ array_push( $cpt_options, $cpt_form_fields );
332
 
333
  //save new custom post type array in the CPT option
334
+ update_option( 'cpt_custom_post_types', $cpt_options );
335
 
336
+ if ( isset( $_GET['return'] ) ) {
337
+ $RETURN_URL = cpt_check_return( esc_attr( $_GET['return'] ) );
338
+ }else{
339
  $RETURN_URL = $CPT_URL;
340
  }
341
 
342
+ wp_redirect( $RETURN_URL .'&cpt_msg=1' );
343
  }
344
 
345
+ if ( isset( $_POST['cpt_edit_tax'] ) ) {
346
  //edit a custom taxonomy
347
+
348
+ //nonce security check
349
+ check_admin_referer( 'cpt_add_custom_taxonomy' );
350
 
351
  //custom taxonomy to edit
352
+ $cpt_edit = intval( $_POST['cpt_edit_tax'] );
353
 
354
  //edit the custom taxonomy
355
  $cpt_form_fields = $_POST['cpt_custom_tax'];
356
 
357
  //add label values to array
358
+ array_push( $cpt_form_fields, $_POST['cpt_tax_labels'] );
359
 
360
  //add attached post type values to array
361
+ array_push( $cpt_form_fields, $_POST['cpt_post_types'] );
362
 
363
  //load custom posts saved in WP
364
+ $cpt_options = get_option( 'cpt_custom_tax_types' );
365
 
366
+ if ( is_array( $cpt_options ) ) {
367
 
368
+ unset( $cpt_options[$cpt_edit] );
369
 
370
  //insert new custom post type into the array
371
+ array_push( $cpt_options, $cpt_form_fields );
372
 
373
+ $cpt_options = array_values( $cpt_options );
374
 
375
  //save custom post types
376
+ update_option( 'cpt_custom_tax_types', $cpt_options );
377
 
378
+ if ( isset( $_GET['return'] ) ) {
379
+ $RETURN_URL = cpt_check_return( esc_attr( $_GET['return'] ) );
380
+ }else{
381
  $RETURN_URL = $CPT_URL;
382
  }
383
 
384
+ wp_redirect( $RETURN_URL );
385
 
386
  }
387
 
388
+ }elseif( isset( $_POST['cpt_add_tax'] ) ) {
389
  //create new custom taxonomy
390
+
391
+ //nonce security check
392
+ check_admin_referer( 'cpt_add_custom_taxonomy' );
393
 
394
  //retrieve new custom taxonomy values
395
  $cpt_form_fields = $_POST['cpt_custom_tax'];
396
 
397
  //verify required fields are filled out
398
+ if ( empty( $cpt_form_fields["name"] ) ) {
399
+ if ( isset( $_GET['return'] ) ) {
400
+ $RETURN_URL = cpt_check_return( esc_attr( $_GET['return'] ) );
401
  }Else{
402
  $RETURN_URL = $CPT_URL;
403
  }
404
 
405
+ wp_redirect( $RETURN_URL .'&cpt_error=2' );
406
  exit();
407
+
408
  }elseif ( empty( $_POST['cpt_post_types'] ) ) {
409
+ if ( isset( $_GET['return'] ) ) {
410
+ $RETURN_URL = cpt_check_return( esc_attr( $_GET['return'] ) );
411
+ }else{
412
  $RETURN_URL = $CPT_URL;
413
  }
414
 
415
+ wp_redirect( $RETURN_URL .'&cpt_error=3' );
416
  exit();
417
+
418
  }
419
 
420
  //add label values to array
421
+ array_push( $cpt_form_fields, $_POST['cpt_tax_labels'] );
422
 
423
  //add attached post type values to array
424
+ array_push( $cpt_form_fields, $_POST['cpt_post_types'] );
425
 
426
  //load custom taxonomies saved in WP
427
+ $cpt_options = get_option( 'cpt_custom_tax_types' );
428
 
429
  //check if option exists, if not create an array for it
430
+ if ( !is_array( $cpt_options ) ) {
431
  $cpt_options = array();
432
  }
433
 
434
  //insert new custom taxonomy into the array
435
+ array_push( $cpt_options, $cpt_form_fields );
436
 
437
  //save new custom taxonomy array in the CPT option
438
+ update_option( 'cpt_custom_tax_types', $cpt_options );
439
 
440
+ if ( isset( $_GET['return'] ) ) {
441
+ $RETURN_URL = cpt_check_return( esc_attr( $_GET['return'] ) );
442
+ }else{
443
  $RETURN_URL = $CPT_URL;
444
  }
445
 
446
+ wp_redirect( $RETURN_URL .'&cpt_msg=2' );
447
 
448
  }
449
  }
480
  </form>
481
  </p>
482
  </td>
483
+ <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!<br /><strong>Second Edition coming December 2012!</strong></td>
484
  <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>
485
  </tr>
486
  </table>
670
  $custom_post_type .= '\'has_archive\' => '. disp_boolean( $cpt_post_type["has_archive"] ).',';
671
  }
672
 
673
+ if ( isset( $cpt_post_type["exclude_from_search"] ) ) {
674
+ $custom_post_type .= '\'exclude_from_search\' => '. disp_boolean( $cpt_post_type["exclude_from_search"] ).',';
675
+ }
676
+
677
  if ( $cpt_post_type["menu_position"] ) {
678
  $custom_post_type .= '\'menu_position\' => '. $cpt_post_type["menu_position"].',';
679
  }
969
  $cpt_taxes = $cpt_options[$editType][1];
970
  $cpt_labels = $cpt_options[$editType][2];
971
  $cpt_has_archive = ( isset( $cpt_options[$editType]["has_archive"] ) ) ? $cpt_options[$editType]["has_archive"] : null;
972
+ $cpt_exclude_from_search = ( isset( $cpt_options[$editType]["exclude_from_search"] ) ) ? $cpt_options[$editType]["exclude_from_search"] : null;
973
  $cpt_show_in_menu = ( isset( $cpt_options[$editType]["show_in_menu"] ) ) ? $cpt_options[$editType]["show_in_menu"] : null;
974
  $cpt_show_in_menu_string = ( isset( $cpt_options[$editType]["show_in_menu_string"] ) ) ? $cpt_options[$editType]["show_in_menu_string"] : null;
975
 
1037
  }
1038
  ?>
1039
  <?php screen_icon( 'plugins' ); ?>
1040
+ <?php if ( isset( $_GET['edittype'] ) || isset( $_GET['edittax'] ) ) { ?>
1041
  <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>
1042
+ <?php }else{ ?>
1043
  <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>
1044
  <?php } ?>
1045
  <table border="0" cellspacing="10" class="widefat">
1047
  <td width="50%" valign="top">
1048
  <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>
1049
  <form method="post" <?php echo $RETURN_URL; ?>>
1050
+ <?php
1051
+ if ( function_exists( 'wp_nonce_field' ) )
1052
+ wp_nonce_field( 'cpt_add_custom_post_type' );
1053
+ ?>
1054
+ <?php if ( isset( $_GET['edittype'] ) ) { ?>
1055
+ <input type="hidden" name="cpt_edit" value="<?php echo esc_attr( $editType ); ?>" />
1056
  <?php } ?>
1057
  <table class="form-table">
1058
  <tr valign="top">
1059
+ <th scope="row"><?php _e('Post Type Name', 'cpt-plugin') ?> <span style="color:red;">*</span></th>
1060
+ <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); } ?>" maxlength="20" onblur="this.value=this.value.toLowerCase()" /> <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)
1061
+ <br />
1062
+ <p><strong><?php _e( 'Max 20 characters, can not contain capital letters or spaces', 'cpt-plugin' ); ?></strong></p>
1063
+ </td>
1064
  </tr>
1065
+
1066
  <tr valign="top">
1067
  <th scope="row"><?php _e('Label', 'cpt-plugin') ?></th>
1068
  <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>
1189
  </td>
1190
  </tr>
1191
 
1192
+ <tr valign="top">
1193
+ <th scope="row"><?php _e('Exclude From Search', 'cpt-plugin') ?></th>
1194
+ <td>
1195
+ <SELECT name="cpt_custom_post_type[exclude_from_search]" tabindex="6">
1196
+ <OPTION value="0" <?php If (isset($cpt_exclude_from_search)) { If ($cpt_exclude_from_search == 0) { echo 'selected="selected"'; } }Else{ echo 'selected="selected"'; } ?>>False</OPTION>
1197
+ <OPTION value="1" <?php If (isset($cpt_exclude_from_search)) { If ($cpt_exclude_from_search == 1) { echo 'selected="selected"'; } } ?>>True</OPTION>
1198
+ </SELECT> <a href="#" title="Whether the post type will be searchable" style="cursor: help;">?</a> (default: False)
1199
+ </td>
1200
+ </tr>
1201
+
1202
  <tr valign="top">
1203
  <th scope="row"><?php _e('Capability Type', 'cpt-plugin') ?></th>
1204
+ <td><input type="text" name="cpt_custom_post_type[capability_type]" tabindex="6" value="post" value="<?php if ( isset( $cpt_capability ) ) { 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>
1205
  </tr>
1206
 
1207
  <tr valign="top">
1251
  <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>
1252
  <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>
1253
  </SELECT> <a href="#" title="" style="cursor: help;">?</a> Top level page (e.g. 'plugins.php')
1254
+ <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>
1255
  </tr>
1256
 
1257
  <tr valign="top">
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Custom Post Type UI ===
2
  Contributors: williamsba1
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3084056
4
- Tags: custom post types, CMS, post, types, post type, cck, taxonomy, tax
5
  Requires at least: 3.0
6
- Tested up to: 3.2.1
7
- Stable tag: 0.7.1
8
 
9
  Admin UI for creating custom post types and custom taxonomies in WordPress
10
 
@@ -25,6 +25,13 @@ Below is a slightly outdated example video showing Custom Post Type UI in action
25
 
26
  == Changelog ==
27
 
 
 
 
 
 
 
 
28
  = 0.7.1 =
29
  * Fixed XSS security bug (props Duck)
30
 
@@ -107,6 +114,13 @@ Below is a slightly outdated example video showing Custom Post Type UI in action
107
 
108
  == Upgrade Notice ==
109
 
 
 
 
 
 
 
 
110
  = 0.7.1 =
111
  * XSS security bug patched
112
 
@@ -199,10 +213,6 @@ The More Fields plugin does a great job at creating custom meta boxes and fully
199
 
200
  You can either change the custom post type name back to the original name or try the Post Type Switcher plugin here: http://wordpress.org/extend/plugins/post-type-switcher/
201
 
202
- = I upgraded the plugin and all of my custom post types broke =
203
-
204
- v0.5 reworked how custom post types are stored. You need to delete and recreate your post types. You will NOT lose any content by doing this.
205
-
206
  = I receive a 404 error when viewing custom post type content =
207
 
208
  This is usually caused if the rewrite slug was changed. To fix this issue simply visit Settings > Permalinks to flush the rewrite rules in WordPress
@@ -211,9 +221,5 @@ This is usually caused if the rewrite slug was changed. To fix this issue simpl
211
 
212
  The register_post_type function was added in WordPress 2.9 so technically it should work in 2.9, but there is no admin menu UI so all post types are created and used behind the scenes.
213
 
214
- = I'm getting an error: Undefined offset =
215
-
216
- v0.3 reworked how custom taxonomies are stored. You need to delete your current taxonomies and recreate them in the new version for this error to go away.
217
-
218
  == Plugin Support ==
219
  [Custom Post Type UI Support](http://webdevstudios.com/support/forum/custom-post-type-ui/ "WordPress Plugins and Support Services")
1
  === Custom Post Type UI ===
2
  Contributors: williamsba1
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3084056
4
+ Tags: custom post types, CPT, CMS, post, types, post type, cck, taxonomy, tax, custom
5
  Requires at least: 3.0
6
+ Tested up to: 3.4.1
7
+ Stable tag: 0.7.2
8
 
9
  Admin UI for creating custom post types and custom taxonomies in WordPress
10
 
25
 
26
  == Changelog ==
27
 
28
+ = 0.7.2 =
29
+ * Added exclude_from_search support
30
+ * Fixed display bug with capability type
31
+ * Fixed JavaScript bug
32
+ * Strict CPT name check
33
+ * Code cleanup
34
+
35
  = 0.7.1 =
36
  * Fixed XSS security bug (props Duck)
37
 
114
 
115
  == Upgrade Notice ==
116
 
117
+ = 0.7.2 =
118
+ * Added exclude_from_search support
119
+ * Fixed display bug with capability type
120
+ * Fixed JavaScript bug
121
+ * Strict CPT name check
122
+ * Code cleanup
123
+
124
  = 0.7.1 =
125
  * XSS security bug patched
126
 
213
 
214
  You can either change the custom post type name back to the original name or try the Post Type Switcher plugin here: http://wordpress.org/extend/plugins/post-type-switcher/
215
 
 
 
 
 
216
  = I receive a 404 error when viewing custom post type content =
217
 
218
  This is usually caused if the rewrite slug was changed. To fix this issue simply visit Settings > Permalinks to flush the rewrite rules in WordPress
221
 
222
  The register_post_type function was added in WordPress 2.9 so technically it should work in 2.9, but there is no admin menu UI so all post types are created and used behind the scenes.
223
 
 
 
 
 
224
  == Plugin Support ==
225
  [Custom Post Type UI Support](http://webdevstudios.com/support/forum/custom-post-type-ui/ "WordPress Plugins and Support Services")
screenshot-1.png CHANGED
Binary file