Custom Post Type UI - Version 1.3.0

Version Description

  • Added: "CPTUI_VERSION" constant and deprecated "CPT_VERSION".
  • Added: "Public" parameter for taxonomies
  • Added: "View Post Types" and "View Taxonomies" tabs at top of add/edit screens.
  • Added: Better prevention of potential duplicate slugs in new post types and taxonomies.
  • Added: Current theme's textdomain as output in get code textareas.
  • Added: Fill in singular and plural label fields if none provided. WordPress does not auto-fill these.
  • Added: For developers: plenty of extra hooks all over for customization needs.
  • Added: Javascript-based prevention of spaces and special characters for post type and taxonomy slugs.
  • Added: Legend tag support to admin UI class.
  • Added: Minified copies of our JavaScript and CSS. Define SCRIPT_DEBUG to true to use non-minified versions.
  • Added: New post type and taxonomy labels provided by WordPress 4.3 and 4.4 releases.
    • See: https://make.wordpress.org/core/2015/12/11/additional-labels-for-custom-post-types-and-custom-taxonomies/
  • Added: Notes to post type and taxonomy edit screens about WordPress core's post types and taxonomies.
  • Added: Taxonomy slug update ability with preserved term association.
  • Added: Title, Editor, and Featured Image now checked by default for new post types.
  • Added: "Show in Quick Edit" taxonomy parameter available in WP 4.2
  • Added: Promo spots on add/edit screens for other products from WebDevStudios.
  • Fixed: Need to visit permalinks page to flush rewrite rules after creating new post type or taxonomy.
  • Fixed: Missing REST API based parameters in "Get Code" output.
  • Updated: Increased accessibility coverage.
  • Updated: Revised how tabs are added to pages so 3rd party developers can add their own tabs.
  • Updated: Improved string consistency in our UI helper notes. Props @GaryJ
  • Updated: Tested on WordPress 4.5
  • Updated: Cleaned up admin footer area for social links.
  • Updated: Moved all localization work to WordPress.org Translation packs
Download this release

Release Info

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

Code changes from version 1.2.4 to 1.3.0

classes/class.cptui_admin_ui.php CHANGED
@@ -1,108 +1,154 @@
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.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.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.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.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.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.0
70
  *
71
- * @return string $value Closing </td> tag.
72
  */
73
  public function get_td_end() {
74
  return '</td>';
75
  }
76
 
77
  /**
78
- * Return an opening <fieldset> tag.
79
  *
80
  * @since 1.2.0
 
81
  *
82
- * @return string $value Opening <fieldset> tag.
 
83
  */
84
- public function get_fieldset_start() {
85
- return '<fieldset>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
 
88
  /**
89
- * Return an closing <fieldset> tag.
90
  *
91
  * @since 1.2.0
92
  *
93
- * @return string $value Closing <fieldset> tag.
94
  */
95
  public function get_fieldset_end() {
96
  return '</fieldset>';
97
  }
98
 
99
  /**
100
- * Return string wrapped in a <p> tag.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  *
102
  * @since 1.0.0
103
  *
104
- * @param string $text Content to wrap in a <p> tag.
105
- * @return string $value Content wrapped in a <p> tag.
106
  */
107
  public function get_p( $text = '' ) {
108
  return '<p>' . $text . '</p>';
@@ -113,27 +159,56 @@ class cptui_admin_ui {
113
  *
114
  * @since 1.0.0
115
  *
116
- * @param string $label_for Form input to associate <label> with.
117
- * @param string $label_text Text to display in the <label> tag.
118
- * @return string $value <label> tag with filled out parts.
119
  */
120
  public function get_label( $label_for = '', $label_text = '' ) {
121
  return '<label for="' . esc_attr( $label_for ) . '">' . strip_tags( $label_text ) . '</label>';
122
  }
123
 
124
  /**
125
- * Return a <span> to indicate required status, with class attribute.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  *
127
  * @since 1.0.0
128
  *
129
- * @return string span tag.
 
 
 
 
 
 
 
 
 
 
 
 
130
  */
131
- public function get_required() {
132
- return '<span class="required">*</span>';
 
133
  }
134
 
135
  /**
136
- * Return an <a> tag with title attribute holding help text.
137
  *
138
  * @since 1.0.0
139
  *
@@ -144,6 +219,18 @@ class cptui_admin_ui {
144
  return '<a href="#" class="cptui-help dashicons-before dashicons-editor-help" title="' . esc_attr( $help_text ) . '"></a>';
145
  }
146
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  /**
148
  * Return a maxlength HTML attribute with a specified length.
149
  *
@@ -169,11 +256,35 @@ class cptui_admin_ui {
169
  }
170
 
171
  /**
172
- * Return a populated <select> input.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  *
174
  * @since 1.0.0
175
  *
176
- * @param array $args Arguments to use with the <select> input.
177
  * @return string $value Complete <select> input with options and selected attribute.
178
  */
179
  public function get_select_input( $args = array() ) {
@@ -188,15 +299,15 @@ class cptui_admin_ui {
188
  $value = $this->get_tr_start();
189
  $value .= $this->get_th_start();
190
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
191
- if ( $args['required'] ) { $value .= $this->get_required(); }
192
- if ( !empty( $args['helptext'] ) ) { $value .= $this->get_help( $args['helptext'] ); }
193
  $value .= $this->get_th_end();
194
  $value .= $this->get_td_start();
195
  }
196
 
197
  $value .= '<select id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']">';
198
- if ( !empty( $args['selections']['options'] ) && is_array( $args['selections']['options'] ) ) {
199
- foreach( $args['selections']['options'] as $val ) {
200
  $result = '';
201
  $bool = disp_boolean( $val['attr'] );
202
 
@@ -206,17 +317,17 @@ class cptui_admin_ui {
206
  $selected = $args['selections']['selected'];
207
  }
208
 
209
- if ( ( !empty( $selected ) ) && $selected === $bool ) {
210
  $result = ' selected="selected"';
211
  } else {
212
- if ( array_key_exists( 'default', $val ) && !empty( $val['default'] ) ) {
213
  if ( empty( $selected ) ) {
214
  $result = ' selected="selected"';
215
  }
216
  }
217
  }
218
 
219
- if ( !is_numeric( $args['selections']['selected'] ) && ( !empty( $args['selections']['selected'] ) && $args['selections']['selected'] == $val['attr'] ) ) {
220
  $result = ' selected="selected"';
221
  }
222
 
@@ -225,8 +336,9 @@ class cptui_admin_ui {
225
  }
226
  $value .= '</select>';
227
 
228
- if ( !empty( $args['aftertext'] ) )
229
- $value .= $args['aftertext'];
 
230
 
231
  if ( $args['wrap'] ) {
232
  $value .= $this->get_td_end();
@@ -242,7 +354,7 @@ class cptui_admin_ui {
242
  * @since 1.0.0
243
  *
244
  * @param array $args Arguments to use with the text input.
245
- * @return string Complete text <input> with proper attributes.
246
  */
247
  public function get_text_input( $args = array() ) {
248
  $defaults = $this->get_default_input_parameters(
@@ -258,10 +370,10 @@ class cptui_admin_ui {
258
  $value .= $this->get_tr_start();
259
  $value .= $this->get_th_start();
260
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
261
- if ( $args['required'] ) { $value .= $this->get_required(); }
262
- if ( !$args['helptext_after'] ) {
263
  $value .= $this->get_help( $args['helptext'] );
264
- }
265
  $value .= $this->get_th_end();
266
  $value .= $this->get_td_start();
267
  }
@@ -276,15 +388,25 @@ class cptui_admin_ui {
276
  $value .= ' ' . $this->get_onblur( $args['onblur'] );
277
  }
278
 
 
 
 
 
 
 
 
 
 
 
279
  $value .= ' />';
280
 
281
- if ( $args['helptext_after'] ) {
282
- $value .= $this->get_help( $args['helptext'] );
283
  }
284
- $value .= '<br/>';
285
 
286
- if ( !empty( $args['aftertext'] ) )
287
- $value .= $args['aftertext'];
 
288
 
289
  if ( $args['wrap'] ) {
290
  $value .= $this->get_td_end();
@@ -295,7 +417,7 @@ class cptui_admin_ui {
295
  }
296
 
297
  /**
298
- * Return a <textarea> input.
299
  *
300
  * @since 1.0.0
301
  *
@@ -317,16 +439,20 @@ class cptui_admin_ui {
317
  $value .= $this->get_tr_start();
318
  $value .= $this->get_th_start();
319
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
320
- if ( $args['required'] ) { $value .= $this->get_required(); }
321
- $value .= $this->get_help( $args['helptext'] );
322
  $value .= $this->get_th_end();
323
  $value .= $this->get_td_start();
324
  }
325
 
326
  $value .= '<textarea id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']" rows="' . $args['rows'] . '" cols="' . $args['cols'] . '">' . $args['textvalue'] . '</textarea>';
327
 
328
- if ( !empty ( $args['aftertext'] ) )
329
  $value .= $args['aftertext'];
 
 
 
 
 
330
 
331
  if ( $args['wrap'] ) {
332
  $value .= $this->get_td_end();
@@ -337,12 +463,12 @@ class cptui_admin_ui {
337
  }
338
 
339
  /**
340
- * Return a checkbox <input>.
341
  *
342
  * @since 1.0.0
343
  *
344
  * @param array $args Arguments to use with the checkbox input.
345
- * @return string $value Complete checkbox <input> with proper attributes.
346
  */
347
  public function get_check_input( $args = array() ) {
348
  $defaults = $this->get_default_input_parameters(
@@ -350,7 +476,7 @@ class cptui_admin_ui {
350
  'checkvalue' => '',
351
  'checked' => 'true',
352
  'checklisttext' => '',
353
- 'default' => false
354
  )
355
  );
356
 
@@ -361,18 +487,20 @@ class cptui_admin_ui {
361
  $value .= $this->get_tr_start();
362
  $value .= $this->get_th_start();
363
  $value .= $args['checklisttext'];
364
- if ( $args['required'] ) { $value .= $this->get_required(); }
365
  $value .= $this->get_th_end();
366
  $value .= $this->get_td_start();
367
  }
368
 
369
- if ( isset( $args['checked'] ) && 'false' == $args['checked'] ) {
370
  $value .= '<input type="checkbox" id="' . $args['name'] . '" name="' . $args['namearray'] . '[]" value="' . $args['checkvalue'] . '" />';
371
  } else {
372
  $value .= '<input type="checkbox" id="' . $args['name'] . '" name="' . $args['namearray'] . '[]" value="' . $args['checkvalue'] . '" checked="checked" />';
373
  }
374
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
375
- $value .= $this->get_help( $args['helptext'] );
 
 
376
  $value .= '<br/>';
377
 
378
  if ( $args['wrap'] ) {
@@ -383,6 +511,21 @@ class cptui_admin_ui {
383
  return $value;
384
  }
385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  /**
387
  * Return some array_merged default arguments for all input types.
388
  *
@@ -394,17 +537,18 @@ class cptui_admin_ui {
394
  public function get_default_input_parameters( $additions = array() ) {
395
  return array_merge(
396
  array(
397
- 'namearray' => '',
398
- 'name' => '',
399
- 'textvalue' => '',
400
- 'labeltext' => '',
401
- 'aftertext' => '',
402
- 'helptext' => '',
403
- 'helptext_after'=> false,
404
- 'required' => false,
405
- 'wrap' => true
 
406
  ),
407
- (array)$additions
408
  );
409
  }
410
  }
1
  <?php
2
  /**
3
+ * Custom Post Type UI Admin UI.
4
+ *
5
+ * @package CPTUI
6
+ * @subpackage AdminUI
7
+ * @author WebDevStudios
8
+ * @since 1.0.0
9
  */
10
 
11
  /**
12
+ * Custom Post Type UI Admin UI
13
+ */
14
  class cptui_admin_ui {
15
 
16
  /**
17
+ * Return an opening `<tr>` tag.
18
  *
19
  * @since 1.0.0
20
  *
21
+ * @return string $value Opening `<tr>` tag with attributes.
22
  */
23
  public function get_tr_start() {
24
  return '<tr valign="top">';
25
  }
26
 
27
  /**
28
+ * Return a closing `</tr>` tag.
29
  *
30
  * @since 1.0.0
31
  *
32
+ * @return string $value Closing `</tr>` tag.
33
  */
34
  public function get_tr_end() {
35
  return '</tr>';
36
  }
37
 
38
  /**
39
+ * Return an opening `<th>` tag.
40
  *
41
  * @since 1.0.0
42
  *
43
+ * @return string $value Opening `<th>` tag with attributes.
44
  */
45
  public function get_th_start() {
46
  return '<th scope="row">';
47
  }
48
 
49
  /**
50
+ * Return a closing `</th>` tag.
51
  *
52
  * @since 1.0.0
53
  *
54
+ * @return string $value Closing `</th>` tag.
55
  */
56
  public function get_th_end() {
57
  return '</th>';
58
  }
59
 
60
  /**
61
+ * Return an opening `<td>` tag.
62
  *
63
  * @since 1.0.0
64
  *
65
+ * @return string $value Opening `<td>` tag.
66
  */
67
  public function get_td_start() {
68
  return '<td>';
69
  }
70
 
71
  /**
72
+ * Return a closing `</td>` tag.
73
  *
74
  * @since 1.0.0
75
  *
76
+ * @return string $value Closing `</td>` tag.
77
  */
78
  public function get_td_end() {
79
  return '</td>';
80
  }
81
 
82
  /**
83
+ * Return an opening `<fieldset>` tag.
84
  *
85
  * @since 1.2.0
86
+ * @since 1.3.0 Added $args parameter.
87
  *
88
+ * @param array $args Array of arguments.
89
+ * @return string $value Opening `<fieldset>` tag.
90
  */
91
+ public function get_fieldset_start( $args = array() ) {
92
+ $fieldset = '<fieldset';
93
+
94
+ if ( ! empty( $args['id'] ) ) {
95
+ $fieldset .= ' id="' . esc_attr( $args['id'] ) . '"';
96
+ }
97
+
98
+ if ( ! empty( $args['classes'] ) ) {
99
+ $classes = 'class="' . implode( ' ', $args['classes'] ) . '"';
100
+ $fieldset .= ' ' . $classes;
101
+ }
102
+
103
+ if ( !empty( $args['aria-expanded'] ) ) {
104
+ $fieldset .= ' aria-expanded="' . $args['aria-expanded'] . '"';
105
+ }
106
+
107
+ $fieldset .= ' tabindex="0">';
108
+
109
+ return $fieldset;
110
  }
111
 
112
  /**
113
+ * Return an closing `<fieldset>` tag.
114
  *
115
  * @since 1.2.0
116
  *
117
+ * @return string $value Closing `<fieldset>` tag.
118
  */
119
  public function get_fieldset_end() {
120
  return '</fieldset>';
121
  }
122
 
123
  /**
124
+ * Return an opening `<legend>` tag.
125
+ *
126
+ * @since 1.3.0
127
+ *
128
+ * @return string
129
+ */
130
+ public function get_legend_start() {
131
+ return '<legend>';
132
+ }
133
+
134
+ /**
135
+ * Return a closing `</legend>` tag.
136
+ *
137
+ * @since 1.3.0
138
+ *
139
+ * @return string
140
+ */
141
+ public function get_legend_end() {
142
+ return '</legend>';
143
+ }
144
+
145
+ /**
146
+ * Return string wrapped in a `<p>` tag.
147
  *
148
  * @since 1.0.0
149
  *
150
+ * @param string $text Content to wrap in a `<p>` tag.
151
+ * @return string $value Content wrapped in a `<p>` tag.
152
  */
153
  public function get_p( $text = '' ) {
154
  return '<p>' . $text . '</p>';
159
  *
160
  * @since 1.0.0
161
  *
162
+ * @param string $label_for Form input to associate `<label>` with.
163
+ * @param string $label_text Text to display in the `<label>` tag.
164
+ * @return string $value `<label>` tag with filled out parts.
165
  */
166
  public function get_label( $label_for = '', $label_text = '' ) {
167
  return '<label for="' . esc_attr( $label_for ) . '">' . strip_tags( $label_text ) . '</label>';
168
  }
169
 
170
  /**
171
+ * Return an html attribute denoting a required field.
172
+ *
173
+ * @since 1.3.0
174
+ *
175
+ * @param bool $required Whether or not the field is required.
176
+ * @return string `Required` attribute.
177
+ */
178
+ public function get_required_attribute( $required = false ) {
179
+ $attr = '';
180
+ if ( $required ) {
181
+ $attr .= 'required="true"';
182
+ }
183
+ return $attr;
184
+ }
185
+
186
+ /**
187
+ * Return a `<span>` to indicate required status, with class attribute.
188
  *
189
  * @since 1.0.0
190
  *
191
+ * @return string Span tag.
192
+ */
193
+ public function get_required_span() {
194
+ return ' <span class="required">*</span>';
195
+ }
196
+
197
+ /**
198
+ * Return an aria-required attribute set to true.
199
+ *
200
+ * @since 1.3.0
201
+ *
202
+ * @param bool $required Whether or not the field is required.
203
+ * @return string Aria required attribute
204
  */
205
+ public function get_aria_required( $required = false ) {
206
+ $attr = ( $required ) ? 'true' : 'false';
207
+ return 'aria-required="' . $attr . '"';
208
  }
209
 
210
  /**
211
+ * Return an `<a>` tag with title attribute holding help text.
212
  *
213
  * @since 1.0.0
214
  *
219
  return '<a href="#" class="cptui-help dashicons-before dashicons-editor-help" title="' . esc_attr( $help_text ) . '"></a>';
220
  }
221
 
222
+ /**
223
+ * Return a `<span>` tag with the help text.
224
+ *
225
+ * @since 1.3.0
226
+ *
227
+ * @param string $help_text Text to display after the input.
228
+ * @return string
229
+ */
230
+ public function get_description( $help_text = '' ) {
231
+ return '<span class="cptui-field-description">' . $help_text . '</span>';
232
+ }
233
+
234
  /**
235
  * Return a maxlength HTML attribute with a specified length.
236
  *
256
  }
257
 
258
  /**
259
+ * Return a placeholder HTML attribtue for a specified value.
260
+ *
261
+ * @since 1.3.0
262
+ *
263
+ * @param string $text Text to place in the placeholder attribute.
264
+ * @return string $value Placeholder HTML attribute.
265
+ */
266
+ public function get_placeholder( $text = '' ) {
267
+ return 'placeholder="' . esc_attr( $text ) . '"';
268
+ }
269
+
270
+ /**
271
+ * Return a span that will only be visible for screenreaders.
272
+ *
273
+ * @since 1.3.0
274
+ *
275
+ * @param string $text Text to visually hide.
276
+ * @return string $value Visually hidden text meant for screen readers.
277
+ */
278
+ public function get_hidden_text( $text = '' ) {
279
+ return '<span class="visuallyhidden">' . $text . '</span>';
280
+ }
281
+
282
+ /**
283
+ * Return a populated `<select>` input.
284
  *
285
  * @since 1.0.0
286
  *
287
+ * @param array $args Arguments to use with the `<select>` input.
288
  * @return string $value Complete <select> input with options and selected attribute.
289
  */
290
  public function get_select_input( $args = array() ) {
299
  $value = $this->get_tr_start();
300
  $value .= $this->get_th_start();
301
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
302
+ if ( $args['required'] ) { $value .= $this->get_required_span(); }
303
+ if ( ! empty( $args['helptext'] ) ) { $value .= $this->get_help( $args['helptext'] ); }
304
  $value .= $this->get_th_end();
305
  $value .= $this->get_td_start();
306
  }
307
 
308
  $value .= '<select id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']">';
309
+ if ( ! empty( $args['selections']['options'] ) && is_array( $args['selections']['options'] ) ) {
310
+ foreach ( $args['selections']['options'] as $val ) {
311
  $result = '';
312
  $bool = disp_boolean( $val['attr'] );
313
 
317
  $selected = $args['selections']['selected'];
318
  }
319
 
320
+ if ( ( ! empty( $selected ) ) && $selected === $bool ) {
321
  $result = ' selected="selected"';
322
  } else {
323
+ if ( array_key_exists( 'default', $val ) && ! empty( $val['default'] ) ) {
324
  if ( empty( $selected ) ) {
325
  $result = ' selected="selected"';
326
  }
327
  }
328
  }
329
 
330
+ if ( ! is_numeric( $args['selections']['selected'] ) && ( ! empty( $args['selections']['selected'] ) && $args['selections']['selected'] === $val['attr'] ) ) {
331
  $result = ' selected="selected"';
332
  }
333
 
336
  }
337
  $value .= '</select>';
338
 
339
+ if ( ! empty( $args['aftertext'] ) ) {
340
+ $value .= ' ' . $this->get_description( $args['aftertext'] );
341
+ }
342
 
343
  if ( $args['wrap'] ) {
344
  $value .= $this->get_td_end();
354
  * @since 1.0.0
355
  *
356
  * @param array $args Arguments to use with the text input.
357
+ * @return string Complete text `<input>` with proper attributes.
358
  */
359
  public function get_text_input( $args = array() ) {
360
  $defaults = $this->get_default_input_parameters(
370
  $value .= $this->get_tr_start();
371
  $value .= $this->get_th_start();
372
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
373
+ if ( $args['required'] ) { $value .= $this->get_required_span(); }
374
+ /*if ( !$args['helptext_after'] ) {
375
  $value .= $this->get_help( $args['helptext'] );
376
+ }*/
377
  $value .= $this->get_th_end();
378
  $value .= $this->get_td_start();
379
  }
388
  $value .= ' ' . $this->get_onblur( $args['onblur'] );
389
  }
390
 
391
+ $value .= ' ' . $this->get_aria_required( $args['required'] );
392
+
393
+ $value .= ' ' . $this->get_required_attribute( $args['required'] );
394
+
395
+ if ( ! empty( $args['aftertext'] ) ) {
396
+ if ( $args['placeholder'] ) {
397
+ $value .= ' ' . $this->get_placeholder( $args['aftertext'] );
398
+ }
399
+ }
400
+
401
  $value .= ' />';
402
 
403
+ if ( ! empty( $args['aftertext'] ) ) {
404
+ $value .= $this->get_hidden_text( $args['aftertext'] );
405
  }
 
406
 
407
+ if ( $args['helptext'] ) {
408
+ $value .= '<br/>' . $this->get_description( $args['helptext'] );
409
+ }
410
 
411
  if ( $args['wrap'] ) {
412
  $value .= $this->get_td_end();
417
  }
418
 
419
  /**
420
+ * Return a `<textarea>` input.
421
  *
422
  * @since 1.0.0
423
  *
439
  $value .= $this->get_tr_start();
440
  $value .= $this->get_th_start();
441
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
442
+ if ( $args['required'] ) { $value .= $this->get_required_span(); }
 
443
  $value .= $this->get_th_end();
444
  $value .= $this->get_td_start();
445
  }
446
 
447
  $value .= '<textarea id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']" rows="' . $args['rows'] . '" cols="' . $args['cols'] . '">' . $args['textvalue'] . '</textarea>';
448
 
449
+ if ( ! empty( $args['aftertext'] ) ) {
450
  $value .= $args['aftertext'];
451
+ }
452
+
453
+ if ( $args['helptext'] ) {
454
+ $value .= '<br/>' . $this->get_description( $args['helptext'] );
455
+ }
456
 
457
  if ( $args['wrap'] ) {
458
  $value .= $this->get_td_end();
463
  }
464
 
465
  /**
466
+ * Return a checkbox `<input>`.
467
  *
468
  * @since 1.0.0
469
  *
470
  * @param array $args Arguments to use with the checkbox input.
471
+ * @return string $value Complete checkbox `<input>` with proper attributes.
472
  */
473
  public function get_check_input( $args = array() ) {
474
  $defaults = $this->get_default_input_parameters(
476
  'checkvalue' => '',
477
  'checked' => 'true',
478
  'checklisttext' => '',
479
+ 'default' => false,
480
  )
481
  );
482
 
487
  $value .= $this->get_tr_start();
488
  $value .= $this->get_th_start();
489
  $value .= $args['checklisttext'];
490
+ if ( $args['required'] ) { $value .= $this->get_required_span(); }
491
  $value .= $this->get_th_end();
492
  $value .= $this->get_td_start();
493
  }
494
 
495
+ if ( isset( $args['checked'] ) && 'false' === $args['checked'] ) {
496
  $value .= '<input type="checkbox" id="' . $args['name'] . '" name="' . $args['namearray'] . '[]" value="' . $args['checkvalue'] . '" />';
497
  } else {
498
  $value .= '<input type="checkbox" id="' . $args['name'] . '" name="' . $args['namearray'] . '[]" value="' . $args['checkvalue'] . '" checked="checked" />';
499
  }
500
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
501
+ if ( ! empty( $args['helptext'] ) ) {
502
+ $value .= $this->get_help( $args['helptext'] );
503
+ }
504
  $value .= '<br/>';
505
 
506
  if ( $args['wrap'] ) {
511
  return $value;
512
  }
513
 
514
+ /**
515
+ * Return a button `<input>`.
516
+ *
517
+ * @since 1.3.0
518
+ *
519
+ * @param array $args Arguments to use with the button input.
520
+ * @return string Complete button `<input>`.
521
+ */
522
+ public function get_button( $args = array() ) {
523
+ $value = '';
524
+ $value .= '<input id="' . $args['id'] . '" class="button" type="button" value="' . $args['textvalue'] . '" />';
525
+
526
+ return $value;
527
+ }
528
+
529
  /**
530
  * Return some array_merged default arguments for all input types.
531
  *
537
  public function get_default_input_parameters( $additions = array() ) {
538
  return array_merge(
539
  array(
540
+ 'namearray' => '',
541
+ 'name' => '',
542
+ 'textvalue' => '',
543
+ 'labeltext' => '',
544
+ 'aftertext' => '',
545
+ 'helptext' => '',
546
+ 'helptext_after' => false,
547
+ 'required' => false,
548
+ 'wrap' => true,
549
+ 'placeholder' => true,
550
  ),
551
+ (array) $additions
552
  );
553
  }
554
  }
classes/class.cptui_debug_info.php CHANGED
@@ -1,17 +1,40 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
 
 
3
  class CPTUI_Debug_Info {
4
 
 
 
 
 
 
5
  public function tab_site_info() {
6
  ?>
7
  <p><?php _e( 'If you have sought support for Custom Post Type UI on the forums, you may be requested to send the information below to the plugin developer. Simply insert the email they provided in the input field at the bottom and click the "Send debug info" button. Only the data below will be sent to them.', 'custom-post-type-ui' ); ?></p>
8
  <label for="cptui_audit_textarea">
9
- <textarea readonly="readonly" id="cptui-audit-textarea" name="cptui_audit_textarea" rows="20" cols="100">
10
  <?php echo $this->system_status(); ?>
11
  </textarea></label>
12
  <?php
13
  }
14
 
 
 
 
 
 
 
 
15
  private function system_status() {
16
  if ( ! current_user_can( 'manage_options' ) ) {
17
  return '';
@@ -63,13 +86,11 @@ class CPTUI_Debug_Info {
63
  $mu_plugins = get_mu_plugins();
64
 
65
  if ( $mu_plugins ) :
66
- $mu_count = count( $mu_plugins );
67
-
68
- echo 'MU PLUGINS: (' . $mu_count . ')' . "\n\n";
69
 
70
  foreach ( $mu_plugins as $mu_path => $mu_plugin ) {
71
 
72
- echo $mu_plugin['Name'] . ': ' . $mu_plugin['Version'] . "\n";
73
  }
74
  endif;
75
  // standard plugins - active
@@ -79,7 +100,7 @@ class CPTUI_Debug_Info {
79
  $ac_count = count( $active );
80
  $ic_count = $pg_count - $ac_count;
81
 
82
- echo 'ACTIVE PLUGINS: (' . $ac_count . ')' . "\n\n";
83
 
84
  foreach ( $plugins as $plugin_path => $plugin ) {
85
  // If the plugin isn't active, don't show it.
@@ -87,11 +108,11 @@ class CPTUI_Debug_Info {
87
  continue;
88
  }
89
 
90
- echo $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
91
  }
92
  // standard plugins - inactive
93
  echo "\n";
94
- echo 'INACTIVE PLUGINS: (' . $ic_count . ')' . "\n\n";
95
 
96
  foreach ( $plugins as $plugin_path => $plugin ) {
97
  // If the plugin isn't active, show it here.
@@ -99,7 +120,7 @@ class CPTUI_Debug_Info {
99
  continue;
100
  }
101
 
102
- echo $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
103
  }
104
 
105
  // if multisite, grab network as well
@@ -127,15 +148,28 @@ class CPTUI_Debug_Info {
127
  endif;
128
 
129
  echo "\n";
130
- $cptui_post_types = get_option( 'cptui_post_types', array() );
131
- echo 'Post Types: ' . "\n";
132
- echo esc_html( json_encode( $cptui_post_types ) ) . "\n";
133
 
134
  echo "\n\n";
135
 
136
- $cptui_taxonomies = get_option( 'cptui_taxonomies', array() );
137
- echo 'Taxonomies: ' . "\n";
138
- echo esc_html( json_encode( $cptui_taxonomies ) ) . "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  echo "\n";
140
  ?>
141
  ### End Debug Info ###
@@ -145,7 +179,9 @@ class CPTUI_Debug_Info {
145
  }
146
 
147
  /**
148
- * helper function for number conversions
 
 
149
  * @access public
150
  *
151
  * @param mixed $v
@@ -170,7 +206,15 @@ class CPTUI_Debug_Info {
170
  return $ret;
171
  }
172
 
173
- public function send_email( $args ) {
 
 
 
 
 
 
 
 
174
 
175
  if ( ! isset( $args['email'] ) || ! is_email( $args['email'] ) ) {
176
  return false;
@@ -182,12 +226,25 @@ class CPTUI_Debug_Info {
182
 
183
  $message = $this->system_status();
184
 
185
- $subject = sprintf(
186
- __( 'CPTUI debug information for %s'),
 
 
 
 
 
 
 
187
  home_url( '/' )
188
- );
189
 
190
  wp_mail( $args['email'], $subject, $message );
 
 
 
 
 
 
 
191
  }
192
  }
193
-
1
  <?php
2
+ /**
3
+ * Custom Post Type UI Debug Information.
4
+ *
5
+ * @package CPTUI
6
+ * @subpackage Debugging
7
+ * @author WebDevStudios
8
+ * @since 1.2.0
9
+ */
10
+
11
+ /**
12
+ * Custom Post Type UI Debug Info
13
+ */
14
  class CPTUI_Debug_Info {
15
 
16
+ /**
17
+ * Tab content for the debug info tab.
18
+ *
19
+ * @since 1.2.0
20
+ */
21
  public function tab_site_info() {
22
  ?>
23
  <p><?php _e( 'If you have sought support for Custom Post Type UI on the forums, you may be requested to send the information below to the plugin developer. Simply insert the email they provided in the input field at the bottom and click the "Send debug info" button. Only the data below will be sent to them.', 'custom-post-type-ui' ); ?></p>
24
  <label for="cptui_audit_textarea">
25
+ <textarea readonly="readonly" aria-readonly="true" id="cptui-audit-textarea" name="cptui_audit_textarea" rows="20" cols="100">
26
  <?php echo $this->system_status(); ?>
27
  </textarea></label>
28
  <?php
29
  }
30
 
31
+ /**
32
+ * Generate the debug information content.
33
+ *
34
+ * @since 1.2.0
35
+ *
36
+ * @return string
37
+ */
38
  private function system_status() {
39
  if ( ! current_user_can( 'manage_options' ) ) {
40
  return '';
86
  $mu_plugins = get_mu_plugins();
87
 
88
  if ( $mu_plugins ) :
89
+ echo "\t\t" . 'MU PLUGINS: (' . count( $mu_plugins ) . ')' . "\n\n";
 
 
90
 
91
  foreach ( $mu_plugins as $mu_path => $mu_plugin ) {
92
 
93
+ echo "\t\t" . $mu_plugin['Name'] . ': ' . $mu_plugin['Version'] . "\n";
94
  }
95
  endif;
96
  // standard plugins - active
100
  $ac_count = count( $active );
101
  $ic_count = $pg_count - $ac_count;
102
 
103
+ echo "\t\t" . 'ACTIVE PLUGINS: (' . $ac_count . ')' . "\n\n";
104
 
105
  foreach ( $plugins as $plugin_path => $plugin ) {
106
  // If the plugin isn't active, don't show it.
108
  continue;
109
  }
110
 
111
+ echo "\t\t" . $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
112
  }
113
  // standard plugins - inactive
114
  echo "\n";
115
+ echo "\t\t" , 'INACTIVE PLUGINS: (' . $ic_count . ')' . "\n\n";
116
 
117
  foreach ( $plugins as $plugin_path => $plugin ) {
118
  // If the plugin isn't active, show it here.
120
  continue;
121
  }
122
 
123
+ echo "\t\t" . $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
124
  }
125
 
126
  // if multisite, grab network as well
148
  endif;
149
 
150
  echo "\n";
151
+ $cptui_post_types = cptui_get_post_type_data();
152
+ echo "\t\t" . 'Post Types: ' . "\n";
153
+ echo "\t\t" . esc_html( json_encode( $cptui_post_types ) ) . "\n";
154
 
155
  echo "\n\n";
156
 
157
+ $cptui_taxonomies = cptui_get_taxonomy_data();
158
+ echo "\t\t" . 'Taxonomies: ' . "\n";
159
+ echo "\t\t" . esc_html( json_encode( $cptui_taxonomies ) ) . "\n";
160
+ echo "\n";
161
+
162
+ if ( has_action( 'cptui_custom_debug_info' ) ) {
163
+ echo "\t\t" . 'EXTRA DEBUG INFO';
164
+ }
165
+
166
+ /**
167
+ * Fires at the end of the debug info output.
168
+ *
169
+ * @since 1.3.0
170
+ */
171
+ do_action( 'cptui_custom_debug_info' );
172
+
173
  echo "\n";
174
  ?>
175
  ### End Debug Info ###
179
  }
180
 
181
  /**
182
+ * Helper function for number conversions.
183
+ *
184
+ * @since 1.2.0
185
  * @access public
186
  *
187
  * @param mixed $v
206
  return $ret;
207
  }
208
 
209
+ /**
210
+ * Sends an email to the specified address, with the system status as the message.
211
+ *
212
+ * @since 1.2.0
213
+ *
214
+ * @param array $args Array of arguments for the method.
215
+ * @return bool
216
+ */
217
+ public function send_email( $args = array() ) {
218
 
219
  if ( ! isset( $args['email'] ) || ! is_email( $args['email'] ) ) {
220
  return false;
226
 
227
  $message = $this->system_status();
228
 
229
+ /**
230
+ * Filters the debug email subject.
231
+ *
232
+ * @since 1.3.0
233
+ *
234
+ * @param string $value Intended email subject.
235
+ */
236
+ $subject = apply_filters( 'cptui_debug_email_subject', sprintf(
237
+ __( 'CPTUI debug information for %s', 'custom-post-type-ui' ),
238
  home_url( '/' )
239
+ ) );
240
 
241
  wp_mail( $args['email'], $subject, $message );
242
+
243
+ /**
244
+ * Fires after the debug email has been sent.
245
+ *
246
+ * @since 1.3.0
247
+ */
248
+ do_action( 'cptui_after_debug_email_sent' );
249
  }
250
  }
 
css/cptui.css CHANGED
@@ -1,124 +1,265 @@
1
- .required { color: rgb(255,0,0); }
2
- .cptui-table #excerpt { height: 16px; margin-right: 4px; width: auto; }
3
- .cptui-table td.outter { vertical-align: top; width: 50%; }
4
- #cptui_select_post_type, #cptui_select_taxonomy { margin-top: 15px; }
5
- .cptui_post_import, .cptui_tax_import {
6
- height: 200px;
7
- margin-bottom: 10px;
8
- resize: vertical;
9
- width: 100%;
10
- }
11
- .cptui_post_type_get_code, .cptui_tax_get_code {
12
- height: 300px;
13
- resize: vertical;
14
- width: 100%;
15
- }
16
- .cptui-table .question:hover { cursor: pointer; }
17
- .question { font-size: 18px; font-weight: bold; }
18
- .answer { margin: 10px 0 0 20px; }
19
- #support li { position: relative; }
20
- #support .question:before {
21
- content: "\f139";
22
- display: inline-block;
23
- font: normal 25px/1 'dashicons';
24
- -webkit-font-smoothing: antialiased;
25
  }
26
- #support .question.active:before { content: "\f140"; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  #support .question:before {
28
- margin-left: -25px;
29
- position: absolute;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  }
31
- #support ol li { list-style: none; }
32
- .one-third { width: 33%; }
33
- .valign { vertical-align: top; }
34
- .typetax-rename {
35
- color: rgb(255,0,0);
36
- display: block;
37
  }
38
- .typetax-rename.cptui-hidden { display: none; }
39
  .about-wrap .cptui-feature {
40
- overflow: visible !important;
41
- *zoom:1;
42
  }
43
- .about-wrap h3 + .cptui-feature { margin-top: 0; }
44
- .about-wrap .cptui-feature:before,
 
 
 
 
45
  .about-wrap .cptui-feature:after {
46
- content: " ";
47
- display: table;
 
 
 
48
  }
49
- .about-wrap .cptui-feature:after { clear: both; }
50
  .about-wrap .feature-rest div {
51
- width: 50% !important;
52
- padding-right: 100px;
53
- -moz-box-sizing: border-box;
54
- box-sizing: border-box;
55
- margin: 0 !important;
56
  }
57
- .rtl .about-wrap .feature-rest div { padding-left: 100px; }
58
  .about-wrap .feature-rest div.last-feature {
59
- padding-left: 100px;
60
- padding-right: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
 
 
 
 
 
62
  .rtl .about-wrap .feature-rest div.last-feature {
63
- padding-right: 100px;
64
- padding-left: 0;
65
  }
66
- .about-wrap div.icon {
67
- width: 0 !important;
68
- padding: 0;
69
- margin: 0;
70
  }
71
- .about-wrap .feature-rest div.icon:before {
72
- font-weight: normal;
73
- width: 100%;
74
- font-size: 170px;
75
- line-height: 125px;
76
- color: #9c5d90;
77
- display: inline-block;
78
- position: relative;
79
- text-align: center;
80
- speak: none;
81
- margin: 0 0 0 -100px;
82
- content: "\e01d";
83
- -webkit-font-smoothing: antialiased;
84
- -moz-osx-font-smoothing: grayscale;
85
- }
86
- .rtl .about-wrap .feature-rest div.icon:before { margin: 0 -100px 0 0; }
87
  .about-integrations {
88
- background: #fff;
89
- margin: 20px 0;
90
- padding: 1px 20px 10px;
91
  }
92
- .changelog h4 { line-height: 1.4; }
93
- .cptui-about-text { margin-bottom: 1em !important; }
94
- .cptui-table th p {
95
- font-weight: 400;
96
- font-size: 12px;
 
 
97
  }
 
98
  .js #cptui_select_post_type input[type='submit'],
99
  .js #cptui_select_taxonomy input[type='submit'] {
100
- display: none;
101
  }
 
 
 
 
 
 
 
 
 
102
  .cptui-help {
103
- color: #424242;
104
- margin-left: 4px;
105
- opacity: 0.5;
106
- text-decoration: none;
107
- width: 16px;
108
  }
 
109
  fieldset .cptui-help {
110
- position: relative;
111
- top: 4px;
112
  }
 
113
  .cptui-help:hover {
114
- color: #0074a2;
115
- opacity: 1;
116
  }
 
117
  .cptui-help:focus {
118
- box-shadow: none;
119
  }
 
120
  #toplevel_page_cptui_main_menu img {
121
- height: 20px;
122
- margin-top: -2px;
123
- width: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
1
+ .posttypesui .cptui-section:first-child, .taxonomiesui .cptui-section:first-child {
2
+ margin-top: 30px;
3
+ }
4
+
5
+ .cptui-table #excerpt {
6
+ display: inline-block;
7
+ height: 16px;
8
+ margin: 12px 4px 12px 0;
9
+ width: auto;
10
+ }
11
+
12
+ .cptui-table td.outter {
13
+ vertical-align: top;
14
+ width: 50%;
15
+ }
16
+
17
+ .cptui-table input[type="text"],
18
+ .cptui-new .cptui-table textarea,
19
+ .cptui-edit .cptui-table textarea {
20
+ width: 50%;
21
+ }
22
+
23
+ .cptui-table .question:hover {
24
+ cursor: pointer;
25
  }
26
+
27
+ .cptui-table th p {
28
+ font-weight: 400;
29
+ font-size: 12px;
30
+ }
31
+
32
+ .cptui-table .cptui-slug-details {
33
+ margin-top: 15px;
34
+ }
35
+
36
+ #support .question {
37
+ font-size: 18px;
38
+ font-weight: bold;
39
+ }
40
+
41
  #support .question:before {
42
+ content: "\f139";
43
+ display: inline-block;
44
+ font: normal 25px/1 'dashicons';
45
+ margin-left: -25px;
46
+ position: absolute;
47
+ -webkit-font-smoothing: antialiased;
48
+ }
49
+
50
+ #support .question.active:before {
51
+ content: "\f140";
52
+ }
53
+
54
+ #support .answer {
55
+ margin: 10px 0 0 20px;
56
+ }
57
+
58
+ #support ol li {
59
+ list-style: none;
60
+ }
61
+
62
+ #support li {
63
+ position: relative;
64
+ }
65
+
66
+ .required {
67
+ color: red;
68
+ }
69
+
70
+ .cptui-field-description {
71
+ font-style: italic;
72
+ }
73
+
74
+ #cptui_select_post_type,
75
+ #cptui_select_taxonomy {
76
+ margin-top: 15px;
77
+ }
78
+
79
+ .cptui_post_import,
80
+ .cptui_tax_import {
81
+ height: 200px;
82
+ margin-bottom: 10px;
83
+ resize: vertical;
84
+ width: 100%;
85
+ }
86
+
87
+ .cptui_post_type_get_code,
88
+ .cptui_tax_get_code {
89
+ height: 300px;
90
+ resize: vertical;
91
+ width: 100%;
92
+ }
93
+
94
+ .one-third {
95
+ width: 33%;
96
  }
97
+
98
+ .valign {
99
+ vertical-align: top;
 
 
 
100
  }
101
+
102
  .about-wrap .cptui-feature {
103
+ overflow: visible !important;
104
+ *zoom: 1;
105
  }
106
+
107
+ .about-wrap .cptui-feature:before, .about-wrap .cptui-feature:after {
108
+ content: " ";
109
+ display: table;
110
+ }
111
+
112
  .about-wrap .cptui-feature:after {
113
+ clear: both;
114
+ }
115
+
116
+ .about-wrap h3 + .cptui-feature {
117
+ margin-top: 0;
118
  }
119
+
120
  .about-wrap .feature-rest div {
121
+ width: 50% !important;
122
+ padding-right: 100px;
123
+ box-sizing: border-box;
124
+ margin: 0 !important;
 
125
  }
126
+
127
  .about-wrap .feature-rest div.last-feature {
128
+ padding-left: 100px;
129
+ padding-right: 0;
130
+ }
131
+
132
+ .about-wrap .feature-rest div.icon {
133
+ width: 0 !important;
134
+ padding: 0;
135
+ margin: 0;
136
+ }
137
+
138
+ .about-wrap .feature-rest div.icon:before {
139
+ font-weight: normal;
140
+ width: 100%;
141
+ font-size: 170px;
142
+ line-height: 125px;
143
+ color: #9c5d90;
144
+ display: inline-block;
145
+ position: relative;
146
+ text-align: center;
147
+ speak: none;
148
+ margin: 0 0 0 -100px;
149
+ content: "\e01d";
150
+ -webkit-font-smoothing: antialiased;
151
+ -moz-osx-font-smoothing: grayscale;
152
  }
153
+
154
+ .rtl .about-wrap .feature-rest div {
155
+ padding-left: 100px;
156
+ }
157
+
158
  .rtl .about-wrap .feature-rest div.last-feature {
159
+ padding-right: 100px;
160
+ padding-left: 0;
161
  }
162
+
163
+ .rtl .about-wrap .feature-rest div.icon:before {
164
+ margin: 0 -100px 0 0;
 
165
  }
166
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  .about-integrations {
168
+ background: #fff;
169
+ margin: 20px 0;
170
+ padding: 1px 20px 10px;
171
  }
172
+
173
+ .changelog h4 {
174
+ line-height: 1.4;
175
+ }
176
+
177
+ .cptui-about-text {
178
+ margin-bottom: 1em !important;
179
  }
180
+
181
  .js #cptui_select_post_type input[type='submit'],
182
  .js #cptui_select_taxonomy input[type='submit'] {
183
+ display: none;
184
  }
185
+
186
+ #togglelabels {
187
+ display: none;
188
+ }
189
+
190
+ .js #togglelabels {
191
+ display: inline-block;
192
+ }
193
+
194
  .cptui-help {
195
+ color: #424242;
196
+ margin-left: 4px;
197
+ opacity: 0.5;
198
+ text-decoration: none;
199
+ width: 16px;
200
  }
201
+
202
  fieldset .cptui-help {
203
+ position: relative;
204
+ top: 4px;
205
  }
206
+
207
  .cptui-help:hover {
208
+ color: #0074a2;
209
+ opacity: 1;
210
  }
211
+
212
  .cptui-help:focus {
213
+ box-shadow: none;
214
  }
215
+
216
  #toplevel_page_cptui_main_menu img {
217
+ height: 20px;
218
+ margin-top: -2px;
219
+ width: 20px;
220
+ }
221
+
222
+ .visuallyhidden {
223
+ position: absolute;
224
+ left: -10000px;
225
+ top: auto;
226
+ width: 1px;
227
+ height: 1px;
228
+ overflow: hidden;
229
+ }
230
+
231
+ .cptui-section fieldset {
232
+ border: solid #cccccc 1px;
233
+ display: block;
234
+ margin-bottom: 30px;
235
+ padding: 10px;
236
+ overflow: hidden;
237
+ }
238
+
239
+ .js .cptui-section fieldset.toggledclosed {
240
+ height: 1px;
241
+ }
242
+
243
+ .cptui-section legend {
244
+ border: solid #cccccc 1px;
245
+ border-bottom: 0px;
246
+ font-size: 14px;
247
+ font-weight: bold;
248
+ padding: 5px;
249
+ }
250
+
251
+ .cptui-spacer {
252
+ display: block;
253
+ margin-top: 25px;
254
+ }
255
+
256
+ .wdspromos {
257
+ float: right;
258
+ margin-left: 20px;
259
+ margin-top: 10px;
260
+ width: 275px;
261
+ }
262
+
263
+ .wdspromos img {
264
+ margin-bottom: 10px;
265
  }
css/cptui.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .posttypesui .cptui-section:first-child,.taxonomiesui .cptui-section:first-child{margin-top:30px}.cptui-table #excerpt{display:inline-block;height:16px;margin:12px 4px 12px 0;width:auto}.cptui-table td.outter{vertical-align:top;width:50%}.cptui-edit .cptui-table textarea,.cptui-new .cptui-table textarea,.cptui-table input[type=text]{width:50%}.cptui-table .question:hover{cursor:pointer}.cptui-table th p{font-weight:400;font-size:12px}.cptui-table .cptui-slug-details{margin-top:15px}#support .question{font-size:18px;font-weight:700}#support .question:before{content:"\f139";display:inline-block;font:normal 25px/1 dashicons;margin-left:-25px;position:absolute;-webkit-font-smoothing:antialiased}#support .question.active:before{content:"\f140"}#support .answer{margin:10px 0 0 20px}#support ol li{list-style:none}#support li{position:relative}.required{color:red}.cptui-field-description{font-style:italic}#cptui_select_post_type,#cptui_select_taxonomy{margin-top:15px}.cptui_post_import,.cptui_tax_import{height:200px;margin-bottom:10px;resize:vertical;width:100%}.cptui_post_type_get_code,.cptui_tax_get_code{height:300px;resize:vertical;width:100%}.one-third{width:33%}.valign{vertical-align:top}.about-wrap .cptui-feature{overflow:visible!important;*zoom:1}.about-wrap .cptui-feature:after,.about-wrap .cptui-feature:before{content:" ";display:table}.about-wrap .cptui-feature:after{clear:both}.about-wrap h3+.cptui-feature{margin-top:0}.about-wrap .feature-rest div{width:50%!important;padding-right:100px;box-sizing:border-box;margin:0!important}.about-wrap .feature-rest div.last-feature{padding-left:100px;padding-right:0}.about-wrap .feature-rest div.icon{width:0!important;padding:0;margin:0}.about-wrap .feature-rest div.icon:before{font-weight:400;width:100%;font-size:170px;line-height:125px;color:#9c5d90;display:inline-block;position:relative;text-align:center;speak:none;margin:0 0 0 -100px;content:"\e01d";-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.rtl .about-wrap .feature-rest div{padding-left:100px}.rtl .about-wrap .feature-rest div.last-feature{padding-right:100px;padding-left:0}.rtl .about-wrap .feature-rest div.icon:before{margin:0 -100px 0 0}.about-integrations{background:#fff;margin:20px 0;padding:1px 20px 10px}.changelog h4{line-height:1.4}.cptui-about-text{margin-bottom:1em!important}#togglelabels,.js #cptui_select_post_type input[type=submit],.js #cptui_select_taxonomy input[type=submit]{display:none}.js #togglelabels{display:inline-block}.cptui-help{color:#424242;margin-left:4px;opacity:.5;text-decoration:none;width:16px}fieldset .cptui-help{position:relative;top:4px}.cptui-help:hover{color:#0074a2;opacity:1}.cptui-help:focus{box-shadow:none}#toplevel_page_cptui_main_menu img{height:20px;margin-top:-2px;width:20px}.visuallyhidden{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}.cptui-section fieldset{border:1px solid #ccc;display:block;margin-bottom:30px;padding:10px;overflow:hidden}.js .cptui-section fieldset.toggledclosed{height:1px}.cptui-section legend{border:1px solid #ccc;border-bottom:0;font-size:14px;font-weight:700;padding:5px}.cptui-spacer{display:block;margin-top:25px}.wdspromos{float:right;margin-left:20px;margin-top:10px;width:275px}.wdspromos img{margin-bottom:10px}
css/cptui.scss ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .posttypesui, .taxonomiesui {
2
+ .cptui-section:first-child {
3
+ margin-top: 30px;
4
+ }
5
+ }
6
+ .cptui-table {
7
+ #excerpt {
8
+ display: inline-block;
9
+ height: 16px;
10
+ margin: 12px 4px 12px 0;
11
+ width: auto;
12
+ }
13
+ td.outter {
14
+ vertical-align: top;
15
+ width: 50%;
16
+ }
17
+ input[type="text"],
18
+ .cptui-new & textarea,
19
+ .cptui-edit & textarea {
20
+ width: 50%;
21
+ }
22
+ .question:hover {
23
+ cursor: pointer;
24
+ }
25
+ th p {
26
+ font-weight: 400;
27
+ font-size: 12px;
28
+ }
29
+ .cptui-slug-details {
30
+ margin-top: 15px;
31
+ }
32
+ }
33
+
34
+ #support {
35
+ .question {
36
+ font-size: 18px;
37
+ font-weight: bold;
38
+ &:before {
39
+ content: "\f139";
40
+ display: inline-block;
41
+ font: normal 25px/1 'dashicons';
42
+ margin-left: -25px;
43
+ position: absolute;
44
+ -webkit-font-smoothing: antialiased;
45
+ }
46
+ &.active:before {
47
+ content: "\f140";
48
+ }
49
+ }
50
+ .answer {
51
+ margin: 10px 0 0 20px;
52
+ }
53
+ ol li {
54
+ list-style: none;
55
+ }
56
+ li {
57
+ position: relative;
58
+ }
59
+ }
60
+ .required {
61
+ color: rgb(255,0,0);
62
+ }
63
+ .cptui-field-description {
64
+ font-style: italic;
65
+ }
66
+ #cptui_select_post_type,
67
+ #cptui_select_taxonomy {
68
+ margin-top: 15px;
69
+ }
70
+ .cptui_post_import,
71
+ .cptui_tax_import {
72
+ height: 200px;
73
+ margin-bottom: 10px;
74
+ resize: vertical;
75
+ width: 100%;
76
+ }
77
+ .cptui_post_type_get_code,
78
+ .cptui_tax_get_code {
79
+ height: 300px;
80
+ resize: vertical;
81
+ width: 100%;
82
+ }
83
+ .one-third {
84
+ width: 33%;
85
+ }
86
+ .valign {
87
+ vertical-align: top;
88
+ }
89
+
90
+ .about-wrap {
91
+ .cptui-feature {
92
+ overflow: visible !important;
93
+ *zoom:1;
94
+ &:before,
95
+ &:after {
96
+ content: " ";
97
+ display: table;
98
+ }
99
+ &:after {
100
+ clear: both;
101
+ }
102
+ }
103
+ h3 + .cptui-feature {
104
+ margin-top: 0;
105
+ }
106
+ .feature-rest {
107
+ div {
108
+ width: 50% !important;
109
+ padding-right: 100px;
110
+ -moz-box-sizing: border-box;
111
+ box-sizing: border-box;
112
+ margin: 0 !important;
113
+ &.last-feature {
114
+ padding-left: 100px;
115
+ padding-right: 0;
116
+ }
117
+ &.icon {
118
+ width: 0 !important;
119
+ padding: 0;
120
+ margin: 0;
121
+ &:before {
122
+ font-weight: normal;
123
+ width: 100%;
124
+ font-size: 170px;
125
+ line-height: 125px;
126
+ color: #9c5d90;
127
+ display: inline-block;
128
+ position: relative;
129
+ text-align: center;
130
+ speak: none;
131
+ margin: 0 0 0 -100px;
132
+ content: "\e01d";
133
+ -webkit-font-smoothing: antialiased;
134
+ -moz-osx-font-smoothing: grayscale;
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
140
+ .rtl {
141
+ .about-wrap {
142
+ .feature-rest div {
143
+ padding-left: 100px;
144
+ }
145
+ .feature-rest div.last-feature {
146
+ padding-right: 100px;
147
+ padding-left: 0;
148
+ }
149
+ .feature-rest div.icon:before {
150
+ margin: 0 -100px 0 0;
151
+ }
152
+ }
153
+ }
154
+ .about-integrations {
155
+ background: #fff;
156
+ margin: 20px 0;
157
+ padding: 1px 20px 10px;
158
+ }
159
+ .changelog {
160
+ h4 {
161
+ line-height: 1.4;
162
+ }
163
+ }
164
+ .cptui-about-text {
165
+ margin-bottom: 1em !important;
166
+ }
167
+ .js {
168
+ #cptui_select_post_type input[type='submit'],
169
+ #cptui_select_taxonomy input[type='submit'] {
170
+ display: none;
171
+ }
172
+ }
173
+ #togglelabels {
174
+ display: none;
175
+ .js & {
176
+ display: inline-block;
177
+ }
178
+ }
179
+ .cptui-help {
180
+ color: #424242;
181
+ margin-left: 4px;
182
+ opacity: 0.5;
183
+ text-decoration: none;
184
+ width: 16px;
185
+ fieldset & {
186
+ position: relative;
187
+ top: 4px;
188
+ }
189
+ &:hover {
190
+ color: #0074a2;
191
+ opacity: 1;
192
+ }
193
+ &:focus {
194
+ box-shadow: none;
195
+ }
196
+ }
197
+ #toplevel_page_cptui_main_menu {
198
+ img {
199
+ height: 20px;
200
+ margin-top: -2px;
201
+ width: 20px;
202
+ }
203
+ }
204
+ .visuallyhidden {
205
+ position: absolute;
206
+ left: -10000px;
207
+ top: auto;
208
+ width: 1px;
209
+ height: 1px;
210
+ overflow: hidden;
211
+ }
212
+ .cptui-section {
213
+ fieldset {
214
+ border: solid rgb(204, 204, 204) 1px;
215
+ display: block;
216
+ margin-bottom: 30px;
217
+ padding: 10px;
218
+ overflow: hidden;
219
+ .js &.toggledclosed {
220
+ height: 1px;
221
+ }
222
+ }
223
+ legend {
224
+ border: solid rgb(204, 204, 204) 1px;
225
+ border-bottom: 0px;
226
+ font-size: 14px;
227
+ font-weight: bold;
228
+ padding: 5px;
229
+ }
230
+ }
231
+ .cptui-spacer {
232
+ display: block;
233
+ margin-top: 25px;
234
+ }
235
+ .wdspromos {
236
+ float: right;
237
+ margin-left: 20px;
238
+ margin-top: 10px;
239
+ width: 275px;
240
+
241
+ img {
242
+ margin-bottom: 10px;
243
+ }
244
+ }
custom-post-type-ui.php CHANGED
@@ -1,29 +1,40 @@
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
7
- Version: 1.2.4
8
- Author URI: http://webdevstudios.com/
9
  Text Domain: custom-post-type-ui
10
  Domain Path: /languages
11
  License: GPLv2
12
  */
13
 
14
- # Exit if accessed directly
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
17
  }
18
 
19
- define( 'CPT_VERSION', '1.2.4' ); // Left for legacy purposes.
20
- define( 'CPTUI_VERSION', '1.2.4' );
21
  define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
22
 
23
  /**
24
  * Load our Admin UI class that powers our form inputs.
25
  *
26
  * @since 1.0.0
 
 
27
  */
28
  function cptui_load_ui_class() {
29
  require_once( plugin_dir_path( __FILE__ ) . 'classes/class.cptui_admin_ui.php' );
@@ -35,6 +46,8 @@ add_action( 'init', 'cptui_load_ui_class' );
35
  * Flush our rewrite rules on deactivation.
36
  *
37
  * @since 0.8.0
 
 
38
  */
39
  function cptui_deactivation() {
40
  flush_rewrite_rules();
@@ -45,11 +58,13 @@ register_deactivation_hook( __FILE__, 'cptui_deactivation' );
45
  * Register our text domain.
46
  *
47
  * @since 0.8.0
 
 
48
  */
49
  function cptui_load_textdomain() {
50
- load_plugin_textdomain( 'custom-post-type-ui', false, basename( dirname( __FILE__ ) ) . '/languages' );
51
  }
52
- add_action( 'init', 'cptui_load_textdomain' );
53
 
54
  /**
55
  * Load our main menu.
@@ -57,41 +72,115 @@ add_action( 'init', 'cptui_load_textdomain' );
57
  * Submenu items added in version 1.1.0
58
  *
59
  * @since 0.1.0
 
 
60
  */
61
  function cptui_plugin_menu() {
62
- add_menu_page( __( 'Custom Post Types', 'custom-post-type-ui' ), __( 'CPT UI', 'custom-post-type-ui' ), 'manage_options', 'cptui_main_menu', 'cptui_settings', cptui_menu_icon() );
63
- add_submenu_page( 'cptui_main_menu', __( 'Add/Edit Post Types', 'custom-post-type-ui' ), __( 'Add/Edit Post Types', 'custom-post-type-ui' ), 'manage_options', 'cptui_manage_post_types', 'cptui_manage_post_types' );
64
- add_submenu_page( 'cptui_main_menu', __( 'Add/Edit Taxonomies', 'custom-post-type-ui' ), __( 'Add/Edit Taxonomies', 'custom-post-type-ui' ), 'manage_options', 'cptui_manage_taxonomies', 'cptui_manage_taxonomies' );
65
- add_submenu_page( 'cptui_main_menu', __( 'Registered Types and Taxes', 'custom-post-type-ui' ), __( 'Registered Types/Taxes', 'custom-post-type-ui' ), 'manage_options', 'cptui_listings', 'cptui_listings' );
66
- add_submenu_page( 'cptui_main_menu', __( 'Import/Export', 'custom-post-type-ui' ), __( 'Import/Export', 'custom-post-type-ui' ), 'manage_options', 'cptui_importexport', 'cptui_importexport' );
67
- add_submenu_page( 'cptui_main_menu', __( 'Help/Support', 'custom-post-type-ui' ), __( 'Help/Support', 'custom-post-type-ui' ), 'manage_options', 'cptui_support', 'cptui_support' );
68
-
69
- # Remove the default one so we can add our customized version.
70
- remove_submenu_page('cptui_main_menu', 'cptui_main_menu');
71
- add_submenu_page( 'cptui_main_menu', __( 'About CPT UI', 'custom-post-type-ui' ), __( 'About CPT UI', 'custom-post-type-ui' ), 'manage_options', 'cptui_main_menu', 'cptui_settings' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
  add_action( 'admin_menu', 'cptui_plugin_menu' );
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  /**
76
  * Load our submenus.
77
  *
78
  * @since 1.0.0
 
 
79
  */
80
  function cptui_create_submenus() {
 
 
81
  require_once( plugin_dir_path( __FILE__ ) . 'inc/post-types.php' );
82
  require_once( plugin_dir_path( __FILE__ ) . 'inc/taxonomies.php' );
83
  require_once( plugin_dir_path( __FILE__ ) . 'inc/listings.php' );
84
  require_once( plugin_dir_path( __FILE__ ) . 'inc/import_export.php' );
85
  require_once( plugin_dir_path( __FILE__ ) . 'inc/support.php' );
86
  }
87
- add_action( 'init', 'cptui_create_submenus' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
 
 
 
 
 
 
 
89
  function cptui_add_styles() {
90
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
91
  return;
92
  }
93
 
94
- wp_enqueue_style( 'cptui-css', plugins_url( 'css/cptui.css', __FILE__ ), array(), CPTUI_VERSION );
 
 
95
  }
96
  add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
97
 
@@ -99,26 +188,50 @@ add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
99
  * Register our users' custom post types.
100
  *
101
  * @since 0.5.0
 
 
102
  */
103
  function cptui_create_custom_post_types() {
104
  $cpts = get_option( 'cptui_post_types' );
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  if ( is_array( $cpts ) ) {
107
  foreach ( $cpts as $post_type ) {
108
  cptui_register_single_post_type( $post_type );
109
  }
110
  }
111
- return;
 
 
 
 
 
 
 
 
112
  }
113
- add_action( 'init', 'cptui_create_custom_post_types', 10 );
114
 
115
  /**
116
  * Helper function to register the actual post_type.
117
  *
118
  * @since 1.0.0
119
  *
120
- * @param array $post_type Post type array to register.
121
  *
 
122
  * @return null Result of register_post_type.
123
  */
124
  function cptui_register_single_post_type( $post_type = array() ) {
@@ -145,20 +258,24 @@ function cptui_register_single_post_type( $post_type = array() ) {
145
  */
146
  $user_supports_params = apply_filters( 'cptui_user_supports_params', array(), $post_type['name'], $post_type );
147
 
148
- if ( is_array( $user_supports_params ) ) {
149
- $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
 
 
 
 
150
  }
151
 
152
- $yarpp = false; # Prevent notices.
153
  if ( ! empty( $post_type['custom_supports'] ) ) {
154
  $custom = explode( ',', $post_type['custom_supports'] );
155
- foreach( $custom as $part ) {
156
- # We'll handle YARPP separately.
157
  if ( in_array( $part, array( 'YARPP', 'yarpp' ) ) ) {
158
  $yarpp = true;
159
  continue;
160
  }
161
- $post_type['supports'][] = $part;
162
  }
163
  }
164
 
@@ -168,13 +285,13 @@ function cptui_register_single_post_type( $post_type = array() ) {
168
 
169
  $labels = array(
170
  'name' => $post_type['label'],
171
- 'singular_name' => $post_type['singular_label']
172
  );
173
 
174
  $preserved = cptui_get_preserved_keys( 'post_types' );
175
- foreach( $post_type['labels'] as $key => $label ) {
176
 
177
- if ( !empty( $label ) ) {
178
  $labels[ $key ] = $label;
179
  } elseif ( empty( $label ) && in_array( $key, $preserved ) ) {
180
  $labels[ $key ] = cptui_get_preserved_label( 'post_types', $key, $post_type['label'], $post_type['singular_label'] );
@@ -182,24 +299,24 @@ function cptui_register_single_post_type( $post_type = array() ) {
182
  }
183
 
184
  $has_archive = get_disp_boolean( $post_type['has_archive'] );
185
- if ( !empty( $post_type['has_archive_string'] ) ) {
186
  $has_archive = $post_type['has_archive_string'];
187
  }
188
 
189
  $show_in_menu = get_disp_boolean( $post_type['show_in_menu'] );
190
- if ( !empty( $post_type['show_in_menu_string'] ) ) {
191
  $show_in_menu = $post_type['show_in_menu_string'];
192
  }
193
 
194
- $rewrite = get_disp_boolean( $post_type['rewrite' ] );
195
  if ( false !== $rewrite ) {
196
- //Core converts to an empty array anyway, so safe to leave this instead of passing in boolean true.
197
  $rewrite = array();
198
- $rewrite['slug'] = ( !empty( $post_type['rewrite_slug'] ) ) ? $post_type['rewrite_slug'] : $post_type['name'];
199
  $rewrite['with_front'] = ( 'false' === disp_boolean( $post_type['rewrite_withfront'] ) ) ? false : true;
200
  }
201
 
202
- $menu_icon = ( !empty( $post_type['menu_icon'] ) ) ? $post_type['menu_icon'] : null;
203
 
204
  if ( in_array( $post_type['query_var'], array( 'true', 'false', '0', '1' ) ) ) {
205
  $post_type['query_var'] = get_disp_boolean( $post_type['query_var'] );
@@ -209,7 +326,7 @@ function cptui_register_single_post_type( $post_type = array() ) {
209
  }
210
 
211
  $menu_position = null;
212
- if ( !empty( $post_type['menu_position'] ) ) {
213
  $menu_position = (int) $post_type['menu_position'];
214
  }
215
 
@@ -253,7 +370,7 @@ function cptui_register_single_post_type( $post_type = array() ) {
253
  'menu_icon' => $menu_icon,
254
  'query_var' => $post_type['query_var'],
255
  'supports' => $post_type['supports'],
256
- 'taxonomies' => $post_type['taxonomies']
257
  );
258
 
259
  if ( true === $yarpp ) {
@@ -264,11 +381,13 @@ function cptui_register_single_post_type( $post_type = array() ) {
264
  * Filters the arguments used for a post type right before registering.
265
  *
266
  * @since 1.0.0
 
267
  *
268
- * @param array $args Array of arguments to use for registering post type.
269
- * @param string $value Post type slug to be registered.
 
270
  */
271
- $args = apply_filters( 'cptui_pre_register_post_type', $args, $post_type['name'] );
272
 
273
  return register_post_type( $post_type['name'], $args );
274
  }
@@ -277,41 +396,68 @@ function cptui_register_single_post_type( $post_type = array() ) {
277
  * Register our users' custom taxonomies.
278
  *
279
  * @since 0.5.0
 
 
280
  */
281
  function cptui_create_custom_taxonomies() {
282
- $taxes = get_option('cptui_taxonomies');
 
 
 
 
 
 
 
 
 
 
 
 
 
283
 
284
  if ( is_array( $taxes ) ) {
285
  foreach ( $taxes as $tax ) {
286
  cptui_register_single_taxonomy( $tax );
287
  }
288
  }
 
 
 
 
 
 
 
 
 
289
  }
290
- add_action( 'init', 'cptui_create_custom_taxonomies', 9 );
291
 
292
  /**
293
  * Helper function to register the actual taxonomy.
294
  *
295
- * @param array $taxonomy Taxonomy array to register.
 
 
296
  *
 
297
  * @return null Result of register_taxonomy.
298
  */
299
  function cptui_register_single_taxonomy( $taxonomy = array() ) {
300
 
301
  $labels = array(
302
  'name' => $taxonomy['label'],
303
- 'singular_name' => $taxonomy['singular_label']
304
  );
305
 
306
  $description = '';
307
- if ( !empty( $taxonomy['description'] ) ) {
308
  $description = $taxonomy['description'];
309
  }
310
 
311
  $preserved = cptui_get_preserved_keys( 'taxonomies' );
312
- foreach( $taxonomy['labels'] as $key => $label ) {
313
 
314
- if ( !empty( $label ) ) {
315
  $labels[ $key ] = $label;
316
  } elseif ( empty( $label ) && in_array( $key, $preserved ) ) {
317
  $labels[ $key ] = cptui_get_preserved_label( 'taxonomies', $key, $taxonomy['label'], $taxonomy['singular_label'] );
@@ -321,7 +467,7 @@ function cptui_register_single_taxonomy( $taxonomy = array() ) {
321
  $rewrite = get_disp_boolean( $taxonomy['rewrite'] );
322
  if ( false !== get_disp_boolean( $taxonomy['rewrite'] ) ) {
323
  $rewrite = array();
324
- $rewrite['slug'] = ( !empty( $taxonomy['rewrite_slug'] ) ) ? $taxonomy['rewrite_slug'] : $taxonomy['name'];
325
  $rewrite['with_front'] = ( 'false' === disp_boolean( $taxonomy['rewrite_withfront'] ) ) ? false : true;
326
  $rewrite['hierarchical'] = ( 'true' === disp_boolean( $taxonomy['rewrite_hierarchical'] ) ) ? true : false;
327
  }
@@ -329,323 +475,126 @@ function cptui_register_single_taxonomy( $taxonomy = array() ) {
329
  if ( in_array( $taxonomy['query_var'], array( 'true', 'false', '0', '1' ) ) ) {
330
  $taxonomy['query_var'] = get_disp_boolean( $taxonomy['query_var'] );
331
  }
332
- if ( true === $taxonomy['query_var'] && !empty( $taxonomy['query_var_slug'] ) ) {
333
  $taxonomy['query_var'] = $taxonomy['query_var_slug'];
334
  }
335
 
336
- $show_admin_column = ( !empty( $taxonomy['show_admin_column'] ) && false !== get_disp_boolean( $taxonomy['show_admin_column'] ) ) ? true : false;
 
 
337
 
338
  $show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? true : false;
339
 
 
 
340
  $rest_base = null;
341
  if ( ! empty( $taxonomy['rest_base'] ) ) {
342
  $rest_base = $taxonomy['rest_base'];
343
  }
344
 
345
  $args = array(
346
- 'labels' => $labels,
347
- 'label' => $taxonomy['label'],
348
- 'description' => $description,
349
- 'hierarchical' => get_disp_boolean( $taxonomy['hierarchical'] ),
350
- 'show_ui' => get_disp_boolean( $taxonomy['show_ui'] ),
351
- 'query_var' => $taxonomy['query_var'],
352
- 'rewrite' => $rewrite,
353
- 'show_admin_column' => $show_admin_column,
354
- 'show_in_rest' => $show_in_rest,
355
- 'rest_base' => $rest_base,
 
 
356
  );
357
 
358
- $object_type = ( !empty( $taxonomy['object_types'] ) ) ? $taxonomy['object_types'] : '';
359
 
360
  /**
361
  * Filters the arguments used for a taxonomy right before registering.
362
  *
363
  * @since 1.0.0
 
364
  *
365
- * @param array $args Array of arguments to use for registering taxonomy.
366
- * @param string $value Taxonomy slug to be registered.
 
367
  */
368
- $args = apply_filters( 'cptui_pre_register_taxonomy', $args, $taxonomy['name'] );
369
 
370
  return register_taxonomy( $taxonomy['name'], $object_type, $args );
371
  }
372
 
373
- /**
374
- * Display our primary menu page.
375
- *
376
- * @since 0.3.0
377
- *
378
- * @return string $value HTML markup for the page.
379
- */
380
- function cptui_settings() { ?>
381
- <div class="wrap about-wrap">
382
- <?php
383
-
384
- /**
385
- * Fires inside and at the top of the wrapper for the main plugin landing page.
386
- *
387
- * @since 1.0.0
388
- */
389
- do_action( 'cptui_main_page_start' ); ?>
390
- <h1><?php _e( 'Custom Post Type UI', 'custom-post-type-ui' ); ?> <?php echo CPTUI_VERSION; ?></h1>
391
-
392
- <div class="about-text cptui-about-text">
393
- <?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.', 'custom-post-type-ui' ); ?>
394
- </div>
395
- <h2><?php printf( __( 'What\'s new in version %s', 'custom-post-type-ui' ), CPTUI_VERSION ); ?></h2>
396
- <div class="changelog about-integrations">
397
- <div class="cptui-feature feature-section col three-col">
398
-
399
- <div>
400
- <h2><?php _e( 'Updated internationalization', 'custom-post-type-ui' ); ?></h2>
401
- <p><?php _e( 'Our textdomain now matches the plugin slug from our WordPress.org repository to help aid in translating Custom Post Type UI', 'custom-post-type-ui' ); ?></p>
402
- </div>
403
- <div>
404
- <h2><?php _e( 'Debugging information', 'custom-post-type-ui' ); ?></h2>
405
- <p><?php _e( 'We have added a new "Debug Info" tab to the Import/Export area to aid in debugging issues with Custom Post Type UI.', 'custom-post-type-ui' ); ?></p>
406
- </div>
407
- <div>
408
- <h2><?php _e( 'Improved accessibility', 'custom-post-type-ui' ); ?></h2>
409
- <p><?php _e( 'A lot of work was done in the areas of accessibility to help aid users who need it. If you have feedback on where it could be further improved, let us know.', 'custom-post-type-ui' ); ?></p>
410
- </div>
411
- <div>
412
- <h2><?php _e( 'WP REST API support', 'custom-post-type-ui' ); ?></h2>
413
- <p><?php _e( 'We now have support for the required fields for the WP REST API. Now you can add your Custom Post Type UI post types and taxonomies to the available REST API lists.', 'custom-post-type-ui' ); ?></p>
414
- </div>
415
- <div>
416
- <h2><?php _e( 'More parameter support', 'custom-post-type-ui' ); ?></h2>
417
- <p><?php _e( 'We have added more parameters for greater customization of your post type and taxonomy settings.', 'custom-post-type-ui' ); ?></p>
418
- </div>
419
- <div>
420
- <h2><?php _e( 'New individual "Get Code" sections', 'custom-post-type-ui' ); ?></h2>
421
- <p><?php _e( 'The "Get Code" area now has support for copy/paste of individual post types and taxonomies.', 'custom-post-type-ui' ); ?></p>
422
- </div>
423
- <div class="last-feature">
424
- <h2><?php _e( 'Template hierarchy reference', 'custom-post-type-ui' ); ?></h2>
425
- <p><?php _e( 'To help aid your development with post types and taxonomies, we have added a quick reference list of common template files you can use in your theme. They will be listed on the "Registered Types/Taxes" screen.', 'custom-post-type-ui' ); ?></p>
426
- </div>
427
- </div>
428
- </div>
429
-
430
- <h1><?php _e( 'Help Support This Plugin!', 'custom-post-type-ui' ); ?></h1>
431
- <table border="0">
432
- <tr>
433
- <td class="one-third valign">
434
- <h2><?php _e( 'Professional WordPress<br />Third Edition', 'custom-post-type-ui' ); ?></h2>
435
- <a href="http://bit.ly/prowp3" target="_blank">
436
- <img src="<?php echo plugins_url( '/images/professional-wordpress-thirdedition.jpg', __FILE__ ); ?>" width="200" alt="<?php esc_attr_e( 'Professional WordPress Design and Development book cover.', 'custom-post-type-ui' ); ?>">
437
- </a>
438
- <br />
439
- <p><?php _e( 'The leading book on WordPress design and development! Brand new third edition!', 'custom-post-type-ui' ); ?></p>
440
- </td>
441
- <td class="one-third valign">
442
- <h2><?php _e( 'Professional WordPress<br />Plugin Development', 'custom-post-type-ui' ); ?></h2>
443
- <a href="http://amzn.to/plugindevbook" target="_blank">
444
- <img src="<?php echo plugins_url( '/images/professional-wordpress-plugin-development.png', __FILE__ ); ?>" width="200" alt="<?php esc_attr_e( 'Professional WordPress Pluing Development book cover.', 'custom-post-type-ui' ); ?>">
445
- </a>
446
- <br />
447
- <p><?php _e( 'Highest rated WordPress development book on Amazon!', 'custom-post-type-ui' ); ?></p>
448
- </td>
449
- <td class="one-third valign">
450
-</