Custom Post Type UI - Version 0.9.5

Version Description

  • Revert 0.9.0 release until unfound bugs are fixed.
Download this release

Release Info

Developer tw2113
Plugin Icon 128x128 Custom Post Type UI
Version 0.9.5
Comparing to
See all releases

Code changes from version 0.9.0 to 0.9.5

classes/class.cptui_admin_ui.php DELETED
@@ -1,386 +0,0 @@
1
- <?php
2
- /**
3
- * Ideas: $this->get_td( $content ). Returns content wrapped in <td>. Similar with $this->get_tr(), $this->th()
4
- */
5
-
6
- /**
7
- * Custom Post Type UI Admin UI
8
- */
9
- class cptui_admin_ui {
10
-
11
- /**
12
- * Return an opening <tr> tag.
13
- *
14
- * @since 1.0
15
- *
16
- * @return string $value Opening <tr> tag with attributes.
17
- */
18
- public function get_tr_start() {
19
- return '<tr valign="top">';
20
- }
21
-
22
- /**
23
- * Return a closing </tr> tag.
24
- *
25
- * @since 1.0
26
- *
27
- * @return string $value Closing </tr> tag.
28
- */
29
- public function get_tr_end() {
30
- return '</tr>';
31
- }
32
-
33
- /**
34
- * Return an opening <th> tag.
35
- *
36
- * @since 1.0
37
- *
38
- * @return string $value Opening <th> tag with attributes.
39
- */
40
- public function get_th_start() {
41
- return '<th scope="row">';
42
- }
43
-
44
- /**
45
- * Return a closing </th> tag.
46
- *
47
- * @since 1.0
48
- *
49
- * @return string $value Closing </th> tag.
50
- */
51
- public function get_th_end() {
52
- return '</th>';
53
- }
54
-
55
- /**
56
- * Return an opening <td> tag.
57
- *
58
- * @since 1.0
59
- *
60
- * @return string $value Opening <td> tag.
61
- */
62
- public function get_td_start() {
63
- return '<td>';
64
- }
65
-
66
- /**
67
- * Return a closing </td> tag.
68
- *
69
- * @since 1.0
70
- *
71
- * @return string $value Closing </td> tag.
72
- */
73
- public function get_td_end() {
74
- return '</td>';
75
- }
76
-
77
- /**
78
- * Return string wrapped in a <p> tag.
79
- *
80
- * @since 1.0
81
- *
82
- * @param string $text Content to wrap in a <p> tag.
83
- *
84
- * @return string $value Content wrapped in a <p> tag.
85
- */
86
- public function get_p( $text = '' ) {
87
- return '<p>' . strip_tags( $text ) . '</p>';
88
- }
89
-
90
- /**
91
- * Return a form <label> with for attribute.
92
- *
93
- * @since 1.0
94
- *
95
- * @param string $label_for Form input to associate <label> with.
96
- * @param string $label_text Text to display in the <label> tag.
97
- *
98
- * @return string $value <label> tag with filled out parts.
99
- */
100
- public function get_label( $label_for = '', $label_text = '' ) {
101
- return '<label for="' . esc_attr( $label_for ) . '">' . strip_tags( $label_text ) . '</label>';
102
- }
103
-
104
- /**
105
- * Return a <span> to indicate required status, with class attribute.
106
- *
107
- * @since 1.0
108
- *
109
- * @return string span tag.
110
- */
111
- public function get_required() {
112
- return '<span class="required">*</span>';
113
- }
114
-
115
- /**
116
- * Return an <a> tag with title attribute holding help text.
117
- *
118
- * @since 1.0
119
- *
120
- * @param string $help_text Text to use in the title attribute.
121
- *
122
- * @return string <a> tag with filled out parts.
123
- */
124
- public function get_help( $help_text = '' ) {
125
- return '<a href="#" title="' . esc_attr( $help_text ) . '" class="help wp-ui-highlight">?</a>';
126
- }
127
-
128
- /**
129
- * Return a maxlength HTML attribute with a specified length.
130
- *
131
- * @param string $length How many characters the max length should be set to.
132
- *
133
- * @return string $value Maxlength HTML attribute.
134
- */
135
- public function get_maxlength( $length = '' ) {
136
- return 'maxlength="' . esc_attr( $length ) . '"';
137
- }
138
-
139
- /**
140
- * Return a onblur HTML attribute for a specified value.
141
- *
142
- * @param string $text Text to place in the onblur attribute.
143
- *
144
- * @return string $value Onblur HTML attribute.
145
- */
146
- public function get_onblur( $text = '' ) {
147
- return 'onblur="' . esc_attr( $text ) . '"';
148
- }
149
-
150
- /**
151
- * Return a populated <select> input.
152
- *
153
- * @since 1.0
154
- *
155
- * @param array $args Arguments to use with the <select> input.
156
- *
157
- * @return string $value Complete <select> input with options and selected attribute.
158
- */
159
- public function get_select_input( $args = array() ) {
160
- $defaults = $this->get_default_input_parameters(
161
- array( 'selections' => array() )
162
- );
163
-
164
- $args = wp_parse_args( $args, $defaults );
165
-
166
- $value = '';
167
- if ( $args['wrap'] ) {
168
- $value = $this->get_tr_start();
169
- $value .= $this->get_th_start();
170
- $value .= $this->get_label( $args['name'], $args['labeltext'] );
171
- if ( $args['required'] ) { $value .= $this->get_required(); }
172
- if ( !empty( $args['helptext'] ) ) { $value .= $this->get_help( $args['helptext'] ); }
173
- $value .= $this->get_th_end();
174
- $value .= $this->get_td_start();
175
- }
176
-
177
- $value .= '<select id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']">';
178
- if ( !empty( $args['selections']['options'] ) && is_array( $args['selections']['options'] ) ) {
179
- foreach( $args['selections']['options'] as $val ) {
180
- $result = '';
181
- $bool = disp_boolean( $val['attr'] );
182
-
183
- if ( is_numeric( $args['selections']['selected'] ) ) {
184
- $selected = disp_boolean( $args['selections']['selected'] );
185
- } elseif ( in_array( $args['selections']['selected'], array( 'true', 'false' ) ) ) {
186
- $selected = $args['selections']['selected'];
187
- }
188
-
189
- if ( ( !empty( $selected ) ) && $selected === $bool ) {
190
- $result = ' selected="selected"';
191
- } else {
192
- if ( array_key_exists( 'default', $val ) && !empty( $val['default'] ) ) {
193
- if ( empty( $selected ) ) {
194
- $result = ' selected="selected"';
195
- }
196
- }
197
- }
198
-
199
- if ( !is_numeric( $args['selections']['selected'] ) && ( !empty( $args['selections']['selected'] ) && $args['selections']['selected'] == $val['attr'] ) ) {
200
- $result = ' selected="selected"';
201
- }
202
-
203
- $value .= '<option value="' . $val['attr'] . '"' . $result . '>' . $val['text'] . '</option>';
204
- }
205
- }
206
- $value .= '</select>';
207
-
208
- if ( !empty( $args['aftertext'] ) )
209
- $value .= $args['aftertext'];
210
-
211
- if ( $args['wrap'] ) {
212
- $value .= $this->get_td_end();
213
- $value .= $this->get_tr_end();
214
- }
215
-
216
- return $value;
217
- }
218
-
219
- /**
220
- * Return a text input.
221
- *
222
- * @since 1.0
223
- *
224
- * @param array $args Arguments to use with the text input.
225
- *
226
- * @return string Complete text <input> with proper attributes.
227
- */
228
- public function get_text_input( $args = array() ) {
229
- $defaults = $this->get_default_input_parameters(
230
- array(
231
- 'maxlength' => '',
232
- 'onblur' => '',
233
- )
234
- );
235
- $args = wp_parse_args( $args, $defaults );
236
-
237
- $value = '';
238
- if ( $args['wrap'] ) {
239
- $value .= $this->get_tr_start();
240
- $value .= $this->get_th_start();
241
- $value .= $this->get_label( $args['name'], $args['labeltext'] );
242
- if ( $args['required'] ) { $value .= $this->get_required(); }
243
- $value .= $this->get_help( $args['helptext'] );
244
- $value .= $this->get_th_end();
245
- $value .= $this->get_td_start();
246
- }
247
-
248
- $value .= '<input type="text" id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']" value="' . $args['textvalue'] . '"';
249
-
250
- if ( $args['maxlength'] ) {
251
- $value .= ' ' . $this->get_maxlength( $args['maxlength'] );
252
- }
253
-
254
- if ( $args['onblur'] ) {
255
- $value .= ' ' . $this->get_onblur( $args['onblur'] );
256
- }
257
-
258
- $value .= ' /><br/>';
259
-
260
- if ( !empty( $args['aftertext'] ) )
261
- $value .= $args['aftertext'];
262
-
263
- if ( $args['wrap'] ) {
264
- $value .= $this->get_td_end();
265
- $value .= $this->get_tr_end();
266
- }
267
-
268
- return $value;
269
- }
270
-
271
- /**
272
- * Return a <textarea> input.
273
- *
274
- * @since 1.0
275
- *
276
- * @param array $args Arguments to use with the textarea input.
277
- *
278
- * @return string $value Complete <textarea> input with proper attributes.
279
- */
280
- public function get_textarea_input( $args = array() ) {
281
- $defaults = $this->get_default_input_parameters(
282
- array(
283
- 'rows' => '',
284
- 'cols' => '',
285
- )
286
- );
287
- $args = wp_parse_args( $args, $defaults );
288
-
289
- $value = '';
290
-
291
- if ( $args['wrap'] ) {
292
- $value .= $this->get_tr_start();
293
- $value .= $this->get_th_start();
294
- $value .= $this->get_label( $args['name'], $args['labeltext'] );
295
- if ( $args['required'] ) { $value .= $this->get_required(); }
296
- $value .= $this->get_help( $args['helptext'] );
297
- $value .= $this->get_th_end();
298
- $value .= $this->get_td_start();
299
- }
300
-
301
- $value .= '<textarea id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']" rows="' . $args['rows'] . '" cols="' . $args['cols'] . '">' . $args['textvalue'] . '</textarea>';
302
-
303
- if ( !empty ( $args['aftertext'] ) )
304
- $value .= $args['aftertext'];
305
-
306
- if ( $args['wrap'] ) {
307
- $value .= $this->get_td_end();
308
- $value .= $this->get_tr_end();
309
- }
310
-
311
- return $value;
312
- }
313
-
314
- /**
315
- * Return a checkbox <input>.
316
- *
317
- * @since 1.0
318
- *
319
- * @param array $args Arguments to use with the checkbox input.
320
- *
321
- * @return string $value Complete checkbox <input> with proper attributes.
322
- */
323
- public function get_check_input( $args = array() ) {
324
- $defaults = $this->get_default_input_parameters(
325
- array(
326
- 'checkvalue' => '',
327
- 'checked' => 'true',
328
- 'checklisttext' => '',
329
- 'default' => false
330
- )
331
- );
332
-
333
- $args = wp_parse_args( $args, $defaults );
334
-
335
- $value = '';
336
- if ( $args['wrap'] ) {
337
- $value .= $this->get_tr_start();
338
- $value .= $this->get_th_start();
339
- $value .= $args['checklisttext'];
340
- if ( $args['required'] ) { $value .= $this->get_required(); }
341
- $value .= $this->get_th_end();
342
- $value .= $this->get_td_start();
343
- }
344
-
345
- if ( isset( $args['checked'] ) && 'false' == $args['checked'] ) {
346
- $value .= '<input type="checkbox" id="' . $args['name'] . '" name="' . $args['namearray'] . '[]" value="' . $args['checkvalue'] . '" />';
347
- } else {
348
- $value .= '<input type="checkbox" id="' . $args['name'] . '" name="' . $args['namearray'] . '[]" value="' . $args['checkvalue'] . '" checked="checked" />';
349
- }
350
- $value .= $this->get_label( $args['name'], $args['labeltext'] );
351
- $value .= $this->get_help( $args['helptext'] );
352
- $value .= '<br/>';
353
-
354
- if ( $args['wrap'] ) {
355
- $value .= $this->get_td_end();
356
- $value .= $this->get_tr_end();
357
- }
358
-
359
- return $value;
360
- }
361
-
362
- /**
363
- * Return some array_merged default arguments for all input types.
364
- *
365
- * @since 1.0
366
- *
367
- * @param array $additions Arguments array to merge with our defaults.
368
- *
369
- * @return array $value Merged arrays for our default parameters.
370
- */
371
- public function get_default_input_parameters( $additions = array() ) {
372
- return array_merge(
373
- array(
374
- 'namearray' => '',
375
- 'name' => '',
376
- 'textvalue' => '',
377
- 'labeltext' => '',
378
- 'aftertext' => '',
379
- 'helptext' => '',
380
- 'required' => false,
381
- 'wrap' => true
382
- ),
383
- (array)$additions
384
- );
385
- }
386
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/cptui.css DELETED
@@ -1,81 +0,0 @@
1
- .help {
2
- border-radius: 50%;
3
- display: inline-block;
4
- height: 15px;
5
- margin-left: 2px;
6
- text-align: center;
7
- width: 15px;
8
- }
9
- .help:hover { font-weight: bold; }
10
- .required { color: rgb(255,0,0); }
11
- .cptui-table #excerpt { height: 16px; margin-right: 4px; width: auto; }
12
- .cptui-table td { vertical-align: top; width: 50%; }
13
- #cptui_select_post_type, #cptui_select_taxonomy { margin-top: 15px; }
14
- .cptui_post_import, .cptui_tax_import {
15
- height: 200px;
16
- margin-bottom: 10px;
17
- resize: vertical;
18
- width: 100%;
19
- }
20
- .cptui_post_type_get_code, .cptui_tax_get_code {
21
- height: 300px;
22
- resize: vertical;
23
- width: 100%;
24
- }
25
- #cptui_accordion { height: 500px; }
26
- #cptui_accordion h3:hover, .cptui-table .question:hover { cursor: pointer; }
27
- .question { font-size: 18px; font-weight: bold; }
28
- .answer { margin: 10px 0 0 20px; }
29
- #support li {
30
- position: relative;
31
- }
32
- #cptui_accordion h3:after, #support .question:before {
33
- content: "\f139";
34
- display: inline-block;
35
- font: normal 25px/1 'dashicons';
36
- -webkit-font-smoothing: antialiased;
37
- }
38
- #cptui_accordion h3.ui-state-active:after, #support .question.active:before {
39
- content: "\f140";
40
- }
41
- #support .question:before {
42
- margin-left: -25px;
43
- position: absolute;
44
- }
45
- #cptui_accordion h3:after {
46
- position: absolute;
47
- }
48
- #support ol li { list-style: none; }
49
-
50
- .ui-accordion-content {
51
- overflow: auto;
52
- margin: 0 auto;
53
-
54
- background:
55
- /* Shadow covers */
56
- linear-gradient(#F1F1F1 30%, rgba(255,255,255,0)),
57
- linear-gradient(rgba(255,255,255,0), #F1F1F1 70%) 0 100%,
58
-
59
- /* Shadows */
60
- radial-gradient(50% 0, farthest-side, rgba(0,0,0,.3), rgba(0,0,0,0)),
61
- radial-gradient(50% 100%,farthest-side, rgba(0,0,0,.3), rgba(0,0,0,0)) 0 100%;
62
- background:
63
- /* Shadow covers */
64
- linear-gradient(#F1F1F1 30%, rgba(255,255,255,0)),
65
- linear-gradient(rgba(255,255,255,0), #F1F1F1 70%) 0 100%,
66
-
67
- /* Shadows */
68
- radial-gradient(farthest-side at 50% 0, rgba(0,0,0,.3), rgba(0,0,0,0)),
69
- radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.3), rgba(0,0,0,0)) 0 100%;
70
- background-repeat: no-repeat;
71
- background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
72
-
73
- /* Opera doesn't support this in the shorthand */
74
- background-attachment: local, local, scroll, scroll;
75
- }
76
- .one-third {
77
- width: 33%;
78
- }
79
- .valign {
80
- vertical-align: top;
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
custom-post-type-ui.php CHANGED
@@ -1,649 +1,1721 @@
1
  <?php
2
  /*
3
  Plugin Name: Custom Post Type UI
4
- Plugin URI: https://github.com/WebDevStudios/custom-post-type-ui/
5
  Description: Admin panel for creating custom post types and custom taxonomies in WordPress
6
  Author: WebDevStudios.com
7
- Version: 0.9.0
8
  Author URI: http://webdevstudios.com/
9
  Text Domain: cpt-plugin
10
  License: GPLv2
11
  */
12
 
13
- # Exit if accessed directly
14
- if ( ! defined( 'ABSPATH' ) ) {
15
- exit;
16
- }
17
 
18
- define( 'CPT_VERSION', '0.9.0' );
19
  define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
20
 
21
- /**
22
- * Load our Admin UI class that powers our form inputs.
23
- *
24
- * @since 0.9.0
25
- */
26
- function cptui_load_ui_class() {
27
- require_once( plugin_dir_path( __FILE__ ) . 'classes/class.cptui_admin_ui.php' );
28
- }
29
- add_action( 'init', 'cptui_load_ui_class' );
30
-
31
- /**
32
- * Flush our rewrite rules on deactivation.
33
- *
34
- * @since 0.8.0
35
- */
36
- function cptui_deactivation() {
 
 
 
 
 
 
 
 
 
 
 
 
37
  flush_rewrite_rules();
38
  }
39
- register_deactivation_hook( __FILE__, 'cptui_deactivation' );
40
-
41
- /**
42
- * Register our text domain.
43
- *
44
- * @since 0.8.0
45
- */
46
- function cptui_load_textdomain() {
47
  load_plugin_textdomain( 'cpt-plugin', false, basename( dirname( __FILE__ ) ) . '/languages' );
48
  }
49
- add_action( 'init', 'cptui_load_textdomain' );
50
-
51
- /**
52
- * Load our main menu.
53
- *
54
- * @since 0.1.0
55
- */
56
- function cptui_plugin_menu() {
57
- add_menu_page( __( 'Custom Post Types', 'cpt-plugin' ), __( 'CPT UI', 'cpt-plugin' ), 'manage_options', 'cptui_main_menu', 'cptui_settings' );
58
  }
59
- add_action( 'admin_menu', 'cptui_plugin_menu' );
60
-
61
- /**
62
- * Load our submenus.
63
- *
64
- * @since 0.9.0
65
- */
66
- function cptui_create_submenus() {
67
- require_once( plugin_dir_path( __FILE__ ) . 'inc/post-types.php' );
68
- require_once( plugin_dir_path( __FILE__ ) . 'inc/taxonomies.php' );
69
- require_once( plugin_dir_path( __FILE__ ) . 'inc/import_export.php' );
70
- require_once( plugin_dir_path( __FILE__ ) . 'inc/support.php' );
71
  }
72
- add_action( 'init', 'cptui_create_submenus' );
73
 
74
- function cptui_add_styles() {
75
- wp_enqueue_style( 'cptui-css', plugins_url( 'css/cptui.css', __FILE__ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
- add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
78
-
79
- /**
80
- * Register our users' custom post types.
81
- *
82
- * @since 0.5.0
83
- */
84
- function cptui_create_custom_post_types() {
85
- $cpts = get_option( 'cptui_post_types' );
86
-
87
- if ( is_array( $cpts ) ) {
88
- foreach ( $cpts as $post_type ) {
89
- cptui_register_single_post_type( $post_type );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
  }
92
- return;
93
  }
94
- add_action( 'init', 'cptui_create_custom_post_types', 11 ); //Priority 11 so that the taxonomies are registered first.
95
-
96
- /**
97
- * Helper function to register the actual post_type.
98
- *
99
- * @since 0.9.0
100
- *
101
- * @param array $post_type Post type array to register.
102
- *
103
- * @return null Result of register_post_type.
104
- */
105
- function cptui_register_single_post_type( $post_type = array() ) {
106
-
107
- /**
108
- * Filters the map_meta_cap value.
109
- *
110
- * @since 0.9.0
111
- *
112
- * @param bool $value True.
113
- * @param string $name Post type name being registered.
114
- * @param array $post_type All parameters for post type registration.
115
- */
116
- $post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', 'true', $post_type['name'], $post_type );
117
-
118
- /**
119
- * Filters custom supports parameters for 3rd party plugins.
120
- *
121
- * @since 0.9.0
122
- *
123
- * @param array $value Empty array to add supports keys to.
124
- * @param string $name Post type slug being registered.
125
- * @param array $post_type Array of post type arguments to be registered.
126
- */
127
- $user_supports_params = apply_filters( 'cptui_user_supports_params', array(), $post_type['name'], $post_type );
128
 
129
- if ( is_array( $user_supports_params ) ) {
130
- $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
131
- }
132
 
133
- if ( in_array( 'none', $post_type['supports'] ) ) {
134
- $post_type['supports'] = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
 
 
 
 
 
136
 
137
- $labels = array(
138
- 'name' => $post_type['label'],
139
- 'singular_name' => $post_type['singular_label']
140
- );
141
 
142
- foreach( $post_type['labels'] as $key => $label ) {
143
- if ( !empty( $label ) ) {
144
- $labels[ $key ] = $label;
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
 
 
146
  }
147
 
148
- $show_in_menu = get_disp_boolean( $post_type['show_in_menu'] );
149
- if ( !empty( $post_type['show_in_menu_string'] ) ) {
150
- $show_in_menu = $post_type['show_in_menu_string'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
 
153
- $rewrite = get_disp_boolean( $post_type['rewrite' ] );
154
- if ( false !== $rewrite ) {
155
- $rewrite = array();
156
- if ( !empty( $post_type['rewrite_slug'] ) ) {
157
- $rewrite['slug'] = $post_type['rewrite_slug'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  }
159
 
160
- $withfront = disp_boolean( $post_type['rewrite_withfront'] );
161
- if ( !empty( $withfront ) ) {
162
- $rewrite['with_front'] = $post_type['rewrite_withfront'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  }
164
- }
165
 
166
- $args = array(
167
- 'labels' => $labels,
168
- 'description' => $post_type['description'],
169
- 'public' => get_disp_boolean( $post_type['public'] ),
170
- 'show_ui' => get_disp_boolean( $post_type['show_ui'] ),
171
- 'has_archive' => get_disp_boolean( $post_type['has_archive'] ),
172
- 'show_in_menu' => $show_in_menu,
173
- 'exclude_from_search' => get_disp_boolean( $post_type['exclude_from_search'] ),
174
- 'capability_type' => $post_type['capability_type'],
175
- 'map_meta_cap' => $post_type['map_meta_cap'],
176
- 'hierarchical' => get_disp_boolean( $post_type['hierarchical'] ),
177
- 'rewrite' => $rewrite,
178
- 'menu_position' => $post_type['menu_position'],
179
- 'menu_icon' => $post_type['menu_icon'],
180
- 'query_var' => $post_type['query_var'],
181
- 'supports' => $post_type['supports'],
182
- 'taxonomies' => $post_type['taxonomies']
183
- );
184
-
185
- /**
186
- * Filters the arguments used for a post type right before registering.
187
- *
188
- * @since 0.9.0
189
- *
190
- * @param array $args Array of arguments to use for registering post type.
191
- * @param string $value Post type slug to be registered.
192
- */
193
- $args = apply_filters( 'cptui_pre_register_post_type', $args, $post_type['name'] );
194
 
195
- return register_post_type( $post_type['name'], $args );
196
- }
 
197
 
198
- /**
199
- * Register our users' custom taxonomies.
200
- *
201
- * @since 0.5.0
202
- */
203
- function cptui_create_custom_taxonomies() {
204
- $taxes = get_option('cptui_taxonomies');
205
-
206
- if ( is_array( $taxes ) ) {
207
- foreach ( $taxes as $tax ) {
208
- cptui_register_single_taxonomy( $tax );
209
  }
210
- }
211
- }
212
- add_action( 'init', 'cptui_create_custom_taxonomies' );
213
-
214
- /**
215
- * Helper function to register the actual taxonomy.
216
- *
217
- * @param array $taxonomy Taxonomy array to register.
218
- *
219
- * @return null Result of register_taxonomy.
220
- */
221
- function cptui_register_single_taxonomy( $taxonomy = array() ) {
222
-
223
- $labels = array(
224
- 'name' => $taxonomy['label'],
225
- 'singular_name' => $taxonomy['singular_label']
226
- );
227
-
228
- foreach( $taxonomy['labels'] as $key => $label ) {
229
- if ( !empty( $label ) ) {
230
- $labels[ $key ] = $label;
231
  }
 
 
232
  }
233
 
234
- $rewrite = get_disp_boolean( $taxonomy['rewrite' ] );
235
- if ( false !== get_disp_boolean( $taxonomy['rewrite' ] ) ) {
236
- $rewrite = array();
237
- if ( !empty( $taxonomy['rewrite_slug'] ) ) {
238
- $rewrite['slug'] = $taxonomy['rewrite_slug'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  }
240
 
241
- $withfront = disp_boolean( $taxonomy['rewrite_withfront'] );
242
- if ( !empty( $withfront ) ) {
243
- $rewrite['with_front'] = $taxonomy['rewrite_withfront'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
 
246
- $hierarchical = disp_boolean( $taxonomy['rewrite_hierarchical'] );
247
- if ( !empty( $hierarchical ) ) {
248
- $rewrite['rewrite_hierarchical'] = $taxonomy['rewrite_hierarchical'];
 
 
 
 
 
 
 
 
 
249
  }
250
- }
251
 
252
- $args = array(
253
- 'labels' => $labels,
254
- 'label' => $taxonomy[ 'label' ],
255
- 'hierarchical' => get_disp_boolean( $taxonomy[ 'hierarchical' ] ),
256
- 'show_ui' => get_disp_boolean( $taxonomy[ 'show_ui' ] ),
257
- 'query_var' => $taxonomy[ 'query_var' ],
258
- 'query_var_slug' => $taxonomy[ 'query_var_slug' ],
259
- 'rewrite' => $rewrite,
260
- 'show_admin_column' => $taxonomy[ 'show_admin_column' ]
261
- );
262
-
263
- /**
264
- * Filters the arguments used for a taxonomy right before registering.
265
- *
266
- * @since 0.9.0
267
- *
268
- * @param array $args Array of arguments to use for registering taxonomy.
269
- * @param string $value Taxonomy slug to be registered.
270
- */
271
- $args = apply_filters( 'cptui_pre_register_taxonomy', $args, $taxonomy['name'] );
272
 
273
- return register_taxonomy( $taxonomy['name'], $taxonomy['object_type'], $args );
274
- }
275
 
276
- /**
277
- * Display our primary menu page.
278
- *
279
- * @since 0.3.0
280
- *
281
- * @return string $value HTML markup for the page.
282
- */
283
- function cptui_settings() { ?>
284
- <div class="wrap">
285
- <?php
286
 
287
- /**
288
- * Fires inside and at the top of the wrapper for the main plugin landing page.
289
- *
290
- * @since 0.9.0
291
- */
292
- do_action( 'cptui_main_page_start' ); ?>
293
- <h2><?php _e( 'Custom Post Type UI', 'cpt-plugin' ); ?> <?php echo CPT_VERSION; ?></h2>
294
-
295
- <div class="alignleft">
296
- <p><?php _e( 'Thank you for choosing Custom Post Type UI. We hope that your experience with our plugin provides efficiency and speed in creating post types and taxonomies, to better organize your content, without having to touch code.', 'cpt-plugin' ); ?></p>
297
-
298
- <p><?php echo sprintf( __( 'To get started with creating some post types, please visit %s and for taxonomies, visit %s. If you need some help, check the %s page. If nothing there fits your issue, visit our %s and we will try to get to your question as soon as possible.', 'cpt-plugin' ),
299
- sprintf( '<a href="' . admin_url( 'admin.php?page=cptui_manage_post_types' ) . '">%s</a>', __( 'Add/Edit Post Types', 'cpt-plugin' ) ),
300
- sprintf( '<a href="' . admin_url( 'admin.php?page=cptui_manage_taxonomies' ) . '">%s</a>', __( 'Add/Edit Taxonomies', 'cpt-plugin' ) ),
301
- sprintf( '<a href="' . admin_url( 'admin.php?page=cptui_support' ) . '">%s</a>', __( 'Help/Support', 'cpt-plugin' ) ),
302
- sprintf( '<a href="http://wordpress.org/support/plugin/custom-post-type-ui">%s</a>', __( 'CPT UI Support Forum', 'cpt-plugin' ) )
303
- );
304
- ?>
305
- </p>
306
- </div>
307
 
308
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
 
310
- /**
311
- * Fires right above the table displaying the promoted books.
312
- *
313
- * @since 0.9.0
314
- */
315
- do_action( 'cptui_main_page_before_books' ); ?>
316
  <table border="0">
317
  <tr>
318
- <td colspan="3"><h2><?php _e( 'Help Support This Plugin!', 'cpt-plugin' ); ?></h2></td>
319
  </tr>
320
  <tr>
321
- <td class="one-third valign">
322
- <h3><?php _e( 'Professional WordPress<br />Third Edition', 'cpt-plugin' ); ?></h3>
323
- <a href="http://bit.ly/prowp3" target="_blank">
324
- <img src="<?php echo plugins_url( '/images/professional-wordpress-thirdedition.jpg', __FILE__ ); ?>" width="200">
325
- </a>
326
- <br />
327
- <?php _e( 'The leading book on WordPress design and development! Brand new third edition!', 'cpt-plugin' ); ?>
328
- </td>
329
- <td class="one-third valign">
330
- <h3><?php _e( 'Professional WordPress<br />Plugin Development', 'cpt-plugin' ); ?></h3>
331
- <a href="http://amzn.to/plugindevbook" target="_blank">
332
- <img src="<?php echo plugins_url( '/images/professional-wordpress-plugin-development.png', __FILE__ ); ?>" width="200">
333
- </a>
334
- <br />
335
- <?php _e( 'Highest rated WordPress development book on Amazon!', 'cpt-plugin' ); ?>
336
- </td>
337
- <td class="one-third valign">
338
- <h3><?php _e( 'PayPal Donation', 'cpt-plugin' ); ?></h3>
339
- <p><?php _e( 'Please donate to the development of Custom Post Type UI:', 'cpt-plugin' ); ?></p>
340
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
341
- <input type="hidden" name="cmd" value="_s-xclick">
342
- <input type="hidden" name="hosted_button_id" value="YJEDXPHE49Q3U">
343
- <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" name="submit" alt="<?php esc_attr_e( 'PayPal - The safer, easier way to pay online!', 'cpt-plugin' ); ?>">
344
- <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
345
- </form>
346
- </td>
347
  </tr>
348
  </table>
349
-
350
  <?php
351
- /**
352
- * Fires right after the table displaying the promoted books.
353
- *
354
- * @since 0.9.0
355
- */
356
- do_action( 'cptui_main_page_after_books' ); ?>
357
 
 
 
 
 
 
 
 
 
 
 
358
  </div>
359
- <?php
 
 
360
  }
361
 
362
- /**
363
- * Display footer links and plugin credits.
364
- *
365
- * @since 0.3.0
366
- *
367
- * @param string $original Original footer content.
368
- *
369
- * @return string $value HTML for footer.
370
- */
371
- function cptui_footer( $original = '' ) {
372
-
373
- $screen = get_current_screen();
374
-
375
- if ( ! is_object( $screen ) || 'cptui_main_menu' != $screen->parent_base ) {
376
- return $original;
377
- }
378
 
379
- return sprintf(
380
- __( '%s version %s by %s - %s %s &middot; %s &middot; %s &middot; %s', 'cpt-plugin' ),
381
- sprintf(
382
- '<a target="_blank" href="http://wordpress.org/support/plugin/custom-post-type-ui">%s</a>',
383
- __( 'Custom Post Type UI', 'cpt-plugin' )
384
- ),
385
- CPT_VERSION,
386
- '<a href="http://webdevstudios.com" target="_blank">WebDevStudios</a>',
387
- sprintf(
388
- '<a href="https://github.com/WebDevStudios/custom-post-type-ui/issues" target="_blank">%s</a>',
389
- __( 'Please Report Bugs', 'cpt-plugin' )
390
- ),
391
- __( 'Follow on Twitter:', 'cpt-plugin' ),
392
- '<a href="http://twitter.com/tw2113" target="_blank">Michael</a>',
393
- '<a href="http://twitter.com/williamsba" target="_blank">Brad</a>',
394
- '<a href="http://twitter.com/webdevstudios" target="_blank">WebDevStudios</a>'
395
- );
396
- }
397
- add_filter( 'admin_footer_text', 'cptui_footer' );
398
-
399
- /**
400
- * Return boolean status depending on passed in value.
401
- *
402
- * @since 0.5.0
403
- *
404
- * @param mixed $booText text to compare to typical boolean values.
405
- *
406
- * @return bool Which bool value the passed in value was.
407
- */
408
- function get_disp_boolean( $booText ) {
409
- $booText = (string) $booText;
410
- if ( empty( $booText ) || $booText == '0' || $booText == 'false' ) {
411
- return false;
412
- }
413
 
414
- return true;
 
 
 
 
 
 
 
 
415
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
 
417
- /**
418
- * Return string versions of boolean values.
419
- *
420
- * @since 0.1.0
421
- *
422
- * @param string $booText String boolean value.
423
- *
424
- * @return string standardized boolean text.
425
- */
426
- function disp_boolean( $booText ) {
427
- $booText = (string) $booText;
428
- if ( empty( $booText ) || $booText == '0' || $booText == 'false' ) {
429
- return 'false';
430
- }
431
 
432
- return 'true';
433
- }
434
 
435
- /**
436
- * Construct and output tab navigation.
437
- *
438
- * @since 0.9.0
439
- *
440
- * @param string $page Whether it's the CPT or Taxonomy page.
441
- *
442
- * @return string $value HTML tabs.
443
- */
444
- function cptui_settings_tab_menu( $page = 'post_types' ) {
445
-
446
- # initiate our arrays with default classes
447
- $tab1 = $tab2 = $tab3 = array( 'nav-tab' );
448
- $has = false;
449
-
450
- if ( 'importexport' == $page ) :
451
- $title = __( 'Import/Export', 'cpt-plugin' );
452
- elseif ( 'taxonomies' == $page ) :
453
- $title = __( 'Manage Taxonomies', 'cpt-plugin' );
454
- $taxes = get_option( 'cptui_taxonomies' );
455
- $has = ( !empty( $taxes ) ) ? true : false;
456
- else :
457
- $title = __( 'Manage Post Types', 'cpt-plugin' );
458
- $types = get_option( 'cptui_post_types' );
459
- $has = ( !empty( $types ) ) ? true : false;
460
- endif;
461
-
462
- if ( !empty( $_GET['action'] ) ) {
463
- if ( 'edit' == $_GET['action'] || 'taxonomies' == $_GET['action'] ) {
464
- $tab2[] = 'nav-tab-active';
465
- } elseif ( 'get_code' == $_GET['action'] ) {
466
- $tab3[] = 'nav-tab-active';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  }
468
- } else {
469
- $tab1[] = 'nav-tab-active';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
  }
 
471
 
472
- # implode our arrays for class attributes
473
- $tab1 = implode( ' ', $tab1 ); $tab2 = implode( ' ', $tab2 ); $tab3 = implode( ' ', $tab3 );
 
474
 
475
- ?>
476
- <h2 class="nav-tab-wrapper">
477
- <?php echo $title;
478
 
479
- # Import/Export area is getting different tabs, so we need to separate out.
480
- if ( 'importexport' != $page ) { ?>
481
- <a class="<?php echo $tab1; ?>" href="<?php echo admin_url( 'admin.php?page=cptui_manage_' . $page ); ?>"><?php _e( 'Add New', 'cpt-plugin' ); ?></a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
482
  <?php
 
 
483
 
484
- if ( 'post_types' == $page ) {
485
- if ( $has ) { ?>
486
- <a class="<?php echo $tab2; ?>" href="<?php echo add_query_arg( array( 'action' => 'edit' ), admin_url( 'admin.php?page=cptui_manage_' . $page ) ); ?>"><?php _e( 'Edit Post Types', 'cpt-plugin' ); ?></a>
487
- <?php }
488
- } elseif ( 'taxonomies' == $page ) {
489
- if ( $has ) { ?>
490
- <a class="<?php echo $tab2; ?>" href="<?php echo add_query_arg( array( 'action' => 'edit' ), admin_url( 'admin.php?page=cptui_manage_' . $page ) ); ?>"><?php _e( 'Edit Taxonomies', 'cpt-plugin' ); ?></a>
491
- <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
492
  }
493
- } else { ?>
494
- <a class="<?php echo $tab1; ?>" href="<?php echo admin_url( 'admin.php?page=cptui_' . $page ); ?>"><?php _e( 'Post Types', 'cpt-plugin' ); ?></a>
495
- <a class="<?php echo $tab2; ?>" href="<?php echo add_query_arg( array( 'action' => 'taxonomies' ), admin_url( 'admin.php?page=cptui_' . $page ) ); ?>"><?php _e( 'Taxonomies', 'cpt-plugin' ); ?></a>
496
- <a class="<?php echo $tab3; ?>" href="<?php echo add_query_arg( array( 'action' => 'get_code' ), admin_url( 'admin.php?page=cptui_' . $page ) ); ?>"><?php _e( 'Get Code', 'cpt-plugin' ); ?></a>
497
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  }
499
 
500
- /**
501
- * Fires inside and at end of the `<h2>` tag for settings tabs area.
502
- *
503
- * @since 0.9.0
 
504
  */
505
- do_action( 'cptui_settings_tabs_after' );
506
  ?>
507
- </h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
508