Custom Post Type UI - Version 1.7.0

Version Description

  • 2019-11-06 =
  • Actually added this time: Delete with user support for post types. Managed to miss the code with 1.6.0 which was a long time ago.
  • Added: Ability to disable registration of post types or taxonomies, via code filter, without deleting them completely from settings.
  • Added: New post type labels introduced in WordPress 5.0.0.
  • Added: Link to Dashicon documentation for when editing menu icon. Props @juliekuehl
  • Added: Ability to automatically fill in additional labels based on chosen plural and singular label text.
  • Updated: Added post type templates documentation to help section.
  • Updated: Redirect user to the "add" tab if deleting the last post type or taxonomy created.
  • Updated: Touched up tab markup to match semantic improvements provided by WordPress 5.2.0.
  • Fixed: potential duplicate output of "parent_item_colon" with "Get Code" output.
  • Misc: Added code of conduct file to github repo. Props GaryJones.
Download this release

Release Info

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

Code changes from version 1.6.2 to 1.7.0

classes/class.cptui_admin_ui.php CHANGED
@@ -7,6 +7,8 @@
7
  * @author WebDevStudios
8
  * @since 1.0.0
9
  * @license GPL-2.0+
 
 
10
  */
11
 
12
  /**
@@ -91,7 +93,7 @@ class cptui_admin_ui {
91
  * @param array $args Array of arguments.
92
  * @return string $value Opening `<fieldset>` tag.
93
  */
94
- public function get_fieldset_start( $args = array() ) {
95
  $fieldset = '<fieldset';
96
 
97
  if ( ! empty( $args['id'] ) ) {
@@ -99,7 +101,7 @@ class cptui_admin_ui {
99
  }
100
 
101
  if ( ! empty( $args['classes'] ) ) {
102
- $classes = 'class="' . implode( ' ', $args['classes'] ) . '"';
103
  $fieldset .= ' ' . $classes;
104
  }
105
 
@@ -167,7 +169,7 @@ class cptui_admin_ui {
167
  * @return string $value `<label>` tag with filled out parts.
168
  */
169
  public function get_label( $label_for = '', $label_text = '' ) {
170
- return '<label for="' . esc_attr( $label_for ) . '">' . strip_tags( $label_text ) . '</label>';
171
  }
172
 
173
  /**
@@ -206,7 +208,7 @@ class cptui_admin_ui {
206
  * @return string Aria required attribute
207
  */
208
  public function get_aria_required( $required = false ) {
209
- $attr = ( $required ) ? 'true' : 'false';
210
  return 'aria-required="' . $attr . '"';
211
  }
212
 
@@ -290,9 +292,9 @@ class cptui_admin_ui {
290
  * @param array $args Arguments to use with the `<select>` input.
291
  * @return string $value Complete <select> input with options and selected attribute.
292
  */
293
- public function get_select_input( $args = array() ) {
294
  $defaults = $this->get_default_input_parameters(
295
- array( 'selections' => array() )
296
  );
297
 
298
  $args = wp_parse_args( $args, $defaults );
@@ -302,8 +304,12 @@ class cptui_admin_ui {
302
  $value = $this->get_tr_start();
303
  $value .= $this->get_th_start();
304
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
305
- if ( $args['required'] ) { $value .= $this->get_required_span(); }
306
- if ( ! empty( $args['helptext'] ) ) { $value .= $this->get_help( $args['helptext'] ); }
 
 
 
 
307
  $value .= $this->get_th_end();
308
  $value .= $this->get_td_start();
309
  }
@@ -312,15 +318,15 @@ class cptui_admin_ui {
312
  if ( ! empty( $args['selections']['options'] ) && is_array( $args['selections']['options'] ) ) {
313
  foreach ( $args['selections']['options'] as $val ) {
314
  $result = '';
315
- $bool = disp_boolean( $val['attr'] );
316
 
317
  if ( is_numeric( $args['selections']['selected'] ) ) {
318
  $selected = disp_boolean( $args['selections']['selected'] );
319
- } elseif ( in_array( $args['selections']['selected'], array( 'true', 'false' ) ) ) {
320
  $selected = $args['selections']['selected'];
321
  }
322
 
323
- if ( ( ! empty( $selected ) ) && $selected === $bool ) {
324
  $result = ' selected="selected"';
325
  } else {
326
  if ( array_key_exists( 'default', $val ) && ! empty( $val['default'] ) ) {
@@ -359,21 +365,23 @@ class cptui_admin_ui {
359
  * @param array $args Arguments to use with the text input.
360
  * @return string Complete text `<input>` with proper attributes.
361
  */
362
- public function get_text_input( $args = array() ) {
363
  $defaults = $this->get_default_input_parameters(
364
- array(
365
- 'maxlength' => '',
366
- 'onblur' => '',
367
- )
368
  );
369
- $args = wp_parse_args( $args, $defaults );
370
 
371
  $value = '';
372
  if ( $args['wrap'] ) {
373
  $value .= $this->get_tr_start();
374
  $value .= $this->get_th_start();
375
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
376
- if ( $args['required'] ) { $value .= $this->get_required_span(); }
 
 
377
  $value .= $this->get_th_end();
378
  $value .= $this->get_td_start();
379
  }
@@ -398,6 +406,12 @@ class cptui_admin_ui {
398
  }
399
  }
400
 
 
 
 
 
 
 
401
  $value .= ' />';
402
 
403
  if ( ! empty( $args['aftertext'] ) ) {
@@ -424,14 +438,14 @@ class cptui_admin_ui {
424
  * @param array $args Arguments to use with the textarea input.
425
  * @return string $value Complete <textarea> input with proper attributes.
426
  */
427
- public function get_textarea_input( $args = array() ) {
428
  $defaults = $this->get_default_input_parameters(
429
- array(
430
  'rows' => '',
431
  'cols' => '',
432
- )
433
  );
434
- $args = wp_parse_args( $args, $defaults );
435
 
436
  $value = '';
437
 
@@ -439,7 +453,9 @@ class cptui_admin_ui {
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
  }
@@ -470,24 +486,25 @@ class cptui_admin_ui {
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(
475
- array(
476
- 'checkvalue' => '',
477
- 'checked' => 'true',
478
- 'checklisttext' => '',
479
- 'default' => false,
480
- )
481
  );
482
-
483
- $args = wp_parse_args( $args, $defaults );
484
 
485
  $value = '';
486
  if ( $args['wrap'] ) {
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
  }
@@ -516,8 +533,8 @@ class cptui_admin_ui {
516
  * @param array $args Arguments to use with the button input.
517
  * @return string Complete button `<input>`.
518
  */
519
- public function get_button( $args = array() ) {
520
- $value = '';
521
  $value .= '<input id="' . $args['id'] . '" class="button" type="button" value="' . $args['textvalue'] . '" />';
522
 
523
  return $value;
@@ -531,9 +548,9 @@ class cptui_admin_ui {
531
  * @param array $additions Arguments array to merge with our defaults.
532
  * @return array $value Merged arrays for our default parameters.
533
  */
534
- public function get_default_input_parameters( $additions = array() ) {
535
  return array_merge(
536
- array(
537
  'namearray' => '',
538
  'name' => '',
539
  'textvalue' => '',
@@ -544,7 +561,7 @@ class cptui_admin_ui {
544
  'required' => false,
545
  'wrap' => true,
546
  'placeholder' => true,
547
- ),
548
  (array) $additions
549
  );
550
  }
7
  * @author WebDevStudios
8
  * @since 1.0.0
9
  * @license GPL-2.0+
10
+ *
11
+ * phpcs:disable WebDevStudios.All.RequireAuthor
12
  */
13
 
14
  /**
93
  * @param array $args Array of arguments.
94
  * @return string $value Opening `<fieldset>` tag.
95
  */
96
+ public function get_fieldset_start( $args = [] ) {
97
  $fieldset = '<fieldset';
98
 
99
  if ( ! empty( $args['id'] ) ) {
101
  }
102
 
103
  if ( ! empty( $args['classes'] ) ) {
104
+ $classes = 'class="' . implode( ' ', $args['classes'] ) . '"';
105
  $fieldset .= ' ' . $classes;
106
  }
107
 
169
  * @return string $value `<label>` tag with filled out parts.
170
  */
171
  public function get_label( $label_for = '', $label_text = '' ) {
172
+ return '<label for="' . esc_attr( $label_for ) . '">' . wp_strip_all_tags( $label_text ) . '</label>';
173
  }
174
 
175
  /**
208
  * @return string Aria required attribute
209
  */
210
  public function get_aria_required( $required = false ) {
211
+ $attr = $required ? 'true' : 'false';
212
  return 'aria-required="' . $attr . '"';
213
  }
214
 
292
  * @param array $args Arguments to use with the `<select>` input.
293
  * @return string $value Complete <select> input with options and selected attribute.
294
  */
295
+ public function get_select_input( $args = [] ) {
296
  $defaults = $this->get_default_input_parameters(
297
+ [ 'selections' => [] ]
298
  );
299
 
300
  $args = wp_parse_args( $args, $defaults );
304
  $value = $this->get_tr_start();
305
  $value .= $this->get_th_start();
306
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
307
+ if ( $args['required'] ) {
308
+ $value .= $this->get_required_span();
309
+ }
310
+ if ( ! empty( $args['helptext'] ) ) {
311
+ $value .= $this->get_help( $args['helptext'] );
312
+ }
313
  $value .= $this->get_th_end();
314
  $value .= $this->get_td_start();
315
  }
318
  if ( ! empty( $args['selections']['options'] ) && is_array( $args['selections']['options'] ) ) {
319
  foreach ( $args['selections']['options'] as $val ) {
320
  $result = '';
321
+ $bool = disp_boolean( $val['attr'] );
322
 
323
  if ( is_numeric( $args['selections']['selected'] ) ) {
324
  $selected = disp_boolean( $args['selections']['selected'] );
325
+ } elseif ( in_array( $args['selections']['selected'], [ 'true', 'false' ], true ) ) {
326
  $selected = $args['selections']['selected'];
327
  }
328
 
329
+ if ( ! empty( $selected ) && $selected === $bool ) {
330
  $result = ' selected="selected"';
331
  } else {
332
  if ( array_key_exists( 'default', $val ) && ! empty( $val['default'] ) ) {
365
  * @param array $args Arguments to use with the text input.
366
  * @return string Complete text `<input>` with proper attributes.
367
  */
368
+ public function get_text_input( $args = [] ) {
369
  $defaults = $this->get_default_input_parameters(
370
+ [
371
+ 'maxlength' => '',
372
+ 'onblur' => '',
373
+ ]
374
  );
375
+ $args = wp_parse_args( $args, $defaults );
376
 
377
  $value = '';
378
  if ( $args['wrap'] ) {
379
  $value .= $this->get_tr_start();
380
  $value .= $this->get_th_start();
381
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
382
+ if ( $args['required'] ) {
383
+ $value .= $this->get_required_span();
384
+ }
385
  $value .= $this->get_th_end();
386
  $value .= $this->get_td_start();
387
  }
406
  }
407
  }
408
 
409
+ if ( ! empty( $args['data'] ) ) {
410
+ foreach ( $args['data'] as $dkey => $dvalue ) {
411
+ $value .= " data-{$dkey}=\"{$dvalue}\"";
412
+ }
413
+ }
414
+
415
  $value .= ' />';
416
 
417
  if ( ! empty( $args['aftertext'] ) ) {
438
  * @param array $args Arguments to use with the textarea input.
439
  * @return string $value Complete <textarea> input with proper attributes.
440
  */
441
+ public function get_textarea_input( $args = [] ) {
442
  $defaults = $this->get_default_input_parameters(
443
+ [
444
  'rows' => '',
445
  'cols' => '',
446
+ ]
447
  );
448
+ $args = wp_parse_args( $args, $defaults );
449
 
450
  $value = '';
451
 
453
  $value .= $this->get_tr_start();
454
  $value .= $this->get_th_start();
455
  $value .= $this->get_label( $args['name'], $args['labeltext'] );
456
+ if ( $args['required'] ) {
457
+ $value .= $this->get_required_span();
458
+ }
459
  $value .= $this->get_th_end();
460
  $value .= $this->get_td_start();
461
  }
486
  * @param array $args Arguments to use with the checkbox input.
487
  * @return string $value Complete checkbox `<input>` with proper attributes.
488
  */
489
+ public function get_check_input( $args = [] ) {
490
  $defaults = $this->get_default_input_parameters(
491
+ [
492
+ 'checkvalue' => '',
493
+ 'checked' => 'true',
494
+ 'checklisttext' => '',
495
+ 'default' => false,
496
+ ]
497
  );
498
+ $args = wp_parse_args( $args, $defaults );
 
499
 
500
  $value = '';
501
  if ( $args['wrap'] ) {
502
  $value .= $this->get_tr_start();
503
  $value .= $this->get_th_start();
504
  $value .= $args['checklisttext'];
505
+ if ( $args['required'] ) {
506
+ $value .= $this->get_required_span();
507
+ }
508
  $value .= $this->get_th_end();
509
  $value .= $this->get_td_start();
510
  }
533
  * @param array $args Arguments to use with the button input.
534
  * @return string Complete button `<input>`.
535
  */
536
+ public function get_button( $args = [] ) {
537
+ $value = '';
538
  $value .= '<input id="' . $args['id'] . '" class="button" type="button" value="' . $args['textvalue'] . '" />';
539
 
540
  return $value;
548
  * @param array $additions Arguments array to merge with our defaults.
549
  * @return array $value Merged arrays for our default parameters.
550
  */
551
+ public function get_default_input_parameters( $additions = [] ) {
552
  return array_merge(
553
+ [
554
  'namearray' => '',
555
  'name' => '',
556
  'textvalue' => '',
561
  'required' => false,
562
  'wrap' => true,
563
  'placeholder' => true,
564
+ ],
565
  (array) $additions
566
  );
567
  }
classes/class.cptui_debug_info.php CHANGED
@@ -23,7 +23,7 @@ class CPTUI_Debug_Info {
23
  ?>
24
  <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>
25
  <label for="cptui_audit_textarea">
26
- <textarea readonly="readonly" aria-readonly="true" id="cptui-audit-textarea" name="cptui_audit_textarea" rows="20" cols="100">
27
  <?php echo $this->system_status(); ?>
28
  </textarea></label>
29
  <?php
@@ -92,7 +92,7 @@ class CPTUI_Debug_Info {
92
  // Standard plugins - active.
93
  echo "\n";
94
 
95
- $active = get_option( 'active_plugins', array() );
96
  $ac_count = count( $active );
97
  $ic_count = $pg_count - $ac_count;
98
 
@@ -123,7 +123,7 @@ class CPTUI_Debug_Info {
123
  if ( is_multisite() ) :
124
 
125
  $net_plugins = wp_get_active_network_plugins();
126
- $net_active = get_site_option( 'active_sitewide_plugins', array() );
127
 
128
  echo "\n";
129
  echo 'NETWORK ACTIVE PLUGINS: (' . count( $net_plugins ) . ')' . "\n\n";
@@ -210,7 +210,7 @@ class CPTUI_Debug_Info {
210
  * @param array $args Array of arguments for the method. Optional.
211
  * @return bool
212
  */
213
- public function send_email( $args = array() ) {
214
 
215
  if ( ! isset( $args['email'] ) || ! is_email( $args['email'] ) ) {
216
  return false;
23
  ?>
24
  <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>
25
  <label for="cptui_audit_textarea">
26
+ <textarea readonly="readonly" aria-readonly="true" id="cptui-audit-textarea" name="cptui_audit_textarea" rows="20" cols="100" class="large-text code">
27
  <?php echo $this->system_status(); ?>
28
  </textarea></label>
29
  <?php
92
  // Standard plugins - active.
93
  echo "\n";
94
 
95
+ $active = get_option( 'active_plugins', [] );
96
  $ac_count = count( $active );
97
  $ic_count = $pg_count - $ac_count;
98
 
123
  if ( is_multisite() ) :
124
 
125
  $net_plugins = wp_get_active_network_plugins();
126
+ $net_active = get_site_option( 'active_sitewide_plugins', [] );
127
 
128
  echo "\n";
129
  echo 'NETWORK ACTIVE PLUGINS: (' . count( $net_plugins ) . ')' . "\n\n";
210
  * @param array $args Array of arguments for the method. Optional.
211
  * @return bool
212
  */
213
+ public function send_email( $args = [] ) {
214
 
215
  if ( ! isset( $args['email'] ) || ! is_email( $args['email'] ) ) {
216
  return false;
css/cptui.css CHANGED
@@ -127,7 +127,6 @@
127
  .cptui_tax_get_code {
128
  height: 300px;
129
  resize: vertical;
130
- width: 100%;
131
  }
132
 
133
  .about-wrap .cptui-feature {
@@ -313,7 +312,7 @@ fieldset .cptui-help {
313
  -ms-flex-pack: justify;
314
  justify-content: space-between;
315
  -ms-flex-line-pack: stretch;
316
- align-content: stretch;
317
  -ms-flex-align: start;
318
  align-items: flex-start;
319
  margin: 20px 0;
@@ -325,7 +324,7 @@ fieldset .cptui-help {
325
  -ms-flex: 0 1 auto;
326
  flex: 0 1 auto;
327
  -ms-flex-item-align: auto;
328
- -ms-grid-row-align: auto;
329
  align-self: auto;
330
  }
331
 
@@ -335,7 +334,7 @@ fieldset .cptui-help {
335
  -ms-flex: 0 1 auto;
336
  flex: 0 1 auto;
337
  -ms-flex-item-align: auto;
338
- -ms-grid-row-align: auto;
339
  align-self: auto;
340
  }
341
 
@@ -345,7 +344,7 @@ fieldset .cptui-help {
345
  -ms-flex: 0 1 auto;
346
  flex: 0 1 auto;
347
  -ms-flex-item-align: auto;
348
- -ms-grid-row-align: auto;
349
  align-self: auto;
350
  }
351
 
@@ -354,11 +353,11 @@ fieldset .cptui-help {
354
  }
355
 
356
  .wdspromos-about p:nth-child(1) {
357
- padding-left: 0px;
358
  }
359
 
360
  .wdspromos-about p:nth-child(4) {
361
- padding-right: 0px;
362
  }
363
 
364
  .no-js #cptui_choose_icon {
@@ -415,7 +414,6 @@ fieldset .cptui-help {
415
  .cptui-table td.outer {
416
  width: 100%;
417
  }
418
- #cptui-audit-textarea,
419
  #cptui_debug_info_email {
420
  width: 100%;
421
  }
127
  .cptui_tax_get_code {
128
  height: 300px;
129
  resize: vertical;
 
130
  }
131
 
132
  .about-wrap .cptui-feature {
312
  -ms-flex-pack: justify;
313
  justify-content: space-between;
314
  -ms-flex-line-pack: stretch;
315
+ align-content: stretch;
316
  -ms-flex-align: start;
317
  align-items: flex-start;
318
  margin: 20px 0;
324
  -ms-flex: 0 1 auto;
325
  flex: 0 1 auto;
326
  -ms-flex-item-align: auto;
327
+ -ms-grid-row-align: auto;
328
  align-self: auto;
329
  }
330
 
334
  -ms-flex: 0 1 auto;
335
  flex: 0 1 auto;
336
  -ms-flex-item-align: auto;
337
+ -ms-grid-row-align: auto;
338
  align-self: auto;
339
  }
340
 
344
  -ms-flex: 0 1 auto;
345
  flex: 0 1 auto;
346
  -ms-flex-item-align: auto;
347
+ -ms-grid-row-align: auto;
348
  align-self: auto;
349
  }
350
 
353
  }
354
 
355
  .wdspromos-about p:nth-child(1) {
356
+ padding-left: 0;
357
  }
358
 
359
  .wdspromos-about p:nth-child(4) {
360
+ padding-right: 0;
361
  }
362
 
363
  .no-js #cptui_choose_icon {
414
  .cptui-table td.outer {
415
  width: 100%;
416
  }
 
417
  #cptui_debug_info_email {
418
  width: 100%;
419
  }
css/cptui.min.css CHANGED
@@ -1 +1 @@
1
- .posttypesui,.taxonomiesui{width:calc(100% - 300px)}.posttypesui .cptui-section:first-child,.taxonomiesui .cptui-section:first-child{margin-top:30px}.posttypesui .postbox-container,.taxonomiesui .postbox-container{width:100%}.posttypesui .postbox .toggle-indicator:before,.taxonomiesui .postbox .toggle-indicator:before{content:"\f142";display:inline-block;font:normal 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.posttypesui .postbox.closed .handlediv .toggle-indicator:before,.taxonomiesui .postbox.closed .handlediv .toggle-indicator:before{content:"\f140"}.posttypesui .postbox .hndle,.taxonomiesui .postbox .hndle{cursor:pointer}.posttypesui .required,.taxonomiesui .required{color:red}.cptui-table #excerpt{display:inline-block;height:16px;margin:12px 4px 12px 0;width:auto}.cptui-table td.outer{vertical-align:top;width:50%}.cptui-edit .cptui-table textarea,.cptui-new .cptui-table textarea,.cptui-table input[type=text]{width:75%}.cptui-table .question:hover{cursor:pointer}.cptui-table th p{font-weight:400;font-size:12px}.cptui-table .cptui-slug-details{margin-top:15px}.cptui-table #slugchanged,.cptui-table #slugexists{color:red;font-weight:700}.cptui-table #slugchanged.hidemessage,.cptui-table #slugexists.hidemessage{display:none}.cpt-ui_page_cptui_tools .cptui-table .outer p{padding:0 4px}.cptui-support #support .question{font-size:18px;font-weight:700}.cptui-support #support .question:before{content:"\f139";display:inline-block;font:normal 25px/1 dashicons;margin-left:-25px;position:absolute;-webkit-font-smoothing:antialiased}.cptui-support #support .question.active:before{content:"\f140"}.cptui-support #support .answer{margin:10px 0 0 20px}.cptui-support #support ol li{list-style:none}.cptui-support #support li{position:relative}.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%}.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 .changelog h2{text-align:center}.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-wrap .about-integrations{background:#fff;margin:20px 0;padding:1px 20px 10px}.about-wrap .changelog h4{line-height:1.4}.about-wrap .cptui-about-text{margin-bottom:1em!important}.about-wrap .cptui-badge{position:absolute;top:0;right:0}#togglelabels{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 #mc_embed_signup{background:#fff;border:1px solid #ccc;clear:left;margin-bottom:10px}.wdspromos-about{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-line-pack:stretch;align-content:stretch;-ms-flex-align:start;align-items:flex-start;margin:20px 0}.wdspromos-about a:first-child,.wdspromos-about a:nth-child(2),.wdspromos-about a:nth-child(3){-ms-flex-order:0;order:0;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-item-align:auto;-ms-grid-row-align:auto;align-self:auto}.wdspromos-about p{padding:0 5px}.wdspromos-about p:first-child{padding-left:0}.wdspromos-about p:nth-child(4){padding-right:0}.no-js #cptui_choose_icon{display:none}.cptui-listings th{font-weight:700}.cptui-listings .post-type-listing th{width:16.66667%}.cptui-listings .taxonomy-listing th{width:20%}#poststuff{min-width:463px}@media screen and (min-width:769px){.cptui-badge{padding-top:142px;height:50px;width:173px;color:#fafafa;font-weight:700;font-size:14px;text-align:center;margin:0 -5px;background:url(../images/cptui-icon-173x173.png) no-repeat}}@media screen and (max-width:768px){.cptui-table #description{width:100%}.wdspromos-about{-ms-flex-wrap:wrap;flex-wrap:wrap}.wdspromos-about p{margin:5px auto}.wdspromos-about p:first-child{padding-left:5px}.wdspromos-about p:nth-child(4){padding-right:5px}#cptui-audit-textarea,#cptui_debug_info_email,.cptui-table td.outer{width:100%}}
1
+ .posttypesui,.taxonomiesui{width:calc(100% - 300px)}.posttypesui .cptui-section:first-child,.taxonomiesui .cptui-section:first-child{margin-top:30px}.posttypesui .postbox-container,.taxonomiesui .postbox-container{width:100%}.posttypesui .postbox .toggle-indicator:before,.taxonomiesui .postbox .toggle-indicator:before{content:"\f142";display:inline-block;font:normal 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.posttypesui .postbox.closed .handlediv .toggle-indicator:before,.taxonomiesui .postbox.closed .handlediv .toggle-indicator:before{content:"\f140"}.posttypesui .postbox .hndle,.taxonomiesui .postbox .hndle{cursor:pointer}.posttypesui .required,.taxonomiesui .required{color:red}.cptui-table #excerpt{display:inline-block;height:16px;margin:12px 4px 12px 0;width:auto}.cptui-table td.outer{vertical-align:top;width:50%}.cptui-edit .cptui-table textarea,.cptui-new .cptui-table textarea,.cptui-table input[type=text]{width:75%}.cptui-table .question:hover{cursor:pointer}.cptui-table th p{font-weight:400;font-size:12px}.cptui-table .cptui-slug-details{margin-top:15px}.cptui-table #slugchanged,.cptui-table #slugexists{color:red;font-weight:700}.cptui-table #slugchanged.hidemessage,.cptui-table #slugexists.hidemessage{display:none}.cpt-ui_page_cptui_tools .cptui-table .outer p{padding:0 4px}.cptui-support #support .question{font-size:18px;font-weight:700}.cptui-support #support .question:before{content:"\f139";display:inline-block;font:normal 25px/1 dashicons;margin-left:-25px;position:absolute;-webkit-font-smoothing:antialiased}.cptui-support #support .question.active:before{content:"\f140"}.cptui-support #support .answer{margin:10px 0 0 20px}.cptui-support #support ol li{list-style:none}.cptui-support #support li{position:relative}.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}.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 .changelog h2{text-align:center}.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-wrap .about-integrations{background:#fff;margin:20px 0;padding:1px 20px 10px}.about-wrap .changelog h4{line-height:1.4}.about-wrap .cptui-about-text{margin-bottom:1em!important}.about-wrap .cptui-badge{position:absolute;top:0;right:0}#togglelabels{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 #mc_embed_signup{background:#fff;border:1px solid #ccc;clear:left;margin-bottom:10px}.wdspromos-about{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-line-pack:stretch;align-content:stretch;-ms-flex-align:start;align-items:flex-start;margin:20px 0}.wdspromos-about a:first-child,.wdspromos-about a:nth-child(2),.wdspromos-about a:nth-child(3){-ms-flex-order:0;order:0;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-item-align:auto;-ms-grid-row-align:auto;align-self:auto}.wdspromos-about p{padding:0 5px}.wdspromos-about p:first-child{padding-left:0}.wdspromos-about p:nth-child(4){padding-right:0}.no-js #cptui_choose_icon{display:none}.cptui-listings th{font-weight:700}.cptui-listings .post-type-listing th{width:16.66667%}.cptui-listings .taxonomy-listing th{width:20%}#poststuff{min-width:463px}@media screen and (min-width:769px){.cptui-badge{padding-top:142px;height:50px;width:173px;color:#fafafa;font-weight:700;font-size:14px;text-align:center;margin:0 -5px;background:url(../images/cptui-icon-173x173.png) no-repeat}}@media screen and (max-width:768px){.cptui-table #description{width:100%}.wdspromos-about{-ms-flex-wrap:wrap;flex-wrap:wrap}.wdspromos-about p{margin:5px auto}.wdspromos-about p:first-child{padding-left:5px}.wdspromos-about p:nth-child(4){padding-right:5px}#cptui_debug_info_email,.cptui-table td.outer{width:100%}}
css/cptui.scss CHANGED
@@ -117,7 +117,6 @@ $max-tablet: "screen and (max-width: 768px)";
117
  .cptui_tax_get_code {
118
  height: 300px;
119
  resize: vertical;
120
- width: 100%;
121
  }
122
  .about-wrap {
123
  .cptui-feature {
@@ -297,7 +296,6 @@ $max-tablet: "screen and (max-width: 768px)";
297
  -ms-flex-pack: justify;
298
  justify-content: space-between;
299
  -webkit-align-content: stretch;
300
- -ms-flex-line-pack: stretch;
301
  align-content: stretch;
302
  -webkit-align-items: flex-start;
303
  -ms-flex-align: start;
@@ -305,47 +303,41 @@ $max-tablet: "screen and (max-width: 768px)";
305
  margin: 20px 0;
306
 
307
  a:nth-child(1) {
308
- -webkit-order: 0;
309
  -ms-flex-order: 0;
310
  order: 0;
311
  -webkit-flex: 0 1 auto;
312
  -ms-flex: 0 1 auto;
313
  flex: 0 1 auto;
314
  -webkit-align-self: auto;
315
- -ms-flex-item-align: auto;
316
  align-self: auto;
317
  }
318
 
319
  a:nth-child(2) {
320
- -webkit-order: 0;
321
  -ms-flex-order: 0;
322
  order: 0;
323
  -webkit-flex: 0 1 auto;
324
  -ms-flex: 0 1 auto;
325
  flex: 0 1 auto;
326
  -webkit-align-self: auto;
327
- -ms-flex-item-align: auto;
328
  align-self: auto;
329
  }
330
 
331
  a:nth-child(3) {
332
- -webkit-order: 0;
333
  -ms-flex-order: 0;
334
  order: 0;
335
  -webkit-flex: 0 1 auto;
336
  -ms-flex: 0 1 auto;
337
  flex: 0 1 auto;
338
  -webkit-align-self: auto;
339
- -ms-flex-item-align: auto;
340
  align-self: auto;
341
  }
342
  p {
343
  padding: 0 5px;
344
  &:nth-child(1) {
345
- padding-left: 0px;
346
  }
347
  &:nth-child(4) {
348
- padding-right: 0px;
349
  }
350
  }
351
  }
@@ -410,7 +402,7 @@ $max-tablet: "screen and (max-width: 768px)";
410
  width: 100%;
411
  }
412
  }
413
- #cptui-audit-textarea,
414
  #cptui_debug_info_email {
415
  width: 100%;
416
  }
117
  .cptui_tax_get_code {
118
  height: 300px;
119
  resize: vertical;
 
120
  }
121
  .about-wrap {
122
  .cptui-feature {
296
  -ms-flex-pack: justify;
297
  justify-content: space-between;
298
  -webkit-align-content: stretch;
 
299
  align-content: stretch;
300
  -webkit-align-items: flex-start;
301
  -ms-flex-align: start;
303
  margin: 20px 0;
304
 
305
  a:nth-child(1) {
 
306
  -ms-flex-order: 0;
307
  order: 0;
308
  -webkit-flex: 0 1 auto;
309
  -ms-flex: 0 1 auto;
310
  flex: 0 1 auto;
311
  -webkit-align-self: auto;
 
312
  align-self: auto;
313
  }
314
 
315
  a:nth-child(2) {
 
316
  -ms-flex-order: 0;
317
  order: 0;
318
  -webkit-flex: 0 1 auto;
319
  -ms-flex: 0 1 auto;
320
  flex: 0 1 auto;
321
  -webkit-align-self: auto;
 
322
  align-self: auto;
323
  }
324
 
325
  a:nth-child(3) {
 
326
  -ms-flex-order: 0;
327
  order: 0;
328
  -webkit-flex: 0 1 auto;
329
  -ms-flex: 0 1 auto;
330
  flex: 0 1 auto;
331
  -webkit-align-self: auto;
 
332
  align-self: auto;
333
  }
334
  p {
335
  padding: 0 5px;
336
  &:nth-child(1) {
337
+ padding-left: 0;
338
  }
339
  &:nth-child(4) {
340
+ padding-right: 0;
341
  }
342
  }
343
  }
402
  width: 100%;
403
  }
404
  }
405
+
406
  #cptui_debug_info_email {
407
  width: 100%;
408
  }
custom-post-type-ui.php CHANGED
@@ -11,25 +11,27 @@
11
  * @license GPL-2.0+
12
  */
13
 
14
- /*
15
- Plugin Name: Custom Post Type UI
16
- Plugin URI: https://github.com/WebDevStudios/custom-post-type-ui/
17
- Description: Admin panel for creating custom post types and custom taxonomies in WordPress
18
- Author: WebDevStudios
19
- Version: 1.6.2
20
- Author URI: https://webdevstudios.com/
21
- Text Domain: custom-post-type-ui
22
- Domain Path: /languages
23
- License: GPL-2.0+
24
- */
 
 
25
 
26
  // Exit if accessed directly.
27
  if ( ! defined( 'ABSPATH' ) ) {
28
  exit;
29
  }
30
 
31
- define( 'CPT_VERSION', '1.6.2' ); // Left for legacy purposes.
32
- define( 'CPTUI_VERSION', '1.6.2' );
33
  define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
34
 
35
  /**
@@ -40,8 +42,8 @@ define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
40
  * @internal
41
  */
42
  function cptui_load_ui_class() {
43
- require_once( plugin_dir_path( __FILE__ ) . 'classes/class.cptui_admin_ui.php' );
44
- require_once( plugin_dir_path( __FILE__ ) . 'classes/class.cptui_debug_info.php' );
45
  }
46
  add_action( 'init', 'cptui_load_ui_class' );
47
 
@@ -86,7 +88,7 @@ function cptui_make_activation_redirect() {
86
  // Redirect to CPTUI about page.
87
  wp_safe_redirect(
88
  add_query_arg(
89
- array( 'page' => 'cptui_main_menu' ),
90
  cptui_admin_url( 'admin.php?page=cptui_main_menu' )
91
  )
92
  );
@@ -189,16 +191,16 @@ add_action( 'plugins_loaded', 'cptui_loaded' );
189
  * @internal
190
  */
191
  function cptui_create_submenus() {
192
- require_once( plugin_dir_path( __FILE__ ) . 'inc/about.php' );
193
- require_once( plugin_dir_path( __FILE__ ) . 'inc/utility.php' );
194
- require_once( plugin_dir_path( __FILE__ ) . 'inc/post-types.php' );
195
- require_once( plugin_dir_path( __FILE__ ) . 'inc/taxonomies.php' );
196
- require_once( plugin_dir_path( __FILE__ ) . 'inc/listings.php' );
197
- require_once( plugin_dir_path( __FILE__ ) . 'inc/tools.php' );
198
- require_once( plugin_dir_path( __FILE__ ) . 'inc/support.php' );
199
 
200
  if ( defined( 'WP_CLI' ) && WP_CLI ) {
201
- require_once( plugin_dir_path( __FILE__ ) . 'inc/wp-cli.php' );
202
  }
203
  }
204
  add_action( 'cptui_loaded', 'cptui_create_submenus' );
@@ -234,8 +236,8 @@ function cptui_add_styles() {
234
  }
235
 
236
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
237
- wp_register_script( 'cptui', plugins_url( "js/cptui{$min}.js", __FILE__ ), array( 'jquery', 'postbox' ), CPTUI_VERSION, true );
238
- wp_register_style( 'cptui-css', plugins_url( "css/cptui{$min}.css", __FILE__ ), array(), CPTUI_VERSION );
239
  }
240
  add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
241
 
@@ -264,6 +266,33 @@ function cptui_create_custom_post_types() {
264
 
265
  if ( is_array( $cpts ) ) {
266
  foreach ( $cpts as $post_type ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  cptui_register_single_post_type( $post_type );
268
  }
269
  }
@@ -289,7 +318,7 @@ add_action( 'init', 'cptui_create_custom_post_types', 10 ); // Leave on standard
289
  * @param array $post_type Post type array to register. Optional.
290
  * @return null Result of register_post_type.
291
  */
292
- function cptui_register_single_post_type( $post_type = array() ) {
293
 
294
  /**
295
  * Filters the map_meta_cap value.
@@ -303,7 +332,7 @@ function cptui_register_single_post_type( $post_type = array() ) {
303
  $post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', true, $post_type['name'], $post_type );
304
 
305
  if ( empty( $post_type['supports'] ) ) {
306
- $post_type['supports'] = array();
307
  }
308
 
309
  /**
@@ -315,13 +344,13 @@ function cptui_register_single_post_type( $post_type = array() ) {
315
  * @param string $name Post type slug being registered.
316
  * @param array $post_type Array of post type arguments to be registered.
317
  */
318
- $user_supports_params = apply_filters( 'cptui_user_supports_params', array(), $post_type['name'], $post_type );
319
 
320
  if ( is_array( $user_supports_params ) && ! empty( $user_supports_params ) ) {
321
  if ( is_array( $post_type['supports'] ) ) {
322
  $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
323
  } else {
324
- $post_type['supports'] = array( $user_supports_params );
325
  }
326
  }
327
 
@@ -330,7 +359,7 @@ function cptui_register_single_post_type( $post_type = array() ) {
330
  $custom = explode( ',', $post_type['custom_supports'] );
331
  foreach ( $custom as $part ) {
332
  // We'll handle YARPP separately.
333
- if ( in_array( $part, array( 'YARPP', 'yarpp' ) ) ) {
334
  $yarpp = true;
335
  continue;
336
  }
@@ -338,16 +367,16 @@ function cptui_register_single_post_type( $post_type = array() ) {
338
  }
339
  }
340
 
341
- if ( isset( $post_type['supports'] ) && is_array( $post_type['supports'] ) && in_array( 'none', $post_type['supports'] ) ) {
342
  $post_type['supports'] = false;
343
  }
344
 
345
- $labels = array(
346
  'name' => $post_type['label'],
347
  'singular_name' => $post_type['singular_label'],
348
- );
349
 
350
- $preserved = cptui_get_preserved_keys( 'post_types' );
351
  $preserved_labels = cptui_get_preserved_labels();
352
  foreach ( $post_type['labels'] as $key => $label ) {
353
 
@@ -357,14 +386,14 @@ function cptui_register_single_post_type( $post_type = array() ) {
357
  } else {
358
  $labels[ $key ] = $label;
359
  }
360
- } elseif ( empty( $label ) && in_array( $key, $preserved ) ) {
361
  $singular_or_plural = ( in_array( $key, array_keys( $preserved_labels['post_types']['plural'] ) ) ) ? 'plural' : 'singular';
362
- $label_plurality = ( 'plural' === $singular_or_plural ) ? $post_type['label'] : $post_type['singular_label'];
363
- $labels[ $key ] = sprintf( $preserved_labels['post_types'][ $singular_or_plural ][ $key ], $label_plurality );
364
  }
365
  }
366
 
367
- $has_archive = ( isset( $post_type['has_archive'] ) ) ? get_disp_boolean( $post_type['has_archive'] ) : false;
368
  if ( $has_archive && ! empty( $post_type['has_archive_string'] ) ) {
369
  $has_archive = $post_type['has_archive_string'];
370
  }
@@ -377,18 +406,18 @@ function cptui_register_single_post_type( $post_type = array() ) {
377
  $rewrite = get_disp_boolean( $post_type['rewrite'] );
378
  if ( false !== $rewrite ) {
379
  // Core converts to an empty array anyway, so safe to leave this instead of passing in boolean true.
380
- $rewrite = array();
381
- $rewrite['slug'] = ( ! empty( $post_type['rewrite_slug'] ) ) ? $post_type['rewrite_slug'] : $post_type['name'];
382
 
383
  $rewrite['with_front'] = true; // Default value.
384
  if ( isset( $post_type['rewrite_withfront'] ) ) {
385
- $rewrite['with_front'] = ( 'false' === disp_boolean( $post_type['rewrite_withfront'] ) ) ? false : true;
386
  }
387
  }
388
 
389
- $menu_icon = ( ! empty( $post_type['menu_icon'] ) ) ? $post_type['menu_icon'] : null;
390
 
391
- if ( in_array( $post_type['query_var'], array( 'true', 'false', '0', '1' ) ) ) {
392
  $post_type['query_var'] = get_disp_boolean( $post_type['query_var'] );
393
  }
394
  if ( ! empty( $post_type['query_var_slug'] ) ) {
@@ -400,6 +429,11 @@ function cptui_register_single_post_type( $post_type = array() ) {
400
  $menu_position = (int) $post_type['menu_position'];
401
  }
402
 
 
 
 
 
 
403
  $capability_type = 'post';
404
  if ( ! empty( $post_type['capability_type'] ) ) {
405
  $capability_type = $post_type['capability_type'];
@@ -416,7 +450,7 @@ function cptui_register_single_post_type( $post_type = array() ) {
416
  if ( ! empty( $post_type['exclude_from_search'] ) ) {
417
  $exclude_from_search = get_disp_boolean( $post_type['exclude_from_search'] );
418
  } else {
419
- $exclude_from_search = ( false === $public ) ? true : false;
420
  }
421
 
422
  $queryable = ( ! empty( $post_type['publicly_queryable'] ) && isset( $post_type['publicly_queryable'] ) ) ? get_disp_boolean( $post_type['publicly_queryable'] ) : $public;
@@ -440,7 +474,7 @@ function cptui_register_single_post_type( $post_type = array() ) {
440
  $rest_controller_class = $post_type['rest_controller_class'];
441
  }
442
 
443
- $args = array(
444
  'labels' => $labels,
445
  'description' => $post_type['description'],
446
  'public' => get_disp_boolean( $post_type['public'] ),
@@ -449,6 +483,7 @@ function cptui_register_single_post_type( $post_type = array() ) {
449
  'show_in_nav_menus' => get_disp_boolean( $post_type['show_in_nav_menus'] ),
450
  'has_archive' => $has_archive,
451
  'show_in_menu' => $show_in_menu,
 
452
  'show_in_rest' => get_disp_boolean( $post_type['show_in_rest'] ),
453
  'rest_base' => $rest_base,
454
  'rest_controller_class' => $rest_controller_class,
@@ -462,7 +497,7 @@ function cptui_register_single_post_type( $post_type = array() ) {
462
  'query_var' => $post_type['query_var'],
463
  'supports' => $post_type['supports'],
464
  'taxonomies' => $post_type['taxonomies'],
465
- );
466
 
467
  if ( true === $yarpp ) {
468
  $args['yarpp_support'] = $yarpp;
@@ -508,6 +543,32 @@ function cptui_create_custom_taxonomies() {
508
 
509
  if ( is_array( $taxes ) ) {
510
  foreach ( $taxes as $tax ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  cptui_register_single_taxonomy( $tax );
512
  }
513
  }
@@ -533,35 +594,35 @@ add_action( 'init', 'cptui_create_custom_taxonomies', 9 ); // Leave on standard
533
  * @param array $taxonomy Taxonomy array to register. Optional.
534
  * @return null Result of register_taxonomy.
535
  */
536
- function cptui_register_single_taxonomy( $taxonomy = array() ) {
537
 
538
- $labels = array(
539
- 'name' => $taxonomy['label'],
540
- 'singular_name' => $taxonomy['singular_label'],
541
- );
542
 
543
  $description = '';
544
  if ( ! empty( $taxonomy['description'] ) ) {
545
  $description = $taxonomy['description'];
546
  }
547
 
548
- $preserved = cptui_get_preserved_keys( 'taxonomies' );
549
  $preserved_labels = cptui_get_preserved_labels();
550
  foreach ( $taxonomy['labels'] as $key => $label ) {
551
 
552
  if ( ! empty( $label ) ) {
553
  $labels[ $key ] = $label;
554
- } elseif ( empty( $label ) && in_array( $key, $preserved ) ) {
555
  $singular_or_plural = ( in_array( $key, array_keys( $preserved_labels['taxonomies']['plural'] ) ) ) ? 'plural' : 'singular';
556
- $label_plurality = ( 'plural' === $singular_or_plural ) ? $taxonomy['label'] : $taxonomy['singular_label'];
557
- $labels[ $key ] = sprintf( $preserved_labels['taxonomies'][ $singular_or_plural ][ $key ], $label_plurality );
558
  }
559
  }
560
 
561
  $rewrite = get_disp_boolean( $taxonomy['rewrite'] );
562
  if ( false !== get_disp_boolean( $taxonomy['rewrite'] ) ) {
563
- $rewrite = array();
564
- $rewrite['slug'] = ( ! empty( $taxonomy['rewrite_slug'] ) ) ? $taxonomy['rewrite_slug'] : $taxonomy['name'];
565
  $rewrite['with_front'] = true;
566
  if ( isset( $taxonomy['rewrite_withfront'] ) ) {
567
  $rewrite['with_front'] = ( 'false' === disp_boolean( $taxonomy['rewrite_withfront'] ) ) ? false : true;
@@ -572,7 +633,7 @@ function cptui_register_single_taxonomy( $taxonomy = array() ) {
572
  }
573
  }
574
 
575
- if ( in_array( $taxonomy['query_var'], array( 'true', 'false', '0', '1' ) ) ) {
576
  $taxonomy['query_var'] = get_disp_boolean( $taxonomy['query_var'] );
577
  }
578
  if ( true === $taxonomy['query_var'] && ! empty( $taxonomy['query_var_slug'] ) ) {
@@ -617,7 +678,7 @@ function cptui_register_single_taxonomy( $taxonomy = array() ) {
617
  $meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? $taxonomy['meta_box_cb'] : false;
618
  }
619
 
620
- $args = array(
621
  'labels' => $labels,
622
  'label' => $taxonomy['label'],
623
  'description' => $description,
@@ -635,9 +696,9 @@ function cptui_register_single_taxonomy( $taxonomy = array() ) {
635
  'rest_controller_class' => $rest_controller_class,
636
  'show_in_quick_edit' => $show_in_quick_edit,
637
  'meta_box_cb' => $meta_box_cb,
638
- );
639
 
640
- $object_type = ( ! empty( $taxonomy['object_types'] ) ) ? $taxonomy['object_types'] : '';
641
 
642
  /**
643
  * Filters the arguments used for a taxonomy right before registering.
@@ -662,6 +723,7 @@ function cptui_register_single_taxonomy( $taxonomy = array() ) {
662
  * @since 1.0.0
663
  *
664
  * @param string $page Whether it's the CPT or Taxonomy page. Optional. Default "post_types".
 
665
  */
666
  function cptui_settings_tab_menu( $page = 'post_types' ) {
667
 
@@ -673,17 +735,17 @@ function cptui_settings_tab_menu( $page = 'post_types' ) {
673
  * @param array $value Array of tabs to render.
674
  * @param string $page Current page being displayed.
675
  */
676
- $tabs = (array) apply_filters( 'cptui_get_tabs', array(), $page );
677
 
678
- if ( ! empty( $tabs['page_title'] ) ) {
679
- printf(
680
- '<h1>%s</h1><h2 class="nav-tab-wrapper">',
681
- $tabs['page_title']
682
- );
683
  }
684
 
 
 
 
685
  foreach ( $tabs['tabs'] as $tab ) {
686
- printf(
687
  '<a class="%s" href="%s" aria-selected="%s">%s</a>',
688
  implode( ' ', $tab['classes'] ),
689
  $tab['url'],
@@ -692,7 +754,11 @@ function cptui_settings_tab_menu( $page = 'post_types' ) {
692
  );
693
  }
694
 
695
- echo '</h2>';
 
 
 
 
696
  }
697
 
698
  /**
@@ -716,12 +782,12 @@ function cptui_convert_settings() {
716
 
717
  if ( false === get_option( 'cptui_post_types' ) && ( $post_types = get_option( 'cpt_custom_post_types' ) ) ) {
718
 
719
- $new_post_types = array();
720
  foreach ( $post_types as $type ) {
721
- $new_post_types[ $type['name'] ] = $type; // This one assigns the # indexes. Named arrays are our friend.
722
- $new_post_types[ $type['name'] ]['supports'] = ( ! empty( $type[0] ) ) ? $type[0] : array(); // Especially for multidimensional arrays.
723
- $new_post_types[ $type['name'] ]['taxonomies'] = ( ! empty( $type[1] ) ) ? $type[1] : array();
724
- $new_post_types[ $type['name'] ]['labels'] = ( ! empty( $type[2] ) ) ? $type[2] : array();
725
  unset(
726
  $new_post_types[ $type['name'] ][0],
727
  $new_post_types[ $type['name'] ][1],
@@ -734,10 +800,10 @@ function cptui_convert_settings() {
734
 
735
  if ( false === get_option( 'cptui_taxonomies' ) && ( $taxonomies = get_option( 'cpt_custom_tax_types' ) ) ) {
736
 
737
- $new_taxonomies = array();
738
  foreach ( $taxonomies as $tax ) {
739
  $new_taxonomies[ $tax['name'] ] = $tax; // Yep, still our friend.
740
- $new_taxonomies[ $tax['name'] ]['labels'] = $tax[0]; // Taxonomies are the only thing with
741
  $new_taxonomies[ $tax['name'] ]['object_types'] = $tax[1]; // "tax" in the name that I like.
742
  unset(
743
  $new_taxonomies[ $tax['name'] ][0],
@@ -769,9 +835,9 @@ add_action( 'admin_init', 'cptui_convert_settings' );
769
  */
770
  function cptui_admin_notices( $action = '', $object_type = '', $success = true, $custom = '' ) {
771
 
772
- $class = array();
773
- $class[] = ( $success ) ? 'updated' : 'error';
774
- $class[] = 'notice is-dismissible';
775
  $object_type = esc_attr( $object_type );
776
 
777
  $messagewrapstart = '<div id="message" class="' . implode( ' ', $class ) . '"><p>';
@@ -779,31 +845,31 @@ function cptui_admin_notices( $action = '', $object_type = '', $success = true,
779
 
780
  $messagewrapend = '</p></div>';
781
 
782
- if ( 'add' == $action ) {
783
  if ( $success ) {
784
  $message .= sprintf( __( '%s has been successfully added', 'custom-post-type-ui' ), $object_type );
785
  } else {
786
  $message .= sprintf( __( '%s has failed to be added', 'custom-post-type-ui' ), $object_type );
787
  }
788
- } elseif ( 'update' == $action ) {
789
  if ( $success ) {
790
  $message .= sprintf( __( '%s has been successfully updated', 'custom-post-type-ui' ), $object_type );
791
  } else {
792
  $message .= sprintf( __( '%s has failed to be updated', 'custom-post-type-ui' ), $object_type );
793
  }
794
- } elseif ( 'delete' == $action ) {
795
  if ( $success ) {
796
  $message .= sprintf( __( '%s has been successfully deleted', 'custom-post-type-ui' ), $object_type );
797
  } else {
798
  $message .= sprintf( __( '%s has failed to be deleted', 'custom-post-type-ui' ), $object_type );
799
  }
800
- } elseif ( 'import' == $action ) {
801
  if ( $success ) {
802
  $message .= sprintf( __( '%s has been successfully imported', 'custom-post-type-ui' ), $object_type );
803
  } else {
804
  $message .= sprintf( __( '%s has failed to be imported', 'custom-post-type-ui' ), $object_type );
805
  }
806
- } elseif ( 'error' == $action ) {
807
  if ( ! empty( $custom ) ) {
808
  $message = $custom;
809
  }
@@ -838,18 +904,19 @@ function cptui_admin_notices( $action = '', $object_type = '', $success = true,
838
  */
839
  function cptui_get_preserved_keys( $type = '' ) {
840
 
841
- $preserved_labels = array(
842
- 'post_types' => array(
843
  'add_new_item',
844
  'edit_item',
845
  'new_item',
846
  'view_item',
 
847
  'all_items',
848
  'search_items',
849
  'not_found',
850
  'not_found_in_trash',
851
- ),
852
- 'taxonomies' => array(
853
  'search_items',
854
  'popular_items',
855
  'all_items',
@@ -862,9 +929,9 @@ function cptui_get_preserved_keys( $type = '' ) {
862
  'separate_items_with_commas',
863
  'add_or_remove_items',
864
  'choose_from_most_used',
865
- ),
866
- );
867
- return ( ! empty( $type ) ) ? $preserved_labels[ $type ] : array();
868
  }
869
 
870
  /**
@@ -882,18 +949,19 @@ function cptui_get_preserved_keys( $type = '' ) {
882
  */
883
  function cptui_get_preserved_label( $type = '', $key = '', $plural = '', $singular = '' ) {
884
 
885
- $preserved_labels = array(
886
- 'post_types' => array(
887
  'add_new_item' => sprintf( __( 'Add new %s', 'custom-post-type-ui' ), $singular ),
888
  'edit_item' => sprintf( __( 'Edit %s', 'custom-post-type-ui' ), $singular ),
889
  'new_item' => sprintf( __( 'New %s', 'custom-post-type-ui' ), $singular ),
890
  'view_item' => sprintf( __( 'View %s', 'custom-post-type-ui' ), $singular ),
 
891
  'all_items' => sprintf( __( 'All %s', 'custom-post-type-ui' ), $plural ),
892
  'search_items' => sprintf( __( 'Search %s', 'custom-post-type-ui' ), $plural ),
893
  'not_found' => sprintf( __( 'No %s found.', 'custom-post-type-ui' ), $plural ),
894
  'not_found_in_trash' => sprintf( __( 'No %s found in trash.', 'custom-post-type-ui' ), $plural ),
895
- ),
896
- 'taxonomies' => array(
897
  'search_items' => sprintf( __( 'Search %s', 'custom-post-type-ui' ), $plural ),
898
  'popular_items' => sprintf( __( 'Popular %s', 'custom-post-type-ui' ), $plural ),
899
  'all_items' => sprintf( __( 'All %s', 'custom-post-type-ui' ), $plural ),
@@ -906,8 +974,8 @@ function cptui_get_preserved_label( $type = '', $key = '', $plural = '', $singul
906
  'separate_items_with_commas' => sprintf( __( 'Separate %s with commas', 'custom-post-type-ui' ), $plural ),
907
  'add_or_remove_items' => sprintf( __( 'Add or remove %s', 'custom-post-type-ui' ), $plural ),
908
  'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'custom-post-type-ui' ), $plural ),
909
- ),
910
- );
911
 
912
  return $preserved_labels[ $type ][ $key ];
913
  }
@@ -922,38 +990,39 @@ function cptui_get_preserved_label( $type = '', $key = '', $plural = '', $singul
922
  * @return array
923
  */
924
  function cptui_get_preserved_labels() {
925
- return array(
926
- 'post_types' => array(
927
- 'singular' => array(
928
  'add_new_item' => __( 'Add new %s', 'custom-post-type-ui' ),
929
  'edit_item' => __( 'Edit %s', 'custom-post-type-ui' ),
930
  'new_item' => __( 'New %s', 'custom-post-type-ui' ),
931
  'view_item' => __( 'View %s', 'custom-post-type-ui' ),
932
- ),
933
- 'plural' => array(
 
934
  'all_items' => __( 'All %s', 'custom-post-type-ui' ),
935
  'search_items' => __( 'Search %s', 'custom-post-type-ui' ),
936
  'not_found' => __( 'No %s found.', 'custom-post-type-ui' ),
937
  'not_found_in_trash' => __( 'No %s found in trash.', 'custom-post-type-ui' ),
938
- ),
939
- ),
940
- 'taxonomies' => array(
941
- 'singular' => array(
942
  'parent_item' => __( 'Parent %s', 'custom-post-type-ui' ),
943
  'parent_item_colon' => __( 'Parent %s:', 'custom-post-type-ui' ),
944
  'edit_item' => __( 'Edit %s', 'custom-post-type-ui' ),
945
  'update_item' => __( 'Update %s', 'custom-post-type-ui' ),
946
  'add_new_item' => __( 'Add new %s', 'custom-post-type-ui' ),
947
  'new_item_name' => __( 'New %s name', 'custom-post-type-ui' ),
948
- ),
949
- 'plural' => array(
950
  'search_items' => __( 'Search %s', 'custom-post-type-ui' ),
951
  'popular_items' => __( 'Popular %s', 'custom-post-type-ui' ),
952
  'all_items' => __( 'All %s', 'custom-post-type-ui' ),
953
  'separate_items_with_commas' => __( 'Separate %s with commas', 'custom-post-type-ui' ),
954
  'add_or_remove_items' => __( 'Add or remove %s', 'custom-post-type-ui' ),
955
  'choose_from_most_used' => __( 'Choose from the most used %s', 'custom-post-type-ui' ),
956
- )
957
- ),
958
- );
959
  }
11
  * @license GPL-2.0+
12
  */
13
 
14
+ /**
15
+ * Plugin Name: Custom Post Type UI
16
+ * Plugin URI: https://github.com/WebDevStudios/custom-post-type-ui/
17
+ * Description: Admin panel for creating custom post types and custom taxonomies in WordPress
18
+ * Author: WebDevStudios
19
+ * Version: 1.7.0
20
+ * Author URI: https://webdevstudios.com/
21
+ * Text Domain: custom-post-type-ui
22
+ * Domain Path: /languages
23
+ * License: GPL-2.0+
24
+ */
25
+
26
+ // phpcs:disable WebDevStudios.All.RequireAuthor
27
 
28
  // Exit if accessed directly.
29
  if ( ! defined( 'ABSPATH' ) ) {
30
  exit;
31
  }
32
 
33
+ define( 'CPT_VERSION', '1.7.0' ); // Left for legacy purposes.
34
+ define( 'CPTUI_VERSION', '1.7.0' );
35
  define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
36
 
37
  /**
42
  * @internal
43
  */
44
  function cptui_load_ui_class() {
45
+ require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_admin_ui.php';
46
+ require_once plugin_dir_path( __FILE__ ) . 'classes/class.cptui_debug_info.php';
47
  }
48
  add_action( 'init', 'cptui_load_ui_class' );
49
 
88
  // Redirect to CPTUI about page.
89
  wp_safe_redirect(
90
  add_query_arg(
91
+ [ 'page' => 'cptui_main_menu' ],
92
  cptui_admin_url( 'admin.php?page=cptui_main_menu' )
93
  )
94
  );
191
  * @internal
192
  */
193
  function cptui_create_submenus() {
194
+ require_once plugin_dir_path( __FILE__ ) . 'inc/about.php';
195
+ require_once plugin_dir_path( __FILE__ ) . 'inc/utility.php';
196
+ require_once plugin_dir_path( __FILE__ ) . 'inc/post-types.php';
197
+ require_once plugin_dir_path( __FILE__ ) . 'inc/taxonomies.php';
198
+ require_once plugin_dir_path( __FILE__ ) . 'inc/listings.php';
199
+ require_once plugin_dir_path( __FILE__ ) . 'inc/tools.php';
200
+ require_once plugin_dir_path( __FILE__ ) . 'inc/support.php';
201
 
202
  if ( defined( 'WP_CLI' ) && WP_CLI ) {
203
+ require_once plugin_dir_path( __FILE__ ) . 'inc/wp-cli.php';
204
  }
205
  }
206
  add_action( 'cptui_loaded', 'cptui_create_submenus' );
236
  }
237
 
238
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
239
+ wp_register_script( 'cptui', plugins_url( "js/cptui{$min}.js", __FILE__ ), [ 'jquery', 'jquery-ui-dialog', 'postbox' ], CPTUI_VERSION, true );
240
+ wp_register_style( 'cptui-css', plugins_url( "css/cptui{$min}.css", __FILE__ ), [ 'wp-jquery-ui-dialog' ], CPTUI_VERSION );
241
  }
242
  add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
243
 
266
 
267
  if ( is_array( $cpts ) ) {
268
  foreach ( $cpts as $post_type ) {
269
+
270
+ /**
271
+ * Filters whether or not to skip registration of the current iterated post type.
272
+ *
273
+ * Dynamic part of the filter name is the chosen post type slug.
274
+ *
275
+ * @since 1.7.0
276
+ *
277
+ * @param bool $value Whether or not to skip the post type.
278
+ * @param array $post_type Current post type being registered.
279
+ */
280
+ if ( (bool) apply_filters( "cptui_disable_{$post_type['name']}_cpt", false, $post_type ) ) {
281
+ continue;
282
+ }
283
+
284
+ /**
285
+ * Filters whether or not to skip registration of the current iterated post type.
286
+ *
287
+ * @since 1.7.0
288
+ *
289
+ * @param bool $value Whether or not to skip the post type.
290
+ * @param array $post_type Current post type being registered.
291
+ */
292
+ if ( (bool) apply_filters( 'cptui_disable_cpt', false, $post_type ) ) {
293
+ continue;
294
+ }
295
+
296
  cptui_register_single_post_type( $post_type );
297
  }
298
  }
318
  * @param array $post_type Post type array to register. Optional.
319
  * @return null Result of register_post_type.
320
  */
321
+ function cptui_register_single_post_type( $post_type = [] ) {
322
 
323
  /**
324
  * Filters the map_meta_cap value.
332
  $post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', true, $post_type['name'], $post_type );
333
 
334
  if ( empty( $post_type['supports'] ) ) {
335
+ $post_type['supports'] = [];
336
  }
337
 
338
  /**
344
  * @param string $name Post type slug being registered.
345
  * @param array $post_type Array of post type arguments to be registered.
346
  */
347
+ $user_supports_params = apply_filters( 'cptui_user_supports_params', [], $post_type['name'], $post_type );
348
 
349
  if ( is_array( $user_supports_params ) && ! empty( $user_supports_params ) ) {
350
  if ( is_array( $post_type['supports'] ) ) {
351
  $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
352
  } else {
353
+ $post_type['supports'] = [ $user_supports_params ];
354
  }
355
  }
356
 
359
  $custom = explode( ',', $post_type['custom_supports'] );
360
  foreach ( $custom as $part ) {
361
  // We'll handle YARPP separately.
362
+ if ( in_array( $part, [ 'YARPP', 'yarpp' ], true ) ) {
363
  $yarpp = true;
364
  continue;
365
  }
367
  }
368
  }
369
 
370
+ if ( isset( $post_type['supports'] ) && is_array( $post_type['supports'] ) && in_array( 'none', $post_type['supports'], true ) ) {
371
  $post_type['supports'] = false;
372
  }
373
 
374
+ $labels = [
375
  'name' => $post_type['label'],
376
  'singular_name' => $post_type['singular_label'],
377
+ ];
378
 
379
+ $preserved = cptui_get_preserved_keys( 'post_types' );
380
  $preserved_labels = cptui_get_preserved_labels();
381
  foreach ( $post_type['labels'] as $key => $label ) {
382
 
386
  } else {
387
  $labels[ $key ] = $label;
388
  }
389
+ } elseif ( empty( $label ) && in_array( $key, $preserved, true ) ) {
390
  $singular_or_plural = ( in_array( $key, array_keys( $preserved_labels['post_types']['plural'] ) ) ) ? 'plural' : 'singular';
391
+ $label_plurality = ( 'plural' === $singular_or_plural ) ? $post_type['label'] : $post_type['singular_label'];
392
+ $labels[ $key ] = sprintf( $preserved_labels['post_types'][ $singular_or_plural ][ $key ], $label_plurality );
393
  }
394
  }
395
 
396
+ $has_archive = isset( $post_type['has_archive'] ) ? get_disp_boolean( $post_type['has_archive'] ) : false;
397
  if ( $has_archive && ! empty( $post_type['has_archive_string'] ) ) {
398
  $has_archive = $post_type['has_archive_string'];
399
  }
406
  $rewrite = get_disp_boolean( $post_type['rewrite'] );
407
  if ( false !== $rewrite ) {
408
  // Core converts to an empty array anyway, so safe to leave this instead of passing in boolean true.
409
+ $rewrite = [];
410
+ $rewrite['slug'] = ! empty( $post_type['rewrite_slug'] ) ? $post_type['rewrite_slug'] : $post_type['name'];
411
 
412
  $rewrite['with_front'] = true; // Default value.
413
  if ( isset( $post_type['rewrite_withfront'] ) ) {
414
+ $rewrite['with_front'] = 'false' === disp_boolean( $post_type['rewrite_withfront'] ) ? false : true;
415
  }
416
  }
417
 
418
+ $menu_icon = ! empty( $post_type['menu_icon'] ) ? $post_type['menu_icon'] : null;
419
 
420
+ if ( in_array( $post_type['query_var'], [ 'true', 'false', '0', '1' ], true ) ) {
421
  $post_type['query_var'] = get_disp_boolean( $post_type['query_var'] );
422
  }
423
  if ( ! empty( $post_type['query_var_slug'] ) ) {
429
  $menu_position = (int) $post_type['menu_position'];
430
  }
431
 
432
+ $delete_with_user = null;
433
+ if ( ! empty( $post_type['delete_with_user'] ) ) {
434
+ $delete_with_user = get_disp_boolean( $post_type['delete_with_user'] );
435
+ }
436
+
437
  $capability_type = 'post';
438
  if ( ! empty( $post_type['capability_type'] ) ) {
439
  $capability_type = $post_type['capability_type'];
450
  if ( ! empty( $post_type['exclude_from_search'] ) ) {
451
  $exclude_from_search = get_disp_boolean( $post_type['exclude_from_search'] );
452
  } else {
453
+ $exclude_from_search = false === $public;
454
  }
455
 
456
  $queryable = ( ! empty( $post_type['publicly_queryable'] ) && isset( $post_type['publicly_queryable'] ) ) ? get_disp_boolean( $post_type['publicly_queryable'] ) : $public;
474
  $rest_controller_class = $post_type['rest_controller_class'];
475
  }
476
 
477
+ $args = [
478
  'labels' => $labels,
479
  'description' => $post_type['description'],
480
  'public' => get_disp_boolean( $post_type['public'] ),
483
  'show_in_nav_menus' => get_disp_boolean( $post_type['show_in_nav_menus'] ),
484
  'has_archive' => $has_archive,
485
  'show_in_menu' => $show_in_menu,
486
+ 'delete_with_user' => $delete_with_user,
487
  'show_in_rest' => get_disp_boolean( $post_type['show_in_rest'] ),
488
  'rest_base' => $rest_base,
489
  'rest_controller_class' => $rest_controller_class,
497
  'query_var' => $post_type['query_var'],
498
  'supports' => $post_type['supports'],
499
  'taxonomies' => $post_type['taxonomies'],
500
+ ];
501
 
502
  if ( true === $yarpp ) {
503
  $args['yarpp_support'] = $yarpp;
543
 
544
  if ( is_array( $taxes ) ) {
545
  foreach ( $taxes as $tax ) {
546
+ /**
547
+ * Filters whether or not to skip registration of the current iterated taxonomy.
548
+ *
549
+ * Dynamic part of the filter name is the chosen taxonomy slug.
550
+ *
551
+ * @since 1.7.0
552
+ *
553
+ * @param bool $value Whether or not to skip the taxonomy.
554
+ * @param array $tax Current taxonomy being registered.
555
+ */
556
+ if ( (bool) apply_filters( "cptui_disable_{$tax['name']}_tax", false, $tax ) ) {
557
+ continue;
558
+ }
559
+
560
+ /**
561
+ * Filters whether or not to skip registration of the current iterated taxonomy.
562
+ *
563
+ * @since 1.7.0
564
+ *
565
+ * @param bool $value Whether or not to skip the taxonomy.
566
+ * @param array $tax Current taxonomy being registered.
567
+ */
568
+ if ( (bool) apply_filters( 'cptui_disable_tax', false, $tax ) ) {
569
+ continue;
570
+ }
571
+
572
  cptui_register_single_taxonomy( $tax );
573
  }
574
  }
594
  * @param array $taxonomy Taxonomy array to register. Optional.
595
  * @return null Result of register_taxonomy.
596
  */
597
+ function cptui_register_single_taxonomy( $taxonomy = [] ) {
598
 
599
+ $labels = [
600
+ 'name' => $taxonomy['label'],
601
+ 'singular_name' => $taxonomy['singular_label'],
602
+ ];
603
 
604
  $description = '';
605
  if ( ! empty( $taxonomy['description'] ) ) {
606
  $description = $taxonomy['description'];
607
  }
608
 
609
+ $preserved = cptui_get_preserved_keys( 'taxonomies' );
610
  $preserved_labels = cptui_get_preserved_labels();
611
  foreach ( $taxonomy['labels'] as $key => $label ) {
612
 
613
  if ( ! empty( $label ) ) {
614
  $labels[ $key ] = $label;
615
+ } elseif ( empty( $label ) && in_array( $key, $preserved, true ) ) {
616
  $singular_or_plural = ( in_array( $key, array_keys( $preserved_labels['taxonomies']['plural'] ) ) ) ? 'plural' : 'singular';
617
+ $label_plurality = ( 'plural' === $singular_or_plural ) ? $taxonomy['label'] : $taxonomy['singular_label'];
618
+ $labels[ $key ] = sprintf( $preserved_labels['taxonomies'][ $singular_or_plural ][ $key ], $label_plurality );
619
  }
620
  }
621
 
622
  $rewrite = get_disp_boolean( $taxonomy['rewrite'] );
623
  if ( false !== get_disp_boolean( $taxonomy['rewrite'] ) ) {
624
+ $rewrite = [];
625
+ $rewrite['slug'] = ! empty( $taxonomy['rewrite_slug'] ) ? $taxonomy['rewrite_slug'] : $taxonomy['name'];
626
  $rewrite['with_front'] = true;
627
  if ( isset( $taxonomy['rewrite_withfront'] ) ) {
628
  $rewrite['with_front'] = ( 'false' === disp_boolean( $taxonomy['rewrite_withfront'] ) ) ? false : true;
633
  }
634
  }
635
 
636
+ if ( in_array( $taxonomy['query_var'], [ 'true', 'false', '0', '1' ], true ) ) {
637
  $taxonomy['query_var'] = get_disp_boolean( $taxonomy['query_var'] );
638
  }
639
  if ( true === $taxonomy['query_var'] && ! empty( $taxonomy['query_var_slug'] ) ) {
678
  $meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? $taxonomy['meta_box_cb'] : false;
679
  }
680
 
681
+ $args = [
682
  'labels' => $labels,
683
  'label' => $taxonomy['label'],
684
  'description' => $description,
696
  'rest_controller_class' => $rest_controller_class,
697
  'show_in_quick_edit' => $show_in_quick_edit,
698
  'meta_box_cb' => $meta_box_cb,
699
+ ];
700
 
701
+ $object_type = ! empty( $taxonomy['object_types'] ) ? $taxonomy['object_types'] : '';
702
 
703
  /**
704
  * Filters the arguments used for a taxonomy right before registering.
723
  * @since 1.0.0
724
  *
725
  * @param string $page Whether it's the CPT or Taxonomy page. Optional. Default "post_types".
726
+ * @return string
727
  */
728
  function cptui_settings_tab_menu( $page = 'post_types' ) {
729
 
735
  * @param array $value Array of tabs to render.
736
  * @param string $page Current page being displayed.
737
  */
738
+ $tabs = (array) apply_filters( 'cptui_get_tabs', [], $page );
739
 
740
+ if ( empty( $tabs['page_title'] ) ) {
741
+ return '';
 
 
 
742
  }
743
 
744
+ $tmpl = '<h1>%s</h1><nav class="nav-tab-wrapper wp-clearfix" aria-label="Secondary menu">%s</nav>';
745
+
746
+ $tab_output = '';
747
  foreach ( $tabs['tabs'] as $tab ) {
748
+ $tab_output .= sprintf(
749
  '<a class="%s" href="%s" aria-selected="%s">%s</a>',
750
  implode( ' ', $tab['classes'] ),
751
  $tab['url'],
754
  );
755
  }
756
 
757
+ printf(
758
+ $tmpl,
759
+ $tabs['page_title'],
760
+ $tab_output
761
+ );
762
  }
763
 
764
  /**
782
 
783
  if ( false === get_option( 'cptui_post_types' ) && ( $post_types = get_option( 'cpt_custom_post_types' ) ) ) {
784
 
785
+ $new_post_types = [];
786
  foreach ( $post_types as $type ) {
787
+ $new_post_types[ $type['name'] ] = $type; // This one assigns the # indexes. Named arrays are our friend.
788
+ $new_post_types[ $type['name'] ]['supports'] = ! empty( $type[0] ) ? $type[0] : []; // Especially for multidimensional arrays.
789
+ $new_post_types[ $type['name'] ]['taxonomies'] = ! empty( $type[1] ) ? $type[1] : [];
790
+ $new_post_types[ $type['name'] ]['labels'] = ! empty( $type[2] ) ? $type[2] : [];
791
  unset(
792
  $new_post_types[ $type['name'] ][0],
793
  $new_post_types[ $type['name'] ][1],
800
 
801
  if ( false === get_option( 'cptui_taxonomies' ) && ( $taxonomies = get_option( 'cpt_custom_tax_types' ) ) ) {
802
 
803
+ $new_taxonomies = [];
804
  foreach ( $taxonomies as $tax ) {
805
  $new_taxonomies[ $tax['name'] ] = $tax; // Yep, still our friend.
806
+ $new_taxonomies[ $tax['name'] ]['labels'] = $tax[0]; // Taxonomies are the only thing with.
807
  $new_taxonomies[ $tax['name'] ]['object_types'] = $tax[1]; // "tax" in the name that I like.
808
  unset(
809
  $new_taxonomies[ $tax['name'] ][0],
835
  */
836
  function cptui_admin_notices( $action = '', $object_type = '', $success = true, $custom = '' ) {
837
 
838
+ $class = [];
839
+ $class[] = $success ? 'updated' : 'error';
840
+ $class[] = 'notice is-dismissible';
841
  $object_type = esc_attr( $object_type );
842
 
843
  $messagewrapstart = '<div id="message" class="' . implode( ' ', $class ) . '"><p>';
845
 
846
  $messagewrapend = '</p></div>';
847
 
848
+ if ( 'add' === $action ) {
849
  if ( $success ) {
850
  $message .= sprintf( __( '%s has been successfully added', 'custom-post-type-ui' ), $object_type );
851
  } else {
852
  $message .= sprintf( __( '%s has failed to be added', 'custom-post-type-ui' ), $object_type );
853
  }
854
+ } elseif ( 'update' === $action ) {
855
  if ( $success ) {
856
  $message .= sprintf( __( '%s has been successfully updated', 'custom-post-type-ui' ), $object_type );
857
  } else {
858
  $message .= sprintf( __( '%s has failed to be updated', 'custom-post-type-ui' ), $object_type );
859
  }
860
+ } elseif ( 'delete' === $action ) {
861
  if ( $success ) {
862
  $message .= sprintf( __( '%s has been successfully deleted', 'custom-post-type-ui' ), $object_type );
863
  } else {
864
  $message .= sprintf( __( '%s has failed to be deleted', 'custom-post-type-ui' ), $object_type );
865
  }
866
+ } elseif ( 'import' === $action ) {
867
  if ( $success ) {
868
  $message .= sprintf( __( '%s has been successfully imported', 'custom-post-type-ui' ), $object_type );
869
  } else {
870
  $message .= sprintf( __( '%s has failed to be imported', 'custom-post-type-ui' ), $object_type );
871
  }
872
+ } elseif ( 'error' === $action ) {
873
  if ( ! empty( $custom ) ) {
874
  $message = $custom;
875
  }
904
  */
905
  function cptui_get_preserved_keys( $type = '' ) {
906
 
907
+ $preserved_labels = [
908
+ 'post_types' => [
909
  'add_new_item',
910
  'edit_item',
911
  'new_item',
912
  'view_item',
913
+ 'view_items',
914
  'all_items',
915
  'search_items',
916
  'not_found',
917
  'not_found_in_trash',
918
+ ],
919
+ 'taxonomies' => [
920
  'search_items',
921
  'popular_items',
922
  'all_items',
929
  'separate_items_with_commas',
930
  'add_or_remove_items',
931
  'choose_from_most_used',
932
+ ],
933
+ ];
934
+ return ! empty( $type ) ? $preserved_labels[ $type ] : [];
935
  }
936
 
937
  /**
949
  */
950
  function cptui_get_preserved_label( $type = '', $key = '', $plural = '', $singular = '' ) {
951
 
952
+ $preserved_labels = [
953
+ 'post_types' => [
954
  'add_new_item' => sprintf( __( 'Add new %s', 'custom-post-type-ui' ), $singular ),
955
  'edit_item' => sprintf( __( 'Edit %s', 'custom-post-type-ui' ), $singular ),
956
  'new_item' => sprintf( __( 'New %s', 'custom-post-type-ui' ), $singular ),
957
  'view_item' => sprintf( __( 'View %s', 'custom-post-type-ui' ), $singular ),
958
+ 'view_items' => sprintf( __( 'View %s', 'custom-post-type-ui' ), $plural ),
959
  'all_items' => sprintf( __( 'All %s', 'custom-post-type-ui' ), $plural ),
960
  'search_items' => sprintf( __( 'Search %s', 'custom-post-type-ui' ), $plural ),
961
  'not_found' => sprintf( __( 'No %s found.', 'custom-post-type-ui' ), $plural ),
962
  'not_found_in_trash' => sprintf( __( 'No %s found in trash.', 'custom-post-type-ui' ), $plural ),
963
+ ],
964
+ 'taxonomies' => [
965
  'search_items' => sprintf( __( 'Search %s', 'custom-post-type-ui' ), $plural ),
966
  'popular_items' => sprintf( __( 'Popular %s', 'custom-post-type-ui' ), $plural ),
967
  'all_items' => sprintf( __( 'All %s', 'custom-post-type-ui' ), $plural ),
974
  'separate_items_with_commas' => sprintf( __( 'Separate %s with commas', 'custom-post-type-ui' ), $plural ),
975
  'add_or_remove_items' => sprintf( __( 'Add or remove %s', 'custom-post-type-ui' ), $plural ),
976
  'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'custom-post-type-ui' ), $plural ),
977
+ ],
978
+ ];
979
 
980
  return $preserved_labels[ $type ][ $key ];
981
  }
990
  * @return array
991
  */
992
  function cptui_get_preserved_labels() {
993
+ return [
994
+ 'post_types' => [
995
+ 'singular' => [
996
  'add_new_item' => __( 'Add new %s', 'custom-post-type-ui' ),
997
  'edit_item' => __( 'Edit %s', 'custom-post-type-ui' ),
998
  'new_item' => __( 'New %s', 'custom-post-type-ui' ),
999
  'view_item' => __( 'View %s', 'custom-post-type-ui' ),
1000
+ ],
1001
+ 'plural' => [
1002
+ 'view_items' => __( 'View %s', 'custom-post-type-ui' ),
1003
  'all_items' => __( 'All %s', 'custom-post-type-ui' ),
1004
  'search_items' => __( 'Search %s', 'custom-post-type-ui' ),
1005
  'not_found' => __( 'No %s found.', 'custom-post-type-ui' ),
1006
  'not_found_in_trash' => __( 'No %s found in trash.', 'custom-post-type-ui' ),
1007
+ ],
1008
+ ],
1009
+ 'taxonomies' => [
1010
+ 'singular' => [
1011
  'parent_item' => __( 'Parent %s', 'custom-post-type-ui' ),
1012
  'parent_item_colon' => __( 'Parent %s:', 'custom-post-type-ui' ),
1013
  'edit_item' => __( 'Edit %s', 'custom-post-type-ui' ),
1014
  'update_item' => __( 'Update %s', 'custom-post-type-ui' ),
1015
  'add_new_item' => __( 'Add new %s', 'custom-post-type-ui' ),
1016
  'new_item_name' => __( 'New %s name', 'custom-post-type-ui' ),
1017
+ ],
1018
+ 'plural' => [
1019
  'search_items' => __( 'Search %s', 'custom-post-type-ui' ),
1020
  'popular_items' => __( 'Popular %s', 'custom-post-type-ui' ),
1021
  'all_items' => __( 'All %s', 'custom-post-type-ui' ),
1022
  'separate_items_with_commas' => __( 'Separate %s with commas', 'custom-post-type-ui' ),
1023
  'add_or_remove_items' => __( 'Add or remove %s', 'custom-post-type-ui' ),
1024
  'choose_from_most_used' => __( 'Choose from the most used %s', 'custom-post-type-ui' ),
1025
+ ],
1026
+ ],
1027
+ ];
1028
  }
inc/about.php CHANGED
@@ -9,6 +9,8 @@
9
  * @license GPL-2.0+
10
  */
11
 
 
 
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
@@ -51,7 +53,8 @@ function cptui_settings() {
51
  *
52
  * @since 1.0.0
53
  */
54
- do_action( 'cptui_main_page_start' ); ?>
 
55
  <h1><?php esc_html_e( 'Custom Post Type UI', 'custom-post-type-ui' ); ?> <?php echo esc_html( CPTUI_VERSION ); ?></h1>
56
 
57
  <?php
@@ -75,22 +78,23 @@ function cptui_settings() {
75
  *
76
  * @since 1.4.0
77
  */
78
- do_action( 'cptui_main_page_before_changelog' ); ?>
 
79
 
80
  <h2><?php printf( esc_html__( "What's new in version %s", 'custom-post-type-ui' ), CPTUI_VERSION ); ?></h2>
81
  <div class="changelog about-integrations">
82
  <div class="cptui-feature feature-section col three-col">
83
  <div class="col">
84
- <h2><?php esc_html_e( 'Taxonomy support for meta_box_cb parameter', 'custom-post-type-ui' ); ?></h2>
85
- <p><?php esc_html_e( 'We have added a field to provide a function callback to use for the metabox for your taxonomies. This allows you to customize and provide your own metabox output instead of using the default.', 'custom-post-type-ui' ); ?></p>
86
  </div>
87
  <div class="col">
88
- <h2><?php esc_html_e( 'WP-CLI Support', 'custom-post-type-ui' ); ?></h2>
89
- <p><?php esc_html_e( 'We have added some initial WP-CLI support around importing and exporting your Custom Post Type UI settings. This will help with setting up your websites and provide some possible automation tools.', 'custom-post-type-ui' ); ?></p>
90
  </div>
91
  <div class="col last-feature">
92
- <h2><?php esc_html_e( 'Adjusted default "Show in REST" parameter.', 'custom-post-type-ui' ); ?></h2>
93
- <p><?php esc_html_e( 'Gutenberg is coming with WordPress 5.0. For post types to have "Gutenberg" support, the "Show in REST" parameter needs to be set to true. We are changing this to help ease users into better integration.', 'custom-post-type-ui' ) ?></p>
94
  </div>
95
  </div>
96
  </div>
@@ -103,7 +107,8 @@ function cptui_settings() {
103
  *
104
  * @since 1.3.0
105
  */
106
- do_action( 'cptui_main_page_extra_notes' ); ?>
 
107
  </div>
108
  </div>
109
  <?php
9
  * @license GPL-2.0+
10
  */
11
 
12
+ // phpcs:disable WebDevStudios.All.RequireAuthor
13
+
14
  // Exit if accessed directly.
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
53
  *
54
  * @since 1.0.0
55
  */
56
+ do_action( 'cptui_main_page_start' );
57
+ ?>
58
  <h1><?php esc_html_e( 'Custom Post Type UI', 'custom-post-type-ui' ); ?> <?php echo esc_html( CPTUI_VERSION ); ?></h1>
59
 
60
  <?php
78
  *
79
  * @since 1.4.0
80
  */
81
+ do_action( 'cptui_main_page_before_changelog' );
82
+ ?>
83
 
84
  <h2><?php printf( esc_html__( "What's new in version %s", 'custom-post-type-ui' ), CPTUI_VERSION ); ?></h2>
85
  <div class="changelog about-integrations">
86
  <div class="cptui-feature feature-section col three-col">
87
  <div class="col">
88
+ <h2><?php esc_html_e( 'Ability to temporarily disable content types without deleting them.', 'custom-post-type-ui' ); ?></h2>
89
+ <p><?php esc_html_e( 'Have you ever wanted to temporarily disable things without removing their settings, as you continue developing the site? Custom Post Type UI now has the ability to skip content types with a WordPress filter. UI options to toggle will be in a later version.', 'custom-post-type-ui' ); ?></p>
90
  </div>
91
  <div class="col">
92
+ <h2><?php esc_html_e( 'New post type labels introduced in WordPress 5.0', 'custom-post-type-ui' ); ?></h2>
93
+ <p><?php esc_html_e( 'We have increased our minimum supported WordPress version and with that, we now support the newest available label options. You now have even finer control over your admin UI wording.', 'custom-post-type-ui' ); ?></p>
94
  </div>
95
  <div class="col last-feature">
96
+ <h2></h2>
97
+ <p></p>
98
  </div>
99
  </div>
100
  </div>
107
  *
108
  * @since 1.3.0
109
  */
110
+ do_action( 'cptui_main_page_extra_notes' );
111
+ ?>
112
  </div>
113
  </div>
114
  <?php
inc/listings.php CHANGED
@@ -9,6 +9,8 @@
9
  * @license GPL-2.0+
10
  */
11
 
 
 
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
@@ -53,13 +55,16 @@ function cptui_listings() {
53
  do_action( 'cptui_inside_listings_wrap' );
54
  ?>
55
 
56
- <h1><?php esc_html_e( 'Post Types and Taxonomies registered by Custom Post Type UI.', 'custom-post-type-ui' ); ?></h1>
 
 
57
  <?php
58
  $post_types = cptui_get_post_type_data();
59
  echo '<h2 id="post-types">' . esc_html__( 'Post Types', 'custom-post-type-ui' ) . '</h2>';
60
  if ( ! empty( $post_types ) ) {
61
  ?>
62
- <p><?php
 
63
  printf(
64
  /* translators: %s: Total count of registered CPTUI post types */
65
  esc_html__( 'Custom Post Type UI registered post types count total: %d', 'custom-post-type-ui' ),
@@ -70,14 +75,14 @@ function cptui_listings() {
70
 
71
  <?php
72
 
73
- $post_type_table_heads = array(
74
- __( 'Post Type', 'custom-post-type-ui' ),
75
- __( 'Settings', 'custom-post-type-ui' ),
76
- __( 'Supports', 'custom-post-type-ui' ),
77
- __( 'Taxonomies', 'custom-post-type-ui' ),
78
- __( 'Labels', 'custom-post-type-ui' ),
79
- __( 'Template Hierarchy', 'custom-post-type-ui' ),
80
- );
81
 
82
  /**
83
  * Fires before the listing of registered post type data.
@@ -92,7 +97,8 @@ function cptui_listings() {
92
  <?php
93
  foreach ( $post_type_table_heads as $head ) {
94
  echo '<th>' . esc_html( $head ) . '</th>';
95
- } ?>
 
96
  </tr>
97
  </thead>
98
  <tbody>
@@ -102,10 +108,10 @@ function cptui_listings() {
102
 
103
  $rowclass = ( 0 === $counter % 2 ) ? '' : 'alternate';
104
 
105
- $strings = array();
106
- $supports = array();
107
- $taxonomies = array();
108
- $archive = '';
109
  foreach ( $post_type_settings as $settings_key => $settings_value ) {
110
  if ( 'labels' === $settings_key ) {
111
  continue;
@@ -133,7 +139,8 @@ function cptui_listings() {
133
  <tr class="<?php echo esc_attr( $rowclass ); ?>">
134
  <?php
135
  $edit_path = 'admin.php?page=cptui_manage_post_types&action=edit&cptui_post_type=' . $post_type;
136
- $post_type_link_url = ( is_network_admin() ) ? network_admin_url( $edit_path ) : admin_url( $edit_path ); ?>
 
137
  <td>
138
  <?php
139
  printf(
@@ -142,7 +149,8 @@ function cptui_listings() {
142
  esc_attr( $post_type_link_url ),
143
  sprintf(
144
  /* translators: %s: Post type slug */
145
- esc_html__( 'Edit %s', 'custom-post-type-ui' ),
 
146
  esc_html( $post_type )
147
  ),
148
  esc_attr( admin_url( 'admin.php?page=cptui_tools&action=get_code#' . $post_type ) ),
@@ -158,19 +166,21 @@ function cptui_listings() {
158
  <?php
159
  foreach ( $strings as $key => $value ) {
160
  printf( '<strong>%s:</strong> ', esc_html( $key ) );
161
- if ( in_array( $value, array( '1', '0' ), true ) ) {
162
  echo esc_html( disp_boolean( $value ) );
163
  } else {
164
- echo ( ! empty( $value ) ) ? esc_html( $value ) : '""';
165
  }
166
  echo '<br/>';
167
- } ?>
 
168
  </td>
169
  <td>
170
  <?php
171
  foreach ( $supports['supports'] as $support ) {
172
  echo esc_html( $support ) . '<br/>';
173
- } ?>
 
174
  </td>
175
  <td>
176
  <?php
@@ -195,7 +205,7 @@ function cptui_listings() {
195
  continue;
196
  }
197
  printf(
198
- '%s: %s<br/>',
199
  esc_html( $key ),
200
  esc_html( $value )
201
  );
@@ -227,11 +237,13 @@ function cptui_listings() {
227
  <?php esc_html_e( '*Replace "post_slug" with the slug of the actual post slug.', 'custom-post-type-ui' ); ?>
228
  </p>
229
 
230
- <p><?php
 
231
  printf(
232
  '<a href="https://developer.wordpress.org/themes/basics/template-hierarchy/">%s</a>',
233
  esc_html__( 'Template hierarchy Theme Handbook', 'custom-post-type-ui' )
234
- ); ?>
 
235
  </p>
236
  </td>
237
  </tr>
@@ -246,7 +258,8 @@ function cptui_listings() {
246
  <?php
247
  foreach ( $post_type_table_heads as $head ) {
248
  echo '<th>' . esc_html( $head ) . '</th>';
249
- } ?>
 
250
  </tr>
251
  </tfoot>
252
  </table>
@@ -283,13 +296,13 @@ function cptui_listings() {
283
 
284
  <?php
285
 
286
- $taxonomy_table_heads = array(
287
- __( 'Taxonomy', 'custom-post-type-ui' ),
288
- __( 'Settings', 'custom-post-type-ui' ),
289
- __( 'Post Types', 'custom-post-type-ui' ),
290
- __( 'Labels', 'custom-post-type-ui' ),
291
- __( 'Template Hierarchy', 'custom-post-type-ui' ),
292
- );
293
 
294
  /**
295
  * Fires before the listing of registered taxonomy data.
@@ -304,7 +317,8 @@ function cptui_listings() {
304
  <?php
305
  foreach ( $taxonomy_table_heads as $head ) {
306
  echo '<th>' . esc_html( $head ) . '</th>';
307
- } ?>
 
308
  </tr>
309
  </thead>
310
  <tbody>
@@ -314,8 +328,8 @@ function cptui_listings() {
314
 
315
  $rowclass = ( 0 === $counter % 2 ) ? '' : 'alternate';
316
 
317
- $strings = array();
318
- $object_types = array();
319
  foreach ( $taxonomy_settings as $settings_key => $settings_value ) {
320
  if ( 'labels' === $settings_key ) {
321
  continue;
@@ -329,7 +343,7 @@ function cptui_listings() {
329
 
330
  // In case they are not associated from the post type settings.
331
  if ( empty( $object_types['object_types'] ) ) {
332
- $types = get_taxonomy( $taxonomy );
333
  $object_types['object_types'] = $types->object_type;
334
  }
335
  }
@@ -338,33 +352,38 @@ function cptui_listings() {
338
  ?>
339
  <tr class="<?php echo esc_attr( $rowclass ); ?>">
340
  <?php
341
- $edit_path = 'admin.php?page=cptui_manage_taxonomies&action=edit&cptui_taxonomy=' . $taxonomy;
342
- $taxonomy_link_url = ( is_network_admin() ) ? network_admin_url( $edit_path ) : admin_url( $edit_path ); ?>
 
343
  <td>
344
- <?php printf(
 
345
  '<a href="%s">%s</a><br/>
346
  <a href="%s">%s</a>',
347
  esc_attr( $taxonomy_link_url ),
348
  sprintf(
349
  /* translators: %s: Taxonomy slug */
350
- esc_html__( 'Edit %s', 'custom-post-type-ui' ),
 
351
  esc_html( $taxonomy )
352
  ),
353
  esc_attr( admin_url( 'admin.php?page=cptui_tools&action=get_code#' . $taxonomy ) ),
354
  esc_html__( 'Get code', 'custom-post-type-ui' )
355
- ); ?>
 
356
  </td>
357
  <td>
358
  <?php
359
  foreach ( $strings as $key => $value ) {
360
  printf( '<strong>%s:</strong> ', esc_html( $key ) );
361
- if ( in_array( $value, array( '1', '0' ), true ) ) {
362
  echo esc_html( disp_boolean( $value ) );
363
  } else {
364
- echo ( ! empty( $value ) ) ? esc_html( $value ) : '""';
365
  }
366
  echo '<br/>';
367
- } ?>
 
368
  </td>
369
  <td>
370
  <?php
@@ -372,7 +391,8 @@ function cptui_listings() {
372
  foreach ( $object_types['object_types'] as $type ) {
373
  echo esc_html( $type ) . '<br/>';
374
  }
375
- } ?>
 
376
  </td>
377
  <td>
378
  <?php
@@ -380,7 +400,7 @@ function cptui_listings() {
380
  if ( ! empty( $maybe_empty ) ) {
381
  foreach ( $taxonomy_settings['labels'] as $key => $value ) {
382
  printf(
383
- '%s: %s<br/>',
384
  esc_html( $key ),
385
  esc_html( $value )
386
  );
@@ -405,11 +425,14 @@ function cptui_listings() {
405
  <p>
406
  <?php esc_html_e( '*Replace "term_slug" with the slug of the actual taxonomy term.', 'custom-post-type-ui' ); ?>
407
  </p>
408
- <p><?php
 
409
  printf(
410
  '<a href="https://developer.wordpress.org/themes/basics/template-hierarchy/">%s</a>',
411
  esc_html__( 'Template hierarchy Theme Handbook', 'custom-post-type-ui' )
412
- ); ?></p>
 
 
413
  </td>
414
  </tr>
415
 
@@ -423,7 +446,8 @@ function cptui_listings() {
423
  <?php
424
  foreach ( $taxonomy_table_heads as $head ) {
425
  echo '<th>' . esc_html( $head ) . '</th>';
426
- } ?>
 
427
  </tr>
428
  </tfoot>
429
  </table>
9
  * @license GPL-2.0+
10
  */
11
 
12
+ // phpcs:disable WebDevStudios.All.RequireAuthor
13
+
14
  // Exit if accessed directly.
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
55
  do_action( 'cptui_inside_listings_wrap' );
56
  ?>
57
 
58
+ <h1 class="wp-heading-inline"><?php esc_html_e( 'Content types registered with Custom Post Type UI.', 'custom-post-type-ui' ); ?></h1>
59
+ <a href="<?php echo esc_url( cptui_get_add_new_link( 'post_types' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Add New Post Type', 'custom-post-type-ui' ); ?></a>
60
+ <a href="<?php echo esc_url( cptui_get_add_new_link( 'taxonomies' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Add New Taxonomy', 'custom-post-type-ui' ); ?></a>
61
  <?php
62
  $post_types = cptui_get_post_type_data();
63
  echo '<h2 id="post-types">' . esc_html__( 'Post Types', 'custom-post-type-ui' ) . '</h2>';
64
  if ( ! empty( $post_types ) ) {
65
  ?>
66
+ <p>
67
+ <?php
68
  printf(
69
  /* translators: %s: Total count of registered CPTUI post types */
70
  esc_html__( 'Custom Post Type UI registered post types count total: %d', 'custom-post-type-ui' ),
75
 
76
  <?php
77
 
78
+ $post_type_table_heads = [
79
+ esc_html__( 'Post Type', 'custom-post-type-ui' ),
80
+ esc_html__( 'Settings', 'custom-post-type-ui' ),
81
+ esc_html__( 'Supports', 'custom-post-type-ui' ),
82
+ esc_html__( 'Taxonomies', 'custom-post-type-ui' ),
83
+ esc_html__( 'Labels', 'custom-post-type-ui' ),
84
+ esc_html__( 'Template Hierarchy', 'custom-post-type-ui' ),
85
+ ];
86
 
87
  /**
88
  * Fires before the listing of registered post type data.
97
  <?php
98
  foreach ( $post_type_table_heads as $head ) {
99
  echo '<th>' . esc_html( $head ) . '</th>';
100
+ }
101
+ ?>
102
  </tr>
103
  </thead>
104
  <tbody>
108
 
109
  $rowclass = ( 0 === $counter % 2 ) ? '' : 'alternate';
110
 
111
+ $strings = [];
112
+ $supports = [];
113
+ $taxonomies = [];
114
+ $archive = '';
115
  foreach ( $post_type_settings as $settings_key => $settings_value ) {
116
  if ( 'labels' === $settings_key ) {
117
  continue;
139
  <tr class="<?php echo esc_attr( $rowclass ); ?>">
140
  <?php
141
  $edit_path = 'admin.php?page=cptui_manage_post_types&action=edit&cptui_post_type=' . $post_type;
142
+ $post_type_link_url = is_network_admin() ? network_admin_url( $edit_path ) : admin_url( $edit_path );
143
+ ?>
144
  <td>
145
  <?php
146
  printf(
149
  esc_attr( $post_type_link_url ),
150
  sprintf(
151
  /* translators: %s: Post type slug */
152
+ esc_html__( 'Edit %1$s (%2$s)', 'custom-post-type-ui' ),
153
+ esc_html( $post_type_settings['label'] ),
154
  esc_html( $post_type )
155
  ),
156
  esc_attr( admin_url( 'admin.php?page=cptui_tools&action=get_code#' . $post_type ) ),
166
  <?php
167
  foreach ( $strings as $key => $value ) {
168
  printf( '<strong>%s:</strong> ', esc_html( $key ) );
169
+ if ( in_array( $value, [ '1', '0' ], true ) ) {
170
  echo esc_html( disp_boolean( $value ) );
171
  } else {
172
+ echo ! empty( $value ) ? esc_html( $value ) : '""';
173
  }
174
  echo '<br/>';
175
+ }
176
+ ?>
177
  </td>
178
  <td>
179
  <?php
180
  foreach ( $supports['supports'] as $support ) {
181
  echo esc_html( $support ) . '<br/>';
182
+ }
183
+ ?>
184
  </td>
185
  <td>
186
  <?php
205
  continue;
206
  }
207
  printf(
208
+ '<strong>%s</strong>: %s<br/>',
209
  esc_html( $key ),
210
  esc_html( $value )
211
  );
237
  <?php esc_html_e( '*Replace "post_slug" with the slug of the actual post slug.', 'custom-post-type-ui' ); ?>
238
  </p>
239
 
240
+ <p>
241
+ <?php
242
  printf(
243
  '<a href="https://developer.wordpress.org/themes/basics/template-hierarchy/">%s</a>',
244
  esc_html__( 'Template hierarchy Theme Handbook', 'custom-post-type-ui' )
245
+ );
246
+ ?>
247
  </p>
248
  </td>
249
  </tr>
258
  <?php
259
  foreach ( $post_type_table_heads as $head ) {
260
  echo '<th>' . esc_html( $head ) . '</th>';
261
+ }
262
+ ?>
263
  </tr>
264
  </tfoot>
265
  </table>
296
 
297
  <?php
298
 
299
+ $taxonomy_table_heads = [
300
+ esc_html__( 'Taxonomy', 'custom-post-type-ui' ),
301
+ esc_html__( 'Settings', 'custom-post-type-ui' ),
302
+ esc_html__( 'Post Types', 'custom-post-type-ui' ),
303
+ esc_html__( 'Labels', 'custom-post-type-ui' ),
304
+ esc_html__( 'Template Hierarchy', 'custom-post-type-ui' ),
305
+ ];
306
 
307
  /**
308
  * Fires before the listing of registered taxonomy data.
317
  <?php
318
  foreach ( $taxonomy_table_heads as $head ) {
319
  echo '<th>' . esc_html( $head ) . '</th>';
320
+ }
321
+ ?>
322
  </tr>
323
  </thead>
324
  <tbody>
328
 
329
  $rowclass = ( 0 === $counter % 2 ) ? '' : 'alternate';
330
 
331
+ $strings = [];
332
+ $object_types = [];
333
  foreach ( $taxonomy_settings as $settings_key => $settings_value ) {
334
  if ( 'labels' === $settings_key ) {
335
  continue;
343
 
344
  // In case they are not associated from the post type settings.
345
  if ( empty( $object_types['object_types'] ) ) {
346
+ $types = get_taxonomy( $taxonomy );
347
  $object_types['object_types'] = $types->object_type;
348
  }
349
  }
352
  ?>
353
  <tr class="<?php echo esc_attr( $rowclass ); ?>">
354
  <?php
355
+ $edit_path = 'admin.php?page=cptui_manage_taxonomies&action=edit&cptui_taxonomy=' . $taxonomy;
356
+ $taxonomy_link_url = is_network_admin() ? network_admin_url( $edit_path ) : admin_url( $edit_path );
357
+ ?>
358
  <td>
359
+ <?php
360
+ printf(
361
  '<a href="%s">%s</a><br/>
362
  <a href="%s">%s</a>',
363
  esc_attr( $taxonomy_link_url ),
364
  sprintf(
365
  /* translators: %s: Taxonomy slug */
366
+ esc_html__( 'Edit %1$s (%2$s)', 'custom-post-type-ui' ),
367
+ esc_html( $taxonomy_settings['label'] ),
368
  esc_html( $taxonomy )
369
  ),
370
  esc_attr( admin_url( 'admin.php?page=cptui_tools&action=get_code#' . $taxonomy ) ),
371
  esc_html__( 'Get code', 'custom-post-type-ui' )
372
+ );
373
+ ?>
374
  </td>
375
  <td>
376
  <?php
377
  foreach ( $strings as $key => $value ) {
378
  printf( '<strong>%s:</strong> ', esc_html( $key ) );
379
+ if ( in_array( $value, [ '1', '0' ], true ) ) {
380
  echo esc_html( disp_boolean( $value ) );
381
  } else {
382
+ echo ! empty( $value ) ? esc_html( $value ) : '""';
383
  }
384
  echo '<br/>';
385
+ }
386
+ ?>
387
  </td>
388
  <td>
389
  <?php
391
  foreach ( $object_types['object_types'] as $type ) {
392
  echo esc_html( $type ) . '<br/>';
393
  }
394
+ }
395
+ ?>
396
  </td>
397
  <td>
398
  <?php
400
  if ( ! empty( $maybe_empty ) ) {
401
  foreach ( $taxonomy_settings['labels'] as $key => $value ) {
402
  printf(
403
+ '<strong>%s</strong>: %s<br/>',
404
  esc_html( $key ),
405
  esc_html( $value )
406
  );
425
  <p>
426
  <?php esc_html_e( '*Replace "term_slug" with the slug of the actual taxonomy term.', 'custom-post-type-ui' ); ?>
427
  </p>
428
+ <p>
429
+ <?php
430
  printf(
431
  '<a href="https://developer.wordpress.org/themes/basics/template-hierarchy/">%s</a>',
432
  esc_html__( 'Template hierarchy Theme Handbook', 'custom-post-type-ui' )
433
+ );
434
+ ?>
435
+ </p>
436
  </td>
437
  </tr>
438
 
446
  <?php
447
  foreach ( $taxonomy_table_heads as $head ) {
448
  echo '<th>' . esc_html( $head ) . '</th>';
449
+ }
450
+ ?>
451
  </tr>
452
  </tfoot>
453
  </table>
inc/post-types.php CHANGED
@@ -9,6 +9,8 @@
9
  * @license GPL-2.0+
10
  */
11
 
 
 
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
@@ -37,16 +39,16 @@ function cptui_post_type_enqueue_scripts() {
37
  wp_enqueue_script( 'cptui' );
38
  wp_enqueue_style( 'cptui-css' );
39
 
40
- $core = get_post_types( array( '_builtin' => true ) );
41
- $public = get_post_types( array( '_builtin' => false, 'public' => true ) );
42
- $private = get_post_types( array( '_builtin' => false, 'public' => false ) );
43
  $registered_post_types = array_merge( $core, $public, $private );
44
 
45
  wp_localize_script( 'cptui', 'cptui_type_data',
46
- array(
47
- 'confirm' => esc_html__( 'Are you sure you want to delete this? Deleting will NOT remove created content.', 'custom-post-type-ui' ),
48
  'existing_post_types' => $registered_post_types,
49
- )
50
  );
51
  }
52
  add_action( 'admin_enqueue_scripts', 'cptui_post_type_enqueue_scripts' );
@@ -62,25 +64,25 @@ add_action( 'admin_enqueue_scripts', 'cptui_post_type_enqueue_scripts' );
62
  * @param string $current_page Current page being shown. Optional. Default empty string.
63
  * @return array Amended array of tabs to show.
64
  */
65
- function cptui_post_type_tabs( $tabs = array(), $current_page = '' ) {
66
 
67
  if ( 'post_types' === $current_page ) {
68
  $post_types = cptui_get_post_type_data();
69
- $classes = array( 'nav-tab' );
70
 
71
  $tabs['page_title'] = get_admin_page_title();
72
- $tabs['tabs'] = array();
73
  // Start out with our basic "Add new" tab.
74
- $tabs['tabs']['add'] = array(
75
  'text' => __( 'Add New Post Type', 'custom-post-type-ui' ),
76
  'classes' => $classes,
77
  'url' => cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ),
78
  'aria-selected' => 'false',
79
- );
80
 
81
  $action = cptui_get_current_action();
82
  if ( empty( $action ) ) {
83
- $tabs['tabs']['add']['classes'][] = 'nav-tab-active';
84
  $tabs['tabs']['add']['aria-selected'] = 'true';
85
  }
86
 
@@ -89,26 +91,26 @@ function cptui_post_type_tabs( $tabs = array(), $current_page = '' ) {
89
  if ( ! empty( $action ) ) {
90
  $classes[] = 'nav-tab-active';
91
  }
92
- $tabs['tabs']['edit'] = array(
93
  'text' => __( 'Edit Post Types', 'custom-post-type-ui' ),
94
  'classes' => $classes,
95
- 'url' => esc_url( add_query_arg( array( 'action' => 'edit' ), cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ) ) ),
96
- 'aria-selected' => ( ! empty( $action ) ) ? 'true' : 'false',
97
- );
98
 
99
- $tabs['tabs']['view'] = array(
100
  'text' => __( 'View Post Types', 'custom-post-type-ui' ),
101
- 'classes' => array( 'nav-tab' ), // Prevent notices.
102
  'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_listings#post-types' ) ),
103
  'aria-selected' => 'false',
104
- );
105
 
106
- $tabs['tabs']['export'] = array(
107
  'text' => __( 'Import/Export Post Types', 'custom-post-type-ui' ),
108
- 'classes' => array( 'nav-tab' ), // Prevent notices.
109
  'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_tools' ) ),
110
  'aria-selected' => 'false',
111
- );
112
  }
113
  }
114
 
@@ -164,10 +166,8 @@ function cptui_manage_post_types() {
164
 
165
  $selected_post_type = cptui_get_current_post_type( $post_type_deleted );
166
 
167
- if ( $selected_post_type ) {
168
- if ( array_key_exists( $selected_post_type, $post_types ) ) {
169
- $current = $post_types[ $selected_post_type ];
170
- }
171
  }
172
  }
173
 
@@ -230,16 +230,16 @@ function cptui_manage_post_types() {
230
 
231
  echo $ui->get_th_end() . $ui->get_td_start();
232
 
233
- echo $ui->get_text_input( array(
234
- 'namearray' => 'cpt_custom_post_type',
235
- 'name' => 'name',
236
- 'textvalue' => ( isset( $current['name'] ) ) ? esc_attr( $current['name'] ) : '',
237
- 'maxlength' => '20',
238
- 'helptext' => esc_html__( 'The post type name/slug. Used for various queries for post type content.', 'custom-post-type-ui' ),
239
- 'required' => true,
240
- 'placeholder' => false,
241
- 'wrap' => false,
242
- ) );
243
  echo '<p class="cptui-slug-details">';
244
  esc_html_e( 'Slugs should only contain alphanumeric, latin characters. Underscores should be used in place of spaces. Set "Custom Rewrite Slug" field to make slug use dashes for URLs.', 'custom-post-type-ui' );
245
  echo '</p>';
@@ -250,7 +250,7 @@ function cptui_manage_post_types() {
250
  echo '</p>';
251
 
252
  echo '<div class="cptui-spacer">';
253
- echo $ui->get_check_input( array(
254
  'checkvalue' => 'update_post_types',
255
  'checked' => 'false',
256
  'name' => 'update_post_types',
@@ -259,33 +259,45 @@ function cptui_manage_post_types() {
259
  'helptext' => false,
260
  'default' => false,
261
  'wrap' => false,
262
- ) );
263
  echo '</div>';
264
  }
265
 
266
  echo $ui->get_td_end(); echo $ui->get_tr_end();
267
 
268
- echo $ui->get_text_input( array(
269
  'namearray' => 'cpt_custom_post_type',
270
  'name' => 'label',
271
- 'textvalue' => ( isset( $current['label'] ) ) ? esc_attr( $current['label'] ) : '',
272
  'labeltext' => esc_html__( 'Plural Label', 'custom-post-type-ui' ),
273
  'aftertext' => esc_html__( '(e.g. Movies)', 'custom-post-type-ui' ),
274
  'helptext' => esc_html__( 'Used for the post type admin menu item.', 'custom-post-type-ui' ),
275
  'required' => true,
276
- ) );
277
 
278
- echo $ui->get_text_input( array(
279
  'namearray' => 'cpt_custom_post_type',
280
  'name' => 'singular_label',
281
- 'textvalue' => ( isset( $current['singular_label'] ) ) ? esc_attr( $current['singular_label'] ) : '',
282
  'labeltext' => esc_html__( 'Singular Label', 'custom-post-type-ui' ),
283
  'aftertext' => esc_html__( '(e.g. Movie)', 'custom-post-type-ui' ),
284
  'helptext' => esc_html__( 'Used when a singular label is needed.', 'custom-post-type-ui' ),
285
  'required' => true,
286
- ) );
287
- ?>
288
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
289
  <p class="submit">
290
  <?php wp_nonce_field( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
291
  if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) { ?>
@@ -335,7 +347,7 @@ function cptui_manage_post_types() {
335
  </div>
336
  </div>
337
  </div>
338
- <div class="cptui-section postbox">
339
  <button type="button" class="handlediv button-link" aria-expanded="true">
340
  <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Additional labels', 'custom-post-type-ui' ); ?></span>
341
  <span class="toggle-indicator" aria-hidden="true"></span>
@@ -351,239 +363,429 @@ function cptui_manage_post_types() {
351
  if ( isset( $current['description'] ) ) {
352
  $current['description'] = stripslashes_deep( $current['description'] );
353
  }
354
- echo $ui->get_textarea_input( array(
355
  'namearray' => 'cpt_custom_post_type',
356
  'name' => 'description',
357
  'rows' => '4',
358
  'cols' => '40',
359
- 'textvalue' => ( isset( $current['description'] ) ) ? esc_textarea( $current['description'] ) : '',
360
  'labeltext' => esc_html__( 'Post Type Description', 'custom-post-type-ui' ),
361
  'helptext' => esc_html__( 'Perhaps describe what your custom post type is used for?', 'custom-post-type-ui' ),
362
- ) );
363
 
364
- echo $ui->get_text_input( array(
365
  'labeltext' => esc_html__( 'Menu Name', 'custom-post-type-ui' ),
366
  'helptext' => esc_html__( 'Custom admin menu name for your custom post type.', 'custom-post-type-ui' ),
367
  'namearray' => 'cpt_labels',
368
  'name' => 'menu_name',
369
- 'textvalue' => ( isset( $current['labels']['menu_name'] ) ) ? esc_attr( $current['labels']['menu_name'] ) : '',
370
  'aftertext' => esc_html__( '(e.g. My Movies)', 'custom-post-type-ui' ),
371
- ) );
372
-
373
- echo $ui->get_text_input( array(
 
 
 
 
 
374
  'labeltext' => esc_html__( 'All Items', 'custom-post-type-ui' ),
375
  'helptext' => esc_html__( 'Used in the post type admin submenu.', 'custom-post-type-ui' ),
376
  'namearray' => 'cpt_labels',
377
  'name' => 'all_items',
378
- 'textvalue' => ( isset( $current['labels']['all_items'] ) ) ? esc_attr( $current['labels']['all_items'] ) : '',
379
  'aftertext' => esc_html__( '(e.g. All Movies)', 'custom-post-type-ui' ),
380
- ) );
381
-
382
- echo $ui->get_text_input( array(
 
 
 
 
 
383
  'labeltext' => esc_html__( 'Add New', 'custom-post-type-ui' ),
384
  'helptext' => esc_html__( 'Used in the post type admin submenu.', 'custom-post-type-ui' ),
385
  'namearray' => 'cpt_labels',
386
  'name' => 'add_new',
387
- 'textvalue' => ( isset( $current['labels']['add_new'] ) ) ? esc_attr( $current['labels']['add_new'] ) : '',
388
  'aftertext' => esc_html__( '(e.g. Add New)', 'custom-post-type-ui' ),
389
- ) );
390
-
391
- echo $ui->get_text_input( array(
 
 
 
 
 
392
  'labeltext' => esc_html__( 'Add New Item', 'custom-post-type-ui' ),
393
  'helptext' => esc_html__( 'Used at the top of the post editor screen for a new post type post.', 'custom-post-type-ui' ),
394
  'namearray' => 'cpt_labels',
395
  'name' => 'add_new_item',
396
- 'textvalue' => ( isset( $current['labels']['add_new_item'] ) ) ? esc_attr( $current['labels']['add_new_item'] ) : '',
397
  'aftertext' => esc_html__( '(e.g. Add New Movie)', 'custom-post-type-ui' ),
398
- ) );
399
-
400
- echo $ui->get_text_input( array(
 
 
 
 
 
401
  'labeltext' => esc_html__( 'Edit Item', 'custom-post-type-ui' ),
402
  'helptext' => esc_html__( 'Used at the top of the post editor screen for an existing post type post.', 'custom-post-type-ui' ),
403
  'namearray' => 'cpt_labels',
404
  'name' => 'edit_item',
405
- 'textvalue' => ( isset( $current['labels']['edit_item'] ) ) ? esc_attr( $current['labels']['edit_item'] ) : '',
406
  'aftertext' => esc_html__( '(e.g. Edit Movie)', 'custom-post-type-ui' ),
407
- ) );
408
-
409
- echo $ui->get_text_input( array(
 
 
 
 
 
410
  'labeltext' => esc_html__( 'New Item', 'custom-post-type-ui' ),
411
  'helptext' => esc_html__( 'Post type label. Used in the admin menu for displaying post types.', 'custom-post-type-ui' ),
412
  'namearray' => 'cpt_labels',
413
  'name' => 'new_item',
414
- 'textvalue' => ( isset( $current['labels']['new_item'] ) ) ? esc_attr( $current['labels']['new_item'] ) : '',
415
  'aftertext' => esc_html__( '(e.g. New Movie)', 'custom-post-type-ui' ),
416
- ) );
417
-
418
- echo $ui->get_text_input( array(
 
 
 
 
 
419
  'labeltext' => esc_html__( 'View Item', 'custom-post-type-ui' ),
420
  'helptext' => esc_html__( 'Used in the admin bar when viewing editor screen for a published post in the post type.', 'custom-post-type-ui' ),
421
  'namearray' => 'cpt_labels',
422
  'name' => 'view_item',
423
- 'textvalue' => ( isset( $current['labels']['view_item'] ) ) ? esc_attr( $current['labels']['view_item'] ) : '',
424
  'aftertext' => esc_html__( '(e.g. View Movie)', 'custom-post-type-ui' ),
425
- ) );
426
-
427
- echo $ui->get_text_input( array(
 
 
 
 
 
428
  'labeltext' => esc_html__( 'View Items', 'custom-post-type-ui' ),
429
  'helptext' => esc_html__( 'Used in the admin bar when viewing editor screen for a published post in the post type.', 'custom-post-type-ui' ),
430
  'namearray' => 'cpt_labels',
431
  'name' => 'view_items',
432
- 'textvalue' => ( isset( $current['labels']['view_items'] ) ) ? esc_attr( $current['labels']['view_items'] ) : '',
433
  'aftertext' => esc_html__( '(e.g. View Movies)', 'custom-post-type-ui' ),
434
- ) );
435
-
436
- echo $ui->get_text_input( array(
 
 
 
 
 
437
  'labeltext' => esc_html__( 'Search Item', 'custom-post-type-ui' ),
438
  'helptext' => esc_html__( 'Used as the text for the search button on post type list screen.', 'custom-post-type-ui' ),
439
  'namearray' => 'cpt_labels',
440
  'name' => 'search_items',
441
- 'textvalue' => ( isset( $current['labels']['search_items'] ) ) ? esc_attr( $current['labels']['search_items'] ) : '',
442
- 'aftertext' => esc_html__( '(e.g. Search Movie)', 'custom-post-type-ui' ),
443
- ) );
444
-
445
- echo $ui->get_text_input( array(
 
 
 
 
 
446
  'labeltext' => esc_html__( 'Not Found', 'custom-post-type-ui' ),
447
  'helptext' => esc_html__( 'Used when there are no posts to display on the post type list screen.', 'custom-post-type-ui' ),
448
  'namearray' => 'cpt_labels',
449
  'name' => 'not_found',
450
- 'textvalue' => ( isset( $current['labels']['not_found'] ) ) ? esc_attr( $current['labels']['not_found'] ) : '',
451
  'aftertext' => esc_html__( '(e.g. No Movies found)', 'custom-post-type-ui' ),
452
- ) );
453
-
454
- echo $ui->get_text_input( array(
 
 
 
 
 
455
  'labeltext' => esc_html__( 'Not Found in Trash', 'custom-post-type-ui' ),
456
  'helptext' => esc_html__( 'Used when there are no posts to display on the post type list trash screen.', 'custom-post-type-ui' ),
457
  'namearray' => 'cpt_labels',
458
  'name' => 'not_found_in_trash',
459
- 'textvalue' => ( isset( $current['labels']['not_found_in_trash'] ) ) ? esc_attr( $current['labels']['not_found_in_trash'] ) : '',
460
  'aftertext' => esc_html__( '(e.g. No Movies found in Trash)', 'custom-post-type-ui' ),
461
- ) );
 
 
 
 
 
462
 
463
  // As of 1.4.0, this will register into `parent_item_colon` paramter upon registration and export.
464
- echo $ui->get_text_input( array(
465
  'labeltext' => esc_html__( 'Parent', 'custom-post-type-ui' ),
466
  'helptext' => esc_html__( 'Used for hierarchical types that need a colon.', 'custom-post-type-ui' ),
467
  'namearray' => 'cpt_labels',
468
  'name' => 'parent',
469
- 'textvalue' => ( isset( $current['labels']['parent'] ) ) ? esc_attr( $current['labels']['parent'] ) : '',
470
  'aftertext' => esc_html__( '(e.g. Parent Movie:)', 'custom-post-type-ui' ),
471
- ) );
472
-
473
- echo $ui->get_text_input( array(
 
 
 
 
 
474
  'labeltext' => esc_html__( 'Featured Image', 'custom-post-type-ui' ),
475
  'helptext' => esc_html__( 'Used as the "Featured Image" phrase for the post type.', 'custom-post-type-ui' ),
476
  'namearray' => 'cpt_labels',
477
  'name' => 'featured_image',
478
- 'textvalue' => ( isset( $current['labels']['featured_image'] ) ) ? esc_attr( $current['labels']['featured_image'] ) : '',
479
  'aftertext' => esc_html__( '(e.g. Featured image for this movie)', 'custom-post-type-ui' ),
480
- ) );
481
-
482
- echo $ui->get_text_input( array(
 
 
 
 
 
483
  'labeltext' => esc_html__( 'Set Featured Image', 'custom-post-type-ui' ),
484
  'helptext' => esc_html__( 'Used as the "Set featured image" phrase for the post type.', 'custom-post-type-ui' ),
485
  'namearray' => 'cpt_labels',
486
  'name' => 'set_featured_image',
487
- 'textvalue' => ( isset( $current['labels']['set_featured_image'] ) ) ? esc_attr( $current['labels']['set_featured_image'] ) : '',
488
  'aftertext' => esc_html__( '(e.g. Set featured image for this movie)', 'custom-post-type-ui' ),
489
- ) );
490
-
491
- echo $ui->get_text_input( array(
 
 
 
 
 
492
  'labeltext' => esc_html__( 'Remove Featured Image', 'custom-post-type-ui' ),
493
  'helptext' => esc_html__( 'Used as the "Remove featured image" phrase for the post type.', 'custom-post-type-ui' ),
494
  'namearray' => 'cpt_labels',
495
  'name' => 'remove_featured_image',
496
- 'textvalue' => ( isset( $current['labels']['remove_featured_image'] ) ) ? esc_attr( $current['labels']['remove_featured_image'] ) : '',
497
  'aftertext' => esc_html__( '(e.g. Remove featured image for this movie)', 'custom-post-type-ui' ),
498
- ) );
499
-
500
- echo $ui->get_text_input( array(
 
 
 
 
 
501
  'labeltext' => esc_html__( 'Use Featured Image', 'custom-post-type-ui' ),
502
  'helptext' => esc_html__( 'Used as the "Use as featured image" phrase for the post type.', 'custom-post-type-ui' ),
503
  'namearray' => 'cpt_labels',
504
  'name' => 'use_featured_image',
505
- 'textvalue' => ( isset( $current['labels']['use_featured_image'] ) ) ? esc_attr( $current['labels']['use_featured_image'] ) : '',
506
  'aftertext' => esc_html__( '(e.g. Use as featured image for this movie)', 'custom-post-type-ui' ),
507
- ) );
508
-
509
- echo $ui->get_text_input( array(
 
 
 
 
 
510
  'labeltext' => esc_html__( 'Archives', 'custom-post-type-ui' ),
511
  'helptext' => esc_html__( 'Post type archive label used in nav menus.', 'custom-post-type-ui' ),
512
  'namearray' => 'cpt_labels',
513
  'name' => 'archives',
514
- 'textvalue' => ( isset( $current['labels']['archives'] ) ) ? esc_attr( $current['labels']['archives'] ) : '',
515
  'aftertext' => esc_html__( '(e.g. Movie archives)', 'custom-post-type-ui' ),
516
- ) );
517
-
518
- echo $ui->get_text_input( array(
 
 
 
 
 
519
  'labeltext' => esc_html__( 'Insert into item', 'custom-post-type-ui' ),
520
  'helptext' => esc_html__( 'Used as the "Insert into post" or "Insert into page" phrase for the post type.', 'custom-post-type-ui' ),
521
  'namearray' => 'cpt_labels',
522
  'name' => 'insert_into_item',
523
- 'textvalue' => ( isset( $current['labels']['insert_into_item'] ) ) ? esc_attr( $current['labels']['insert_into_item'] ) : '',
524
  'aftertext' => esc_html__( '(e.g. Insert into movie)', 'custom-post-type-ui' ),
525
- ) );
526
-
527
- echo $ui->get_text_input( array(
 
 
 
 
 
528
  'labeltext' => esc_html__( 'Uploaded to this Item', 'custom-post-type-ui' ),
529
  'helptext' => esc_html__( 'Used as the "Uploaded to this post" or "Uploaded to this page" phrase for the post type.', 'custom-post-type-ui' ),
530
  'namearray' => 'cpt_labels',
531
  'name' => 'uploaded_to_this_item',
532
- 'textvalue' => ( isset( $current['labels']['uploaded_to_this_item'] ) ) ? esc_attr( $current['labels']['uploaded_to_this_item'] ) : '',
533
  'aftertext' => esc_html__( '(e.g. Uploaded to this movie)', 'custom-post-type-ui' ),
534
- ) );
535
-
536
- echo $ui->get_text_input( array(
 
 
 
 
 
537
  'labeltext' => esc_html__( 'Filter Items List', 'custom-post-type-ui' ),
538
  'helptext' => esc_html__( 'Screen reader text for the filter links heading on the post type listing screen.', 'custom-post-type-ui' ),
539
  'namearray' => 'cpt_labels',
540
  'name' => 'filter_items_list',
541
- 'textvalue' => ( isset( $current['labels']['filter_items_list'] ) ) ? esc_attr( $current['labels']['filter_items_list'] ) : '',
542
  'aftertext' => esc_html__( '(e.g. Filter movies list)', 'custom-post-type-ui' ),
543
- ) );
544
-
545
- echo $ui->get_text_input( array(
 
 
 
 
 
546
  'labeltext' => esc_html__( 'Items List Navigation', 'custom-post-type-ui' ),
547
  'helptext' => esc_html__( 'Screen reader text for the pagination heading on the post type listing screen.', 'custom-post-type-ui' ),
548
  'namearray' => 'cpt_labels',
549
  'name' => 'items_list_navigation',
550
- 'textvalue' => ( isset( $current['labels']['items_list_navigation'] ) ) ? esc_attr( $current['labels']['items_list_navigation'] ) : '',
551
  'aftertext' => esc_html__( '(e.g. Movies list navigation)', 'custom-post-type-ui' ),
552
- ) );
553
-
554
- echo $ui->get_text_input( array(
 
 
 
 
 
555
  'labeltext' => esc_html__( 'Items List', 'custom-post-type-ui' ),
556
  'helptext' => esc_html__( 'Screen reader text for the items list heading on the post type listing screen.', 'custom-post-type-ui' ),
557
  'namearray' => 'cpt_labels',
558
  'name' => 'items_list',
559
- 'textvalue' => ( isset( $current['labels']['items_list'] ) ) ? esc_attr( $current['labels']['items_list'] ) : '',
560
  'aftertext' => esc_html__( '(e.g. Movies list)', 'custom-post-type-ui' ),
561
- ) );
562
-
563
- echo $ui->get_text_input( array(
 
 
 
 
 
564
  'labeltext' => esc_html__( 'Attributes', 'custom-post-type-ui' ),
565
  'helptext' => esc_html__( 'Used for the title of the post attributes meta box.', 'custom-post-type-ui' ),
566
  'namearray' => 'cpt_labels',
567
  'name' => 'attributes',
568
- 'textvalue' => ( isset( $current['labels']['attributes'] ) ) ? esc_attr( $current['labels']['attributes'] ) : '',
569
  'aftertext' => esc_html__( '(e.g. Movies Attributes)', 'custom-post-type-ui' ),
570
- ) );
571
-
572
- echo $ui->get_text_input( array(
 
 
 
 
 
573
  'labeltext' => esc_html__( '"New" menu in admin bar', 'custom-post-type-ui' ),
574
  'helptext' => esc_html__( 'Used in New in Admin menu bar. Default "singular name" label.', 'custom-post-type-ui' ),
575
  'namearray' => 'cpt_labels',
576
  'name' => 'name_admin_bar',
577
- 'textvalue' => ( isset( $current['labels']['name_admin_bar'] ) ) ? esc_attr( $current['labels']['name_admin_bar'] ) : '',
578
  'aftertext' => esc_html__( '(e.g. Movie)', 'custom-post-type-ui' ),
579
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
580
 
581
  ?>
582
  </table>
583
  </div>
584
  </div>
585
  </div>
586
- <div class="cptui-section postbox">
587
  <button type="button" class="handlediv button-link" aria-expanded="true">
588
  <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Settings', 'custom-post-type-ui' ); ?></span>
589
  <span class="toggle-indicator" aria-hidden="true"></span>
@@ -595,240 +797,256 @@ function cptui_manage_post_types() {
595
  <div class="main">
596
  <table class="form-table cptui-table">
597
  <?php
598
- $select = array(
599
- 'options' => array(
600
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
601
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
602
- ),
603
- );
604
- $selected = ( isset( $current ) ) ? disp_boolean( $current['public'] ) : '';
605
- $select['selected'] = ( ! empty( $selected ) ) ? $current['public'] : '';
606
- echo $ui->get_select_input( array(
607
  'namearray' => 'cpt_custom_post_type',
608
  'name' => 'public',
609
  'labeltext' => esc_html__( 'Public', 'custom-post-type-ui' ),
610
  'aftertext' => esc_html__( '(Custom Post Type UI default: true) Whether or not posts of this type should be shown in the admin UI and is publicly queryable.', 'custom-post-type-ui' ),
611
  'selections' => $select,
612
- ) );
613
-
614
- $select = array(
615
- 'options' => array(
616
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
617
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
618
- ),
619
- );
620
- $selected = ( isset( $current ) && ! empty( $current['publicly_queryable'] ) ) ? disp_boolean( $current['publicly_queryable'] ) : '';
621
- $select['selected'] = ( ! empty( $selected ) ) ? $current['publicly_queryable'] : '';
622
- echo $ui->get_select_input( array(
623
  'namearray' => 'cpt_custom_post_type',
624
  'name' => 'publicly_queryable',
625
  'labeltext' => esc_html__( 'Publicly Queryable', 'custom-post-type-ui' ),
626
  'aftertext' => esc_html__( '(default: true) Whether or not queries can be performed on the front end as part of parse_request()', 'custom-post-type-ui' ),
627
  'selections' => $select,
628
- ) );
629
-
630
- $select = array(
631
- 'options' => array(
632
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
633
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
634
- ),
635
- );
636
- $selected = ( isset( $current ) ) ? disp_boolean( $current['show_ui'] ) : '';
637
- $select['selected'] = ( ! empty( $selected ) ) ? $current['show_ui'] : '';
638
- echo $ui->get_select_input( array(
639
  'namearray' => 'cpt_custom_post_type',
640
  'name' => 'show_ui',
641
  'labeltext' => esc_html__( 'Show UI', 'custom-post-type-ui' ),
642
  'aftertext' => esc_html__( '(default: true) Whether or not to generate a default UI for managing this post type.', 'custom-post-type-ui' ),
643
  'selections' => $select,
644
- ) );
645
-
646
- $select = array(
647
- 'options' => array(
648
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
649
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
650
- ),
651
- );
652
- $selected = ( isset( $current ) && ! empty( $current['show_in_nav_menus'] ) ) ? disp_boolean( $current['show_in_nav_menus'] ) : '';
653
  $select['selected'] = ( ! empty( $selected ) && ! empty( $current['show_in_nav_menus'] ) ) ? $current['show_in_nav_menus'] : '';
654
- echo $ui->get_select_input( array(
655
  'namearray' => 'cpt_custom_post_type',
656
  'name' => 'show_in_nav_menus',
657
  'labeltext' => esc_html__( 'Show in Nav Menus', 'custom-post-type-ui' ),
658
  'aftertext' => esc_html__( '(Custom Post Type UI default: true) Whether or not this post type is available for selection in navigation menus.', 'custom-post-type-ui' ),
659
  'selections' => $select,
660
- ) );
661
-
662
- $select = array(
663
- 'options' => array(
664
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
665
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
666
- ),
667
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
668
  $selected = ( isset( $current ) && ! empty( $current['show_in_rest'] ) ) ? disp_boolean( $current['show_in_rest'] ) : '';
669
  $select['selected'] = ( ! empty( $selected ) && ! empty( $current['show_in_rest'] ) ) ? $current['show_in_rest'] : '';
670
- echo $ui->get_select_input( array(
671
  'namearray' => 'cpt_custom_post_type',
672
  'name' => 'show_in_rest',
673
  'labeltext' => esc_html__( 'Show in REST API', 'custom-post-type-ui' ),
674
  'aftertext' => esc_html__( '(Custom Post Type UI default: true) Whether or not to show this post type data in the WP REST API.', 'custom-post-type-ui' ),
675
  'selections' => $select,
676
- ) );
677
 
678
- echo $ui->get_text_input( array(
679
  'namearray' => 'cpt_custom_post_type',
680
  'name' => 'rest_base',
681
  'labeltext' => esc_html__( 'REST API base slug', 'custom-post-type-ui' ),
682
  'aftertext' => esc_attr__( 'Slug to use in REST API URLs.', 'custom-post-type-ui' ),
683
- 'textvalue' => ( isset( $current['rest_base'] ) ) ? esc_attr( $current['rest_base'] ) : '',
684
- ) );
685
 
686
- echo $ui->get_text_input( array(
687
  'namearray' => 'cpt_custom_post_type',
688
  'name' => 'rest_controller_class',
689
  'labeltext' => esc_html__( 'REST API controller class', 'custom-post-type-ui' ),
690
  'aftertext' => esc_attr__( '(default: WP_REST_Posts_Controller) Custom controller to use instead of WP_REST_Posts_Controller.', 'custom-post-type-ui' ),
691
- 'textvalue' => ( isset( $current['rest_controller_class'] ) ) ? esc_attr( $current['rest_controller_class'] ) : '',
692
- ) );
693
 
694
  echo $ui->get_tr_start() . $ui->get_th_start();
695
  echo $ui->get_label( 'has_archive', esc_html__( 'Has Archive', 'custom-post-type-ui' ) );
696
  echo $ui->get_p( esc_html__( 'If left blank, the archive slug will default to the post type slug.', 'custom-post-type-ui' ) );
697
  echo $ui->get_th_end() . $ui->get_td_start();
698
 
699
- $select = array(
700
- 'options' => array(
701
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ), 'default' => 'true' ),
702
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ),
703
- ),
704
- );
705
- $selected = ( isset( $current ) ) ? disp_boolean( $current['has_archive'] ) : '';
706
- $select['selected'] = ( ! empty( $selected ) ) ? $current['has_archive'] : '';
707
- echo $ui->get_select_input( array(
708
  'namearray' => 'cpt_custom_post_type',
709
  'name' => 'has_archive',
710
  'aftertext' => esc_html__( '(default: false) Whether or not the post type will have a post type archive URL.', 'custom-post-type-ui' ),
711
  'selections' => $select,
712
  'wrap' => false,
713
- ) );
714
 
715
  echo '<br/>';
716
 
717
- echo $ui->get_text_input( array(
718
  'namearray' => 'cpt_custom_post_type',
719
  'name' => 'has_archive_string',
720
- 'textvalue' => ( isset( $current['has_archive_string'] ) ) ? esc_attr( $current['has_archive_string'] ) : '',
721
  'aftertext' => esc_attr__( 'Slug to be used for archive URL.', 'custom-post-type-ui' ),
722
  'helptext_after' => true,
723
  'wrap' => false,
724
- ) );
725
  echo $ui->get_td_end() . $ui->get_tr_end();
726
 
727
- $select = array(
728
- 'options' => array(
729
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ), 'default' => 'true' ),
730
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ),
731
- ),
732
- );
733
- $selected = ( isset( $current ) ) ? disp_boolean( $current['exclude_from_search'] ) : '';
734
- $select['selected'] = ( ! empty( $selected ) ) ? $current['exclude_from_search'] : '';
735
- echo $ui->get_select_input( array(
736
  'namearray' => 'cpt_custom_post_type',
737
  'name' => 'exclude_from_search',
738
  'labeltext' => esc_html__( 'Exclude From Search', 'custom-post-type-ui' ),
739
  'aftertext' => esc_html__( '(default: false) Whether or not to exclude posts with this post type from front end search results.', 'custom-post-type-ui' ),
740
  'selections' => $select,
741
- ) );
742
 
743
- echo $ui->get_text_input( array(
744
  'namearray' => 'cpt_custom_post_type',
745
  'name' => 'capability_type',
746
- 'textvalue' => ( isset( $current['capability_type'] ) ) ? esc_attr( $current['capability_type'] ) : 'post',
747
  'labeltext' => esc_html__( 'Capability Type', 'custom-post-type-ui' ),
748
  'helptext' => esc_html__( 'The post type to use for checking read, edit, and delete capabilities. A comma-separated second value can be used for plural version.', 'custom-post-type-ui' ),
749
- ) );
750
-
751
- $select = array(
752
- 'options' => array(
753
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ), 'default' => 'true' ),
754
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ),
755
- ),
756
- );
757
- $selected = ( isset( $current ) ) ? disp_boolean( $current['hierarchical'] ) : '';
758
- $select['selected'] = ( ! empty( $selected ) ) ? $current['hierarchical'] : '';
759
- echo $ui->get_select_input( array(
760
  'namearray' => 'cpt_custom_post_type',
761
  'name' => 'hierarchical',
762
  'labeltext' => esc_html__( 'Hierarchical', 'custom-post-type-ui' ),
763
  'aftertext' => esc_html__( '(default: false) Whether or not the post type can have parent-child relationships.', 'custom-post-type-ui' ),
764
  'selections' => $select,
765
- ) );
766
-
767
- $select = array(
768
- 'options' => array(
769
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
770
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
771
- ),
772
- );
773
- $selected = ( isset( $current ) ) ? disp_boolean( $current['rewrite'] ) : '';
774
- $select['selected'] = ( ! empty( $selected ) ) ? $current['rewrite'] : '';
775
- echo $ui->get_select_input( array(
776
  'namearray' => 'cpt_custom_post_type',
777
  'name' => 'rewrite',
778
  'labeltext' => esc_html__( 'Rewrite', 'custom-post-type-ui' ),
779
  'aftertext' => esc_html__( '(default: true) Whether or not WordPress should use rewrites for this post type.', 'custom-post-type-ui' ),
780
  'selections' => $select,
781
- ) );
782
 
783
- echo $ui->get_text_input( array(
784
  'namearray' => 'cpt_custom_post_type',
785
  'name' => 'rewrite_slug',
786
- 'textvalue' => ( isset( $current['rewrite_slug'] ) ) ? esc_attr( $current['rewrite_slug'] ) : '',
787
  'labeltext' => esc_html__( 'Custom Rewrite Slug', 'custom-post-type-ui' ),
788
  'aftertext' => esc_attr__( '(default: post type slug)', 'custom-post-type-ui' ),
789
  'helptext' => esc_html__( 'Custom post type slug to use instead of the default.', 'custom-post-type-ui' ),
790
- ) );
791
-
792
- $select = array(
793
- 'options' => array(
794
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
795
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
796
- ),
797
- );
798
- $selected = ( isset( $current ) ) ? disp_boolean( $current['rewrite_withfront'] ) : '';
799
- $select['selected'] = ( ! empty( $selected ) ) ? $current['rewrite_withfront'] : '';
800
- echo $ui->get_select_input( array(
801
  'namearray' => 'cpt_custom_post_type',
802
  'name' => 'rewrite_withfront',
803
  'labeltext' => esc_html__( 'With Front', 'custom-post-type-ui' ),
804
  'aftertext' => esc_html__( '(default: true) Should the permalink structure be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/).', 'custom-post-type-ui' ),
805
  'selections' => $select,
806
- ) );
807
-
808
- $select = array(
809
- 'options' => array(
810
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
811
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
812
- ),
813
- );
814
- $selected = ( isset( $current ) ) ? disp_boolean( $current['query_var'] ) : '';
815
- $select['selected'] = ( ! empty( $selected ) ) ? $current['query_var'] : '';
816
- echo $ui->get_select_input( array(
817
  'namearray' => 'cpt_custom_post_type',
818
  'name' => 'query_var',
819
  'labeltext' => esc_html__( 'Query Var', 'custom-post-type-ui' ),
820
  'aftertext' => esc_html__( '(default: true) Sets the query_var key for this post type.', 'custom-post-type-ui' ),
821
  'selections' => $select,
822
- ) );
823
 
824
- echo $ui->get_text_input( array(
825
  'namearray' => 'cpt_custom_post_type',
826
  'name' => 'query_var_slug',
827
- 'textvalue' => ( isset( $current['query_var_slug'] ) ) ? esc_attr( $current['query_var_slug'] ) : '',
828
  'labeltext' => esc_html__( 'Custom Query Var Slug', 'custom-post-type-ui' ),
829
  'aftertext' => esc_attr__( '(default: post type slug) Query var needs to be true to use.', 'custom-post-type-ui' ),
830
  'helptext' => esc_html__( 'Custom query var slug to use instead of the default.', 'custom-post-type-ui' ),
831
- ) );
832
 
833
  echo $ui->get_tr_start() . $ui->get_th_start();
834
  echo $ui->get_label( 'menu_position', esc_html__( 'Menu Position', 'custom-post-type-ui' ) );
@@ -846,13 +1064,13 @@ function cptui_manage_post_types() {
846
  );
847
 
848
  echo $ui->get_th_end() . $ui->get_td_start();
849
- echo $ui->get_text_input( array(
850
  'namearray' => 'cpt_custom_post_type',
851
  'name' => 'menu_position',
852
- 'textvalue' => ( isset( $current['menu_position'] ) ) ? esc_attr( $current['menu_position'] ) : '',
853
  'helptext' => esc_html__( 'The position in the menu order the post type should appear. show_in_menu must be true.', 'custom-post-type-ui' ),
854
  'wrap' => false,
855
- ) );
856
  echo $ui->get_td_end() . $ui->get_tr_end();
857
 
858
  echo $ui->get_tr_start() . $ui->get_th_start();
@@ -860,50 +1078,55 @@ function cptui_manage_post_types() {
860
  echo $ui->get_p( esc_html__( '"Show UI" must be "true". If an existing top level page such as "tools.php" is indicated for second input, post type will be sub menu of that.', 'custom-post-type-ui' ) );
861
  echo $ui->get_th_end() . $ui->get_td_start();
862
 
863
- $select = array(
864
- 'options' => array(
865
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
866
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
867
- ),
868
- );
869
- $selected = ( isset( $current ) ) ? disp_boolean( $current['show_in_menu'] ) : '';
870
- $select['selected'] = ( ! empty( $selected ) ) ? $current['show_in_menu'] : '';
871
- echo $ui->get_select_input( array(
872
  'namearray' => 'cpt_custom_post_type',
873
  'name' => 'show_in_menu',
874
  'aftertext' => esc_html__( '(default: true) Whether or not to show the post type in the admin menu and where to show that menu.', 'custom-post-type-ui' ),
875
  'selections' => $select,
876
  'wrap' => false,
877
- ) );
878
 
879
  echo '<br/>';
880
 
881
- echo $ui->get_text_input( array(
882
  'namearray' => 'cpt_custom_post_type',
883
  'name' => 'show_in_menu_string',
884
- 'textvalue' => ( isset( $current['show_in_menu_string'] ) ) ? esc_attr( $current['show_in_menu_string'] ) : '',
885
  'helptext' => esc_attr__( 'The top-level admin menu page file name for which the post type should be in the sub menu of.', 'custom-post-type-ui' ),
886
  'helptext_after' => true,
887
  'wrap' => false,
888
- ) );
889
  echo $ui->get_td_end() . $ui->get_tr_end();
890
 
891
  echo $ui->get_tr_start() . $ui->get_th_start() . '<label for="menu_icon">' . __( 'Menu Icon', 'custom-post-type-ui' ) . '</label>' . $ui->get_th_end() . $ui->get_td_start();
892
- echo $ui->get_text_input( array(
 
893
  'namearray' => 'cpt_custom_post_type',
894
  'name' => 'menu_icon',
895
- 'textvalue' => ( isset( $current['menu_icon'] ) ) ? esc_attr( $current['menu_icon'] ) : '',
896
  'aftertext' => esc_attr__( '(Full URL for icon or Dashicon class)', 'custom-post-type-ui' ),
897
- 'helptext' => esc_html__( 'Image URL or Dashicon class name to use for icon. Custom image should be 20px by 20px.', 'custom-post-type-ui' ),
 
 
 
 
898
  'wrap' => false,
899
- ) );
900
 
901
  echo '<div class="cptui-spacer">';
902
 
903
- echo $ui->get_button( array(
904
  'id' => 'cptui_choose_icon',
905
  'textvalue' => esc_attr__( 'Choose image icon', 'custom-post-type-ui' ),
906
- ) );
907
  echo '</div>';
908
 
909
  echo $ui->get_td_end() . $ui->get_tr_end();
@@ -916,11 +1139,13 @@ function cptui_manage_post_types() {
916
 
917
  echo $ui->get_th_end() . $ui->get_td_start() . $ui->get_fieldset_start();
918
 
 
 
919
  $title_checked = ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'title', $current['supports'] ) ) ? 'true' : 'false';
920
- if ( 'new' == $tab ) {
921
  $title_checked = 'true';
922
  }
923
- echo $ui->get_check_input( array(
924
  'checkvalue' => 'title',
925
  'checked' => $title_checked,
926
  'name' => 'title',
@@ -929,13 +1154,13 @@ function cptui_manage_post_types() {
929
  'labeltext' => esc_html__( 'Title', 'custom-post-type-ui' ),
930
  'default' => true,
931
  'wrap' => false,
932
- ) );
933
 
934
  $editor_checked = ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'editor', $current['supports'] ) ) ? 'true' : 'false';
935
- if ( 'new' == $tab ) {
936
  $editor_checked = 'true';
937
  }
938
- echo $ui->get_check_input( array(
939
  'checkvalue' => 'editor',
940
  'checked' => $editor_checked,
941
  'name' => 'editor',
@@ -944,13 +1169,13 @@ function cptui_manage_post_types() {
944
  'labeltext' => esc_html__( 'Editor', 'custom-post-type-ui' ),
945
  'default' => true,
946
  'wrap' => false,
947
- ) );
948
 
949
  $thumb_checked = ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'thumbnail', $current['supports'] ) ) ? 'true' : 'false';
950
- if ( 'new' == $tab ) {
951
  $thumb_checked = 'true';
952
  }
953
- echo $ui->get_check_input( array(
954
  'checkvalue' => 'thumbnail',
955
  'checked' => $thumb_checked,
956
  'name' => 'thumbnail',
@@ -959,9 +1184,9 @@ function cptui_manage_post_types() {
959
  'labeltext' => esc_html__( 'Featured Image', 'custom-post-type-ui' ),
960
  'default' => true,
961
  'wrap' => false,
962
- ) );
963
 
964
- echo $ui->get_check_input( array(
965
  'checkvalue' => 'excerpt',
966
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'excerpt', $current['supports'] ) ) ? 'true' : 'false',
967
  'name' => 'excerpts',
@@ -970,9 +1195,9 @@ function cptui_manage_post_types() {
970
  'labeltext' => esc_html__( 'Excerpt', 'custom-post-type-ui' ),
971
  'default' => true,
972
  'wrap' => false,
973
- ) );
974
 
975
- echo $ui->get_check_input( array(
976
  'checkvalue' => 'trackbacks',
977
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'trackbacks', $current['supports'] ) ) ? 'true' : 'false',
978
  'name' => 'trackbacks',
@@ -981,9 +1206,9 @@ function cptui_manage_post_types() {
981
  'labeltext' => esc_html__( 'Trackbacks', 'custom-post-type-ui' ),
982
  'default' => true,
983
  'wrap' => false,
984
- ) );
985
 
986
- echo $ui->get_check_input( array(
987
  'checkvalue' => 'custom-fields',
988
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'custom-fields', $current['supports'] ) ) ? 'true' : 'false',
989
  'name' => 'custom-fields',
@@ -992,9 +1217,9 @@ function cptui_manage_post_types() {
992
  'labeltext' => esc_html__( 'Custom Fields', 'custom-post-type-ui' ),
993
  'default' => true,
994
  'wrap' => false,
995
- ) );
996
 
997
- echo $ui->get_check_input( array(
998
  'checkvalue' => 'comments',
999
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'comments', $current['supports'] ) ) ? 'true' : 'false',
1000
  'name' => 'comments',
@@ -1003,9 +1228,9 @@ function cptui_manage_post_types() {
1003
  'labeltext' => esc_html__( 'Comments', 'custom-post-type-ui' ),
1004
  'default' => true,
1005
  'wrap' => false,
1006
- ) );
1007
 
1008
- echo $ui->get_check_input( array(
1009
  'checkvalue' => 'revisions',
1010
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'revisions', $current['supports'] ) ) ? 'true' : 'false',
1011
  'name' => 'revisions',
@@ -1014,9 +1239,9 @@ function cptui_manage_post_types() {
1014
  'labeltext' => esc_html__( 'Revisions', 'custom-post-type-ui' ),
1015
  'default' => true,
1016
  'wrap' => false,
1017
- ) );
1018
 
1019
- echo $ui->get_check_input( array(
1020
  'checkvalue' => 'author',
1021
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'author', $current['supports'] ) ) ? 'true' : 'false',
1022
  'name' => 'author',
@@ -1025,9 +1250,9 @@ function cptui_manage_post_types() {
1025
  'labeltext' => esc_html__( 'Author', 'custom-post-type-ui' ),
1026
  'default' => true,
1027
  'wrap' => false,
1028
- ) );
1029
 
1030
- echo $ui->get_check_input( array(
1031
  'checkvalue' => 'page-attributes',
1032
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'page-attributes', $current['supports'] ) ) ? 'true' : 'false',
1033
  'name' => 'page-attributes',
@@ -1036,9 +1261,9 @@ function cptui_manage_post_types() {
1036
  'labeltext' => esc_html__( 'Page Attributes', 'custom-post-type-ui' ),
1037
  'default' => true,
1038
  'wrap' => false,
1039
- ) );
1040
 
1041
- echo $ui->get_check_input( array(
1042
  'checkvalue' => 'post-formats',
1043
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'post-formats', $current['supports'] ) ) ? 'true' : 'false',
1044
  'name' => 'post-formats',
@@ -1047,9 +1272,9 @@ function cptui_manage_post_types() {
1047
  'labeltext' => esc_html__( 'Post Formats', 'custom-post-type-ui' ),
1048
  'default' => true,
1049
  'wrap' => false,
1050
- ) );
1051
 
1052
- echo $ui->get_check_input( array(
1053
  'checkvalue' => 'none',
1054
  'checked' => ( ! empty( $current['supports'] ) && ( is_array( $current['supports'] ) && in_array( 'none', $current['supports'] ) ) ) ? 'true' : 'false',
1055
  'name' => 'none',
@@ -1058,29 +1283,30 @@ function cptui_manage_post_types() {
1058
  'labeltext' => esc_html__( 'None', 'custom-post-type-ui' ),
1059
  'default' => false,
1060
  'wrap' => false,
1061
- ) );
1062
 
1063
  echo $ui->get_fieldset_end() . $ui->get_td_end() . $ui->get_tr_end();
1064
 
1065
  echo $ui->get_tr_start() . $ui->get_th_start() . '<label for="custom_supports">' . esc_html__( 'Custom "Supports"', 'custom-post-type-ui' ) . '</label>';
1066
  echo $ui->get_p( sprintf( esc_html__( 'Use this input to register custom "supports" values, separated by commas. Learn about this at %s', 'custom-post-type-ui' ), '<a href="http://docs.pluginize.com/article/28-third-party-support-upon-registration" target="_blank">' . esc_html__( 'Custom "Supports"', 'custom-post-type-ui' ) . '</a>' ) );
1067
  echo $ui->get_th_end() . $ui->get_td_start();
1068
- echo $ui->get_text_input( array(
1069
  'namearray' => 'cpt_custom_post_type',
1070
  'name' => 'custom_supports',
1071
- 'textvalue' => ( isset( $current['custom_supports'] ) ) ? esc_attr( $current['custom_supports'] ) : '',
1072
  'helptext' => esc_attr__( 'Provide custom support slugs here.', 'custom-post-type-ui' ),
1073
  'helptext_after' => true,
1074
  'wrap' => false,
1075
- ) );
1076
  echo $ui->get_td_end() . $ui->get_tr_end();
1077
 
1078
- echo $ui->get_tr_start() . $ui->get_th_start() . esc_html__( 'Built-in Taxonomies', 'custom-post-type-ui' );
1079
 
1080
  echo $ui->get_p( esc_html__( 'Add support for available registered taxonomies.', 'custom-post-type-ui' ) );
1081
 
1082
  echo $ui->get_th_end() . $ui->get_td_start() . $ui->get_fieldset_start();
1083
 
 
1084
  /**
1085
  * Filters the arguments for taxonomies to list for post type association.
1086
  *
@@ -1088,11 +1314,11 @@ function cptui_manage_post_types() {
1088
  *
1089
  * @param array $value Array of default arguments.
1090
  */
1091
- $args = apply_filters( 'cptui_attach_taxonomies_to_post_type', array( 'public' => true ) );
1092
 
1093
  // If they don't return an array, fall back to the original default. Don't need to check for empty, because empty array is default for $args param in get_post_types anyway.
1094
  if ( ! is_array( $args ) ) {
1095
- $args = array( 'public' => true );
1096
  }
1097
 
1098
  /**
@@ -1104,11 +1330,11 @@ function cptui_manage_post_types() {
1104
  * @param array $args Array of arguments for the taxonomies query.
1105
  */
1106
  $add_taxes = apply_filters( 'cptui_get_taxonomies_for_post_types', get_taxonomies( $args, 'objects' ), $args );
1107
- unset( $add_taxes['nav_menu'] ); unset( $add_taxes['post_format'] );
1108
  foreach ( $add_taxes as $add_tax ) {
1109
 
1110
- $core_label = ( in_array( $add_tax->name, array( 'category', 'post_tag' ) ) ) ? __( '(WP Core)', 'custom-post-type-ui' ) : '';
1111
- echo $ui->get_check_input( array(
1112
  'checkvalue' => $add_tax->name,
1113
  'checked' => ( ! empty( $current['taxonomies'] ) && is_array( $current['taxonomies'] ) && in_array( $add_tax->name, $current['taxonomies'] ) ) ? 'true' : 'false',
1114
  'name' => $add_tax->name,
@@ -1117,7 +1343,7 @@ function cptui_manage_post_types() {
1117
  'labeltext' => $add_tax->label . ' ' . $core_label,
1118
  'helptext' => sprintf( esc_attr__( 'Adds %s support', 'custom-post-type-ui' ), $add_tax->label ),
1119
  'wrap' => false,
1120
- ) );
1121
  }
1122
  echo $ui->get_fieldset_end() . $ui->get_td_end() . $ui->get_tr_end();
1123
  ?>
@@ -1138,7 +1364,7 @@ function cptui_manage_post_types() {
1138
 
1139
  <p>
1140
  <?php
1141
- if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' == $_GET['action'] ) {
1142
  /**
1143
  * Filters the text value to use on the button when editing.
1144
  *
@@ -1186,17 +1412,17 @@ function cptui_manage_post_types() {
1186
  *
1187
  * @param array $post_types Array of post types that are registered. Optional.
1188
  */
1189
- function cptui_post_types_dropdown( $post_types = array() ) {
1190
 
1191
  $ui = new cptui_admin_ui();
1192
 
1193
  if ( ! empty( $post_types ) ) {
1194
- $select = array();
1195
- $select['options'] = array();
1196
 
1197
  foreach ( $post_types as $type ) {
1198
- $text = ( ! empty( $type['label'] ) ) ? $type['label'] : $type['name'];
1199
- $select['options'][] = array( 'attr' => $type['name'], 'text' => $text );
1200
  }
1201
 
1202
  $current = cptui_get_current_post_type();
@@ -1212,12 +1438,12 @@ function cptui_post_types_dropdown( $post_types = array() ) {
1212
  */
1213
  $select = apply_filters( 'cptui_post_types_dropdown_options', $select, $post_types );
1214
 
1215
- echo $ui->get_select_input( array(
1216
  'namearray' => 'cptui_selected_post_type',
1217
  'name' => 'post_type',
1218
  'selections' => $select,
1219
  'wrap' => false,
1220
- ) );
1221
  }
1222
  }
1223
 
@@ -1283,15 +1509,15 @@ function cptui_get_current_post_type( $post_type_deleted = false ) {
1283
  * @param array $data $_POST values. Optional.
1284
  * @return bool|string False on failure, string on success.
1285
  */
1286
- function cptui_delete_post_type( $data = array() ) {
1287
 
1288
  // Pass double data into last function despite matching values.
1289
  if ( is_string( $data ) && cptui_get_post_type_exists( $data, $data ) ) {
1290
- $data = array(
1291
- 'cpt_custom_post_type' => array(
1292
  'name' => $data,
1293
- ),
1294
- );
1295
  }
1296
 
1297
  if ( empty( $data['cpt_custom_post_type']['name'] ) ) {
@@ -1355,7 +1581,7 @@ function cptui_delete_post_type( $data = array() ) {
1355
  * @param array $data Array of post type data to update. Optional.
1356
  * @return bool|string False on failure, string on success.
1357
  */
1358
- function cptui_update_post_type( $data = array() ) {
1359
 
1360
  /**
1361
  * Fires before a post_type is updated to our saved options.
@@ -1412,7 +1638,7 @@ function cptui_update_post_type( $data = array() ) {
1412
  add_filter( 'cptui_custom_error_message', 'cptui_slug_matches_post_type' );
1413
  return 'error';
1414
  }
1415
- if ( 'new' == $data['cpt_type_status'] ) {
1416
  $slug_as_page = cptui_check_page_slugs( $data['cpt_custom_post_type']['name'] );
1417
  if ( true === $slug_as_page ) {
1418
  add_filter( 'cptui_custom_error_message', 'cptui_slug_matches_page' );
@@ -1421,11 +1647,11 @@ function cptui_update_post_type( $data = array() ) {
1421
  }
1422
 
1423
  if ( empty( $data['cpt_addon_taxes'] ) || ! is_array( $data['cpt_addon_taxes'] ) ) {
1424
- $data['cpt_addon_taxes'] = array();
1425
  }
1426
 
1427
  if ( empty( $data['cpt_supports'] ) || ! is_array( $data['cpt_supports'] ) ) {
1428
- $data['cpt_supports'] = array();
1429
  }
1430
 
1431
  foreach ( $data['cpt_labels'] as $key => $label ) {
@@ -1472,7 +1698,7 @@ function cptui_update_post_type( $data = array() ) {
1472
  $menu_icon = trim( $data['cpt_custom_post_type']['menu_icon'] );
1473
  $custom_supports = trim( $data['cpt_custom_post_type']['custom_supports'] );
1474
 
1475
- $post_types[ $data['cpt_custom_post_type']['name'] ] = array(
1476
  'name' => $name,
1477
  'label' => $label,
1478
  'singular_label' => $singular_label,
@@ -1481,6 +1707,7 @@ function cptui_update_post_type( $data = array() ) {
1481
  'publicly_queryable' => disp_boolean( $data['cpt_custom_post_type']['publicly_queryable'] ),
1482
  'show_ui' => disp_boolean( $data['cpt_custom_post_type']['show_ui'] ),
1483
  'show_in_nav_menus' => disp_boolean( $data['cpt_custom_post_type']['show_in_nav_menus'] ),
 
1484
  'show_in_rest' => disp_boolean( $data['cpt_custom_post_type']['show_in_rest'] ),
1485
  'rest_base' => $rest_base,
1486
  'rest_controller_class' => $rest_controller_class,
@@ -1502,7 +1729,7 @@ function cptui_update_post_type( $data = array() ) {
1502
  'taxonomies' => $data['cpt_addon_taxes'],
1503
  'labels' => $data['cpt_labels'],
1504
  'custom_supports' => $custom_supports,
1505
- );
1506
 
1507
  /**
1508
  * Filters final data to be saved right before saving post type data.
@@ -1539,10 +1766,8 @@ function cptui_update_post_type( $data = array() ) {
1539
  // Used to help flush rewrite rules on init.
1540
  set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
1541
 
1542
- if ( isset( $success ) ) {
1543
- if ( 'new' == $data['cpt_type_status'] ) {
1544
- return 'add_success';
1545
- }
1546
  }
1547
  return 'update_success';
1548
  }
@@ -1556,7 +1781,7 @@ function cptui_update_post_type( $data = array() ) {
1556
  */
1557
  function cptui_reserved_post_types() {
1558
 
1559
- $reserved = array(
1560
  'post',
1561
  'page',
1562
  'attachment',
@@ -1571,7 +1796,7 @@ function cptui_reserved_post_types() {
1571
  'customize_changeset',
1572
  'author',
1573
  'post_type',
1574
- );
1575
 
1576
  /**
1577
  * Filters the list of reserved post types to check against.
@@ -1582,7 +1807,7 @@ function cptui_reserved_post_types() {
1582
  *
1583
  * @param array $value Array of post type slugs to forbid.
1584
  */
1585
- $custom_reserved = apply_filters( 'cptui_reserved_post_types', array() );
1586
 
1587
  if ( is_string( $custom_reserved ) && ! empty( $custom_reserved ) ) {
1588
  $reserved[] = $custom_reserved;
@@ -1606,10 +1831,10 @@ function cptui_reserved_post_types() {
1606
  * @param string $new_slug New post type slug. Optional. Default empty string.
1607
  */
1608
  function cptui_convert_post_type_posts( $original_slug = '', $new_slug = '' ) {
1609
- $args = array(
1610
  'posts_per_page' => -1,
1611
  'post_type' => $original_slug,
1612
- );
1613
  $convert = new WP_Query( $args );
1614
 
1615
  if ( $convert->have_posts() ) :
@@ -1632,7 +1857,7 @@ function cptui_convert_post_type_posts( $original_slug = '', $new_slug = '' ) {
1632
  * @param array $post_types Array of CPTUI-registered post types. Optional.
1633
  * @return bool
1634
  */
1635
- function cptui_check_existing_post_type_slugs( $slug_exists = false, $post_type_slug = '', $post_types = array() ) {
1636
 
1637
  // If true, then we'll already have a conflict, let's not re-process.
1638
  if ( true === $slug_exists ) {
@@ -1650,8 +1875,8 @@ function cptui_check_existing_post_type_slugs( $slug_exists = false, $post_type_
1650
  }
1651
 
1652
  // Check if other plugins have registered non-public this same slug.
1653
- $public = get_post_types( array( '_builtin' => false, 'public' => true ) );
1654
- $private = get_post_types( array( '_builtin' => false, 'public' => false ) );
1655
  $registered_post_types = array_merge( $public, $private );
1656
  if ( in_array( $post_type_slug, $registered_post_types ) ) {
1657
  return true;
@@ -1673,7 +1898,7 @@ add_filter( 'cptui_post_type_slug_exists', 'cptui_check_existing_post_type_slugs
1673
  function cptui_check_page_slugs( $post_type_slug = '' ) {
1674
  $page = get_page_by_path( $post_type_slug );
1675
 
1676
- if ( is_null( $page ) ) {
1677
  return false;
1678
  }
1679
 
@@ -1720,6 +1945,14 @@ function cptui_process_post_type() {
1720
  add_action( 'admin_notices', "cptui_{$result}_admin_notice" );
1721
  }
1722
  }
 
 
 
 
 
 
 
 
1723
  }
1724
  }
1725
  add_action( 'init', 'cptui_process_post_type', 8 );
@@ -1758,9 +1991,9 @@ add_action( 'init', 'cptui_do_convert_post_type_posts' );
1758
  * @param array $post_types CPTUI post types.
1759
  * @return bool
1760
  */
1761
- function cptui_updated_post_type_slug_exists( $slug_exists, $post_type_slug = '', $post_types = array() ) {
1762
  if (
1763
- ( ! empty( $_POST['cpt_type_status'] ) && 'edit' == $_POST['cpt_type_status'] ) &&
1764
  ! in_array( $post_type_slug, cptui_reserved_post_types() ) &&
1765
  ( ! empty( $_POST['cpt_original'] ) && $post_type_slug === $_POST['cpt_original'] )
1766
  )
9
  * @license GPL-2.0+
10
  */
11
 
12
+ // phpcs:disable WebDevStudios.All.RequireAuthor
13
+
14
  // Exit if accessed directly.
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
39
  wp_enqueue_script( 'cptui' );
40
  wp_enqueue_style( 'cptui-css' );
41
 
42
+ $core = get_post_types( [ '_builtin' => true ] );
43
+ $public = get_post_types( [ '_builtin' => false, 'public' => true ] );
44
+ $private = get_post_types( [ '_builtin' => false, 'public' => false ] );
45
  $registered_post_types = array_merge( $core, $public, $private );
46
 
47
  wp_localize_script( 'cptui', 'cptui_type_data',
48
+ [
49
+ 'confirm' => esc_html__( 'Are you sure you want to delete this? Deleting will NOT remove created content.', 'custom-post-type-ui' ),
50
  'existing_post_types' => $registered_post_types,
51
+ ]
52
  );
53
  }
54
  add_action( 'admin_enqueue_scripts', 'cptui_post_type_enqueue_scripts' );
64
  * @param string $current_page Current page being shown. Optional. Default empty string.
65
  * @return array Amended array of tabs to show.
66
  */
67
+ function cptui_post_type_tabs( $tabs = [], $current_page = '' ) {
68
 
69
  if ( 'post_types' === $current_page ) {
70
  $post_types = cptui_get_post_type_data();
71
+ $classes = [ 'nav-tab' ];
72
 
73
  $tabs['page_title'] = get_admin_page_title();
74
+ $tabs['tabs'] = [];
75
  // Start out with our basic "Add new" tab.
76
+ $tabs['tabs']['add'] = [
77
  'text' => __( 'Add New Post Type', 'custom-post-type-ui' ),
78
  'classes' => $classes,
79
  'url' => cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ),
80
  'aria-selected' => 'false',
81
+ ];
82
 
83
  $action = cptui_get_current_action();
84
  if ( empty( $action ) ) {
85
+ $tabs['tabs']['add']['classes'][] = 'nav-tab-active';
86
  $tabs['tabs']['add']['aria-selected'] = 'true';
87
  }
88
 
91
  if ( ! empty( $action ) ) {
92
  $classes[] = 'nav-tab-active';
93
  }
94
+ $tabs['tabs']['edit'] = [
95
  'text' => __( 'Edit Post Types', 'custom-post-type-ui' ),
96
  'classes' => $classes,
97
+ 'url' => esc_url( add_query_arg( [ 'action' => 'edit' ], cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ) ) ),
98
+ 'aria-selected' => ! empty( $action ) ? 'true' : 'false',
99
+ ];
100
 
101
+ $tabs['tabs']['view'] = [
102
  'text' => __( 'View Post Types', 'custom-post-type-ui' ),
103
+ 'classes' => [ 'nav-tab' ], // Prevent notices.
104
  'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_listings#post-types' ) ),
105
  'aria-selected' => 'false',
106
+ ];
107
 
108
+ $tabs['tabs']['export'] = [
109
  'text' => __( 'Import/Export Post Types', 'custom-post-type-ui' ),
110
+ 'classes' => [ 'nav-tab' ], // Prevent notices.
111
  'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_tools' ) ),
112
  'aria-selected' => 'false',
113
+ ];
114
  }
115
  }
116
 
166
 
167
  $selected_post_type = cptui_get_current_post_type( $post_type_deleted );
168
 
169
+ if ( $selected_post_type && array_key_exists( $selected_post_type, $post_types ) ) {
170
+ $current = $post_types[ $selected_post_type ];
 
 
171
  }
172
  }
173
 
230
 
231
  echo $ui->get_th_end() . $ui->get_td_start();
232
 
233
+ echo $ui->get_text_input( [
234
+ 'namearray' => 'cpt_custom_post_type',
235
+ 'name' => 'name',
236
+ 'textvalue' => isset( $current['name'] ) ? esc_attr( $current['name'] ) : '',
237
+ 'maxlength' => '20',
238
+ 'helptext' => esc_html__( 'The post type name/slug. Used for various queries for post type content.', 'custom-post-type-ui' ),
239
+ 'required' => true,
240
+ 'placeholder' => false,
241
+ 'wrap' => false,
242
+ ] );
243
  echo '<p class="cptui-slug-details">';
244
  esc_html_e( 'Slugs should only contain alphanumeric, latin characters. Underscores should be used in place of spaces. Set "Custom Rewrite Slug" field to make slug use dashes for URLs.', 'custom-post-type-ui' );
245
  echo '</p>';
250
  echo '</p>';
251
 
252
  echo '<div class="cptui-spacer">';
253
+ echo $ui->get_check_input( [
254
  'checkvalue' => 'update_post_types',
255
  'checked' => 'false',
256
  'name' => 'update_post_types',
259
  'helptext' => false,
260
  'default' => false,
261
  'wrap' => false,
262
+ ] );
263
  echo '</div>';
264
  }
265
 
266
  echo $ui->get_td_end(); echo $ui->get_tr_end();
267
 
268
+ echo $ui->get_text_input( [
269
  'namearray' => 'cpt_custom_post_type',
270
  'name' => 'label',
271
+ 'textvalue' => isset( $current['label'] ) ? esc_attr( $current['label'] ) : '',
272
  'labeltext' => esc_html__( 'Plural Label', 'custom-post-type-ui' ),
273
  'aftertext' => esc_html__( '(e.g. Movies)', 'custom-post-type-ui' ),
274
  'helptext' => esc_html__( 'Used for the post type admin menu item.', 'custom-post-type-ui' ),
275
  'required' => true,
276
+ ] );
277
 
278
+ echo $ui->get_text_input( [
279
  'namearray' => 'cpt_custom_post_type',
280
  'name' => 'singular_label',
281
+ 'textvalue' => isset( $current['singular_label'] ) ? esc_attr( $current['singular_label'] ) : '',
282
  'labeltext' => esc_html__( 'Singular Label', 'custom-post-type-ui' ),
283
  'aftertext' => esc_html__( '(e.g. Movie)', 'custom-post-type-ui' ),
284
  'helptext' => esc_html__( 'Used when a singular label is needed.', 'custom-post-type-ui' ),
285
  'required' => true,
286
+ ] );
287
+
288
+ $link_text = ( 'new' === $tab ) ?
289
+ esc_html__( 'Populate additional labels based on chosen labels.', 'custom-post-type-ui' ) :
290
+ esc_html__( 'Populate missing labels based on chosen labels.', 'custom-post-type-ui' );
291
+ echo $ui->get_tr_end();
292
+ echo $ui->get_th_start() . esc_html__( 'Auto-populate labels', 'custom-post-type-ui' ) . $ui->get_th_end();
293
+ echo $ui->get_td_start();
294
+ ?>
295
+ <a href="#" id="auto-populate"><?php echo esc_html( $link_text ); ?></a>
296
+ <?php
297
+ echo $ui->get_td_end() . $ui->get_tr_end();
298
+
299
+ ?>
300
+ </table>
301
  <p class="submit">
302
  <?php wp_nonce_field( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
303
  if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) { ?>
347
  </div>
348
  </div>
349
  </div>
350
+ <div class="cptui-section cptui-labels postbox">
351
  <button type="button" class="handlediv button-link" aria-expanded="true">
352
  <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Additional labels', 'custom-post-type-ui' ); ?></span>
353
  <span class="toggle-indicator" aria-hidden="true"></span>
363
  if ( isset( $current['description'] ) ) {
364
  $current['description'] = stripslashes_deep( $current['description'] );
365
  }
366
+ echo $ui->get_textarea_input( [
367
  'namearray' => 'cpt_custom_post_type',
368
  'name' => 'description',
369
  'rows' => '4',
370
  'cols' => '40',
371
+ 'textvalue' => isset( $current['description'] ) ? esc_textarea( $current['description'] ) : '',
372
  'labeltext' => esc_html__( 'Post Type Description', 'custom-post-type-ui' ),
373
  'helptext' => esc_html__( 'Perhaps describe what your custom post type is used for?', 'custom-post-type-ui' ),
374
+ ] );
375
 
376
+ echo $ui->get_text_input( [
377
  'labeltext' => esc_html__( 'Menu Name', 'custom-post-type-ui' ),
378
  'helptext' => esc_html__( 'Custom admin menu name for your custom post type.', 'custom-post-type-ui' ),
379
  'namearray' => 'cpt_labels',
380
  'name' => 'menu_name',
381
+ 'textvalue' => isset( $current['labels']['menu_name'] ) ? esc_attr( $current['labels']['menu_name'] ) : '',
382
  'aftertext' => esc_html__( '(e.g. My Movies)', 'custom-post-type-ui' ),
383
+ 'data' => [
384
+ /* translators: Used for autofill */
385
+ 'label' => sprintf( esc_attr__( 'My %s', 'custom-post-type-ui' ), 'item' ),
386
+ 'plurality' => 'plural',
387
+ ],
388
+ ] );
389
+
390
+ echo $ui->get_text_input( [
391
  'labeltext' => esc_html__( 'All Items', 'custom-post-type-ui' ),
392
  'helptext' => esc_html__( 'Used in the post type admin submenu.', 'custom-post-type-ui' ),
393
  'namearray' => 'cpt_labels',
394
  'name' => 'all_items',
395
+ 'textvalue' => isset( $current['labels']['all_items'] ) ? esc_attr( $current['labels']['all_items'] ) : '',
396
  'aftertext' => esc_html__( '(e.g. All Movies)', 'custom-post-type-ui' ),
397
+ 'data' => [
398
+ /* translators: Used for autofill */
399
+ 'label' => sprintf( esc_attr__( 'All %s', 'custom-post-type-ui' ), 'item' ),
400
+ 'plurality' => 'plural',
401
+ ],
402
+ ] );
403
+
404
+ echo $ui->get_text_input( [
405
  'labeltext' => esc_html__( 'Add New', 'custom-post-type-ui' ),
406
  'helptext' => esc_html__( 'Used in the post type admin submenu.', 'custom-post-type-ui' ),
407
  'namearray' => 'cpt_labels',
408
  'name' => 'add_new',
409
+ 'textvalue' => isset( $current['labels']['add_new'] ) ? esc_attr( $current['labels']['add_new'] ) : '',
410
  'aftertext' => esc_html__( '(e.g. Add New)', 'custom-post-type-ui' ),
411
+ 'data' => [
412
+ /* translators: Used for autofill */
413
+ 'label' => esc_attr__( 'Add new', 'custom-post-type-ui' ),
414
+ 'plurality' => 'plural',
415
+ ],
416
+ ] );
417
+
418
+ echo $ui->get_text_input( [
419
  'labeltext' => esc_html__( 'Add New Item', 'custom-post-type-ui' ),
420
  'helptext' => esc_html__( 'Used at the top of the post editor screen for a new post type post.', 'custom-post-type-ui' ),
421
  'namearray' => 'cpt_labels',
422
  'name' => 'add_new_item',
423
+ 'textvalue' => isset( $current['labels']['add_new_item'] ) ? esc_attr( $current['labels']['add_new_item'] ) : '',
424
  'aftertext' => esc_html__( '(e.g. Add New Movie)', 'custom-post-type-ui' ),
425
+ 'data' => [
426
+ /* translators: Used for autofill */
427
+ 'label' => sprintf( esc_attr__( 'Add new %s', 'custom-post-type-ui' ), 'item' ),
428
+ 'plurality' => 'singular',
429
+ ],
430
+ ] );
431
+
432
+ echo $ui->get_text_input( [
433
  'labeltext' => esc_html__( 'Edit Item', 'custom-post-type-ui' ),
434
  'helptext' => esc_html__( 'Used at the top of the post editor screen for an existing post type post.', 'custom-post-type-ui' ),
435
  'namearray' => 'cpt_labels',
436
  'name' => 'edit_item',
437
+ 'textvalue' => isset( $current['labels']['edit_item'] ) ? esc_attr( $current['labels']['edit_item'] ) : '',
438
  'aftertext' => esc_html__( '(e.g. Edit Movie)', 'custom-post-type-ui' ),
439
+ 'data' => [
440
+ /* translators: Used for autofill */
441
+ 'label' => sprintf( esc_attr__( 'Edit %s', 'custom-post-type-ui' ), 'item' ),
442
+ 'plurality' => 'singular',
443
+ ],
444
+ ] );
445
+
446
+ echo $ui->get_text_input( [
447
  'labeltext' => esc_html__( 'New Item', 'custom-post-type-ui' ),
448
  'helptext' => esc_html__( 'Post type label. Used in the admin menu for displaying post types.', 'custom-post-type-ui' ),
449
  'namearray' => 'cpt_labels',
450
  'name' => 'new_item',
451
+ 'textvalue' => isset( $current['labels']['new_item'] ) ? esc_attr( $current['labels']['new_item'] ) : '',
452
  'aftertext' => esc_html__( '(e.g. New Movie)', 'custom-post-type-ui' ),
453
+ 'data' => [
454
+ /* translators: Used for autofill */
455
+ 'label' => sprintf( esc_attr__( 'New %s', 'custom-post-type-ui' ), 'item' ),
456
+ 'plurality' => 'singular',
457
+ ],
458
+ ] );
459
+
460
+ echo $ui->get_text_input( [
461
  'labeltext' => esc_html__( 'View Item', 'custom-post-type-ui' ),
462
  'helptext' => esc_html__( 'Used in the admin bar when viewing editor screen for a published post in the post type.', 'custom-post-type-ui' ),
463
  'namearray' => 'cpt_labels',
464
  'name' => 'view_item',
465
+ 'textvalue' => isset( $current['labels']['view_item'] ) ? esc_attr( $current['labels']['view_item'] ) : '',
466
  'aftertext' => esc_html__( '(e.g. View Movie)', 'custom-post-type-ui' ),
467
+ 'data' => [
468
+ /* translators: Used for autofill */
469
+ 'label' => sprintf( esc_attr__( 'View %s', 'custom-post-type-ui' ), 'item' ),
470
+ 'plurality' => 'singular',
471
+ ],
472
+ ] );
473
+
474
+ echo $ui->get_text_input( [
475
  'labeltext' => esc_html__( 'View Items', 'custom-post-type-ui' ),
476
  'helptext' => esc_html__( 'Used in the admin bar when viewing editor screen for a published post in the post type.', 'custom-post-type-ui' ),
477
  'namearray' => 'cpt_labels',
478
  'name' => 'view_items',
479
+ 'textvalue' => isset( $current['labels']['view_items'] ) ? esc_attr( $current['labels']['view_items'] ) : '',
480
  'aftertext' => esc_html__( '(e.g. View Movies)', 'custom-post-type-ui' ),
481
+ 'data' => [
482
+ /* translators: Used for autofill */
483
+ 'label' => sprintf( esc_attr__( 'View %s', 'custom-post-type-ui' ), 'item' ),
484
+ 'plurality' => 'plural',
485
+ ],
486
+ ] );
487
+
488
+ echo $ui->get_text_input( [
489
  'labeltext' => esc_html__( 'Search Item', 'custom-post-type-ui' ),
490
  'helptext' => esc_html__( 'Used as the text for the search button on post type list screen.', 'custom-post-type-ui' ),
491
  'namearray' => 'cpt_labels',
492
  'name' => 'search_items',
493
+ 'textvalue' => isset( $current['labels']['search_items'] ) ? esc_attr( $current['labels']['search_items'] ) : '',
494
+ 'aftertext' => esc_html__( '(e.g. Search Movies)', 'custom-post-type-ui' ),
495
+ 'data' => [
496
+ /* translators: Used for autofill */
497
+ 'label' => sprintf( esc_attr__( 'Search %s', 'custom-post-type-ui' ), 'item' ),
498
+ 'plurality' => 'plural',
499
+ ],
500
+ ] );
501
+
502
+ echo $ui->get_text_input( [
503
  'labeltext' => esc_html__( 'Not Found', 'custom-post-type-ui' ),
504
  'helptext' => esc_html__( 'Used when there are no posts to display on the post type list screen.', 'custom-post-type-ui' ),
505
  'namearray' => 'cpt_labels',
506
  'name' => 'not_found',
507
+ 'textvalue' => isset( $current['labels']['not_found'] ) ? esc_attr( $current['labels']['not_found'] ) : '',
508
  'aftertext' => esc_html__( '(e.g. No Movies found)', 'custom-post-type-ui' ),
509
+ 'data' => [
510
+ /* translators: Used for autofill */
511
+ 'label' => sprintf( esc_attr__( 'No %s found', 'custom-post-type-ui' ), 'item' ),
512
+ 'plurality' => 'plural',
513
+ ],
514
+ ] );
515
+
516
+ echo $ui->get_text_input( [
517
  'labeltext' => esc_html__( 'Not Found in Trash', 'custom-post-type-ui' ),
518
  'helptext' => esc_html__( 'Used when there are no posts to display on the post type list trash screen.', 'custom-post-type-ui' ),
519
  'namearray' => 'cpt_labels',
520
  'name' => 'not_found_in_trash',
521
+ 'textvalue' => isset( $current['labels']['not_found_in_trash'] ) ? esc_attr( $current['labels']['not_found_in_trash'] ) : '',
522
  'aftertext' => esc_html__( '(e.g. No Movies found in Trash)', 'custom-post-type-ui' ),
523
+ 'data' => [
524
+ /* translators: Used for autofill */
525
+ 'label' => sprintf( esc_attr__( 'No %s found in trash', 'custom-post-type-ui' ), 'item' ),
526
+ 'plurality' => 'plural',
527
+ ],
528
+ ] );
529
 
530
  // As of 1.4.0, this will register into `parent_item_colon` paramter upon registration and export.
531
+ echo $ui->get_text_input( [
532
  'labeltext' => esc_html__( 'Parent', 'custom-post-type-ui' ),
533
  'helptext' => esc_html__( 'Used for hierarchical types that need a colon.', 'custom-post-type-ui' ),
534
  'namearray' => 'cpt_labels',
535
  'name' => 'parent',
536
+ 'textvalue' => isset( $current['labels']['parent'] ) ? esc_attr( $current['labels']['parent'] ) : '',
537
  'aftertext' => esc_html__( '(e.g. Parent Movie:)', 'custom-post-type-ui' ),
538
+ 'data' => [
539
+ /* translators: Used for autofill */
540
+ 'label' => sprintf( esc_attr__( 'Parent %s:', 'custom-post-type-ui' ), 'item' ),
541
+ 'plurality' => 'singular',
542
+ ],
543
+ ] );
544
+
545
+ echo $ui->get_text_input( [
546
  'labeltext' => esc_html__( 'Featured Image', 'custom-post-type-ui' ),
547
  'helptext' => esc_html__( 'Used as the "Featured Image" phrase for the post type.', 'custom-post-type-ui' ),
548
  'namearray' => 'cpt_labels',
549
  'name' => 'featured_image',
550
+ 'textvalue' => isset( $current['labels']['featured_image'] ) ? esc_attr( $current['labels']['featured_image'] ) : '',
551
  'aftertext' => esc_html__( '(e.g. Featured image for this movie)', 'custom-post-type-ui' ),
552
+ 'data' => [
553
+ /* translators: Used for autofill */
554
+ 'label' => sprintf( esc_attr__( 'Featured image for this %s', 'custom-post-type-ui' ), 'item' ),
555
+ 'plurality' => 'singular',
556
+ ],
557
+ ] );
558
+
559
+ echo $ui->get_text_input( [
560
  'labeltext' => esc_html__( 'Set Featured Image', 'custom-post-type-ui' ),
561
  'helptext' => esc_html__( 'Used as the "Set featured image" phrase for the post type.', 'custom-post-type-ui' ),
562
  'namearray' => 'cpt_labels',
563
  'name' => 'set_featured_image',
564
+ 'textvalue' => isset( $current['labels']['set_featured_image'] ) ? esc_attr( $current['labels']['set_featured_image'] ) : '',
565
  'aftertext' => esc_html__( '(e.g. Set featured image for this movie)', 'custom-post-type-ui' ),
566
+ 'data' => [
567
+ /* translators: Used for autofill */
568
+ 'label' => sprintf( esc_attr__( 'Set featured image for this %s', 'custom-post-type-ui' ), 'item' ),
569
+ 'plurality' => 'singular',
570
+ ],
571
+ ] );
572
+
573
+ echo $ui->get_text_input( [
574
  'labeltext' => esc_html__( 'Remove Featured Image', 'custom-post-type-ui' ),
575
  'helptext' => esc_html__( 'Used as the "Remove featured image" phrase for the post type.', 'custom-post-type-ui' ),
576
  'namearray' => 'cpt_labels',
577
  'name' => 'remove_featured_image',
578
+ 'textvalue' => isset( $current['labels']['remove_featured_image'] ) ? esc_attr( $current['labels']['remove_featured_image'] ) : '',
579
  'aftertext' => esc_html__( '(e.g. Remove featured image for this movie)', 'custom-post-type-ui' ),
580
+ 'data' => [
581
+ /* translators: Used for autofill */
582
+ 'label' => sprintf( esc_attr__( 'Remove featured image for this %s', 'custom-post-type-ui' ), 'item' ),
583
+ 'plurality' => 'singular',
584
+ ],
585
+ ] );
586
+
587
+ echo $ui->get_text_input( [
588
  'labeltext' => esc_html__( 'Use Featured Image', 'custom-post-type-ui' ),
589
  'helptext' => esc_html__( 'Used as the "Use as featured image" phrase for the post type.', 'custom-post-type-ui' ),
590
  'namearray' => 'cpt_labels',
591
  'name' => 'use_featured_image',
592
+ 'textvalue' => isset( $current['labels']['use_featured_image'] ) ? esc_attr( $current['labels']['use_featured_image'] ) : '',
593
  'aftertext' => esc_html__( '(e.g. Use as featured image for this movie)', 'custom-post-type-ui' ),
594
+ 'data' => [
595
+ /* translators: Used for autofill */
596
+ 'label' => sprintf( esc_attr__( 'Use as featured image for this %s', 'custom-post-type-ui' ), 'item' ),
597
+ 'plurality' => 'singular',
598
+ ],
599
+ ] );
600
+
601
+ echo $ui->get_text_input( [
602
  'labeltext' => esc_html__( 'Archives', 'custom-post-type-ui' ),
603
  'helptext' => esc_html__( 'Post type archive label used in nav menus.', 'custom-post-type-ui' ),
604
  'namearray' => 'cpt_labels',
605
  'name' => 'archives',
606
+ 'textvalue' => isset( $current['labels']['archives'] ) ? esc_attr( $current['labels']['archives'] ) : '',
607
  'aftertext' => esc_html__( '(e.g. Movie archives)', 'custom-post-type-ui' ),
608
+ 'data' => [
609
+ /* translators: Used for autofill */
610
+ 'label' => sprintf( esc_attr__( '%s archives', 'custom-post-type-ui' ), 'item' ),
611
+ 'plurality' => 'singular',
612
+ ],
613
+ ] );
614
+
615
+ echo $ui->get_text_input( [
616
  'labeltext' => esc_html__( 'Insert into item', 'custom-post-type-ui' ),
617
  'helptext' => esc_html__( 'Used as the "Insert into post" or "Insert into page" phrase for the post type.', 'custom-post-type-ui' ),
618
  'namearray' => 'cpt_labels',
619
  'name' => 'insert_into_item',
620
+ 'textvalue' => isset( $current['labels']['insert_into_item'] ) ? esc_attr( $current['labels']['insert_into_item'] ) : '',
621
  'aftertext' => esc_html__( '(e.g. Insert into movie)', 'custom-post-type-ui' ),
622
+ 'data' => [
623
+ /* translators: Used for autofill */
624
+ 'label' => sprintf( esc_attr__( 'Insert into %s', 'custom-post-type-ui' ), 'item' ),
625
+ 'plurality' => 'singular',
626
+ ],
627
+ ] );
628
+
629
+ echo $ui->get_text_input( [
630
  'labeltext' => esc_html__( 'Uploaded to this Item', 'custom-post-type-ui' ),
631
  'helptext' => esc_html__( 'Used as the "Uploaded to this post" or "Uploaded to this page" phrase for the post type.', 'custom-post-type-ui' ),
632
  'namearray' => 'cpt_labels',
633
  'name' => 'uploaded_to_this_item',
634
+ 'textvalue' => isset( $current['labels']['uploaded_to_this_item'] ) ? esc_attr( $current['labels']['uploaded_to_this_item'] ) : '',
635
  'aftertext' => esc_html__( '(e.g. Uploaded to this movie)', 'custom-post-type-ui' ),
636
+ 'data' => [
637
+ /* translators: Used for autofill */
638
+ 'label' => sprintf( esc_attr__( 'Upload to this %s', 'custom-post-type-ui' ), 'item' ),
639
+ 'plurality' => 'singular',
640
+ ],
641
+ ] );
642
+
643
+ echo $ui->get_text_input( [
644
  'labeltext' => esc_html__( 'Filter Items List', 'custom-post-type-ui' ),
645
  'helptext' => esc_html__( 'Screen reader text for the filter links heading on the post type listing screen.', 'custom-post-type-ui' ),
646
  'namearray' => 'cpt_labels',
647
  'name' => 'filter_items_list',
648
+ 'textvalue' => isset( $current['labels']['filter_items_list'] ) ? esc_attr( $current['labels']['filter_items_list'] ) : '',
649
  'aftertext' => esc_html__( '(e.g. Filter movies list)', 'custom-post-type-ui' ),
650
+ 'data' => [
651
+ /* translators: Used for autofill */
652
+ 'label' => sprintf( esc_attr__( 'Filter %s list', 'custom-post-type-ui' ), 'item' ),
653
+ 'plurality' => 'plural',
654
+ ],
655
+ ] );
656
+
657
+ echo $ui->get_text_input( [
658
  'labeltext' => esc_html__( 'Items List Navigation', 'custom-post-type-ui' ),
659
  'helptext' => esc_html__( 'Screen reader text for the pagination heading on the post type listing screen.', 'custom-post-type-ui' ),
660
  'namearray' => 'cpt_labels',
661
  'name' => 'items_list_navigation',
662
+ 'textvalue' => isset( $current['labels']['items_list_navigation'] ) ? esc_attr( $current['labels']['items_list_navigation'] ) : '',
663
  'aftertext' => esc_html__( '(e.g. Movies list navigation)', 'custom-post-type-ui' ),
664
+ 'data' => [
665
+ /* translators: Used for autofill */
666
+ 'label' => sprintf( esc_attr__( '%s list navigation', 'custom-post-type-ui' ), 'item' ),
667
+ 'plurality' => 'plural',
668
+ ],
669
+ ] );
670
+
671
+ echo $ui->get_text_input( [
672
  'labeltext' => esc_html__( 'Items List', 'custom-post-type-ui' ),
673
  'helptext' => esc_html__( 'Screen reader text for the items list heading on the post type listing screen.', 'custom-post-type-ui' ),
674
  'namearray' => 'cpt_labels',
675
  'name' => 'items_list',
676
+ 'textvalue' => isset( $current['labels']['items_list'] ) ? esc_attr( $current['labels']['items_list'] ) : '',
677
  'aftertext' => esc_html__( '(e.g. Movies list)', 'custom-post-type-ui' ),
678
+ 'data' => [
679
+ /* translators: Used for autofill */
680
+ 'label' => sprintf( esc_attr__( '%s list', 'custom-post-type-ui' ), 'item' ),
681
+ 'plurality' => 'plural',
682
+ ],
683
+ ] );
684
+
685
+ echo $ui->get_text_input( [
686
  'labeltext' => esc_html__( 'Attributes', 'custom-post-type-ui' ),
687
  'helptext' => esc_html__( 'Used for the title of the post attributes meta box.', 'custom-post-type-ui' ),
688
  'namearray' => 'cpt_labels',
689
  'name' => 'attributes',
690
+ 'textvalue' => isset( $current['labels']['attributes'] ) ? esc_attr( $current['labels']['attributes'] ) : '',
691
  'aftertext' => esc_html__( '(e.g. Movies Attributes)', 'custom-post-type-ui' ),
692
+ 'data' => [
693
+ /* translators: Used for autofill */
694
+ 'label' => sprintf( esc_attr__( '%s attributes', 'custom-post-type-ui' ), 'item' ),
695
+ 'plurality' => 'plural',
696
+ ],
697
+ ] );
698
+
699
+ echo $ui->get_text_input( [
700
  'labeltext' => esc_html__( '"New" menu in admin bar', 'custom-post-type-ui' ),
701
  'helptext' => esc_html__( 'Used in New in Admin menu bar. Default "singular name" label.', 'custom-post-type-ui' ),
702
  'namearray' => 'cpt_labels',
703
  'name' => 'name_admin_bar',
704
+ 'textvalue' => isset( $current['labels']['name_admin_bar'] ) ? esc_attr( $current['labels']['name_admin_bar'] ) : '',
705
  'aftertext' => esc_html__( '(e.g. Movie)', 'custom-post-type-ui' ),
706
+ 'data' => [
707
+ /* translators: Used for autofill */
708
+ 'label' => 'item', // not localizing because it's so isolated.
709
+ 'plurality' => 'singular',
710
+ ],
711
+ ] );
712
+
713
+ echo $ui->get_text_input( [
714
+ 'labeltext' => esc_html__( 'Item Published', 'custom-post-type-ui' ),
715
+ 'helptext' => esc_html__( 'Used in the editor notice after publishing a post. Default "Post published." / "Page published."', 'custom-post-type-ui' ),
716
+ 'namearray' => 'cpt_labels',
717
+ 'name' => 'item_published',
718
+ 'textvalue' => isset( $current['labels']['item_published'] ) ? esc_attr( $current['labels']['item_published'] ) : '',
719
+ 'aftertext' => esc_html__( '(e.g. Movie published)', 'custom-post-type-ui' ),
720
+ 'data' => [
721
+ /* translators: Used for autofill */
722
+ 'label' => sprintf( esc_attr__( '%s published', 'custom-post-type-ui' ), 'item' ),
723
+ 'plurality' => 'singular',
724
+ ],
725
+ ] );
726
+
727
+ echo $ui->get_text_input( [
728
+ 'labeltext' => esc_html__( 'Item Published Privately', 'custom-post-type-ui' ),
729
+ 'helptext' => esc_html__( 'Used in the editor notice after publishing a private post. Default "Post published privately." / "Page published privately."', 'custom-post-type-ui' ),
730
+ 'namearray' => 'cpt_labels',
731
+ 'name' => 'item_published_privately',
732
+ 'textvalue' => isset( $current['labels']['item_published_privately'] ) ? esc_attr( $current['labels']['item_published_privately'] ) : '',
733
+ 'aftertext' => esc_html__( '(e.g. Movie published privately.)', 'custom-post-type-ui' ),
734
+ 'data' => [
735
+ /* translators: Used for autofill */
736
+ 'label' => sprintf( esc_attr__( '%s published privately.', 'custom-post-type-ui' ), 'item' ),
737
+ 'plurality' => 'singular',
738
+ ],
739
+ ] );
740
+
741
+ echo $ui->get_text_input( [
742
+ 'labeltext' => esc_html__( 'Item Reverted To Draft', 'custom-post-type-ui' ),
743
+ 'helptext' => esc_html__( 'Used in the editor notice after reverting a post to draft. Default "Post reverted to draft." / "Page reverted to draft."', 'custom-post-type-ui' ),
744
+ 'namearray' => 'cpt_labels',
745
+ 'name' => 'item_reverted_to_draft',
746
+ 'textvalue' => isset( $current['labels']['item_reverted_to_draft'] ) ? esc_attr( $current['labels']['item_reverted_to_draft'] ) : '',
747
+ 'aftertext' => esc_html__( '(e.g. Movie reverted to draft)', 'custom-post-type-ui' ),
748
+ 'data' => [
749
+ /* translators: Used for autofill */
750
+ 'label' => sprintf( esc_attr__( '%s reverted to draft.', 'custom-post-type-ui' ), 'item' ),
751
+ 'plurality' => 'singular',
752
+ ],
753
+ ] );
754
+
755
+ echo $ui->get_text_input( [
756
+ 'labeltext' => esc_html__( 'Item Scheduled', 'custom-post-type-ui' ),
757
+ 'helptext' => esc_html__( 'Used in the editor notice after scheduling a post to be published at a later date. Default "Post scheduled." / "Page scheduled."', 'custom-post-type-ui' ),
758
+ 'namearray' => 'cpt_labels',
759
+ 'name' => 'item_scheduled',
760
+ 'textvalue' => isset( $current['labels']['item_scheduled'] ) ? esc_attr( $current['labels']['item_scheduled'] ) : '',
761
+ 'aftertext' => esc_html__( '(e.g. Movie scheduled)', 'custom-post-type-ui' ),
762
+ 'data' => [
763
+ /* translators: Used for autofill */
764
+ 'label' => sprintf( esc_attr__( '%s scheduled', 'custom-post-type-ui' ), 'item' ),
765
+ 'plurality' => 'singular',
766
+ ],
767
+ ] );
768
+
769
+ echo $ui->get_text_input( [
770
+ 'labeltext' => esc_html__( 'Item Updated', 'custom-post-type-ui' ),
771
+ 'helptext' => esc_html__( 'Used in the editor notice after updating a post. Default "Post updated." / "Page updated."', 'custom-post-type-ui' ),
772
+ 'namearray' => 'cpt_labels',
773
+ 'name' => 'item_updated',
774
+ 'textvalue' => isset( $current['labels']['item_updated'] ) ? esc_attr( $current['labels']['item_updated'] ) : '',
775
+ 'aftertext' => esc_html__( '(e.g. Movie updated)', 'custom-post-type-ui' ),
776
+ 'data' => [
777
+ /* translators: Used for autofill */
778
+ 'label' => sprintf( esc_attr__( '%s updated.', 'custom-post-type-ui' ), 'item' ),
779
+ 'plurality' => 'singular',
780
+ ],
781
+ ] );
782
 
783
  ?>
784
  </table>
785
  </div>
786
  </div>
787
  </div>
788
+ <div class="cptui-section cptui-settings postbox">
789
  <button type="button" class="handlediv button-link" aria-expanded="true">
790
  <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Settings', 'custom-post-type-ui' ); ?></span>
791
  <span class="toggle-indicator" aria-hidden="true"></span>
797
  <div class="main">
798
  <table class="form-table cptui-table">
799
  <?php
800
+ $select = [
801
+ 'options' => [
802
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ],
803
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ],
804
+ ],
805
+ ];
806
+ $selected = isset( $current ) ? disp_boolean( $current['public'] ) : '';
807
+ $select['selected'] = ! empty( $selected ) ? $current['public'] : '';
808
+ echo $ui->get_select_input( [
809
  'namearray' => 'cpt_custom_post_type',
810
  'name' => 'public',
811
  'labeltext' => esc_html__( 'Public', 'custom-post-type-ui' ),
812
  'aftertext' => esc_html__( '(Custom Post Type UI default: true) Whether or not posts of this type should be shown in the admin UI and is publicly queryable.', 'custom-post-type-ui' ),
813
  'selections' => $select,
814
+ ] );
815
+
816
+ $select = [
817
+ 'options' => [
818
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ],
819
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ],
820
+ ],
821
+ ];
822
+ $selected = isset( $current ) && ! empty( $current['publicly_queryable'] ) ? disp_boolean( $current['publicly_queryable'] ) : '';
823
+ $select['selected'] = ! empty( $selected ) ? $current['publicly_queryable'] : '';
824
+ echo $ui->get_select_input( [
825
  'namearray' => 'cpt_custom_post_type',
826
  'name' => 'publicly_queryable',
827
  'labeltext' => esc_html__( 'Publicly Queryable', 'custom-post-type-ui' ),
828
  'aftertext' => esc_html__( '(default: true) Whether or not queries can be performed on the front end as part of parse_request()', 'custom-post-type-ui' ),
829
  'selections' => $select,
830
+ ] );
831
+
832
+ $select = [
833
+ 'options' => [
834
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ],
835
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ],
836
+ ],
837
+ ];
838
+ $selected = isset( $current ) ? disp_boolean( $current['show_ui'] ) : '';
839
+ $select['selected'] = ! empty( $selected ) ? $current['show_ui'] : '';
840
+ echo $ui->get_select_input( [
841
  'namearray' => 'cpt_custom_post_type',
842
  'name' => 'show_ui',
843
  'labeltext' => esc_html__( 'Show UI', 'custom-post-type-ui' ),
844
  'aftertext' => esc_html__( '(default: true) Whether or not to generate a default UI for managing this post type.', 'custom-post-type-ui' ),
845
  'selections' => $select,
846
+ ] );
847
+
848
+ $select = [
849
+ 'options' => [
850
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ],
851
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ],
852
+ ],
853
+ ];
854
+ $selected = isset( $current ) && ! empty( $current['show_in_nav_menus'] ) ? disp_boolean( $current['show_in_nav_menus'] ) : '';
855
  $select['selected'] = ( ! empty( $selected ) && ! empty( $current['show_in_nav_menus'] ) ) ? $current['show_in_nav_menus'] : '';
856
+ echo $ui->get_select_input( [
857
  'namearray' => 'cpt_custom_post_type',
858
  'name' => 'show_in_nav_menus',
859
  'labeltext' => esc_html__( 'Show in Nav Menus', 'custom-post-type-ui' ),
860
  'aftertext' => esc_html__( '(Custom Post Type UI default: true) Whether or not this post type is available for selection in navigation menus.', 'custom-post-type-ui' ),
861
  'selections' => $select,
862
+ ] );
863
+
864
+ $select = [
865
+ 'options' => [
866
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ), 'default' => 'false' ],
867
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ],
868
+ ]
869
+ ];
870
+ $selected = ( isset( $current ) && ! empty( $current['delete_with_user'] ) ) ? disp_boolean( $current['delete_with_user'] ) : '';
871
+ $select['selected'] = ( ! empty( $selected ) && ! empty( $current['delete_with_user'] ) ) ? $current['delete_with_user'] : '';
872
+ echo $ui->get_select_input( [
873
+ 'namearray' => 'cpt_custom_post_type',
874
+ 'name' => 'delete_with_user',
875
+ 'labeltext' => esc_html__( 'Delete with user', 'custom-post-type-ui' ),
876
+ 'aftertext' => esc_html__( '(CPTUI default: false) Whether to delete posts of this type when deleting a user.', 'custom-post-type-ui' ),
877
+ 'selections' => $select,
878
+ ] );
879
+
880
+ $select = [
881
+ 'options' => [
882
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ],
883
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ],
884
+ ],
885
+ ];
886
  $selected = ( isset( $current ) && ! empty( $current['show_in_rest'] ) ) ? disp_boolean( $current['show_in_rest'] ) : '';
887
  $select['selected'] = ( ! empty( $selected ) && ! empty( $current['show_in_rest'] ) ) ? $current['show_in_rest'] : '';
888
+ echo $ui->get_select_input( [
889
  'namearray' => 'cpt_custom_post_type',
890
  'name' => 'show_in_rest',
891
  'labeltext' => esc_html__( 'Show in REST API', 'custom-post-type-ui' ),
892
  'aftertext' => esc_html__( '(Custom Post Type UI default: true) Whether or not to show this post type data in the WP REST API.', 'custom-post-type-ui' ),
893
  'selections' => $select,
894
+ ] );
895
 
896
+ echo $ui->get_text_input( [
897
  'namearray' => 'cpt_custom_post_type',
898
  'name' => 'rest_base',
899
  'labeltext' => esc_html__( 'REST API base slug', 'custom-post-type-ui' ),
900
  'aftertext' => esc_attr__( 'Slug to use in REST API URLs.', 'custom-post-type-ui' ),
901
+ 'textvalue' => isset( $current['rest_base'] ) ? esc_attr( $current['rest_base'] ) : '',
902
+ ] );
903
 
904
+ echo $ui->get_text_input( [
905
  'namearray' => 'cpt_custom_post_type',
906
  'name' => 'rest_controller_class',
907
  'labeltext' => esc_html__( 'REST API controller class', 'custom-post-type-ui' ),
908
  'aftertext' => esc_attr__( '(default: WP_REST_Posts_Controller) Custom controller to use instead of WP_REST_Posts_Controller.', 'custom-post-type-ui' ),
909
+ 'textvalue' => isset( $current['rest_controller_class'] ) ? esc_attr( $current['rest_controller_class'] ) : '',
910
+ ] );
911
 
912
  echo $ui->get_tr_start() . $ui->get_th_start();
913
  echo $ui->get_label( 'has_archive', esc_html__( 'Has Archive', 'custom-post-type-ui' ) );
914
  echo $ui->get_p( esc_html__( 'If left blank, the archive slug will default to the post type slug.', 'custom-post-type-ui' ) );
915
  echo $ui->get_th_end() . $ui->get_td_start();
916
 
917
+ $select = [
918
+ 'options' => [
919
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ), 'default' => 'true' ],
920
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ],
921
+ ],
922
+ ];
923
+ $selected = isset( $current ) ? disp_boolean( $current['has_archive'] ) : '';
924
+ $select['selected'] = ! empty( $selected ) ? $current['has_archive'] : '';
925
+ echo $ui->get_select_input( [
926
  'namearray' => 'cpt_custom_post_type',
927
  'name' => 'has_archive',
928
  'aftertext' => esc_html__( '(default: false) Whether or not the post type will have a post type archive URL.', 'custom-post-type-ui' ),
929
  'selections' => $select,
930
  'wrap' => false,
931
+ ] );
932
 
933
  echo '<br/>';
934
 
935
+ echo $ui->get_text_input( [
936
  'namearray' => 'cpt_custom_post_type',
937
  'name' => 'has_archive_string',
938
+ 'textvalue' => isset( $current['has_archive_string'] ) ? esc_attr( $current['has_archive_string'] ) : '',
939
  'aftertext' => esc_attr__( 'Slug to be used for archive URL.', 'custom-post-type-ui' ),
940
  'helptext_after' => true,
941
  'wrap' => false,
942
+ ] );
943
  echo $ui->get_td_end() . $ui->get_tr_end();
944
 
945
+ $select = [
946
+ 'options' => [
947
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ), 'default' => 'true' ],
948
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ],
949
+ ],
950
+ ];
951
+ $selected = isset( $current ) ? disp_boolean( $current['exclude_from_search'] ) : '';
952
+ $select['selected'] = ! empty( $selected ) ? $current['exclude_from_search'] : '';
953
+ echo $ui->get_select_input( [
954
  'namearray' => 'cpt_custom_post_type',
955
  'name' => 'exclude_from_search',
956
  'labeltext' => esc_html__( 'Exclude From Search', 'custom-post-type-ui' ),
957
  'aftertext' => esc_html__( '(default: false) Whether or not to exclude posts with this post type from front end search results.', 'custom-post-type-ui' ),
958
  'selections' => $select,
959
+ ] );
960
 
961
+ echo $ui->get_text_input( [
962
  'namearray' => 'cpt_custom_post_type',
963
  'name' => 'capability_type',
964
+ 'textvalue' => isset( $current['capability_type'] ) ? esc_attr( $current['capability_type'] ) : 'post',
965
  'labeltext' => esc_html__( 'Capability Type', 'custom-post-type-ui' ),
966
  'helptext' => esc_html__( 'The post type to use for checking read, edit, and delete capabilities. A comma-separated second value can be used for plural version.', 'custom-post-type-ui' ),
967
+ ] );
968
+
969
+ $select = [
970
+ 'options' => [
971
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ), 'default' => 'true' ],
972
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ],
973
+ ],
974
+ ];
975
+ $selected = isset( $current ) ? disp_boolean( $current['hierarchical'] ) : '';
976
+ $select['selected'] = ! empty( $selected ) ? $current['hierarchical'] : '';
977
+ echo $ui->get_select_input( [
978
  'namearray' => 'cpt_custom_post_type',
979
  'name' => 'hierarchical',
980
  'labeltext' => esc_html__( 'Hierarchical', 'custom-post-type-ui' ),
981
  'aftertext' => esc_html__( '(default: false) Whether or not the post type can have parent-child relationships.', 'custom-post-type-ui' ),
982
  'selections' => $select,
983
+ ] );
984
+
985
+ $select = [
986
+ 'options' => [
987
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ],
988
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ],
989
+ ],
990
+ ];
991
+ $selected = isset( $current ) ? disp_boolean( $current['rewrite'] ) : '';
992
+ $select['selected'] = ! empty( $selected ) ? $current['rewrite'] : '';
993
+ echo $ui->get_select_input( [
994
  'namearray' => 'cpt_custom_post_type',
995
  'name' => 'rewrite',
996
  'labeltext' => esc_html__( 'Rewrite', 'custom-post-type-ui' ),
997
  'aftertext' => esc_html__( '(default: true) Whether or not WordPress should use rewrites for this post type.', 'custom-post-type-ui' ),
998
  'selections' => $select,
999
+ ] );
1000
 
1001
+ echo $ui->get_text_input( [
1002
  'namearray' => 'cpt_custom_post_type',
1003
  'name' => 'rewrite_slug',
1004
+ 'textvalue' => isset( $current['rewrite_slug'] ) ? esc_attr( $current['rewrite_slug'] ) : '',
1005
  'labeltext' => esc_html__( 'Custom Rewrite Slug', 'custom-post-type-ui' ),
1006
  'aftertext' => esc_attr__( '(default: post type slug)', 'custom-post-type-ui' ),
1007
  'helptext' => esc_html__( 'Custom post type slug to use instead of the default.', 'custom-post-type-ui' ),
1008
+ ] );
1009
+
1010
+ $select = [
1011
+ 'options' => [
1012
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ],
1013
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ],
1014
+ ],
1015
+ ];
1016
+ $selected = isset( $current ) ? disp_boolean( $current['rewrite_withfront'] ) : '';
1017
+ $select['selected'] = ! empty( $selected ) ? $current['rewrite_withfront'] : '';
1018
+ echo $ui->get_select_input( [
1019
  'namearray' => 'cpt_custom_post_type',
1020
  'name' => 'rewrite_withfront',
1021
  'labeltext' => esc_html__( 'With Front', 'custom-post-type-ui' ),
1022
  'aftertext' => esc_html__( '(default: true) Should the permalink structure be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/).', 'custom-post-type-ui' ),
1023
  'selections' => $select,
1024
+ ] );
1025
+
1026
+ $select = [
1027
+ 'options' => [
1028
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ],
1029
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ],
1030
+ ],
1031
+ ];
1032
+ $selected = isset( $current ) ? disp_boolean( $current['query_var'] ) : '';
1033
+ $select['selected'] = ! empty( $selected ) ? $current['query_var'] : '';
1034
+ echo $ui->get_select_input( [
1035
  'namearray' => 'cpt_custom_post_type',
1036
  'name' => 'query_var',
1037
  'labeltext' => esc_html__( 'Query Var', 'custom-post-type-ui' ),
1038
  'aftertext' => esc_html__( '(default: true) Sets the query_var key for this post type.', 'custom-post-type-ui' ),
1039
  'selections' => $select,
1040
+ ] );
1041
 
1042
+ echo $ui->get_text_input( [
1043
  'namearray' => 'cpt_custom_post_type',
1044
  'name' => 'query_var_slug',
1045
+ 'textvalue' => isset( $current['query_var_slug'] ) ? esc_attr( $current['query_var_slug'] ) : '',
1046
  'labeltext' => esc_html__( 'Custom Query Var Slug', 'custom-post-type-ui' ),
1047
  'aftertext' => esc_attr__( '(default: post type slug) Query var needs to be true to use.', 'custom-post-type-ui' ),
1048
  'helptext' => esc_html__( 'Custom query var slug to use instead of the default.', 'custom-post-type-ui' ),
1049
+ ] );
1050
 
1051
  echo $ui->get_tr_start() . $ui->get_th_start();
1052
  echo $ui->get_label( 'menu_position', esc_html__( 'Menu Position', 'custom-post-type-ui' ) );
1064
  );
1065
 
1066
  echo $ui->get_th_end() . $ui->get_td_start();
1067
+ echo $ui->get_text_input( [
1068
  'namearray' => 'cpt_custom_post_type',
1069
  'name' => 'menu_position',
1070
+ 'textvalue' => isset( $current['menu_position'] ) ? esc_attr( $current['menu_position'] ) : '',
1071
  'helptext' => esc_html__( 'The position in the menu order the post type should appear. show_in_menu must be true.', 'custom-post-type-ui' ),
1072
  'wrap' => false,
1073
+ ] );
1074
  echo $ui->get_td_end() . $ui->get_tr_end();
1075
 
1076
  echo $ui->get_tr_start() . $ui->get_th_start();
1078
  echo $ui->get_p( esc_html__( '"Show UI" must be "true". If an existing top level page such as "tools.php" is indicated for second input, post type will be sub menu of that.', 'custom-post-type-ui' ) );
1079
  echo $ui->get_th_end() . $ui->get_td_start();
1080
 
1081
+ $select = [
1082
+ 'options' => [
1083
+ [ 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ],
1084
+ [ 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ],
1085
+ ],
1086
+ ];
1087
+ $selected = isset( $current ) ? disp_boolean( $current['show_in_menu'] ) : '';
1088
+ $select['selected'] = ! empty( $selected ) ? $current['show_in_menu'] : '';
1089
+ echo $ui->get_select_input( [
1090
  'namearray' => 'cpt_custom_post_type',
1091
  'name' => 'show_in_menu',
1092
  'aftertext' => esc_html__( '(default: true) Whether or not to show the post type in the admin menu and where to show that menu.', 'custom-post-type-ui' ),
1093
  'selections' => $select,
1094
  'wrap' => false,
1095
+ ] );
1096
 
1097
  echo '<br/>';
1098
 
1099
+ echo $ui->get_text_input( [
1100
  'namearray' => 'cpt_custom_post_type',
1101
  'name' => 'show_in_menu_string',
1102
+ 'textvalue' => isset( $current['show_in_menu_string'] ) ? esc_attr( $current['show_in_menu_string'] ) : '',
1103
  'helptext' => esc_attr__( 'The top-level admin menu page file name for which the post type should be in the sub menu of.', 'custom-post-type-ui' ),
1104
  'helptext_after' => true,
1105
  'wrap' => false,
1106
+ ] );
1107
  echo $ui->get_td_end() . $ui->get_tr_end();
1108
 
1109
  echo $ui->get_tr_start() . $ui->get_th_start() . '<label for="menu_icon">' . __( 'Menu Icon', 'custom-post-type-ui' ) . '</label>' . $ui->get_th_end() . $ui->get_td_start();
1110
+
1111
+ echo $ui->get_text_input( [
1112
  'namearray' => 'cpt_custom_post_type',
1113
  'name' => 'menu_icon',
1114
+ 'textvalue' => isset( $current['menu_icon'] ) ? esc_attr( $current['menu_icon'] ) : '',
1115
  'aftertext' => esc_attr__( '(Full URL for icon or Dashicon class)', 'custom-post-type-ui' ),
1116
+ 'helptext' => sprintf(
1117
+ esc_html__( 'Image URL or %sDashicon class name%s to use for icon. Custom image should be 20px by 20px.', 'custom-post-type-ui' ),
1118
+ '<a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">',
1119
+ '</a>'
1120
+ ),
1121
  'wrap' => false,
1122
+ ] );
1123
 
1124
  echo '<div class="cptui-spacer">';
1125
 
1126
+ echo $ui->get_button( [
1127
  'id' => 'cptui_choose_icon',
1128
  'textvalue' => esc_attr__( 'Choose image icon', 'custom-post-type-ui' ),
1129
+ ] );
1130
  echo '</div>';
1131
 
1132
  echo $ui->get_td_end() . $ui->get_tr_end();
1139
 
1140
  echo $ui->get_th_end() . $ui->get_td_start() . $ui->get_fieldset_start();
1141
 
1142
+ echo $ui->get_legend_start() . esc_html__( 'Post type options', 'custom-post-type-ui' ) . $ui->get_legend_end();
1143
+
1144
  $title_checked = ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'title', $current['supports'] ) ) ? 'true' : 'false';
1145
+ if ( 'new' === $tab ) {
1146
  $title_checked = 'true';
1147
  }
1148
+ echo $ui->get_check_input( [
1149
  'checkvalue' => 'title',
1150
  'checked' => $title_checked,
1151
  'name' => 'title',
1154
  'labeltext' => esc_html__( 'Title', 'custom-post-type-ui' ),
1155
  'default' => true,
1156
  'wrap' => false,
1157
+ ] );
1158
 
1159
  $editor_checked = ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'editor', $current['supports'] ) ) ? 'true' : 'false';
1160
+ if ( 'new' === $tab ) {
1161
  $editor_checked = 'true';
1162
  }
1163
+ echo $ui->get_check_input( [
1164
  'checkvalue' => 'editor',
1165
  'checked' => $editor_checked,
1166
  'name' => 'editor',
1169
  'labeltext' => esc_html__( 'Editor', 'custom-post-type-ui' ),
1170
  'default' => true,
1171
  'wrap' => false,
1172
+ ] );
1173
 
1174
  $thumb_checked = ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'thumbnail', $current['supports'] ) ) ? 'true' : 'false';
1175
+ if ( 'new' === $tab ) {
1176
  $thumb_checked = 'true';
1177
  }
1178
+ echo $ui->get_check_input( [
1179
  'checkvalue' => 'thumbnail',
1180
  'checked' => $thumb_checked,
1181
  'name' => 'thumbnail',
1184
  'labeltext' => esc_html__( 'Featured Image', 'custom-post-type-ui' ),
1185
  'default' => true,
1186
  'wrap' => false,
1187
+ ] );
1188
 
1189
+ echo $ui->get_check_input( [
1190
  'checkvalue' => 'excerpt',
1191
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'excerpt', $current['supports'] ) ) ? 'true' : 'false',
1192
  'name' => 'excerpts',
1195
  'labeltext' => esc_html__( 'Excerpt', 'custom-post-type-ui' ),
1196
  'default' => true,
1197
  'wrap' => false,
1198
+ ] );
1199
 
1200
+ echo $ui->get_check_input( [
1201
  'checkvalue' => 'trackbacks',
1202
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'trackbacks', $current['supports'] ) ) ? 'true' : 'false',
1203
  'name' => 'trackbacks',
1206
  'labeltext' => esc_html__( 'Trackbacks', 'custom-post-type-ui' ),
1207
  'default' => true,
1208
  'wrap' => false,
1209
+ ] );
1210
 
1211
+ echo $ui->get_check_input( [
1212
  'checkvalue' => 'custom-fields',
1213
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'custom-fields', $current['supports'] ) ) ? 'true' : 'false',
1214
  'name' => 'custom-fields',
1217
  'labeltext' => esc_html__( 'Custom Fields', 'custom-post-type-ui' ),
1218
  'default' => true,
1219
  'wrap' => false,
1220
+ ] );
1221
 
1222
+ echo $ui->get_check_input( [
1223
  'checkvalue' => 'comments',
1224
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'comments', $current['supports'] ) ) ? 'true' : 'false',
1225
  'name' => 'comments',
1228
  'labeltext' => esc_html__( 'Comments', 'custom-post-type-ui' ),
1229
  'default' => true,
1230
  'wrap' => false,
1231
+ ] );
1232
 
1233
+ echo $ui->get_check_input( [
1234
  'checkvalue' => 'revisions',
1235
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'revisions', $current['supports'] ) ) ? 'true' : 'false',
1236
  'name' => 'revisions',
1239
  'labeltext' => esc_html__( 'Revisions', 'custom-post-type-ui' ),
1240
  'default' => true,
1241
  'wrap' => false,
1242
+ ] );
1243
 
1244
+ echo $ui->get_check_input( [
1245
  'checkvalue' => 'author',
1246
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'author', $current['supports'] ) ) ? 'true' : 'false',
1247
  'name' => 'author',
1250
  'labeltext' => esc_html__( 'Author', 'custom-post-type-ui' ),
1251
  'default' => true,
1252
  'wrap' => false,
1253
+ ] );
1254
 
1255
+ echo $ui->get_check_input( [
1256
  'checkvalue' => 'page-attributes',
1257
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'page-attributes', $current['supports'] ) ) ? 'true' : 'false',
1258
  'name' => 'page-attributes',
1261
  'labeltext' => esc_html__( 'Page Attributes', 'custom-post-type-ui' ),
1262
  'default' => true,
1263
  'wrap' => false,
1264
+ ] );
1265
 
1266
+ echo $ui->get_check_input( [
1267
  'checkvalue' => 'post-formats',
1268
  'checked' => ( ! empty( $current['supports'] ) && is_array( $current['supports'] ) && in_array( 'post-formats', $current['supports'] ) ) ? 'true' : 'false',
1269
  'name' => 'post-formats',
1272
  'labeltext' => esc_html__( 'Post Formats', 'custom-post-type-ui' ),
1273
  'default' => true,
1274
  'wrap' => false,
1275
+ ] );
1276
 
1277
+ echo $ui->get_check_input( [
1278
  'checkvalue' => 'none',
1279
  'checked' => ( ! empty( $current['supports'] ) && ( is_array( $current['supports'] ) && in_array( 'none', $current['supports'] ) ) ) ? 'true' : 'false',
1280
  'name' => 'none',
1283
  'labeltext' => esc_html__( 'None', 'custom-post-type-ui' ),
1284
  'default' => false,
1285
  'wrap' => false,
1286
+ ] );
1287
 
1288
  echo $ui->get_fieldset_end() . $ui->get_td_end() . $ui->get_tr_end();
1289
 
1290
  echo $ui->get_tr_start() . $ui->get_th_start() . '<label for="custom_supports">' . esc_html__( 'Custom "Supports"', 'custom-post-type-ui' ) . '</label>';
1291
  echo $ui->get_p( sprintf( esc_html__( 'Use this input to register custom "supports" values, separated by commas. Learn about this at %s', 'custom-post-type-ui' ), '<a href="http://docs.pluginize.com/article/28-third-party-support-upon-registration" target="_blank">' . esc_html__( 'Custom "Supports"', 'custom-post-type-ui' ) . '</a>' ) );
1292
  echo $ui->get_th_end() . $ui->get_td_start();
1293
+ echo $ui->get_text_input( [
1294
  'namearray' => 'cpt_custom_post_type',
1295
  'name' => 'custom_supports',
1296
+ 'textvalue' => isset( $current['custom_supports'] ) ? esc_attr( $current['custom_supports'] ) : '',
1297
  'helptext' => esc_attr__( 'Provide custom support slugs here.', 'custom-post-type-ui' ),
1298
  'helptext_after' => true,
1299
  'wrap' => false,
1300
+ ] );
1301
  echo $ui->get_td_end() . $ui->get_tr_end();
1302
 
1303
+ echo $ui->get_tr_start() . $ui->get_th_start() . esc_html__( 'Taxonomies', 'custom-post-type-ui' );
1304
 
1305
  echo $ui->get_p( esc_html__( 'Add support for available registered taxonomies.', 'custom-post-type-ui' ) );
1306
 
1307
  echo $ui->get_th_end() . $ui->get_td_start() . $ui->get_fieldset_start();
1308
 
1309
+ echo $ui->get_legend_start() . esc_html__( 'Taxonomy options', 'custom-post-type-ui' ) . $ui->get_legend_end();
1310
  /**
1311
  * Filters the arguments for taxonomies to list for post type association.
1312
  *
1314
  *
1315
  * @param array $value Array of default arguments.
1316
  */
1317
+ $args = apply_filters( 'cptui_attach_taxonomies_to_post_type', [ 'public' => true ] );
1318
 
1319
  // If they don't return an array, fall back to the original default. Don't need to check for empty, because empty array is default for $args param in get_post_types anyway.
1320
  if ( ! is_array( $args ) ) {
1321
+ $args = [ 'public' => true ];
1322
  }
1323
 
1324
  /**
1330
  * @param array $args Array of arguments for the taxonomies query.
1331
  */
1332
  $add_taxes = apply_filters( 'cptui_get_taxonomies_for_post_types', get_taxonomies( $args, 'objects' ), $args );
1333
+ unset( $add_taxes['nav_menu'], $add_taxes['post_format'] );
1334
  foreach ( $add_taxes as $add_tax ) {
1335
 
1336
+ $core_label = in_array( $add_tax->name, [ 'category', 'post_tag' ] ) ? __( '(WP Core)', 'custom-post-type-ui' ) : '';
1337
+ echo $ui->get_check_input( [
1338
  'checkvalue' => $add_tax->name,
1339
  'checked' => ( ! empty( $current['taxonomies'] ) && is_array( $current['taxonomies'] ) && in_array( $add_tax->name, $current['taxonomies'] ) ) ? 'true' : 'false',
1340
  'name' => $add_tax->name,
1343
  'labeltext' => $add_tax->label . ' ' . $core_label,
1344
  'helptext' => sprintf( esc_attr__( 'Adds %s support', 'custom-post-type-ui' ), $add_tax->label ),
1345
  'wrap' => false,
1346
+ ] );
1347
  }
1348
  echo $ui->get_fieldset_end() . $ui->get_td_end() . $ui->get_tr_end();
1349
  ?>
1364
 
1365
  <p>
1366
  <?php
1367
+ if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) {
1368
  /**
1369
  * Filters the text value to use on the button when editing.
1370
  *
1412
  *
1413
  * @param array $post_types Array of post types that are registered. Optional.
1414
  */
1415
+ function cptui_post_types_dropdown( $post_types = [] ) {
1416
 
1417
  $ui = new cptui_admin_ui();
1418
 
1419
  if ( ! empty( $post_types ) ) {
1420
+ $select = [];
1421
+ $select['options'] = [];
1422
 
1423
  foreach ( $post_types as $type ) {
1424
+ $text = ! empty( $type['label'] ) ? $type['label'] : $type['name'];
1425
+ $select['options'][] = [ 'attr' => $type['name'], 'text' => $text ];
1426
  }
1427
 
1428
  $current = cptui_get_current_post_type();
1438
  */
1439
  $select = apply_filters( 'cptui_post_types_dropdown_options', $select, $post_types );
1440
 
1441
+ echo $ui->get_select_input( [
1442
  'namearray' => 'cptui_selected_post_type',
1443
  'name' => 'post_type',
1444
  'selections' => $select,
1445
  'wrap' => false,
1446
+ ] );
1447
  }
1448
  }
1449
 
1509
  * @param array $data $_POST values. Optional.
1510
  * @return bool|string False on failure, string on success.
1511
  */
1512
+ function cptui_delete_post_type( $data = [] ) {
1513
 
1514
  // Pass double data into last function despite matching values.
1515
  if ( is_string( $data ) && cptui_get_post_type_exists( $data, $data ) ) {
1516
+ $data = [
1517
+ 'cpt_custom_post_type' => [
1518
  'name' => $data,
1519
+ ],
1520
+ ];
1521
  }
1522
 
1523
  if ( empty( $data['cpt_custom_post_type']['name'] ) ) {
1581
  * @param array $data Array of post type data to update. Optional.
1582
  * @return bool|string False on failure, string on success.
1583
  */
1584
+ function cptui_update_post_type( $data = [] ) {
1585
 
1586
  /**
1587
  * Fires before a post_type is updated to our saved options.
1638
  add_filter( 'cptui_custom_error_message', 'cptui_slug_matches_post_type' );
1639
  return 'error';
1640
  }
1641
+ if ( 'new' === $data['cpt_type_status'] ) {
1642
  $slug_as_page = cptui_check_page_slugs( $data['cpt_custom_post_type']['name'] );
1643
  if ( true === $slug_as_page ) {
1644
  add_filter( 'cptui_custom_error_message', 'cptui_slug_matches_page' );
1647
  }
1648
 
1649
  if ( empty( $data['cpt_addon_taxes'] ) || ! is_array( $data['cpt_addon_taxes'] ) ) {
1650
+ $data['cpt_addon_taxes'] = [];
1651
  }
1652
 
1653
  if ( empty( $data['cpt_supports'] ) || ! is_array( $data['cpt_supports'] ) ) {
1654
+ $data['cpt_supports'] = [];
1655
  }
1656
 
1657
  foreach ( $data['cpt_labels'] as $key => $label ) {
1698
  $menu_icon = trim( $data['cpt_custom_post_type']['menu_icon'] );
1699
  $custom_supports = trim( $data['cpt_custom_post_type']['custom_supports'] );
1700
 
1701
+ $post_types[ $data['cpt_custom_post_type']['name'] ] = [
1702
  'name' => $name,
1703
  'label' => $label,
1704
  'singular_label' => $singular_label,
1707
  'publicly_queryable' => disp_boolean( $data['cpt_custom_post_type']['publicly_queryable'] ),
1708
  'show_ui' => disp_boolean( $data['cpt_custom_post_type']['show_ui'] ),
1709
  'show_in_nav_menus' => disp_boolean( $data['cpt_custom_post_type']['show_in_nav_menus'] ),
1710
+ 'delete_with_user' => disp_boolean( $data['cpt_custom_post_type']['delete_with_user'] ),
1711
  'show_in_rest' => disp_boolean( $data['cpt_custom_post_type']['show_in_rest'] ),
1712
  'rest_base' => $rest_base,
1713
  'rest_controller_class' => $rest_controller_class,
1729
  'taxonomies' => $data['cpt_addon_taxes'],
1730
  'labels' => $data['cpt_labels'],
1731
  'custom_supports' => $custom_supports,
1732
+ ];
1733
 
1734
  /**
1735
  * Filters final data to be saved right before saving post type data.
1766
  // Used to help flush rewrite rules on init.
1767
  set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
1768
 
1769
+ if ( isset( $success ) && 'new' === $data['cpt_type_status'] ) {
1770
+ return 'add_success';
 
 
1771
  }
1772
  return 'update_success';
1773
  }
1781
  */
1782
  function cptui_reserved_post_types() {
1783
 
1784
+ $reserved = [
1785
  'post',
1786
  'page',
1787
  'attachment',
1796
  'customize_changeset',
1797
  'author',
1798
  'post_type',
1799
+ ];
1800
 
1801
  /**
1802
  * Filters the list of reserved post types to check against.
1807
  *
1808
  * @param array $value Array of post type slugs to forbid.
1809
  */
1810
+ $custom_reserved = apply_filters( 'cptui_reserved_post_types', [] );
1811
 
1812
  if ( is_string( $custom_reserved ) && ! empty( $custom_reserved ) ) {
1813
  $reserved[] = $custom_reserved;
1831
  * @param string $new_slug New post type slug. Optional. Default empty string.
1832
  */
1833
  function cptui_convert_post_type_posts( $original_slug = '', $new_slug = '' ) {
1834
+ $args = [
1835
  'posts_per_page' => -1,
1836
  'post_type' => $original_slug,
1837
+ ];
1838
  $convert = new WP_Query( $args );
1839
 
1840
  if ( $convert->have_posts() ) :
1857
  * @param array $post_types Array of CPTUI-registered post types. Optional.
1858
  * @return bool
1859
  */
1860
+ function cptui_check_existing_post_type_slugs( $slug_exists = false, $post_type_slug = '', $post_types = [] ) {
1861
 
1862
  // If true, then we'll already have a conflict, let's not re-process.
1863
  if ( true === $slug_exists ) {
1875
  }
1876
 
1877
  // Check if other plugins have registered non-public this same slug.
1878
+ $public = get_post_types( [ '_builtin' => false, 'public' => true ] );
1879
+ $private = get_post_types( [ '_builtin' => false, 'public' => false ] );
1880
  $registered_post_types = array_merge( $public, $private );
1881
  if ( in_array( $post_type_slug, $registered_post_types ) ) {
1882
  return true;
1898
  function cptui_check_page_slugs( $post_type_slug = '' ) {
1899
  $page = get_page_by_path( $post_type_slug );
1900
 
1901
+ if ( null === $page ) {
1902
  return false;
1903
  }
1904
 
1945
  add_action( 'admin_notices', "cptui_{$result}_admin_notice" );
1946
  }
1947
  }
1948
+ if ( empty( cptui_get_post_type_slugs() ) ) {
1949
+ wp_safe_redirect(
1950
+ add_query_arg(
1951
+ [ 'page' => 'cptui_manage_post_types' ],
1952
+ cptui_admin_url( 'admin.php?page=cptui_manage_post_types' )
1953
+ )
1954
+ );
1955
+ }
1956
  }
1957
  }
1958
  add_action( 'init', 'cptui_process_post_type', 8 );
1991
  * @param array $post_types CPTUI post types.
1992
  * @return bool
1993
  */
1994
+ function cptui_updated_post_type_slug_exists( $slug_exists, $post_type_slug = '', $post_types = [] ) {
1995
  if (
1996
+ ( ! empty( $_POST['cpt_type_status'] ) && 'edit' === $_POST['cpt_type_status'] ) &&
1997
  ! in_array( $post_type_slug, cptui_reserved_post_types() ) &&
1998
  ( ! empty( $_POST['cpt_original'] ) && $post_type_slug === $_POST['cpt_original'] )
1999
  )
inc/support.php CHANGED
@@ -9,6 +9,8 @@
9
  * @license GPL-2.0+
10
  */
11
 
 
 
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
@@ -200,14 +202,25 @@ function cptui_support() {
200
  '<a href="http://docs.pluginize.com/article/17-post-types-in-category-tag-archives" target="_blank">http://docs.pluginize.com/article/17-post-types-in-category-tag-archives</a>'
201
  ); ?> </div>
202
  </li>
 
 
 
 
 
 
 
 
 
 
 
203
  </ol>
204
  </td>
205
  <td class="outer">
206
  <h2><?php esc_html_e( 'Advanced', 'custom-post-type-ui' ); ?></h2>
207
  <ol id="questions_advanced">
208
  <li>
209
- <span tabindex="0" class="question" aria-controls="q18" aria-expanded="false"><?php esc_html_e( 'How do I add custom metaboxes to my post type?', 'custom-post-type-ui' ); ?></span>
210
- <div class="answer" id="q18">
211
  <?php
212
  printf(
213
  esc_html__( 'We recommend checking out %s, the latest iteration of "Custom Metaboxes and Fields for WordPress". Both are maintained by WebDevStudios.', 'custom-post-type-ui' ),
@@ -216,8 +229,8 @@ function cptui_support() {
216
  </div>
217
  </li>
218
  <li>
219
- <span tabindex="0" class="question" aria-controls="q19" aria-expanded="false"><?php esc_html_e( 'How do I add a newly registered taxonomy to a post type that already exists?', 'custom-post-type-ui' ); ?></span>
220
- <div class="answer" id="q19">
221
  <?php
222
  printf(
223
  esc_html__( 'Check out the %s function for documentation and usage examples.', 'custom-post-type-ui' ),
@@ -226,8 +239,8 @@ function cptui_support() {
226
  </div>
227
  </li>
228
  <li>
229
- <span tabindex="0" class="question" aria-controls="q20" aria-expanded="false"><?php esc_html_e( 'Post relationships?', 'custom-post-type-ui' ); ?></span>
230
- <div class="answer" id="q20">
231
  <?php
232
  printf(
233
  esc_html__( '%s has an excellent %spost%s introducing users to the %sPosts 2 Posts%s plugin that should be a good start.', 'custom-post-type-ui' ),
@@ -239,13 +252,13 @@ function cptui_support() {
239
  ); ?></div>
240
  </li>
241
  <li>
242
- <span tabindex="0" class="question" aria-controls="q21" aria-expanded="false"><?php esc_html_e( 'Is there any function reference list?', 'custom-post-type-ui' ); ?></span>
243
- <div class="answer" id="q21"><?php printf( esc_html__( '%s has compiled a nice list of functions used by our plugin. Note not all will be useful as they are attached to hooks.', 'custom-post-type-ui' ),
244
  '<a href="http://hookr.io/plugins/custom-post-type-ui/" target="_blank">Hookr.io</a>' ); ?></div>
245
  </li>
246
  <li>
247
- <span tabindex="0" class="question" aria-controls="q22" aria-expanded="false"><?php esc_html_e( 'How do I filter the "enter title here" text in the post editor screen?', 'custom-post-type-ui' ); ?></span>
248
- <div class="answer" id="q22"><p><?php esc_html_e( 'Change text inside the post/page editor title field. Should be able to adapt as necessary.', 'custom-post-type-ui' ); ?></p>
249
  <pre><code>function my_custom_title_text( $title ){
250
  global $post;
251
  if ( 'ENTER POST TYPE SLUG HERE' == $post->post_type )
@@ -256,8 +269,8 @@ add_filter( 'enter_title_here', 'my_custom_title_text' );
256
  </code></pre></div>
257
  </li>
258
  <li>
259
- <span tabindex="0" class="question" aria-controls="q23" aria-expanded="false"><?php esc_html_e( 'Any help with customizing capabilities?', 'custom-post-type-ui' ); ?></span>
260
- <div class="answer" id="q23">
261
  <p><?php printf( esc_html__( 'We recommend %s for some extended customization and addition of extra fields regarding roles and capabilities.', 'custom-post-type-ui' ),
262
  '<a href="https://github.com/tw2113/custom-post-type-ui-capabilities" target="_blank">Custom Post Type UI Capabilities on GitHub</a>' ); ?></p>
263
  </div>
9
  * @license GPL-2.0+
10
  */
11
 
12
+ // phpcs:disable WebDevStudios.All.RequireAuthor
13
+
14
  // Exit if accessed directly.
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
202
  '<a href="http://docs.pluginize.com/article/17-post-types-in-category-tag-archives" target="_blank">http://docs.pluginize.com/article/17-post-types-in-category-tag-archives</a>'
203
  ); ?> </div>
204
  </li>
205
+ <li>
206
+ <span tabindex="0" class="question" aria-controls="q18" aria-expanded="false"><?php esc_html_e( 'How do I add custom post type support for custom templates selection like pages have?', 'custom-post-type-ui' ); ?></span>
207
+ <div class="answer" id="q18">
208
+ <?php
209
+ printf(
210
+ esc_html__( 'Please visit the %sPost Type Templates in 4.7%s post on the Make WordPress Core blog for details about setting templates for multiple post types.', 'custom-post-type-ui' ),
211
+ '<a href="https://make.wordpress.org/core/2016/11/03/post-type-templates-in-4-7/" target="_blank">',
212
+ '</a>'
213
+ ); ?>
214
+ </div>
215
+ </li>
216
  </ol>
217
  </td>
218
  <td class="outer">
219
  <h2><?php esc_html_e( 'Advanced', 'custom-post-type-ui' ); ?></h2>
220
  <ol id="questions_advanced">
221
  <li>
222
+ <span tabindex="0" class="question" aria-controls="q19" aria-expanded="false"><?php esc_html_e( 'How do I add custom metaboxes to my post type?', 'custom-post-type-ui' ); ?></span>
223
+ <div class="answer" id="q19">
224
  <?php
225
  printf(
226
  esc_html__( 'We recommend checking out %s, the latest iteration of "Custom Metaboxes and Fields for WordPress". Both are maintained by WebDevStudios.', 'custom-post-type-ui' ),
229
  </div>
230
  </li>
231
  <li>
232
+ <span tabindex="0" class="question" aria-controls="q20" aria-expanded="false"><?php esc_html_e( 'How do I add a newly registered taxonomy to a post type that already exists?', 'custom-post-type-ui' ); ?></span>
233
+ <div class="answer" id="q20">
234
  <?php
235
  printf(
236
  esc_html__( 'Check out the %s function for documentation and usage examples.', 'custom-post-type-ui' ),
239
  </div>
240
  </li>
241
  <li>
242
+ <span tabindex="0" class="question" aria-controls="q21" aria-expanded="false"><?php esc_html_e( 'Post relationships?', 'custom-post-type-ui' ); ?></span>
243
+ <div class="answer" id="q21">
244
  <?php
245
  printf(
246
  esc_html__( '%s has an excellent %spost%s introducing users to the %sPosts 2 Posts%s plugin that should be a good start.', 'custom-post-type-ui' ),
252
  ); ?></div>
253
  </li>
254
  <li>
255
+ <span tabindex="0" class="question" aria-controls="q22" aria-expanded="false"><?php esc_html_e( 'Is there any function reference list?', 'custom-post-type-ui' ); ?></span>
256
+ <div class="answer" id="q22"><?php printf( esc_html__( '%s has compiled a nice list of functions used by our plugin. Note not all will be useful as they are attached to hooks.', 'custom-post-type-ui' ),
257
  '<a href="http://hookr.io/plugins/custom-post-type-ui/" target="_blank">Hookr.io</a>' ); ?></div>
258
  </li>
259
  <li>
260
+ <span tabindex="0" class="question" aria-controls="q23" aria-expanded="false"><?php esc_html_e( 'How do I filter the "enter title here" text in the post editor screen?', 'custom-post-type-ui' ); ?></span>
261
+ <div class="answer" id="q23"><p><?php esc_html_e( 'Change text inside the post/page editor title field. Should be able to adapt as necessary.', 'custom-post-type-ui' ); ?></p>
262
  <pre><code>function my_custom_title_text( $title ){
263
  global $post;
264
  if ( 'ENTER POST TYPE SLUG HERE' == $post->post_type )
269
  </code></pre></div>
270
  </li>
271
  <li>
272
+ <span tabindex="0" class="question" aria-controls="q24" aria-expanded="false"><?php esc_html_e( 'Any help with customizing capabilities?', 'custom-post-type-ui' ); ?></span>
273
+ <div class="answer" id="q24">
274
  <p><?php printf( esc_html__( 'We recommend %s for some extended customization and addition of extra fields regarding roles and capabilities.', 'custom-post-type-ui' ),
275
  '<a href="https://github.com/tw2113/custom-post-type-ui-capabilities" target="_blank">Custom Post Type UI Capabilities on GitHub</a>' ); ?></p>
276
  </div>
inc/taxonomies.php CHANGED
@@ -9,6 +9,8 @@
9
  * @license GPL-2.0+
10
  */
11
 
 
 
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
@@ -36,16 +38,22 @@ function cptui_taxonomies_enqueue_scripts() {
36
  wp_enqueue_script( 'cptui' );
37
  wp_enqueue_style( 'cptui-css' );
38
 
39
- $core = get_taxonomies( array( '_builtin' => true ) );
40
- $public = get_taxonomies( array( '_builtin' => false, 'public' => true ) );
41
- $private = get_taxonomies( array( '_builtin' => false, 'public' => false ) );
 
 
 
 
 
 
42
  $registered_taxonomies = array_merge( $core, $public, $private );
43
  wp_localize_script( 'cptui', 'cptui_tax_data',
44
- array(
45
- 'confirm' => esc_html__( 'Are you sure you want to delete this? Deleting will NOT remove created content.', 'custom-post-type-ui' ),
46
- 'no_associated_type' => esc_html( 'Please select a post type to associate with.', 'custom-post-type-ui' ),
47
  'existing_taxonomies' => $registered_taxonomies,
48
- )
49
  );
50
  }
51
  add_action( 'admin_enqueue_scripts', 'cptui_taxonomies_enqueue_scripts' );
@@ -61,25 +69,24 @@ add_action( 'admin_enqueue_scripts', 'cptui_taxonomies_enqueue_scripts' );
61
  * @param string $current_page Current page being shown. Optional. Default empty string.
62
  * @return array Amended array of tabs to show.
63
  */
64
- function cptui_taxonomy_tabs( $tabs = array(), $current_page = '' ) {
65
 
66
  if ( 'taxonomies' === $current_page ) {
67
  $taxonomies = cptui_get_taxonomy_data();
68
- $classes = array( 'nav-tab' );
69
 
70
- $tabs['page_title'] = get_admin_page_title();
71
- $tabs['tabs'] = array();
72
- // Start out with our basic "Add new" tab.
73
- $tabs['tabs']['add'] = array(
74
  'text' => esc_html__( 'Add New Taxonomy', 'custom-post-type-ui' ),
75
  'classes' => $classes,
76
  'url' => cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ),
77
  'aria-selected' => 'false',
78
- );
79
 
80
  $action = cptui_get_current_action();
81
  if ( empty( $action ) ) {
82
- $tabs['tabs']['add']['classes'][] = 'nav-tab-active';
83
  $tabs['tabs']['add']['aria-selected'] = 'true';
84
  }
85
 
@@ -88,26 +95,26 @@ function cptui_taxonomy_tabs( $tabs = array(), $current_page = '' ) {
88
  if ( ! empty( $action ) ) {
89
  $classes[] = 'nav-tab-active';
90
  }
91
- $tabs['tabs']['edit'] = array(
92
  'text' => esc_html__( 'Edit Taxonomies', 'custom-post-type-ui' ),
93
  'classes' => $classes,
94
- 'url' => esc_url( add_query_arg( array( 'action' => 'edit' ), cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ) ) ),
95
- 'aria-selected' => ( ! empty( $action ) ) ? 'true' : 'false',
96
- );
97
 
98
- $tabs['tabs']['view'] = array(
99
  'text' => esc_html__( 'View Taxonomies', 'custom-post-type-ui' ),
100
- 'classes' => array( 'nav-tab' ), // Prevent notices.
101
  'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_listings#taxonomies' ) ),
102
  'aria-selected' => 'false',
103
- );
104
 
105
- $tabs['tabs']['export'] = array(
106
  'text' => esc_html__( 'Import/Export Taxonomies', 'custom-post-type-ui' ),
107
- 'classes' => array( 'nav-tab' ), // Prevent notices.
108
  'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_tools&action=taxonomies' ) ),
109
  'aria-selected' => 'false',
110
- );
111
  }
112
  }
113
 
@@ -159,23 +166,22 @@ function cptui_manage_taxonomies() {
159
  */
160
  do_action( 'cptui_below_taxonomy_tab_menu' );
161
 
162
- if ( 'edit' == $tab ) {
163
 
164
  $taxonomies = cptui_get_taxonomy_data();
165
 
166
  $selected_taxonomy = cptui_get_current_taxonomy( $taxonomy_deleted );
167
 
168
- if ( $selected_taxonomy ) {
169
- if ( array_key_exists( $selected_taxonomy, $taxonomies ) ) {
170
- $current = $taxonomies[ $selected_taxonomy ];
171
- }
172
  }
173
  }
174
 
175
  $ui = new cptui_admin_ui();
176
 
177
  // Will only be set if we're already on the edit screen.
178
- if ( ! empty( $taxonomies ) ) { ?>
 
179
  <form id="cptui_select_taxonomy" method="post" action="<?php echo esc_url( cptui_get_post_form_action( $ui ) ); ?>">
180
  <label for="taxonomy"><?php esc_html_e( 'Select: ', 'custom-post-type-ui' ); ?></label>
181
  <?php
@@ -203,7 +209,8 @@ function cptui_manage_taxonomies() {
203
  * @param string $value Current taxonomy selected.
204
  */
205
  do_action( 'cptui_below_taxonomy_select', $current['name'] );
206
- } ?>
 
207
 
208
  <form class="taxonomiesui" method="post" action="<?php echo esc_url( cptui_get_post_form_action( $ui ) ); ?>">
209
  <div class="postbox-container">
@@ -223,35 +230,35 @@ function cptui_manage_taxonomies() {
223
  echo $ui->get_tr_start() . $ui->get_th_start();
224
  echo $ui->get_label( 'name', esc_html__( 'Taxonomy Slug', 'custom-post-type-ui' ) ) . $ui->get_required_span();
225
 
226
- if ( 'edit' == $tab ) {
227
  echo '<p id="slugchanged" class="hidemessage">' . esc_html__( 'Slug has changed', 'custom-post-type-ui' ) . '<span class="dashicons dashicons-warning"></span></p>';
228
  }
229
  echo '<p id="slugexists" class="hidemessage">' . esc_html__( 'Slug already exists', 'custom-post-type-ui' ) . '<span class="dashicons dashicons-warning"></span></p>';
230
 
231
  echo $ui->get_th_end() . $ui->get_td_start();
232
 
233
- echo $ui->get_text_input( array(
234
  'namearray' => 'cpt_custom_tax',
235
  'name' => 'name',
236
- 'textvalue' => ( isset( $current['name'] ) ) ? esc_attr( $current['name'] ) : '',
237
  'maxlength' => '32',
238
  'helptext' => esc_attr__( 'The taxonomy name/slug. Used for various queries for taxonomy content.', 'custom-post-type-ui' ),
239
  'required' => true,
240
  'placeholder' => false,
241
  'wrap' => false,
242
- ) );
243
 
244
  echo '<p class="cptui-slug-details">';
245
  esc_html_e( 'Slugs should only contain alphanumeric, latin characters. Underscores should be used in place of spaces. Set "Custom Rewrite Slug" field to make slug use dashes for URLs.', 'custom-post-type-ui' );
246
  echo '</p>';
247
 
248
- if ( 'edit' == $tab ) {
249
  echo '<p>';
250
  esc_html_e( 'DO NOT EDIT the taxonomy slug unless also planning to migrate terms. Changing the slug registers a new taxonomy entry.', 'custom-post-type-ui' );
251
  echo '</p>';
252
 
253
  echo '<div class="cptui-spacer">';
254
- echo $ui->get_check_input( array(
255
  'checkvalue' => 'update_taxonomy',
256
  'checked' => 'false',
257
  'name' => 'update_taxonomy',
@@ -260,29 +267,42 @@ function cptui_manage_taxonomies() {
260
  'helptext' => '',
261
  'default' => false,
262
  'wrap' => false,
263
- ) );
264
  echo '</div>';
265
  }
266
 
267
- echo $ui->get_text_input( array(
268
  'namearray' => 'cpt_custom_tax',
269
  'name' => 'label',
270
- 'textvalue' => ( isset( $current['label'] ) ) ? esc_attr( $current['label'] ) : '',
271
  'aftertext' => esc_html__( '(e.g. Actors)', 'custom-post-type-ui' ),
272
  'labeltext' => esc_html__( 'Plural Label', 'custom-post-type-ui' ),
273
  'helptext' => esc_attr__( 'Used for the taxonomy admin menu item.', 'custom-post-type-ui' ),
274
  'required' => true,
275
- ) );
276
 
277
- echo $ui->get_text_input( array(
278
  'namearray' => 'cpt_custom_tax',
279
  'name' => 'singular_label',
280
- 'textvalue' => ( isset( $current['singular_label'] ) ) ? esc_attr( $current['singular_label'] ) : '',
281
  'aftertext' => esc_html__( '(e.g. Actor)', 'custom-post-type-ui' ),
282
  'labeltext' => esc_html__( 'Singular Label', 'custom-post-type-ui' ),
283
  'helptext' => esc_attr__( 'Used when a singular label is needed.', 'custom-post-type-ui' ),
284
  'required' => true,
285
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
286
 
287
  echo $ui->get_td_end() . $ui->get_tr_end();
288
 
@@ -290,6 +310,8 @@ function cptui_manage_taxonomies() {
290
  echo $ui->get_p( esc_html__( 'Add support for available registered post types. At least one is required. Only public post types listed by default.', 'custom-post-type-ui' ) );
291
  echo $ui->get_th_end() . $ui->get_td_start() . $ui->get_fieldset_start();
292
 
 
 
293
  /**
294
  * Filters the arguments for post types to list for taxonomy association.
295
  *
@@ -297,11 +319,11 @@ function cptui_manage_taxonomies() {
297
  *
298
  * @param array $value Array of default arguments.
299
  */
300
- $args = apply_filters( 'cptui_attach_post_types_to_taxonomy', array( 'public' => true ) );
301
 
302
  // If they don't return an array, fall back to the original default. Don't need to check for empty, because empty array is default for $args param in get_post_types anyway.
303
  if ( ! is_array( $args ) ) {
304
- $args = array( 'public' => true );
305
  }
306
  $output = 'objects'; // Or objects.
307
 
@@ -317,29 +339,29 @@ function cptui_manage_taxonomies() {
317
  $post_types = apply_filters( 'cptui_get_post_types_for_taxonomies', get_post_types( $args, $output ), $args, $output );
318
 
319
  foreach ( $post_types as $post_type ) {
320
- $core_label = ( in_array( $post_type->name, array(
321
  'post',
322
  'page',
323
  'attachment',
324
- ) ) ) ? esc_html__( '(WP Core)', 'custom-post-type-ui' ) : '';
325
- echo $ui->get_check_input( array(
326
  'checkvalue' => $post_type->name,
327
- 'checked' => ( ! empty( $current['object_types'] ) && is_array( $current['object_types'] ) && in_array( $post_type->name, $current['object_types'] ) ) ? 'true' : 'false',
328
  'name' => $post_type->name,
329
  'namearray' => 'cpt_post_types',
330
  'textvalue' => $post_type->name,
331
- 'labeltext' => $post_type->label . ' ' . $core_label,
332
  'wrap' => false,
333
- ) );
334
  }
335
 
336
  echo $ui->get_fieldset_end() . $ui->get_td_end() . $ui->get_tr_end();
337
  ?>
338
  </table>
339
  <p class="submit">
340
- <?php wp_nonce_field( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
341
- if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' == $_GET['action'] ) { ?>
342
- <?php
343
 
344
  /**
345
  * Filters the text value to use on the button when editing.
@@ -377,15 +399,17 @@ function cptui_manage_taxonomies() {
377
 
378
  <?php if ( ! empty( $current ) ) { ?>
379
  <input type="hidden" name="tax_original" id="tax_original" value="<?php echo esc_attr( $current['name'] ); ?>" />
380
- <?php }
 
381
 
382
- // Used to check and see if we should prevent duplicate slugs. ?>
 
383
  <input type="hidden" name="cpt_tax_status" id="cpt_tax_status" value="<?php echo esc_attr( $tab ); ?>" />
384
  </p>
385
  </div>
386
  </div>
387
  </div>
388
- <div class="cptui-section postbox">
389
  <button type="button" class="handlediv button-link" aria-expanded="true">
390
  <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Additional labels', 'custom-post-type-ui' ); ?></span>
391
  <span class="toggle-indicator" aria-hidden="true"></span>
@@ -401,183 +425,272 @@ function cptui_manage_taxonomies() {
401
  if ( isset( $current['description'] ) ) {
402
  $current['description'] = stripslashes_deep( $current['description'] );
403
  }
404
- echo $ui->get_textarea_input( array(
405
  'namearray' => 'cpt_custom_tax',
406
  'name' => 'description',
407
  'rows' => '4',
408
  'cols' => '40',
409
- 'textvalue' => ( isset( $current['description'] ) ) ? esc_textarea( $current['description'] ) : '',
410
  'labeltext' => esc_html__( 'Description', 'custom-post-type-ui' ),
411
  'helptext' => esc_attr__( 'Describe what your taxonomy is used for.', 'custom-post-type-ui' ),
412
- ) );
413
 
414
- echo $ui->get_text_input( array(
415
  'namearray' => 'cpt_tax_labels',
416
  'name' => 'menu_name',
417
- 'textvalue' => ( isset( $current['labels']['menu_name'] ) ) ? esc_attr( $current['labels']['menu_name'] ) : '',
418
  'aftertext' => esc_attr__( '(e.g. Actors)', 'custom-post-type-ui' ),
419
  'labeltext' => esc_html__( 'Menu Name', 'custom-post-type-ui' ),
420
  'helptext' => esc_html__( 'Custom admin menu name for your taxonomy.', 'custom-post-type-ui' ),
421
- ) );
 
 
 
 
422
 
423
- echo $ui->get_text_input( array(
424
  'namearray' => 'cpt_tax_labels',
425
  'name' => 'all_items',
426
- 'textvalue' => ( isset( $current['labels']['all_items'] ) ) ? esc_attr( $current['labels']['all_items'] ) : '',
427
  'aftertext' => esc_attr__( '(e.g. All Actors)', 'custom-post-type-ui' ),
428
  'labeltext' => esc_html__( 'All Items', 'custom-post-type-ui' ),
429
  'helptext' => esc_html__( 'Used as tab text when showing all terms for hierarchical taxonomy while editing post.', 'custom-post-type-ui' ),
430
- ) );
431
-
432
- echo $ui->get_text_input( array(
 
 
 
 
 
433
  'namearray' => 'cpt_tax_labels',
434
  'name' => 'edit_item',
435
- 'textvalue' => ( isset( $current['labels']['edit_item'] ) ) ? esc_attr( $current['labels']['edit_item'] ) : '',
436
  'aftertext' => esc_attr__( '(e.g. Edit Actor)', 'custom-post-type-ui' ),
437
  'labeltext' => esc_html__( 'Edit Item', 'custom-post-type-ui' ),
438
  'helptext' => esc_html__( 'Used at the top of the term editor screen for an existing taxonomy term.', 'custom-post-type-ui' ),
439
- ) );
440
-
441
- echo $ui->get_text_input( array(
 
 
 
 
 
442
  'namearray' => 'cpt_tax_labels',
443
  'name' => 'view_item',
444
- 'textvalue' => ( isset( $current['labels']['view_item'] ) ) ? esc_attr( $current['labels']['view_item'] ) : '',
445
  'aftertext' => esc_attr__( '(e.g. View Actor)', 'custom-post-type-ui' ),
446
  'labeltext' => esc_html__( 'View Item', 'custom-post-type-ui' ),
447
  'helptext' => esc_html__( 'Used in the admin bar when viewing editor screen for an existing taxonomy term.', 'custom-post-type-ui' ),
448
- ) );
449
-
450
- echo $ui->get_text_input( array(
 
 
 
 
 
451
  'namearray' => 'cpt_tax_labels',
452
  'name' => 'update_item',
453
- 'textvalue' => ( isset( $current['labels']['update_item'] ) ) ? esc_attr( $current['labels']['update_item'] ) : '',
454
  'aftertext' => esc_attr__( '(e.g. Update Actor Name)', 'custom-post-type-ui' ),
455
  'labeltext' => esc_html__( 'Update Item Name', 'custom-post-type-ui' ),
456
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
457
- ) );
458
-
459
- echo $ui->get_text_input( array(
 
 
 
 
 
460
  'namearray' => 'cpt_tax_labels',
461
  'name' => 'add_new_item',
462
- 'textvalue' => ( isset( $current['labels']['add_new_item'] ) ) ? esc_attr( $current['labels']['add_new_item'] ) : '',
463
  'aftertext' => esc_attr__( '(e.g. Add New Actor)', 'custom-post-type-ui' ),
464
  'labeltext' => esc_html__( 'Add New Item', 'custom-post-type-ui' ),
465
  'helptext' => esc_html__( 'Used at the top of the term editor screen and button text for a new taxonomy term.', 'custom-post-type-ui' ),
466
- ) );
467
-
468
- echo $ui->get_text_input( array(
 
 
 
 
 
469
  'namearray' => 'cpt_tax_labels',
470
  'name' => 'new_item_name',
471
- 'textvalue' => ( isset( $current['labels']['new_item_name'] ) ) ? esc_attr( $current['labels']['new_item_name'] ) : '',
472
  'aftertext' => esc_attr__( '(e.g. New Actor Name)', 'custom-post-type-ui' ),
473
  'labeltext' => esc_html__( 'New Item Name', 'custom-post-type-ui' ),
474
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
475
- ) );
476
-
477
- echo $ui->get_text_input( array(
 
 
 
 
 
478
  'namearray' => 'cpt_tax_labels',
479
  'name' => 'parent_item',
480
- 'textvalue' => ( isset( $current['labels']['parent_item'] ) ) ? esc_attr( $current['labels']['parent_item'] ) : '',
481
  'aftertext' => esc_attr__( '(e.g. Parent Actor)', 'custom-post-type-ui' ),
482
  'labeltext' => esc_html__( 'Parent Item', 'custom-post-type-ui' ),
483
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
484
- ) );
485
-
486
- echo $ui->get_text_input( array(
 
 
 
 
 
487
  'namearray' => 'cpt_tax_labels',
488
  'name' => 'parent_item_colon',
489
- 'textvalue' => ( isset( $current['labels']['parent_item_colon'] ) ) ? esc_attr( $current['labels']['parent_item_colon'] ) : '',
490
  'aftertext' => esc_attr__( '(e.g. Parent Actor:)', 'custom-post-type-ui' ),
491
  'labeltext' => esc_html__( 'Parent Item Colon', 'custom-post-type-ui' ),
492
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
493
- ) );
494
-
495
- echo $ui->get_text_input( array(
 
 
 
 
 
496
  'namearray' => 'cpt_tax_labels',
497
  'name' => 'search_items',
498
- 'textvalue' => ( isset( $current['labels']['search_items'] ) ) ? esc_attr( $current['labels']['search_items'] ) : '',
499
  'aftertext' => esc_attr__( '(e.g. Search Actors)', 'custom-post-type-ui' ),
500
  'labeltext' => esc_html__( 'Search Items', 'custom-post-type-ui' ),
501
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
502
- ) );
503
-
504
- echo $ui->get_text_input( array(
 
 
 
 
 
505
  'namearray' => 'cpt_tax_labels',
506
  'name' => 'popular_items',
507
- 'textvalue' => ( isset( $current['labels']['popular_items'] ) ) ? esc_attr( $current['labels']['popular_items'] ) : null,
508
  'aftertext' => esc_attr__( '(e.g. Popular Actors)', 'custom-post-type-ui' ),
509
  'labeltext' => esc_html__( 'Popular Items', 'custom-post-type-ui' ),
510
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
511
- ) );
512
-
513
- echo $ui->get_text_input( array(
 
 
 
 
 
514
  'namearray' => 'cpt_tax_labels',
515
  'name' => 'separate_items_with_commas',
516
- 'textvalue' => ( isset( $current['labels']['separate_items_with_commas'] ) ) ? esc_attr( $current['labels']['separate_items_with_commas'] ) : null,
517
  'aftertext' => esc_attr__( '(e.g. Separate Actors with commas)', 'custom-post-type-ui' ),
518
  'labeltext' => esc_html__( 'Separate Items with Commas', 'custom-post-type-ui' ),
519
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
520
- ) );
521
-
522
- echo $ui->get_text_input( array(
 
 
 
 
 
523
  'namearray' => 'cpt_tax_labels',
524
  'name' => 'add_or_remove_items',
525
- 'textvalue' => ( isset( $current['labels']['add_or_remove_items'] ) ) ? esc_attr( $current['labels']['add_or_remove_items'] ) : null,
526
  'aftertext' => esc_attr__( '(e.g. Add or remove Actors)', 'custom-post-type-ui' ),
527
  'labeltext' => esc_html__( 'Add or Remove Items', 'custom-post-type-ui' ),
528
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
529
- ) );
530
-
531
- echo $ui->get_text_input( array(
 
 
 
 
 
532
  'namearray' => 'cpt_tax_labels',
533
  'name' => 'choose_from_most_used',
534
- 'textvalue' => ( isset( $current['labels']['choose_from_most_used'] ) ) ? esc_attr( $current['labels']['choose_from_most_used'] ) : null,
535
  'aftertext' => esc_attr__( '(e.g. Choose from the most used Actors)', 'custom-post-type-ui' ),
536
  'labeltext' => esc_html__( 'Choose From Most Used', 'custom-post-type-ui' ),
537
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
538
- ) );
539
-
540
- echo $ui->get_text_input( array(
 
 
 
 
 
541
  'namearray' => 'cpt_tax_labels',
542
  'name' => 'not_found',
543
- 'textvalue' => ( isset( $current['labels']['not_found'] ) ) ? esc_attr( $current['labels']['not_found'] ) : null,
544
  'aftertext' => esc_attr__( '(e.g. No Actors found)', 'custom-post-type-ui' ),
545
  'labeltext' => esc_html__( 'Not found', 'custom-post-type-ui' ),
546
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
547
- ) );
548
-
549
- echo $ui->get_text_input( array(
 
 
 
 
 
550
  'namearray' => 'cpt_tax_labels',
551
  'name' => 'no_terms',
552
- 'textvalue' => ( isset( $current['labels']['no_terms'] ) ) ? esc_attr( $current['labels']['no_terms'] ) : null,
553
  'aftertext' => esc_html__( '(e.g. No actors)', 'custom-post-type-ui' ),
554
  'labeltext' => esc_html__( 'No terms', 'custom-post-type-ui' ),
555
  'helptext' => esc_attr__( 'Used when indicating that there are no terms in the given taxonomy associated with an object.', 'custom-post-type-ui' ),
556
- ) );
557
-
558
- echo $ui->get_text_input( array(
 
 
 
 
 
559
  'namearray' => 'cpt_tax_labels',
560
  'name' => 'items_list_navigation',
561
- 'textvalue' => ( isset( $current['labels']['items_list_navigation'] ) ) ? esc_attr( $current['labels']['items_list_navigation'] ) : null,
562
  'aftertext' => esc_html__( '(e.g. Actors list navigation)', 'custom-post-type-ui' ),
563
  'labeltext' => esc_html__( 'Items List Navigation', 'custom-post-type-ui' ),
564
  'helptext' => esc_attr__( 'Screen reader text for the pagination heading on the term listing screen.', 'custom-post-type-ui' ),
565
- ) );
566
-
567
- echo $ui->get_text_input( array(
 
 
 
 
 
568
  'namearray' => 'cpt_tax_labels',
569
  'name' => 'items_list',
570
- 'textvalue' => ( isset( $current['labels']['items_list'] ) ) ? esc_attr( $current['labels']['items_list'] ) : null,
571
  'aftertext' => esc_html__( '(e.g. Actors list)', 'custom-post-type-ui' ),
572
  'labeltext' => esc_html__( 'Items List', 'custom-post-type-ui' ),
573
  'helptext' => esc_attr__( 'Screen reader text for the items list heading on the term listing screen.', 'custom-post-type-ui' ),
574
- ) );
 
 
 
 
 
575
  ?>
576
  </table>
577
  </div>
578
  </div>
579
  </div>
580
- <div class="cptui-section postbox">
581
  <button type="button" class="handlediv button-link" aria-expanded="true">
582
  <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Settings', 'custom-post-type-ui' ); ?></span>
583
  <span class="toggle-indicator" aria-hidden="true"></span>
@@ -590,302 +703,346 @@ function cptui_manage_taxonomies() {
590
  <table class="form-table cptui-table">
591
  <?php
592
 
593
- $select = array(
594
- 'options' => array(
595
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
596
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
597
- ),
598
- );
599
- $selected = ( isset( $current ) ) ? disp_boolean( $current['public'] ) : '';
600
- $select['selected'] = ( ! empty( $selected ) ) ? $current['public'] : '';
601
- echo $ui->get_select_input( array(
 
 
 
 
 
 
 
602
  'namearray' => 'cpt_custom_tax',
603
  'name' => 'public',
604
  'labeltext' => esc_html__( 'Public', 'custom-post-type-ui' ),
605
  'aftertext' => esc_html__( '(default: true) Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users.', 'custom-post-type-ui' ),
606
  'selections' => $select,
607
- ) );
608
-
609
- $select = array(
610
- 'options' => array(
611
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
612
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ), 'default' => 'true' ),
613
- ),
614
- );
615
- $selected = ( isset( $current ) ) ? disp_boolean( $current['publicly_queryable'] ) : '';
616
- $select['selected'] = ( ! empty( $selected ) ) ? $current['publicly_queryable'] : '';
617
- echo $ui->get_select_input( array(
 
 
 
 
 
 
 
618
  'namearray' => 'cpt_custom_tax',
619
  'name' => 'publicly_queryable',
620
  'labeltext' => esc_html__( 'Public Queryable', 'custom-post-type-ui' ),
621
  'aftertext' => esc_html__( '(default: value of "public" setting) Whether or not the taxonomy should be publicly queryable.', 'custom-post-type-ui' ),
622
  'selections' => $select,
623
- ) );
624
 
625
- $select = array(
626
- 'options' => array(
627
- array(
628
  'attr' => '0',
629
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
630
- 'default' => 'true'
631
- ),
632
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ),
633
- ),
634
- );
635
- $selected = ( isset( $current ) ) ? disp_boolean( $current['hierarchical'] ) : '';
636
- $select['selected'] = ( ! empty( $selected ) ) ? $current['hierarchical'] : '';
637
- echo $ui->get_select_input( array(
 
 
 
638
  'namearray' => 'cpt_custom_tax',
639
  'name' => 'hierarchical',
640
  'labeltext' => esc_html__( 'Hierarchical', 'custom-post-type-ui' ),
641
  'aftertext' => esc_html__( '(default: false) Whether the taxonomy can have parent-child relationships.', 'custom-post-type-ui' ),
642
  'selections' => $select,
643
- ) );
644
-
645
- $select = array(
646
- 'options' => array(
647
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
648
- array(
 
 
 
649
  'attr' => '1',
650
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
651
- 'default' => 'true'
652
- ),
653
- ),
654
- );
655
- $selected = ( isset( $current ) ) ? disp_boolean( $current['show_ui'] ) : '';
656
- $select['selected'] = ( ! empty( $selected ) ) ? $current['show_ui'] : '';
657
- echo $ui->get_select_input( array(
658
  'namearray' => 'cpt_custom_tax',
659
  'name' => 'show_ui',
660
  'labeltext' => esc_html__( 'Show UI', 'custom-post-type-ui' ),
661
  'aftertext' => esc_html__( '(default: true) Whether to generate a default UI for managing this custom taxonomy.', 'custom-post-type-ui' ),
662
  'selections' => $select,
663
- ) );
664
-
665
- $select = array(
666
- 'options' => array(
667
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
668
- array(
 
 
 
669
  'attr' => '1',
670
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
671
- 'default' => 'true'
672
- ),
673
- ),
674
- );
675
- $selected = ( isset( $current ) ) ? disp_boolean( $current['show_in_menu'] ) : '';
676
- $select['selected'] = ( ! empty( $selected ) ) ? $current['show_in_menu'] : '';
677
- echo $ui->get_select_input( array(
678
  'namearray' => 'cpt_custom_tax',
679
  'name' => 'show_in_menu',
680
  'labeltext' => esc_html__( 'Show in menu', 'custom-post-type-ui' ),
681
  'aftertext' => esc_html__( '(default: value of show_ui) Whether to show the taxonomy in the admin menu.', 'custom-post-type-ui' ),
682
  'selections' => $select,
683
- ) );
684
-
685
- $select = array(
686
- 'options' => array(
687
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
688
- array(
 
 
 
689
  'attr' => '1',
690
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
691
- 'default' => 'true'
692
- ),
693
- ),
694
- );
695
  $selected = ( isset( $current ) && ! empty( $current['show_in_nav_menus'] ) ) ? disp_boolean( $current['show_in_nav_menus'] ) : '';
696
- $select['selected'] = ( ! empty( $selected ) ) ? $current['show_in_nav_menus'] : '';
697
- echo $ui->get_select_input( array(
698
  'namearray' => 'cpt_custom_tax',
699
  'name' => 'show_in_nav_menus',
700
  'labeltext' => esc_html__( 'Show in nav menus', 'custom-post-type-ui' ),
701
  'aftertext' => esc_html__( '(default: value of public) Whether to make the taxonomy available for selection in navigation menus.', 'custom-post-type-ui' ),
702
  'selections' => $select,
703
- ) );
704
-
705
- $select = array(
706
- 'options' => array(
707
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
708
- array(
 
 
 
709
  'attr' => '1',
710
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
711
- 'default' => 'true'
712
- ),
713
- ),
714
- );
715
- $selected = ( isset( $current ) ) ? disp_boolean( $current['query_var'] ) : '';
716
- $select['selected'] = ( ! empty( $selected ) ) ? $current['query_var'] : '';
717
- echo $ui->get_select_input( array(
718
  'namearray' => 'cpt_custom_tax',
719
  'name' => 'query_var',
720
  'labeltext' => esc_html__( 'Query Var', 'custom-post-type-ui' ),
721
  'aftertext' => esc_html__( '(default: true) Sets the query_var key for this taxonomy.', 'custom-post-type-ui' ),
722
  'selections' => $select,
723
- ) );
724
 
725
- echo $ui->get_text_input( array(
726
  'namearray' => 'cpt_custom_tax',
727
  'name' => 'query_var_slug',
728
- 'textvalue' => ( isset( $current['query_var_slug'] ) ) ? esc_attr( $current['query_var_slug'] ) : '',
729
  'aftertext' => esc_attr__( '(default: taxonomy slug). Query var needs to be true to use.', 'custom-post-type-ui' ),
730
  'labeltext' => esc_html__( 'Custom Query Var String', 'custom-post-type-ui' ),
731
  'helptext' => esc_html__( 'Sets a custom query_var slug for this taxonomy.', 'custom-post-type-ui' ),
732
- ) );
733
-
734
- $select = array(
735
- 'options' => array(
736
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
737
- array(
 
 
 
738
  'attr' => '1',
739
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
740
- 'default' => 'true'
741
- ),
742
- ),
743
- );
744
- $selected = ( isset( $current ) ) ? disp_boolean( $current['rewrite'] ) : '';
745
- $select['selected'] = ( ! empty( $selected ) ) ? $current['rewrite'] : '';
746
- echo $ui->get_select_input( array(
747
  'namearray' => 'cpt_custom_tax',
748
  'name' => 'rewrite',
749
  'labeltext' => esc_html__( 'Rewrite', 'custom-post-type-ui' ),
750
  'aftertext' => esc_html__( '(default: true) Whether or not WordPress should use rewrites for this taxonomy.', 'custom-post-type-ui' ),
751
  'selections' => $select,
752
- ) );
753
 
754
- echo $ui->get_text_input( array(
755
  'namearray' => 'cpt_custom_tax',
756
  'name' => 'rewrite_slug',
757
- 'textvalue' => ( isset( $current['rewrite_slug'] ) ) ? esc_attr( $current['rewrite_slug'] ) : '',
758
  'aftertext' => esc_attr__( '(default: taxonomy name)', 'custom-post-type-ui' ),
759
  'labeltext' => esc_html__( 'Custom Rewrite Slug', 'custom-post-type-ui' ),
760
  'helptext' => esc_html__( 'Custom taxonomy rewrite slug.', 'custom-post-type-ui' ),
761
- ) );
762
-
763
- $select = array(
764
- 'options' => array(
765
- array( 'attr' => '0', 'text' => esc_attr__( 'False', 'custom-post-type-ui' ) ),
766
- array(
 
 
 
767
  'attr' => '1',
768
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
769
- 'default' => 'true'
770
- ),
771
- ),
772
- );
773
- $selected = ( isset( $current ) ) ? disp_boolean( $current['rewrite_withfront'] ) : '';
774
- $select['selected'] = ( ! empty( $selected ) ) ? $current['rewrite_withfront'] : '';
775
- echo $ui->get_select_input( array(
776
  'namearray' => 'cpt_custom_tax',
777
  'name' => 'rewrite_withfront',
778
  'labeltext' => esc_html__( 'Rewrite With Front', 'custom-post-type-ui' ),
779
  'aftertext' => esc_html__( '(default: true) Should the permastruct be prepended with the front base.', 'custom-post-type-ui' ),
780
  'selections' => $select,
781
- ) );
782
 
783
- $select = array(
784
- 'options' => array(
785
- array(
786
  'attr' => '0',
787
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
788
- 'default' => 'false'
789
- ),
790
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ),
791
- ),
792
- );
793
- $selected = ( isset( $current ) ) ? disp_boolean( $current['rewrite_hierarchical'] ) : '';
794
- $select['selected'] = ( ! empty( $selected ) ) ? $current['rewrite_hierarchical'] : '';
795
- echo $ui->get_select_input( array(
 
 
 
796
  'namearray' => 'cpt_custom_tax',
797
  'name' => 'rewrite_hierarchical',
798
  'labeltext' => esc_html__( 'Rewrite Hierarchical', 'custom-post-type-ui' ),
799
  'aftertext' => esc_html__( '(default: false) Should the permastruct allow hierarchical urls.', 'custom-post-type-ui' ),
800
  'selections' => $select,
801
- ) );
802
 
803
- $select = array(
804
- 'options' => array(
805
- array(
806
  'attr' => '0',
807
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
808
- 'default' => 'true'
809
- ),
810
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ),
811
- ),
812
- );
813
- $selected = ( isset( $current ) ) ? disp_boolean( $current['show_admin_column'] ) : '';
814
- $select['selected'] = ( ! empty( $selected ) ) ? $current['show_admin_column'] : '';
815
- echo $ui->get_select_input( array(
 
 
 
816
  'namearray' => 'cpt_custom_tax',
817
  'name' => 'show_admin_column',
818
  'labeltext' => esc_html__( 'Show Admin Column', 'custom-post-type-ui' ),
819
  'aftertext' => esc_html__( '(default: false) Whether to allow automatic creation of taxonomy columns on associated post-types.', 'custom-post-type-ui' ),
820
  'selections' => $select,
821
- ) );
822
 
823
- $select = array(
824
- 'options' => array(
825
- array(
826
  'attr' => '0',
827
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
828
- ),
829
- array(
830
  'attr' => '1',
831
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
832
  'default' => 'true',
833
- ),
834
- ),
835
- );
836
- $selected = ( isset( $current ) ) ? disp_boolean( $current['show_in_rest'] ) : '';
837
- $select['selected'] = ( ! empty( $selected ) ) ? $current['show_in_rest'] : '';
838
- echo $ui->get_select_input( array(
839
  'namearray' => 'cpt_custom_tax',
840
  'name' => 'show_in_rest',
841
  'labeltext' => esc_html__( 'Show in REST API', 'custom-post-type-ui' ),
842
  'aftertext' => esc_html__( '(Custom Post Type UI default: true) Whether to show this taxonomy data in the WP REST API.', 'custom-post-type-ui' ),
843
  'selections' => $select,
844
- ) );
845
 
846
- echo $ui->get_text_input( array(
847
  'namearray' => 'cpt_custom_tax',
848
  'name' => 'rest_base',
849
  'labeltext' => esc_html__( 'REST API base slug', 'custom-post-type-ui' ),
850
  'helptext' => esc_attr__( 'Slug to use in REST API URLs.', 'custom-post-type-ui' ),
851
- 'textvalue' => ( isset( $current['rest_base'] ) ) ? esc_attr( $current['rest_base'] ) : '',
852
- ) );
853
 
854
- echo $ui->get_text_input( array(
855
  'namearray' => 'cpt_custom_tax',
856
  'name' => 'rest_controller_class',
857
  'labeltext' => esc_html__( 'REST API controller class', 'custom-post-type-ui' ),
858
  'aftertext' => esc_attr__( '(default: WP_REST_Terms_Controller) Custom controller to use instead of WP_REST_Terms_Controller.', 'custom-post-type-ui' ),
859
- 'textvalue' => ( isset( $current['rest_controller_class'] ) ) ? esc_attr( $current['rest_controller_class'] ) : '',
860
- ) );
861
 
862
- $select = array(
863
- 'options' => array(
864
- array(
865
  'attr' => '0',
866
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
867
- 'default' => 'false'
868
- ),
869
- array( 'attr' => '1', 'text' => esc_attr__( 'True', 'custom-post-type-ui' ) ),
870
- ),
871
- );
 
 
 
872
  $selected = ( isset( $current ) && ! empty( $current['show_in_quick_edit'] ) ) ? disp_boolean( $current['show_in_quick_edit'] ) : '';
873
- $select['selected'] = ( ! empty( $selected ) ) ? $current['show_in_quick_edit'] : '';
874
- echo $ui->get_select_input( array(
875
  'namearray' => 'cpt_custom_tax',
876
  'name' => 'show_in_quick_edit',
877
  'labeltext' => esc_html__( 'Show in quick/bulk edit panel.', 'custom-post-type-ui' ),
878
  'aftertext' => esc_html__( '(default: false) Whether to show the taxonomy in the quick/bulk edit panel.', 'custom-post-type-ui' ),
879
  'selections' => $select,
880
- ) );
881
 
882
- echo $ui->get_text_input( array(
883
  'namearray' => 'cpt_custom_tax',
884
  'name' => 'meta_box_cb',
885
- 'textvalue' => ( isset( $current['meta_box_cb'] ) ) ? esc_attr( $current['meta_box_cb'] ) : '',
886
  'labeltext' => esc_html__( 'Metabox callback', 'custom-post-type-ui' ),
887
  'helptext' => esc_html__( 'Sets a callback function name for the meta box display. Hierarchical default: post_categories_meta_box, non-hierarchical default: post_tags_meta_box. To remove the metabox completely, use "false".', 'custom-post-type-ui' ),
888
- ) );
889
  ?>
890
  </table>
891
  </div>
@@ -900,11 +1057,13 @@ function cptui_manage_taxonomies() {
900
  *
901
  * @param cptui_admin_ui $ui Admin UI instance.
902
  */
903
- do_action( 'cptui_taxonomy_after_fieldsets', $ui ); ?>
 
904
 
905
  <p class="submit">
906
- <?php wp_nonce_field( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
907
- if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' == $_GET['action'] ) { ?>
 
908
  <?php
909
 
910
  /**
@@ -942,11 +1101,13 @@ function cptui_manage_taxonomies() {
942
  <?php } ?>
943
 
944
  <?php if ( ! empty( $current ) ) { ?>
945
- <input type="hidden" name="tax_original" id="tax_original" value="<?php echo $current['name']; ?>" />
946
- <?php }
 
947
 
948
- // Used to check and see if we should prevent duplicate slugs. ?>
949
- <input type="hidden" name="cpt_tax_status" id="cpt_tax_status" value="<?php echo $tab; ?>" />
 
950
  </p>
951
  </div>
952
  </div>
@@ -962,21 +1123,23 @@ function cptui_manage_taxonomies() {
962
  *
963
  * @param array $taxonomies Array of taxonomies that are registered. Optional.
964
  */
965
- function cptui_taxonomies_dropdown( $taxonomies = array() ) {
966
 
967
  $ui = new cptui_admin_ui();
968
 
969
  if ( ! empty( $taxonomies ) ) {
970
- $select = array();
971
- $select['options'] = array();
972
 
973
  foreach ( $taxonomies as $tax ) {
974
- $text = ( ! empty( $tax['label'] ) ) ? $tax['label'] : $tax['name'];
975
- $select['options'][] = array( 'attr' => $tax['name'], 'text' => $text );
 
 
 
976
  }
977
 
978
- $current = cptui_get_current_taxonomy();
979
-
980
  $select['selected'] = $current;
981
 
982
  /**
@@ -989,12 +1152,12 @@ function cptui_taxonomies_dropdown( $taxonomies = array() ) {
989
  */
990
  $select = apply_filters( 'cptui_taxonomies_dropdown_options', $select, $taxonomies );
991
 
992
- echo $ui->get_select_input( array(
993
- 'namearray' => 'cptui_selected_taxonomy',
994
- 'name' => 'taxonomy',
995
- 'selections' => $select,
996
- 'wrap' => false,
997
- ) );
998
  }
999
  }
1000
 
@@ -1018,10 +1181,10 @@ function cptui_get_current_taxonomy( $taxonomy_deleted = false ) {
1018
  }
1019
  if ( isset( $_POST['cptui_selected_taxonomy']['taxonomy'] ) ) {
1020
  $tax = sanitize_text_field( $_POST['cptui_selected_taxonomy']['taxonomy'] );
1021
- } else if ( $taxonomy_deleted ) {
1022
  $taxonomies = cptui_get_taxonomy_data();
1023
- $tax = key( $taxonomies );
1024
- } else if ( isset( $_POST['cpt_custom_tax']['name'] ) ) {
1025
  // Return the submitted value.
1026
  if ( ! in_array( $_POST['cpt_custom_tax']['name'], cptui_reserved_taxonomies(), true ) ) {
1027
  $tax = sanitize_text_field( $_POST['cpt_custom_tax']['name'] );
@@ -1030,7 +1193,7 @@ function cptui_get_current_taxonomy( $taxonomy_deleted = false ) {
1030
  $tax = sanitize_text_field( $_POST['tax_original'] );
1031
  }
1032
  }
1033
- } else if ( ! empty( $_GET ) && isset( $_GET['cptui_taxonomy'] ) ) {
1034
  $tax = sanitize_text_field( $_GET['cptui_taxonomy'] );
1035
  } else {
1036
  $taxonomies = cptui_get_taxonomy_data();
@@ -1060,14 +1223,14 @@ function cptui_get_current_taxonomy( $taxonomy_deleted = false ) {
1060
  * @param array $data The $_POST values. Optional.
1061
  * @return bool|string False on failure, string on success.
1062
  */
1063
- function cptui_delete_taxonomy( $data = array() ) {
1064
 
1065
  if ( is_string( $data ) && taxonomy_exists( $data ) ) {
1066
- $data = array(
1067
- 'cpt_custom_tax' => array(
1068
  'name' => $data,
1069
- ),
1070
- );
1071
  }
1072
 
1073
  // Check if they selected one to delete.
@@ -1132,7 +1295,7 @@ function cptui_delete_taxonomy( $data = array() ) {
1132
  * @param array $data Array of taxonomy data to update. Optional.
1133
  * @return bool|string False on failure, string on success.
1134
  */
1135
- function cptui_update_taxonomy( $data = array() ) {
1136
 
1137
  /**
1138
  * Fires before a taxonomy is updated to our saved options.
@@ -1153,7 +1316,7 @@ function cptui_update_taxonomy( $data = array() ) {
1153
  return 'error';
1154
  }
1155
 
1156
- if ( ! empty( $data['tax_original'] ) && $data['tax_original'] != $data['cpt_custom_tax']['name'] ) {
1157
  if ( ! empty( $data['update_taxonomy'] ) ) {
1158
  add_filter( 'cptui_convert_taxonomy_terms', '__return_true' );
1159
  }
@@ -1197,9 +1360,9 @@ function cptui_update_taxonomy( $data = array() ) {
1197
  if ( empty( $label ) ) {
1198
  unset( $data['cpt_tax_labels'][ $key ] );
1199
  }
1200
- $label = str_replace( '"', '', htmlspecialchars_decode( $label ) );
1201
- $label = htmlspecialchars( $label, ENT_QUOTES );
1202
- $label = trim( $label );
1203
  $data['cpt_tax_labels'][ $key ] = stripslashes_deep( $label );
1204
  }
1205
 
@@ -1221,16 +1384,16 @@ function cptui_update_taxonomy( $data = array() ) {
1221
  $rewrite_slug = trim( $data['cpt_custom_tax']['rewrite_slug'] );
1222
  $rest_base = trim( $data['cpt_custom_tax']['rest_base'] );
1223
  $rest_controller_class = trim( $data['cpt_custom_tax']['rest_controller_class'] );
1224
- $show_quickpanel_bulk = ( ! empty( $data['cpt_custom_tax']['show_in_quick_edit'] ) ) ? disp_boolean( $data['cpt_custom_tax']['show_in_quick_edit'] ) : '';
1225
 
1226
  $meta_box_cb = trim( $data['cpt_custom_tax']['meta_box_cb'] );
1227
- // We may or may not need to force a boolean false keyword
1228
  $maybe_false = strtolower( trim( $data['cpt_custom_tax']['meta_box_cb'] ) );
1229
  if ( 'false' === $maybe_false ) {
1230
  $meta_box_cb = $maybe_false;
1231
  }
1232
 
1233
- $taxonomies[ $data['cpt_custom_tax']['name'] ] = array(
1234
  'name' => $name,
1235
  'label' => $label,
1236
  'singular_label' => $singular_label,
@@ -1254,7 +1417,7 @@ function cptui_update_taxonomy( $data = array() ) {
1254
  'rest_controller_class' => $rest_controller_class,
1255
  'labels' => $data['cpt_tax_labels'],
1256
  'meta_box_cb' => $meta_box_cb,
1257
- );
1258
 
1259
  $taxonomies[ $data['cpt_custom_tax']['name'] ]['object_types'] = $data['cpt_post_types'];
1260
 
@@ -1293,10 +1456,8 @@ function cptui_update_taxonomy( $data = array() ) {
1293
  // Used to help flush rewrite rules on init.
1294
  set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
1295
 
1296
- if ( isset( $success ) ) {
1297
- if ( 'new' == $data['cpt_tax_status'] ) {
1298
- return 'add_success';
1299
- }
1300
  }
1301
 
1302
  return 'update_success';
@@ -1311,7 +1472,7 @@ function cptui_update_taxonomy( $data = array() ) {
1311
  */
1312
  function cptui_reserved_taxonomies() {
1313
 
1314
- $reserved = array(
1315
  'action',
1316
  'attachment',
1317
  'attachment_id',
@@ -1394,7 +1555,7 @@ function cptui_reserved_taxonomies() {
1394
  'withoutcomments',
1395
  'year',
1396
  'output',
1397
- );
1398
 
1399
  /**
1400
  * Filters the list of reserved post types to check against.
@@ -1404,11 +1565,11 @@ function cptui_reserved_taxonomies() {
1404
  *
1405
  * @param array $value Array of post type slugs to forbid.
1406
  */
1407
- $custom_reserved = apply_filters( 'cptui_reserved_taxonomies', array() );
1408
 
1409
  if ( is_string( $custom_reserved ) && ! empty( $custom_reserved ) ) {
1410
  $reserved[] = $custom_reserved;
1411
- } else if ( is_array( $custom_reserved ) && ! empty( $custom_reserved ) ) {
1412
  foreach ( $custom_reserved as $slug ) {
1413
  $reserved[] = $slug;
1414
  }
@@ -1430,11 +1591,11 @@ function cptui_reserved_taxonomies() {
1430
  function cptui_convert_taxonomy_terms( $original_slug = '', $new_slug = '' ) {
1431
  global $wpdb;
1432
 
1433
- $args = array(
1434
  'taxonomy' => $original_slug,
1435
  'hide_empty' => false,
1436
  'fields' => 'ids',
1437
- );
1438
 
1439
  $term_ids = get_terms( $args );
1440
 
@@ -1465,7 +1626,7 @@ function cptui_convert_taxonomy_terms( $original_slug = '', $new_slug = '' ) {
1465
  *
1466
  * @return bool
1467
  */
1468
- function cptui_check_existing_taxonomy_slugs( $slug_exists = false, $taxonomy_slug = '', $taxonomies = array() ) {
1469
 
1470
  // If true, then we'll already have a conflict, let's not re-process.
1471
  if ( true === $slug_exists ) {
@@ -1483,8 +1644,8 @@ function cptui_check_existing_taxonomy_slugs( $slug_exists = false, $taxonomy_sl
1483
  }
1484
 
1485
  // Check if other plugins have registered this same slug.
1486
- $public = get_taxonomies( array( '_builtin' => false, 'public' => true ) );
1487
- $private = get_taxonomies( array( '_builtin' => false, 'public' => false ) );
1488
  $registered_taxonomies = array_merge( $public, $private );
1489
  if ( in_array( $taxonomy_slug, $registered_taxonomies ) ) {
1490
  return true;
@@ -1526,10 +1687,17 @@ function cptui_process_taxonomy() {
1526
  }
1527
 
1528
  // @TODO Utilize anonymous function to admin_notice `$result` if it happens to error.
1529
- if ( $result ) {
1530
- if ( is_callable( "cptui_{$result}_admin_notice" ) ) {
1531
- add_action( 'admin_notices', "cptui_{$result}_admin_notice" );
1532
- }
 
 
 
 
 
 
 
1533
  }
1534
  }
1535
  }
@@ -1569,13 +1737,12 @@ add_action( 'init', 'cptui_do_convert_taxonomy_terms' );
1569
  * @param array $taxonomies CPTUI taxonomies.
1570
  * @return bool
1571
  */
1572
- function cptui_updated_taxonomy_slug_exists( $slug_exists, $taxonomy_slug = '', $taxonomies = array() ) {
1573
  if (
1574
- ( ! empty( $_POST['cpt_tax_status'] ) && 'edit' == $_POST['cpt_tax_status'] ) &&
1575
- ! in_array( $taxonomy_slug, cptui_reserved_taxonomies() ) &&
1576
  ( ! empty( $_POST['tax_original'] ) && $taxonomy_slug === $_POST['tax_original'] )
1577
- )
1578
- {
1579
  $slug_exists = false;
1580
  }
1581
  return $slug_exists;
9
  * @license GPL-2.0+
10
  */
11
 
12
+ // phpcs:disable WebDevStudios.All.RequireAuthor
13
+
14
  // Exit if accessed directly.
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
38
  wp_enqueue_script( 'cptui' );
39
  wp_enqueue_style( 'cptui-css' );
40
 
41
+ $core = get_taxonomies( [ '_builtin' => true ] );
42
+ $public = get_taxonomies( [
43
+ '_builtin' => false,
44
+ 'public' => true,
45
+ ] );
46
+ $private = get_taxonomies( [
47
+ '_builtin' => false,
48
+ 'public' => false,
49
+ ] );
50
  $registered_taxonomies = array_merge( $core, $public, $private );
51
  wp_localize_script( 'cptui', 'cptui_tax_data',
52
+ [
53
+ 'confirm' => esc_html__( 'Are you sure you want to delete this? Deleting will NOT remove created content.', 'custom-post-type-ui' ),
54
+ 'no_associated_type' => esc_html__( 'Please select a post type to associate with.', 'custom-post-type-ui' ),
55
  'existing_taxonomies' => $registered_taxonomies,
56
+ ]
57
  );
58
  }
59
  add_action( 'admin_enqueue_scripts', 'cptui_taxonomies_enqueue_scripts' );
69
  * @param string $current_page Current page being shown. Optional. Default empty string.
70
  * @return array Amended array of tabs to show.
71
  */
72
+ function cptui_taxonomy_tabs( $tabs = [], $current_page = '' ) {
73
 
74
  if ( 'taxonomies' === $current_page ) {
75
  $taxonomies = cptui_get_taxonomy_data();
76
+ $classes = [ 'nav-tab' ];
77
 
78
+ $tabs['page_title'] = get_admin_page_title();
79
+ $tabs['tabs'] = [];
80
+ $tabs['tabs']['add'] = [ // Start out with our basic "Add new" tab.
 
81
  'text' => esc_html__( 'Add New Taxonomy', 'custom-post-type-ui' ),
82
  'classes' => $classes,
83
  'url' => cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ),
84
  'aria-selected' => 'false',
85
+ ];
86
 
87
  $action = cptui_get_current_action();
88
  if ( empty( $action ) ) {
89
+ $tabs['tabs']['add']['classes'][] = 'nav-tab-active';
90
  $tabs['tabs']['add']['aria-selected'] = 'true';
91
  }
92
 
95
  if ( ! empty( $action ) ) {
96
  $classes[] = 'nav-tab-active';
97
  }
98
+ $tabs['tabs']['edit'] = [
99
  'text' => esc_html__( 'Edit Taxonomies', 'custom-post-type-ui' ),
100
  'classes' => $classes,
101
+ 'url' => esc_url( add_query_arg( [ 'action' => 'edit' ], cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ) ) ),
102
+ 'aria-selected' => ! empty( $action ) ? 'true' : 'false',
103
+ ];
104
 
105
+ $tabs['tabs']['view'] = [
106
  'text' => esc_html__( 'View Taxonomies', 'custom-post-type-ui' ),
107
+ 'classes' => [ 'nav-tab' ], // Prevent notices.
108
  'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_listings#taxonomies' ) ),
109
  'aria-selected' => 'false',
110
+ ];
111
 
112
+ $tabs['tabs']['export'] = [
113
  'text' => esc_html__( 'Import/Export Taxonomies', 'custom-post-type-ui' ),
114
+ 'classes' => [ 'nav-tab' ], // Prevent notices.
115
  'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_tools&action=taxonomies' ) ),
116
  'aria-selected' => 'false',
117
+ ];
118
  }
119
  }
120
 
166
  */
167
  do_action( 'cptui_below_taxonomy_tab_menu' );
168
 
169
+ if ( 'edit' === $tab ) {
170
 
171
  $taxonomies = cptui_get_taxonomy_data();
172
 
173
  $selected_taxonomy = cptui_get_current_taxonomy( $taxonomy_deleted );
174
 
175
+ if ( $selected_taxonomy && array_key_exists( $selected_taxonomy, $taxonomies ) ) {
176
+ $current = $taxonomies[ $selected_taxonomy ];
 
 
177
  }
178
  }
179
 
180
  $ui = new cptui_admin_ui();
181
 
182
  // Will only be set if we're already on the edit screen.
183
+ if ( ! empty( $taxonomies ) ) {
184
+ ?>
185
  <form id="cptui_select_taxonomy" method="post" action="<?php echo esc_url( cptui_get_post_form_action( $ui ) ); ?>">
186
  <label for="taxonomy"><?php esc_html_e( 'Select: ', 'custom-post-type-ui' ); ?></label>
187
  <?php
209
  * @param string $value Current taxonomy selected.
210
  */
211
  do_action( 'cptui_below_taxonomy_select', $current['name'] );
212
+ }
213
+ ?>
214
 
215
  <form class="taxonomiesui" method="post" action="<?php echo esc_url( cptui_get_post_form_action( $ui ) ); ?>">
216
  <div class="postbox-container">
230
  echo $ui->get_tr_start() . $ui->get_th_start();
231
  echo $ui->get_label( 'name', esc_html__( 'Taxonomy Slug', 'custom-post-type-ui' ) ) . $ui->get_required_span();
232
 
233
+ if ( 'edit' === $tab ) {
234
  echo '<p id="slugchanged" class="hidemessage">' . esc_html__( 'Slug has changed', 'custom-post-type-ui' ) . '<span class="dashicons dashicons-warning"></span></p>';
235
  }
236
  echo '<p id="slugexists" class="hidemessage">' . esc_html__( 'Slug already exists', 'custom-post-type-ui' ) . '<span class="dashicons dashicons-warning"></span></p>';
237
 
238
  echo $ui->get_th_end() . $ui->get_td_start();
239
 
240
+ echo $ui->get_text_input( [
241
  'namearray' => 'cpt_custom_tax',
242
  'name' => 'name',
243
+ 'textvalue' => isset( $current['name'] ) ? esc_attr( $current['name'] ) : '',
244
  'maxlength' => '32',
245
  'helptext' => esc_attr__( 'The taxonomy name/slug. Used for various queries for taxonomy content.', 'custom-post-type-ui' ),
246
  'required' => true,
247
  'placeholder' => false,
248
  'wrap' => false,
249
+ ] );
250
 
251
  echo '<p class="cptui-slug-details">';
252
  esc_html_e( 'Slugs should only contain alphanumeric, latin characters. Underscores should be used in place of spaces. Set "Custom Rewrite Slug" field to make slug use dashes for URLs.', 'custom-post-type-ui' );
253
  echo '</p>';
254
 
255
+ if ( 'edit' === $tab ) {
256
  echo '<p>';
257
  esc_html_e( 'DO NOT EDIT the taxonomy slug unless also planning to migrate terms. Changing the slug registers a new taxonomy entry.', 'custom-post-type-ui' );
258
  echo '</p>';
259
 
260
  echo '<div class="cptui-spacer">';
261
+ echo $ui->get_check_input( [
262
  'checkvalue' => 'update_taxonomy',
263
  'checked' => 'false',
264
  'name' => 'update_taxonomy',
267
  'helptext' => '',
268
  'default' => false,
269
  'wrap' => false,
270
+ ] );
271
  echo '</div>';
272
  }
273
 
274
+ echo $ui->get_text_input( [
275
  'namearray' => 'cpt_custom_tax',
276
  'name' => 'label',
277
+ 'textvalue' => isset( $current['label'] ) ? esc_attr( $current['label'] ) : '',
278
  'aftertext' => esc_html__( '(e.g. Actors)', 'custom-post-type-ui' ),
279
  'labeltext' => esc_html__( 'Plural Label', 'custom-post-type-ui' ),
280
  'helptext' => esc_attr__( 'Used for the taxonomy admin menu item.', 'custom-post-type-ui' ),
281
  'required' => true,
282
+ ] );
283
 
284
+ echo $ui->get_text_input( [
285
  'namearray' => 'cpt_custom_tax',
286
  'name' => 'singular_label',
287
+ 'textvalue' => isset( $current['singular_label'] ) ? esc_attr( $current['singular_label'] ) : '',
288
  'aftertext' => esc_html__( '(e.g. Actor)', 'custom-post-type-ui' ),
289
  'labeltext' => esc_html__( 'Singular Label', 'custom-post-type-ui' ),
290
  'helptext' => esc_attr__( 'Used when a singular label is needed.', 'custom-post-type-ui' ),
291
  'required' => true,
292
+ ] );
293
+ echo $ui->get_td_end() . $ui->get_tr_end();
294
+
295
+
296
+ $link_text = ( 'new' === $tab ) ?
297
+ esc_html__( 'Populate additional labels based on chosen labels.', 'custom-post-type-ui' ) :
298
+ esc_html__( 'Populate missing labels based on chosen labels.', 'custom-post-type-ui' );
299
+ echo $ui->get_tr_end();
300
+ echo $ui->get_th_start() . esc_html__( 'Auto-populate labels', 'custom-post-type-ui' ) . $ui->get_th_end();
301
+ echo $ui->get_td_start();
302
+
303
+ ?>
304
+ <a href="#" id="auto-populate"><?php echo esc_html( $link_text ); ?></a>
305
+ <?php
306
 
307
  echo $ui->get_td_end() . $ui->get_tr_end();
308
 
310
  echo $ui->get_p( esc_html__( 'Add support for available registered post types. At least one is required. Only public post types listed by default.', 'custom-post-type-ui' ) );
311
  echo $ui->get_th_end() . $ui->get_td_start() . $ui->get_fieldset_start();
312
 
313
+ echo $ui->get_legend_start() . esc_html__( 'Post type options', 'custom-post-type-ui' ) . $ui->get_legend_end();
314
+
315
  /**
316
  * Filters the arguments for post types to list for taxonomy association.
317
  *
319
  *
320
  * @param array $value Array of default arguments.
321
  */
322
+ $args = apply_filters( 'cptui_attach_post_types_to_taxonomy', [ 'public' => true ] );
323
 
324
  // If they don't return an array, fall back to the original default. Don't need to check for empty, because empty array is default for $args param in get_post_types anyway.
325
  if ( ! is_array( $args ) ) {
326
+ $args = [ 'public' => true ];
327
  }
328
  $output = 'objects'; // Or objects.
329
 
339
  $post_types = apply_filters( 'cptui_get_post_types_for_taxonomies', get_post_types( $args, $output ), $args, $output );
340
 
341
  foreach ( $post_types as $post_type ) {
342
+ $core_label = in_array( $post_type->name, [
343
  'post',
344
  'page',
345
  'attachment',
346
+ ], true ) ? esc_html__( '(WP Core)', 'custom-post-type-ui' ) : '';
347
+ echo $ui->get_check_input( [
348
  'checkvalue' => $post_type->name,
349
+ 'checked' => ( ! empty( $current['object_types'] ) && is_array( $current['object_types'] ) && in_array( $post_type->name, $current['object_types'], true ) ) ? 'true' : 'false',
350
  'name' => $post_type->name,
351
  'namearray' => 'cpt_post_types',
352
  'textvalue' => $post_type->name,
353
+ 'labeltext' => "{$post_type->label} {$core_label}",
354
  'wrap' => false,
355
+ ] );
356
  }
357
 
358
  echo $ui->get_fieldset_end() . $ui->get_td_end() . $ui->get_tr_end();
359
  ?>
360
  </table>
361
  <p class="submit">
362
+ <?php
363
+ wp_nonce_field( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
364
+ if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) {
365
 
366
  /**
367
  * Filters the text value to use on the button when editing.
399
 
400
  <?php if ( ! empty( $current ) ) { ?>
401
  <input type="hidden" name="tax_original" id="tax_original" value="<?php echo esc_attr( $current['name'] ); ?>" />
402
+ <?php
403
+ }
404
 
405
+ // Used to check and see if we should prevent duplicate slugs.
406
+ ?>
407
  <input type="hidden" name="cpt_tax_status" id="cpt_tax_status" value="<?php echo esc_attr( $tab ); ?>" />
408
  </p>
409
  </div>
410
  </div>
411
  </div>
412
+ <div class="cptui-section cptui-labels postbox">
413
  <button type="button" class="handlediv button-link" aria-expanded="true">
414
  <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Additional labels', 'custom-post-type-ui' ); ?></span>
415
  <span class="toggle-indicator" aria-hidden="true"></span>
425
  if ( isset( $current['description'] ) ) {
426
  $current['description'] = stripslashes_deep( $current['description'] );
427
  }
428
+ echo $ui->get_textarea_input( [
429
  'namearray' => 'cpt_custom_tax',
430
  'name' => 'description',
431
  'rows' => '4',
432
  'cols' => '40',
433
+ 'textvalue' => isset( $current['description'] ) ? esc_textarea( $current['description'] ) : '',
434
  'labeltext' => esc_html__( 'Description', 'custom-post-type-ui' ),
435
  'helptext' => esc_attr__( 'Describe what your taxonomy is used for.', 'custom-post-type-ui' ),
436
+ ] );
437
 
438
+ echo $ui->get_text_input( [
439
  'namearray' => 'cpt_tax_labels',
440
  'name' => 'menu_name',
441
+ 'textvalue' => isset( $current['labels']['menu_name'] ) ? esc_attr( $current['labels']['menu_name'] ) : '',
442
  'aftertext' => esc_attr__( '(e.g. Actors)', 'custom-post-type-ui' ),
443
  'labeltext' => esc_html__( 'Menu Name', 'custom-post-type-ui' ),
444
  'helptext' => esc_html__( 'Custom admin menu name for your taxonomy.', 'custom-post-type-ui' ),
445
+ 'data' => [
446
+ 'label' => 'item', // Not localizing because it's isolated.
447
+ 'plurality' => 'plural',
448
+ ],
449
+ ] );
450
 
451
+ echo $ui->get_text_input( [
452
  'namearray' => 'cpt_tax_labels',
453
  'name' => 'all_items',
454
+ 'textvalue' => isset( $current['labels']['all_items'] ) ? esc_attr( $current['labels']['all_items'] ) : '',
455
  'aftertext' => esc_attr__( '(e.g. All Actors)', 'custom-post-type-ui' ),
456
  'labeltext' => esc_html__( 'All Items', 'custom-post-type-ui' ),
457
  'helptext' => esc_html__( 'Used as tab text when showing all terms for hierarchical taxonomy while editing post.', 'custom-post-type-ui' ),
458
+ 'data' => [
459
+ /* translators: Used for autofill */
460
+ 'label' => sprintf( esc_attr__( 'All %s', 'custom-post-type-ui' ), 'item' ),
461
+ 'plurality' => 'plural',
462
+ ],
463
+ ] );
464
+
465
+ echo $ui->get_text_input( [
466
  'namearray' => 'cpt_tax_labels',
467
  'name' => 'edit_item',
468
+ 'textvalue' => isset( $current['labels']['edit_item'] ) ? esc_attr( $current['labels']['edit_item'] ) : '',
469
  'aftertext' => esc_attr__( '(e.g. Edit Actor)', 'custom-post-type-ui' ),
470
  'labeltext' => esc_html__( 'Edit Item', 'custom-post-type-ui' ),
471
  'helptext' => esc_html__( 'Used at the top of the term editor screen for an existing taxonomy term.', 'custom-post-type-ui' ),
472
+ 'data' => [
473
+ /* translators: Used for autofill */
474
+ 'label' => sprintf( esc_attr__( 'Edit %s', 'custom-post-type-ui' ), 'item' ),
475
+ 'plurality' => 'singular',
476
+ ],
477
+ ] );
478
+
479
+ echo $ui->get_text_input( [
480
  'namearray' => 'cpt_tax_labels',
481
  'name' => 'view_item',
482
+ 'textvalue' => isset( $current['labels']['view_item'] ) ? esc_attr( $current['labels']['view_item'] ) : '',
483
  'aftertext' => esc_attr__( '(e.g. View Actor)', 'custom-post-type-ui' ),
484
  'labeltext' => esc_html__( 'View Item', 'custom-post-type-ui' ),
485
  'helptext' => esc_html__( 'Used in the admin bar when viewing editor screen for an existing taxonomy term.', 'custom-post-type-ui' ),
486
+ 'data' => [
487
+ /* translators: Used for autofill */
488
+ 'label' => sprintf( esc_attr__( 'View %s', 'custom-post-type-ui' ), 'item' ),
489
+ 'plurality' => 'singular',
490
+ ],
491
+ ] );
492
+
493
+ echo $ui->get_text_input( [
494
  'namearray' => 'cpt_tax_labels',
495
  'name' => 'update_item',
496
+ 'textvalue' => isset( $current['labels']['update_item'] ) ? esc_attr( $current['labels']['update_item'] ) : '',
497
  'aftertext' => esc_attr__( '(e.g. Update Actor Name)', 'custom-post-type-ui' ),
498
  'labeltext' => esc_html__( 'Update Item Name', 'custom-post-type-ui' ),
499
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
500
+ 'data' => [
501
+ /* translators: Used for autofill */
502
+ 'label' => sprintf( esc_attr__( 'Update %s name', 'custom-post-type-ui' ), 'item' ),
503
+ 'plurality' => 'singular',
504
+ ],
505
+ ] );
506
+
507
+ echo $ui->get_text_input( [
508
  'namearray' => 'cpt_tax_labels',
509
  'name' => 'add_new_item',
510
+ 'textvalue' => isset( $current['labels']['add_new_item'] ) ? esc_attr( $current['labels']['add_new_item'] ) : '',
511
  'aftertext' => esc_attr__( '(e.g. Add New Actor)', 'custom-post-type-ui' ),
512
  'labeltext' => esc_html__( 'Add New Item', 'custom-post-type-ui' ),
513
  'helptext' => esc_html__( 'Used at the top of the term editor screen and button text for a new taxonomy term.', 'custom-post-type-ui' ),
514
+ 'data' => [
515
+ /* translators: Used for autofill */
516
+ 'label' => sprintf( esc_attr__( 'Add new %s', 'custom-post-type-ui' ), 'item' ),
517
+ 'plurality' => 'singular',
518
+ ],
519
+ ] );
520
+
521
+ echo $ui->get_text_input( [
522
  'namearray' => 'cpt_tax_labels',
523
  'name' => 'new_item_name',
524
+ 'textvalue' => isset( $current['labels']['new_item_name'] ) ? esc_attr( $current['labels']['new_item_name'] ) : '',
525
  'aftertext' => esc_attr__( '(e.g. New Actor Name)', 'custom-post-type-ui' ),
526
  'labeltext' => esc_html__( 'New Item Name', 'custom-post-type-ui' ),
527
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
528
+ 'data' => [
529
+ /* translators: Used for autofill */
530
+ 'label' => sprintf( esc_attr__( 'New %s name', 'custom-post-type-ui' ), 'item' ),
531
+ 'plurality' => 'singular',
532
+ ],
533
+ ] );
534
+
535
+ echo $ui->get_text_input( [
536
  'namearray' => 'cpt_tax_labels',
537
  'name' => 'parent_item',
538
+ 'textvalue' => isset( $current['labels']['parent_item'] ) ? esc_attr( $current['labels']['parent_item'] ) : '',
539
  'aftertext' => esc_attr__( '(e.g. Parent Actor)', 'custom-post-type-ui' ),
540
  'labeltext' => esc_html__( 'Parent Item', 'custom-post-type-ui' ),
541
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
542
+ 'data' => [
543
+ /* translators: Used for autofill */
544
+ 'label' => sprintf( esc_attr__( 'Parent %s', 'custom-post-type-ui' ), 'item' ),
545
+ 'plurality' => 'singular',
546
+ ],
547
+ ] );
548
+
549
+ echo $ui->get_text_input( [
550
  'namearray' => 'cpt_tax_labels',
551
  'name' => 'parent_item_colon',
552
+ 'textvalue' => isset( $current['labels']['parent_item_colon'] ) ? esc_attr( $current['labels']['parent_item_colon'] ) : '',
553
  'aftertext' => esc_attr__( '(e.g. Parent Actor:)', 'custom-post-type-ui' ),
554
  'labeltext' => esc_html__( 'Parent Item Colon', 'custom-post-type-ui' ),
555
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
556
+ 'data' => [
557
+ /* translators: Used for autofill */
558
+ 'label' => sprintf( esc_attr__( 'Parent %s:', 'custom-post-type-ui' ), 'item' ),
559
+ 'plurality' => 'singular',
560
+ ],
561
+ ] );
562
+
563
+ echo $ui->get_text_input( [
564
  'namearray' => 'cpt_tax_labels',
565
  'name' => 'search_items',
566
+ 'textvalue' => isset( $current['labels']['search_items'] ) ? esc_attr( $current['labels']['search_items'] ) : '',
567
  'aftertext' => esc_attr__( '(e.g. Search Actors)', 'custom-post-type-ui' ),
568
  'labeltext' => esc_html__( 'Search Items', 'custom-post-type-ui' ),
569
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
570
+ 'data' => [
571
+ /* translators: Used for autofill */
572
+ 'label' => sprintf( esc_attr__( 'Search %s', 'custom-post-type-ui' ), 'item' ),
573
+ 'plurality' => 'plural',
574
+ ],
575
+ ] );
576
+
577
+ echo $ui->get_text_input( [
578
  'namearray' => 'cpt_tax_labels',
579
  'name' => 'popular_items',
580
+ 'textvalue' => isset( $current['labels']['popular_items'] ) ? esc_attr( $current['labels']['popular_items'] ) : null,
581
  'aftertext' => esc_attr__( '(e.g. Popular Actors)', 'custom-post-type-ui' ),
582
  'labeltext' => esc_html__( 'Popular Items', 'custom-post-type-ui' ),
583
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
584
+ 'data' => [
585
+ /* translators: Used for autofill */
586
+ 'label' => sprintf( esc_attr__( 'Popular %s', 'custom-post-type-ui' ), 'item' ),
587
+ 'plurality' => 'plural',
588
+ ],
589
+ ] );
590
+
591
+ echo $ui->get_text_input( [
592
  'namearray' => 'cpt_tax_labels',
593
  'name' => 'separate_items_with_commas',
594
+ 'textvalue' => isset( $current['labels']['separate_items_with_commas'] ) ? esc_attr( $current['labels']['separate_items_with_commas'] ) : null,
595
  'aftertext' => esc_attr__( '(e.g. Separate Actors with commas)', 'custom-post-type-ui' ),
596
  'labeltext' => esc_html__( 'Separate Items with Commas', 'custom-post-type-ui' ),
597
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
598
+ 'data' => [
599
+ /* translators: Used for autofill */
600
+ 'label' => sprintf( esc_attr__( 'Separate %s with commas', 'custom-post-type-ui' ), 'item' ),
601
+ 'plurality' => 'plural',
602
+ ],
603
+ ] );
604
+
605
+ echo $ui->get_text_input( [
606
  'namearray' => 'cpt_tax_labels',
607
  'name' => 'add_or_remove_items',
608
+ 'textvalue' => isset( $current['labels']['add_or_remove_items'] ) ? esc_attr( $current['labels']['add_or_remove_items'] ) : null,
609
  'aftertext' => esc_attr__( '(e.g. Add or remove Actors)', 'custom-post-type-ui' ),
610
  'labeltext' => esc_html__( 'Add or Remove Items', 'custom-post-type-ui' ),
611
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
612
+ 'data' => [
613
+ /* translators: Used for autofill */
614
+ 'label' => sprintf( esc_attr__( 'Add or remove %s', 'custom-post-type-ui' ), 'item' ),
615
+ 'plurality' => 'plural',
616
+ ],
617
+ ] );
618
+
619
+ echo $ui->get_text_input( [
620
  'namearray' => 'cpt_tax_labels',
621
  'name' => 'choose_from_most_used',
622
+ 'textvalue' => isset( $current['labels']['choose_from_most_used'] ) ? esc_attr( $current['labels']['choose_from_most_used'] ) : null,
623
  'aftertext' => esc_attr__( '(e.g. Choose from the most used Actors)', 'custom-post-type-ui' ),
624
  'labeltext' => esc_html__( 'Choose From Most Used', 'custom-post-type-ui' ),
625
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
626
+ 'data' => [
627
+ /* translators: Used for autofill */
628
+ 'label' => sprintf( esc_attr__( 'Choose from the most used %s', 'custom-post-type-ui' ), 'item' ),
629
+ 'plurality' => 'plural',
630
+ ],
631
+ ] );
632
+
633
+ echo $ui->get_text_input( [
634
  'namearray' => 'cpt_tax_labels',
635
  'name' => 'not_found',
636
+ 'textvalue' => isset( $current['labels']['not_found'] ) ? esc_attr( $current['labels']['not_found'] ) : null,
637
  'aftertext' => esc_attr__( '(e.g. No Actors found)', 'custom-post-type-ui' ),
638
  'labeltext' => esc_html__( 'Not found', 'custom-post-type-ui' ),
639
  'helptext' => esc_html__( 'Custom taxonomy label. Used in the admin menu for displaying taxonomies.', 'custom-post-type-ui' ),
640
+ 'data' => [
641
+ /* translators: Used for autofill */
642
+ 'label' => sprintf( esc_attr__( 'No %s found', 'custom-post-type-ui' ), 'item' ),
643
+ 'plurality' => 'plural',
644
+ ],
645
+ ] );
646
+
647
+ echo $ui->get_text_input( [
648
  'namearray' => 'cpt_tax_labels',
649
  'name' => 'no_terms',
650
+ 'textvalue' => isset( $current['labels']['no_terms'] ) ? esc_attr( $current['labels']['no_terms'] ) : null,
651
  'aftertext' => esc_html__( '(e.g. No actors)', 'custom-post-type-ui' ),
652
  'labeltext' => esc_html__( 'No terms', 'custom-post-type-ui' ),
653
  'helptext' => esc_attr__( 'Used when indicating that there are no terms in the given taxonomy associated with an object.', 'custom-post-type-ui' ),
654
+ 'data' => [
655
+ /* translators: Used for autofill */
656
+ 'label' => sprintf( esc_attr__( 'No %s', 'custom-post-type-ui' ), 'item' ),
657
+ 'plurality' => 'plural',
658
+ ],
659
+ ] );
660
+
661
+ echo $ui->get_text_input( [
662
  'namearray' => 'cpt_tax_labels',
663
  'name' => 'items_list_navigation',
664
+ 'textvalue' => isset( $current['labels']['items_list_navigation'] ) ? esc_attr( $current['labels']['items_list_navigation'] ) : null,
665
  'aftertext' => esc_html__( '(e.g. Actors list navigation)', 'custom-post-type-ui' ),
666
  'labeltext' => esc_html__( 'Items List Navigation', 'custom-post-type-ui' ),
667
  'helptext' => esc_attr__( 'Screen reader text for the pagination heading on the term listing screen.', 'custom-post-type-ui' ),
668
+ 'data' => [
669
+ /* translators: Used for autofill */
670
+ 'label' => sprintf( esc_attr__( '%s list navigation', 'custom-post-type-ui' ), 'item' ),
671
+ 'plurality' => 'plural',
672
+ ],
673
+ ] );
674
+
675
+ echo $ui->get_text_input( [
676
  'namearray' => 'cpt_tax_labels',
677
  'name' => 'items_list',
678
+ 'textvalue' => isset( $current['labels']['items_list'] ) ? esc_attr( $current['labels']['items_list'] ) : null,
679
  'aftertext' => esc_html__( '(e.g. Actors list)', 'custom-post-type-ui' ),
680
  'labeltext' => esc_html__( 'Items List', 'custom-post-type-ui' ),
681
  'helptext' => esc_attr__( 'Screen reader text for the items list heading on the term listing screen.', 'custom-post-type-ui' ),
682
+ 'data' => [
683
+ /* translators: Used for autofill */
684
+ 'label' => sprintf( esc_attr__( '%s list', 'custom-post-type-ui' ), 'item' ),
685
+ 'plurality' => 'plural',
686
+ ],
687
+ ] );
688
  ?>
689
  </table>
690
  </div>
691
  </div>
692
  </div>
693
+ <div class="cptui-section cptui-settings postbox">
694
  <button type="button" class="handlediv button-link" aria-expanded="true">
695
  <span class="screen-reader-text"><?php esc_html_e( 'Toggle panel: Settings', 'custom-post-type-ui' ); ?></span>
696
  <span class="toggle-indicator" aria-hidden="true"></span>
703
  <table class="form-table cptui-table">
704
  <?php
705
 
706
+ $select = [
707
+ 'options' => [
708
+ [
709
+ 'attr' => '0',
710
+ 'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
711
+ ],
712
+ [
713
+ 'attr' => '1',
714
+ 'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
715
+ 'default' => 'true',
716
+ ],
717
+ ],
718
+ ];
719
+ $selected = isset( $current ) ? disp_boolean( $current['public'] ) : '';
720
+ $select['selected'] = ! empty( $selected ) ? $current['public'] : '';
721
+ echo $ui->get_select_input( [
722
  'namearray' => 'cpt_custom_tax',
723
  'name' => 'public',
724
  'labeltext' => esc_html__( 'Public', 'custom-post-type-ui' ),
725
  'aftertext' => esc_html__( '(default: true) Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users.', 'custom-post-type-ui' ),
726
  'selections' => $select,
727
+ ] );
728
+
729
+ $select = [
730
+ 'options' => [
731
+ [
732
+ 'attr' => '0',
733
+ 'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
734
+ ],
735
+ [
736
+ 'attr' => '1',
737
+ 'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
738
+ 'default' => 'true',
739
+ ],
740
+ ],
741
+ ];
742
+ $selected = isset( $current ) ? disp_boolean( $current['publicly_queryable'] ) : '';
743
+ $select['selected'] = ! empty( $selected ) ? $current['publicly_queryable'] : '';
744
+ echo $ui->get_select_input( [
745
  'namearray' => 'cpt_custom_tax',
746
  'name' => 'publicly_queryable',
747
  'labeltext' => esc_html__( 'Public Queryable', 'custom-post-type-ui' ),
748
  'aftertext' => esc_html__( '(default: value of "public" setting) Whether or not the taxonomy should be publicly queryable.', 'custom-post-type-ui' ),
749
  'selections' => $select,
750
+ ] );
751
 
752
+ $select = [
753
+ 'options' => [
754
+ [
755
  'attr' => '0',
756
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
757
+ 'default' => 'true',
758
+ ],
759
+ [
760
+ 'attr' => '1',
761
+ 'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
762
+ ],
763
+ ],
764
+ ];
765
+ $selected = isset( $current ) ? disp_boolean( $current['hierarchical'] ) : '';
766
+ $select['selected'] = ! empty( $selected ) ? $current['hierarchical'] : '';
767
+ echo $ui->get_select_input( [
768
  'namearray' => 'cpt_custom_tax',
769
  'name' => 'hierarchical',
770
  'labeltext' => esc_html__( 'Hierarchical', 'custom-post-type-ui' ),
771
  'aftertext' => esc_html__( '(default: false) Whether the taxonomy can have parent-child relationships.', 'custom-post-type-ui' ),
772
  'selections' => $select,
773
+ ] );
774
+
775
+ $select = [
776
+ 'options' => [
777
+ [
778
+ 'attr' => '0',
779
+ 'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
780
+ ],
781
+ [
782
  'attr' => '1',
783
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
784
+ 'default' => 'true',
785
+ ],
786
+ ],
787
+ ];
788
+ $selected = isset( $current ) ? disp_boolean( $current['show_ui'] ) : '';
789
+ $select['selected'] = ! empty( $selected ) ? $current['show_ui'] : '';
790
+ echo $ui->get_select_input( [
791
  'namearray' => 'cpt_custom_tax',
792
  'name' => 'show_ui',
793
  'labeltext' => esc_html__( 'Show UI', 'custom-post-type-ui' ),
794
  'aftertext' => esc_html__( '(default: true) Whether to generate a default UI for managing this custom taxonomy.', 'custom-post-type-ui' ),
795
  'selections' => $select,
796
+ ] );
797
+
798
+ $select = [
799
+ 'options' => [
800
+ [
801
+ 'attr' => '0',
802
+ 'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
803
+ ],
804
+ [
805
  'attr' => '1',
806
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
807
+ 'default' => 'true',
808
+ ],
809
+ ],
810
+ ];
811
+ $selected = isset( $current ) ? disp_boolean( $current['show_in_menu'] ) : '';
812
+ $select['selected'] = ! empty( $selected ) ? $current['show_in_menu'] : '';
813
+ echo $ui->get_select_input( [
814
  'namearray' => 'cpt_custom_tax',
815
  'name' => 'show_in_menu',
816
  'labeltext' => esc_html__( 'Show in menu', 'custom-post-type-ui' ),
817
  'aftertext' => esc_html__( '(default: value of show_ui) Whether to show the taxonomy in the admin menu.', 'custom-post-type-ui' ),
818
  'selections' => $select,
819
+ ] );
820
+
821
+ $select = [
822
+ 'options' => [
823
+ [
824
+ 'attr' => '0',
825
+ 'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
826
+ ],
827
+ [
828
  'attr' => '1',
829
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
830
+ 'default' => 'true',
831
+ ],
832
+ ],
833
+ ];
834
  $selected = ( isset( $current ) && ! empty( $current['show_in_nav_menus'] ) ) ? disp_boolean( $current['show_in_nav_menus'] ) : '';
835
+ $select['selected'] = ! empty( $selected ) ? $current['show_in_nav_menus'] : '';
836
+ echo $ui->get_select_input( [
837
  'namearray' => 'cpt_custom_tax',
838
  'name' => 'show_in_nav_menus',
839
  'labeltext' => esc_html__( 'Show in nav menus', 'custom-post-type-ui' ),
840
  'aftertext' => esc_html__( '(default: value of public) Whether to make the taxonomy available for selection in navigation menus.', 'custom-post-type-ui' ),
841
  'selections' => $select,
842
+ ] );
843
+
844
+ $select = [
845
+ 'options' => [
846
+ [
847
+ 'attr' => '0',
848
+ 'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
849
+ ],
850
+ [
851
  'attr' => '1',
852
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
853
+ 'default' => 'true',
854
+ ],
855
+ ],
856
+ ];
857
+ $selected = isset( $current ) ? disp_boolean( $current['query_var'] ) : '';
858
+ $select['selected'] = ! empty( $selected ) ? $current['query_var'] : '';
859
+ echo $ui->get_select_input( [
860
  'namearray' => 'cpt_custom_tax',
861
  'name' => 'query_var',
862
  'labeltext' => esc_html__( 'Query Var', 'custom-post-type-ui' ),
863
  'aftertext' => esc_html__( '(default: true) Sets the query_var key for this taxonomy.', 'custom-post-type-ui' ),
864
  'selections' => $select,
865
+ ] );
866
 
867
+ echo $ui->get_text_input( [
868
  'namearray' => 'cpt_custom_tax',
869
  'name' => 'query_var_slug',
870
+ 'textvalue' => isset( $current['query_var_slug'] ) ? esc_attr( $current['query_var_slug'] ) : '',
871
  'aftertext' => esc_attr__( '(default: taxonomy slug). Query var needs to be true to use.', 'custom-post-type-ui' ),
872
  'labeltext' => esc_html__( 'Custom Query Var String', 'custom-post-type-ui' ),
873
  'helptext' => esc_html__( 'Sets a custom query_var slug for this taxonomy.', 'custom-post-type-ui' ),
874
+ ] );
875
+
876
+ $select = [
877
+ 'options' => [
878
+ [
879
+ 'attr' => '0',
880
+ 'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
881
+ ],
882
+ [
883
  'attr' => '1',
884
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
885
+ 'default' => 'true',
886
+ ],
887
+ ],
888
+ ];
889
+ $selected = isset( $current ) ? disp_boolean( $current['rewrite'] ) : '';
890
+ $select['selected'] = ! empty( $selected ) ? $current['rewrite'] : '';
891
+ echo $ui->get_select_input( [
892
  'namearray' => 'cpt_custom_tax',
893
  'name' => 'rewrite',
894
  'labeltext' => esc_html__( 'Rewrite', 'custom-post-type-ui' ),
895
  'aftertext' => esc_html__( '(default: true) Whether or not WordPress should use rewrites for this taxonomy.', 'custom-post-type-ui' ),
896
  'selections' => $select,
897
+ ] );
898
 
899
+ echo $ui->get_text_input( [
900
  'namearray' => 'cpt_custom_tax',
901
  'name' => 'rewrite_slug',
902
+ 'textvalue' => isset( $current['rewrite_slug'] ) ? esc_attr( $current['rewrite_slug'] ) : '',
903
  'aftertext' => esc_attr__( '(default: taxonomy name)', 'custom-post-type-ui' ),
904
  'labeltext' => esc_html__( 'Custom Rewrite Slug', 'custom-post-type-ui' ),
905
  'helptext' => esc_html__( 'Custom taxonomy rewrite slug.', 'custom-post-type-ui' ),
906
+ ] );
907
+
908
+ $select = [
909
+ 'options' => [
910
+ [
911
+ 'attr' => '0',
912
+ 'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
913
+ ],
914
+ [
915
  'attr' => '1',
916
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
917
+ 'default' => 'true',
918
+ ],
919
+ ],
920
+ ];
921
+ $selected = isset( $current ) ? disp_boolean( $current['rewrite_withfront'] ) : '';
922
+ $select['selected'] = ! empty( $selected ) ? $current['rewrite_withfront'] : '';
923
+ echo $ui->get_select_input( [
924
  'namearray' => 'cpt_custom_tax',
925
  'name' => 'rewrite_withfront',
926
  'labeltext' => esc_html__( 'Rewrite With Front', 'custom-post-type-ui' ),
927
  'aftertext' => esc_html__( '(default: true) Should the permastruct be prepended with the front base.', 'custom-post-type-ui' ),
928
  'selections' => $select,
929
+ ] );
930
 
931
+ $select = [
932
+ 'options' => [
933
+ [
934
  'attr' => '0',
935
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
936
+ 'default' => 'false',
937
+ ],
938
+ [
939
+ 'attr' => '1',
940
+ 'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
941
+ ],
942
+ ],
943
+ ];
944
+ $selected = isset( $current ) ? disp_boolean( $current['rewrite_hierarchical'] ) : '';
945
+ $select['selected'] = ! empty( $selected ) ? $current['rewrite_hierarchical'] : '';
946
+ echo $ui->get_select_input( [
947
  'namearray' => 'cpt_custom_tax',
948
  'name' => 'rewrite_hierarchical',
949
  'labeltext' => esc_html__( 'Rewrite Hierarchical', 'custom-post-type-ui' ),
950
  'aftertext' => esc_html__( '(default: false) Should the permastruct allow hierarchical urls.', 'custom-post-type-ui' ),
951
  'selections' => $select,
952
+ ] );
953
 
954
+ $select = [
955
+ 'options' => [
956
+ [
957
  'attr' => '0',
958
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
959
+ 'default' => 'true',
960
+ ],
961
+ [
962
+ 'attr' => '1',
963
+ 'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
964
+ ],
965
+ ],
966
+ ];
967
+ $selected = isset( $current ) ? disp_boolean( $current['show_admin_column'] ) : '';
968
+ $select['selected'] = ! empty( $selected ) ? $current['show_admin_column'] : '';
969
+ echo $ui->get_select_input( [
970
  'namearray' => 'cpt_custom_tax',
971
  'name' => 'show_admin_column',
972
  'labeltext' => esc_html__( 'Show Admin Column', 'custom-post-type-ui' ),
973
  'aftertext' => esc_html__( '(default: false) Whether to allow automatic creation of taxonomy columns on associated post-types.', 'custom-post-type-ui' ),
974
  'selections' => $select,
975
+ ] );
976
 
977
+ $select = [
978
+ 'options' => [
979
+ [
980
  'attr' => '0',
981
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
982
+ ],
983
+ [
984
  'attr' => '1',
985
  'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
986
  'default' => 'true',
987
+ ],
988
+ ],
989
+ ];
990
+ $selected = isset( $current ) ? disp_boolean( $current['show_in_rest'] ) : '';
991
+ $select['selected'] = ! empty( $selected ) ? $current['show_in_rest'] : '';
992
+ echo $ui->get_select_input( [
993
  'namearray' => 'cpt_custom_tax',
994
  'name' => 'show_in_rest',
995
  'labeltext' => esc_html__( 'Show in REST API', 'custom-post-type-ui' ),
996
  'aftertext' => esc_html__( '(Custom Post Type UI default: true) Whether to show this taxonomy data in the WP REST API.', 'custom-post-type-ui' ),
997
  'selections' => $select,
998
+ ] );
999
 
1000
+ echo $ui->get_text_input( [
1001
  'namearray' => 'cpt_custom_tax',
1002
  'name' => 'rest_base',
1003
  'labeltext' => esc_html__( 'REST API base slug', 'custom-post-type-ui' ),
1004
  'helptext' => esc_attr__( 'Slug to use in REST API URLs.', 'custom-post-type-ui' ),
1005
+ 'textvalue' => isset( $current['rest_base'] ) ? esc_attr( $current['rest_base'] ) : '',
1006
+ ] );
1007
 
1008
+ echo $ui->get_text_input( [
1009
  'namearray' => 'cpt_custom_tax',
1010
  'name' => 'rest_controller_class',
1011
  'labeltext' => esc_html__( 'REST API controller class', 'custom-post-type-ui' ),
1012
  'aftertext' => esc_attr__( '(default: WP_REST_Terms_Controller) Custom controller to use instead of WP_REST_Terms_Controller.', 'custom-post-type-ui' ),
1013
+ 'textvalue' => isset( $current['rest_controller_class'] ) ? esc_attr( $current['rest_controller_class'] ) : '',
1014
+ ] );
1015
 
1016
+ $select = [
1017
+ 'options' => [
1018
+ [
1019
  'attr' => '0',
1020
  'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
1021
+ 'default' => 'false',
1022
+ ],
1023
+ [
1024
+ 'attr' => '1',
1025
+ 'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
1026
+ ],
1027
+ ],
1028
+ ];
1029
  $selected = ( isset( $current ) && ! empty( $current['show_in_quick_edit'] ) ) ? disp_boolean( $current['show_in_quick_edit'] ) : '';
1030
+ $select['selected'] = ! empty( $selected ) ? $current['show_in_quick_edit'] : '';
1031
+ echo $ui->get_select_input( [
1032
  'namearray' => 'cpt_custom_tax',
1033
  'name' => 'show_in_quick_edit',
1034
  'labeltext' => esc_html__( 'Show in quick/bulk edit panel.', 'custom-post-type-ui' ),
1035
  'aftertext' => esc_html__( '(default: false) Whether to show the taxonomy in the quick/bulk edit panel.', 'custom-post-type-ui' ),
1036
  'selections' => $select,
1037
+ ] );
1038
 
1039
+ echo $ui->get_text_input( [
1040
  'namearray' => 'cpt_custom_tax',
1041
  'name' => 'meta_box_cb',
1042
+ 'textvalue' => isset( $current['meta_box_cb'] ) ? esc_attr( $current['meta_box_cb'] ) : '',
1043
  'labeltext' => esc_html__( 'Metabox callback', 'custom-post-type-ui' ),
1044
  'helptext' => esc_html__( 'Sets a callback function name for the meta box display. Hierarchical default: post_categories_meta_box, non-hierarchical default: post_tags_meta_box. To remove the metabox completely, use "false".', 'custom-post-type-ui' ),
1045
+ ] );
1046
  ?>
1047
  </table>
1048
  </div>
1057
  *
1058
  * @param cptui_admin_ui $ui Admin UI instance.
1059
  */
1060
+ do_action( 'cptui_taxonomy_after_fieldsets', $ui );
1061
+ ?>
1062
 
1063
  <p class="submit">
1064
+ <?php
1065
+ wp_nonce_field( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
1066
+ if ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) { ?>
1067
  <?php
1068
 
1069
  /**
1101
  <?php } ?>
1102
 
1103
  <?php if ( ! empty( $current ) ) { ?>
1104
+ <input type="hidden" name="tax_original" id="tax_original" value="<?php echo esc_attr( $current['name'] ); ?>" />
1105
+ <?php
1106
+ }
1107
 
1108
+ // Used to check and see if we should prevent duplicate slugs.
1109
+ ?>
1110
+ <input type="hidden" name="cpt_tax_status" id="cpt_tax_status" value="<?php echo esc_attr( $tab ); ?>" />
1111
  </p>
1112
  </div>
1113
  </div>
1123
  *
1124
  * @param array $taxonomies Array of taxonomies that are registered. Optional.
1125
  */
1126
+ function cptui_taxonomies_dropdown( $taxonomies = [] ) {
1127
 
1128
  $ui = new cptui_admin_ui();
1129
 
1130
  if ( ! empty( $taxonomies ) ) {
1131
+ $select = [];
1132
+ $select['options'] = [];
1133
 
1134
  foreach ( $taxonomies as $tax ) {
1135
+ $text = ! empty( $tax['label'] ) ? $tax['label'] : $tax['name'];
1136
+ $select['options'][] = [
1137
+ 'attr' => $tax['name'],
1138
+ 'text' => $text,
1139
+ ];
1140
  }
1141
 
1142
+ $current = cptui_get_current_taxonomy();
 
1143
  $select['selected'] = $current;
1144
 
1145
  /**
1152
  */
1153
  $select = apply_filters( 'cptui_taxonomies_dropdown_options', $select, $taxonomies );
1154
 
1155
+ echo $ui->get_select_input( [
1156
+ 'namearray' => 'cptui_selected_taxonomy',
1157
+ 'name' => 'taxonomy',
1158
+ 'selections' => $select,
1159
+ 'wrap' => false,
1160
+ ] );
1161
  }
1162
  }
1163
 
1181
  }
1182
  if ( isset( $_POST['cptui_selected_taxonomy']['taxonomy'] ) ) {
1183
  $tax = sanitize_text_field( $_POST['cptui_selected_taxonomy']['taxonomy'] );
1184
+ } elseif ( $taxonomy_deleted ) {
1185
  $taxonomies = cptui_get_taxonomy_data();
1186
+ $tax = key( $taxonomies );
1187
+ } elseif ( isset( $_POST['cpt_custom_tax']['name'] ) ) {
1188
  // Return the submitted value.
1189
  if ( ! in_array( $_POST['cpt_custom_tax']['name'], cptui_reserved_taxonomies(), true ) ) {
1190
  $tax = sanitize_text_field( $_POST['cpt_custom_tax']['name'] );
1193
  $tax = sanitize_text_field( $_POST['tax_original'] );
1194
  }
1195
  }
1196
+ } elseif ( ! empty( $_GET ) && isset( $_GET['cptui_taxonomy'] ) ) {
1197
  $tax = sanitize_text_field( $_GET['cptui_taxonomy'] );
1198
  } else {
1199
  $taxonomies = cptui_get_taxonomy_data();
1223
  * @param array $data The $_POST values. Optional.
1224
  * @return bool|string False on failure, string on success.
1225
  */
1226
+ function cptui_delete_taxonomy( $data = [] ) {
1227
 
1228
  if ( is_string( $data ) && taxonomy_exists( $data ) ) {
1229
+ $data = [
1230
+ 'cpt_custom_tax' => [
1231
  'name' => $data,
1232
+ ],
1233
+ ];
1234
  }
1235
 
1236
  // Check if they selected one to delete.
1295
  * @param array $data Array of taxonomy data to update. Optional.
1296
  * @return bool|string False on failure, string on success.
1297
  */
1298
+ function cptui_update_taxonomy( $data = [] ) {
1299
 
1300
  /**
1301
  * Fires before a taxonomy is updated to our saved options.
1316
  return 'error';
1317
  }
1318
 
1319
+ if ( ! empty( $data['tax_original'] ) && $data['tax_original'] !== $data['cpt_custom_tax']['name'] ) {
1320
  if ( ! empty( $data['update_taxonomy'] ) ) {
1321
  add_filter( 'cptui_convert_taxonomy_terms', '__return_true' );
1322
  }
1360
  if ( empty( $label ) ) {
1361
  unset( $data['cpt_tax_labels'][ $key ] );
1362
  }
1363
+ $label = str_replace( '"', '', htmlspecialchars_decode( $label ) );
1364
+ $label = htmlspecialchars( $label, ENT_QUOTES );
1365
+ $label = trim( $label );
1366
  $data['cpt_tax_labels'][ $key ] = stripslashes_deep( $label );
1367
  }
1368
 
1384
  $rewrite_slug = trim( $data['cpt_custom_tax']['rewrite_slug'] );
1385
  $rest_base = trim( $data['cpt_custom_tax']['rest_base'] );
1386
  $rest_controller_class = trim( $data['cpt_custom_tax']['rest_controller_class'] );
1387
+ $show_quickpanel_bulk = ! empty( $data['cpt_custom_tax']['show_in_quick_edit'] ) ? disp_boolean( $data['cpt_custom_tax']['show_in_quick_edit'] ) : '';
1388
 
1389
  $meta_box_cb = trim( $data['cpt_custom_tax']['meta_box_cb'] );
1390
+ // We may or may not need to force a boolean false keyword.
1391
  $maybe_false = strtolower( trim( $data['cpt_custom_tax']['meta_box_cb'] ) );
1392
  if ( 'false' === $maybe_false ) {
1393
  $meta_box_cb = $maybe_false;
1394
  }
1395
 
1396
+ $taxonomies[ $data['cpt_custom_tax']['name'] ] = [
1397
  'name' => $name,
1398
  'label' => $label,
1399
  'singular_label' => $singular_label,
1417
  'rest_controller_class' => $rest_controller_class,
1418
  'labels' => $data['cpt_tax_labels'],
1419
  'meta_box_cb' => $meta_box_cb,
1420
+ ];
1421
 
1422
  $taxonomies[ $data['cpt_custom_tax']['name'] ]['object_types'] = $data['cpt_post_types'];
1423
 
1456
  // Used to help flush rewrite rules on init.
1457
  set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
1458
 
1459
+ if ( isset( $success ) && 'new' === $data['cpt_tax_status'] ) {
1460
+ return 'add_success';
 
 
1461
  }
1462
 
1463
  return 'update_success';
1472
  */
1473
  function cptui_reserved_taxonomies() {
1474
 
1475
+ $reserved = [
1476
  'action',
1477
  'attachment',
1478
  'attachment_id',
1555
  'withoutcomments',
1556
  'year',
1557
  'output',
1558
+ ];
1559
 
1560
  /**
1561
  * Filters the list of reserved post types to check against.
1565
  *
1566
  * @param array $value Array of post type slugs to forbid.
1567
  */
1568
+ $custom_reserved = apply_filters( 'cptui_reserved_taxonomies', [] );
1569
 
1570
  if ( is_string( $custom_reserved ) && ! empty( $custom_reserved ) ) {
1571
  $reserved[] = $custom_reserved;
1572
+ } elseif ( is_array( $custom_reserved ) && ! empty( $custom_reserved ) ) {
1573
  foreach ( $custom_reserved as $slug ) {
1574
  $reserved[] = $slug;
1575
  }
1591
  function cptui_convert_taxonomy_terms( $original_slug = '', $new_slug = '' ) {
1592
  global $wpdb;
1593
 
1594
+ $args = [
1595
  'taxonomy' => $original_slug,
1596
  'hide_empty' => false,
1597
  'fields' => 'ids',
1598
+ ];
1599
 
1600
  $term_ids = get_terms( $args );
1601
 
1626
  *
1627
  * @return bool
1628
  */
1629
+ function cptui_check_existing_taxonomy_slugs( $slug_exists = false, $taxonomy_slug = '', $taxonomies = [] ) {
1630
 
1631
  // If true, then we'll already have a conflict, let's not re-process.
1632
  if ( true === $slug_exists ) {
1644
  }
1645
 
1646
  // Check if other plugins have registered this same slug.
1647
+ $public = get_taxonomies( [ '_builtin' => false, 'public' => true ] );
1648
+ $private = get_taxonomies( [ '_builtin' => false, 'public' => false ] );
1649
  $registered_taxonomies = array_merge( $public, $private );
1650
  if ( in_array( $taxonomy_slug, $registered_taxonomies ) ) {
1651
  return true;
1687
  }
1688
 
1689
  // @TODO Utilize anonymous function to admin_notice `$result` if it happens to error.
1690
+ if ( $result && is_callable( "cptui_{$result}_admin_notice" ) ) {
1691
+ add_action( 'admin_notices', "cptui_{$result}_admin_notice" );
1692
+ }
1693
+
1694
+ if ( empty( cptui_get_taxonomy_slugs() ) ) {
1695
+ wp_safe_redirect(
1696
+ add_query_arg(
1697
+ [ 'page' => 'cptui_manage_taxonomies' ],
1698
+ cptui_admin_url( 'admin.php?page=cptui_manage_taxonomies' )
1699
+ )
1700
+ );
1701
  }
1702
  }
1703
  }
1737
  * @param array $taxonomies CPTUI taxonomies.
1738
  * @return bool
1739
  */
1740
+ function cptui_updated_taxonomy_slug_exists( $slug_exists, $taxonomy_slug = '', $taxonomies = [] ) {
1741
  if (
1742
+ ( ! empty( $_POST['cpt_tax_status'] ) && 'edit' === $_POST['cpt_tax_status'] ) &&
1743
+ ! in_array( $taxonomy_slug, cptui_reserved_taxonomies(), true ) &&
1744
  ( ! empty( $_POST['tax_original'] ) && $taxonomy_slug === $_POST['tax_original'] )
1745
+ ) {
 
1746
  $slug_exists = false;
1747
  }
1748
  return $slug_exists;
inc/tools.php CHANGED
@@ -9,6 +9,8 @@
9
  * @license GPL-2.0+
10
  */
11
 
 
 
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
@@ -18,6 +20,8 @@ if ( ! defined( 'ABSPATH' ) ) {
18
  * Enqueue our Custom Post Type UI assets.
19
  *
20
  * @since 1.6.0
 
 
21
  */
22
  function cptui_tools_assets() {
23
  $current_screen = get_current_screen();
@@ -46,56 +50,56 @@ add_action( 'admin_enqueue_scripts', 'cptui_tools_assets' );
46
  * @param string $current_page Current page being shown. Optional. Default empty string.
47
  * @return array Amended array of tabs to show.
48
  */
49
- function cptui_tools_tabs( $tabs = array(), $current_page = '' ) {
50
 
51
  if ( 'tools' === $current_page ) {
52
- $classes = array( 'nav-tab' );
53
 
54
- $tabs['page_title'] = get_admin_page_title();
55
- $tabs['tabs'] = array();
56
- $tabs['tabs']['post_types'] = array(
57
  'text' => __( 'Post Types', 'custom-post-type-ui' ),
58
  'classes' => $classes,
59
  'url' => cptui_admin_url( 'admin.php?page=cptui_' . $current_page ),
60
  'aria-selected' => 'false',
61
- );
62
 
63
- $tabs['tabs']['taxonomies'] = array(
64
  'text' => __( 'Taxonomies', 'custom-post-type-ui' ),
65
  'classes' => $classes,
66
- 'url' => esc_url( add_query_arg( array( 'action' => 'taxonomies' ), cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
67
  'aria-selected' => 'false',
68
- );
69
 
70
- $tabs['tabs']['get_code'] = array(
71
  'text' => __( 'Get Code', 'custom-post-type-ui' ),
72
  'classes' => $classes,
73
- 'url' => esc_url( add_query_arg( array( 'action' => 'get_code' ), cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
74
  'aria-selected' => 'false',
75
- );
76
 
77
- $tabs['tabs']['debuginfo'] = array(
78
  'text' => __( 'Debug Info', 'custom-post-type-ui' ),
79
  'classes' => $classes,
80
- 'url' => esc_url( add_query_arg( array( 'action' => 'debuginfo' ), cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
81
  'aria-selected' => 'false',
82
- );
83
 
84
  $active_class = 'nav-tab-active';
85
- $action = cptui_get_current_action();
86
  if ( ! empty( $action ) ) {
87
  if ( 'taxonomies' === $action ) {
88
- $tabs['tabs']['taxonomies']['classes'][] = $active_class;
89
  $tabs['tabs']['taxonomies']['aria-selected'] = 'true';
90
  } elseif ( 'get_code' === $action ) {
91
- $tabs['tabs']['get_code']['classes'][] = $active_class;
92
  $tabs['tabs']['get_code']['aria-selected'] = 'true';
93
  } elseif ( 'debuginfo' === $action ) {
94
- $tabs['tabs']['debuginfo']['classes'][] = $active_class;
95
  $tabs['tabs']['debuginfo']['aria-selected'] = 'true';
96
  }
97
  } else {
98
- $tabs['tabs']['post_types']['classes'][] = $active_class;
99
  $tabs['tabs']['post_types']['aria-selected'] = 'true';
100
  }
101
 
@@ -146,7 +150,7 @@ function cptui_tools() {
146
  *
147
  * @deprecated 1.5.0
148
  */
149
- do_action_deprecated( 'cptui_inside_importexport_wrap', array(), '1.5.0', 'cptui_inside_tools_wrap' );
150
 
151
  /**
152
  * Fires right inside the wrap div for the tools pages.
@@ -169,7 +173,7 @@ function cptui_tools() {
169
  *
170
  * @param string $tab Current tab being displayed.
171
  */
172
- do_action_deprecated( 'cptui_import_export_sections', array( $tab ), '1.5.0', 'cptui_tools_sections' );
173
 
174
  /**
175
  * Fires inside the markup for the tools section.
@@ -195,7 +199,7 @@ function cptui_tools() {
195
  * @param array $cptui_taxonomies Array of taxonomies to render. Optional.
196
  * @param bool $single Whether or not we are rendering a single taxonomy. Optional. Default false.
197
  */
198
- function cptui_get_taxonomy_code( $cptui_taxonomies = array(), $single = false ) {
199
  if ( ! empty( $cptui_taxonomies ) ) {
200
  $callback = 'cptui_register_my_taxes';
201
  if ( $single ) {
@@ -223,11 +227,11 @@ add_action( 'init', '<?php echo $callback; ?>' );
223
  *
224
  * @param array $taxonomy Taxonomy data to output. Optional.
225
  */
226
- function cptui_get_single_taxonomy_registery( $taxonomy = array() ) {
227
 
228
  $post_types = "''";
229
  if ( is_array( $taxonomy['object_types'] ) ) {
230
- $post_types = 'array( "' . implode( '", "', $taxonomy['object_types'] ) . '" )';
231
  }
232
 
233
  if ( false !== get_disp_boolean( $taxonomy['rewrite'] ) ) {
@@ -239,29 +243,29 @@ function cptui_get_single_taxonomy_registery( $taxonomy = array() ) {
239
  }
240
 
241
  $rewrite_withfront = '';
242
- $withfront = disp_boolean( $taxonomy['rewrite_withfront'] );
243
  if ( ! empty( $withfront ) ) {
244
  $rewrite_withfront = ' \'with_front\' => ' . $withfront . ', ';
245
  }
246
 
247
- $hierarchical = ( ! empty( $taxonomy['rewrite_hierarchical'] ) ) ? disp_boolean( $taxonomy['rewrite_hierarchical'] ) : '';
248
  $rewrite_hierarchcial = '';
249
  if ( ! empty( $hierarchical ) ) {
250
  $rewrite_hierarchcial = ' \'hierarchical\' => ' . $hierarchical . ', ';
251
  }
252
 
253
  if ( ! empty( $taxonomy['rewrite_slug'] ) || false !== disp_boolean( $taxonomy['rewrite_withfront'] ) ) {
254
- $rewrite_start = 'array(';
255
- $rewrite_end = ')';
256
 
257
  $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_hierarchcial . $rewrite_end;
258
  }
259
  } else {
260
  $rewrite = disp_boolean( $taxonomy['rewrite'] );
261
  }
262
- $public = ( isset( $taxonomy['public'] ) ) ? disp_boolean( $taxonomy['public'] ) : 'true';
263
- $publicly_queryable = ( isset( $taxonomy['publicly_queryable'] ) ) ? disp_boolean( $taxonomy['publicly_queryable'] ) : disp_boolean( $taxonomy['public'] );
264
- $show_in_quick_edit = ( isset( $taxonomy['show_in_quick_edit'] ) ) ? disp_boolean( $taxonomy['show_in_quick_edit'] ) : disp_boolean( $taxonomy['show_ui'] );
265
 
266
  $show_in_menu = ( ! empty( $taxonomy['show_in_menu'] ) && false !== get_disp_boolean( $taxonomy['show_in_menu'] ) ) ? 'true' : 'false';
267
  if ( empty( $taxonomy['show_in_menu'] ) ) {
@@ -274,8 +278,8 @@ function cptui_get_single_taxonomy_registery( $taxonomy = array() ) {
274
  }
275
 
276
  $show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? 'true' : 'false';
277
- $rest_base = ( ! empty( $taxonomy['rest_base'] ) ) ? $taxonomy['rest_base'] : $taxonomy['name'];
278
- $rest_controller_class = ( ! empty( $taxonomy['rest_controller_class'] ) ) ? $taxonomy['rest_controller_class'] : 'WP_REST_Terms_Controller';
279
 
280
  if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
281
  $meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? '"' . $taxonomy['meta_box_cb'] . '"' : 'false';
@@ -292,7 +296,7 @@ function cptui_get_single_taxonomy_registery( $taxonomy = array() ) {
292
  * Taxonomy: <?php echo esc_html( $taxonomy['label'] ); ?>.
293
  */
294
 
295
- $labels = array(
296
  "name" => __( "<?php echo esc_html( $taxonomy['label'] ); ?>", "<?php echo esc_html( $textdomain ); ?>" ),
297
  "singular_name" => __( "<?php echo esc_html( $taxonomy['singular_label'] ); ?>", "<?php echo esc_html( $textdomain ); ?>" ),
298
  <?php
@@ -302,9 +306,9 @@ foreach ( $taxonomy['labels'] as $key => $label ) {
302
  }
303
  }
304
  ?>
305
- );
306
 
307
- $args = array(
308
  "label" => __( "<?php echo $taxonomy['label']; ?>", "<?php echo $textdomain; ?>" ),
309
  "labels" => $labels,
310
  "public" => <?php echo $public; ?>,
@@ -323,7 +327,7 @@ foreach ( $taxonomy['labels'] as $key => $label ) {
323
  <?php if ( ! empty( $meta_box_cb ) ) { ?>
324
  "meta_box_cb" => <?php echo $meta_box_cb; ?>,
325
  <?php } ?>
326
- );
327
  register_taxonomy( "<?php echo $taxonomy['name']; ?>", <?php echo $post_types; ?>, $args );
328
  <?php
329
  }
@@ -338,18 +342,19 @@ foreach ( $taxonomy['labels'] as $key => $label ) {
338
  * @param array $cptui_post_types Array of post types to render. Optional.
339
  * @param bool $single Whether or not we are rendering a single post type. Optional. Default false.
340
  */
341
- function cptui_get_post_type_code( $cptui_post_types = array(), $single = false ) {
342
  // Whitespace very much matters here, thus why it's all flush against the left side.
343
  if ( ! empty( $cptui_post_types ) ) {
344
  $callback = 'cptui_register_my_cpts';
345
  if ( $single ) {
346
- $key = key( $cptui_post_types );
347
  $callback = 'cptui_register_my_cpts_' . str_replace( '-', '_', $cptui_post_types[ $key ]['name'] );
348
  }
349
  ?>
350
 
351
  function <?php echo $callback; ?>() {
352
- <?php // Space before this line reflects in textarea.
 
353
  foreach ( $cptui_post_types as $type ) {
354
  echo cptui_get_single_post_type_registery( $type );
355
  }
@@ -370,13 +375,13 @@ add_action( 'init', '<?php echo $callback; ?>' );
370
  *
371
  * @param array $post_type Post type data to output. Optional.
372
  */
373
- function cptui_get_single_post_type_registery( $post_type = array() ) {
374
 
375
- /** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
376
  $post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', 'true', $post_type['name'], $post_type );
377
 
378
- /** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
379
- $user_supports_params = apply_filters( 'cptui_user_supports_params', array(), $post_type['name'], $post_type );
380
  if ( is_array( $user_supports_params ) ) {
381
  $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
382
  }
@@ -386,7 +391,7 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
386
  $custom = explode( ',', $post_type['custom_supports'] );
387
  foreach ( $custom as $part ) {
388
  // We'll handle YARPP separately.
389
- if ( in_array( $part, array( 'YARPP', 'yarpp' ) ) ) {
390
  $yarpp = true;
391
  continue;
392
  }
@@ -395,7 +400,7 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
395
  }
396
 
397
  $rewrite_withfront = '';
398
- $rewrite = get_disp_boolean( $post_type['rewrite'] );
399
  if ( false !== $rewrite ) {
400
  $rewrite = disp_boolean( $post_type['rewrite'] );
401
 
@@ -410,8 +415,8 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
410
  }
411
 
412
  if ( ! empty( $post_type['rewrite_slug'] ) || ! empty( $post_type['rewrite_withfront'] ) ) {
413
- $rewrite_start = 'array(';
414
- $rewrite_end = ')';
415
 
416
  $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_end;
417
  }
@@ -431,19 +436,19 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
431
  $supports = '';
432
  // Do a little bit of php work to get these into strings.
433
  if ( ! empty( $post_type['supports'] ) && is_array( $post_type['supports'] ) ) {
434
- $supports = 'array( "' . implode( '", "', $post_type['supports'] ) . '" )';
435
  }
436
 
437
- if ( in_array( 'none', $post_type['supports'] ) ) {
438
  $supports = 'false';
439
  }
440
 
441
  $taxonomies = '';
442
  if ( ! empty( $post_type['taxonomies'] ) && is_array( $post_type['taxonomies'] ) ) {
443
- $taxonomies = 'array( "' . implode( '", "', $post_type['taxonomies'] ) . '" )';
444
  }
445
 
446
- if ( in_array( $post_type['query_var'], array( 'true', 'false', '0', '1' ) ) ) {
447
  $post_type['query_var'] = disp_boolean( $post_type['query_var'] );
448
  }
449
  if ( ! empty( $post_type['query_var_slug'] ) ) {
@@ -453,7 +458,7 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
453
  if ( empty( $post_type['show_in_rest'] ) ) {
454
  $post_type['show_in_rest'] = 'false';
455
  }
456
- $rest_controller_class = ( ! empty( $post_type['rest_controller_class'] ) ) ? $post_type['rest_controller_class'] : 'WP_REST_Posts_Controller';
457
 
458
  $delete_with_user = ( ! empty( $post_type['delete_with_user'] ) && false !== get_disp_boolean( $post_type['delete_with_user'] ) ) ? 'true' : 'false';
459
 
@@ -467,7 +472,12 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
467
  $show_in_menu = disp_boolean( $post_type['show_in_menu'] );
468
  }
469
 
470
- $public = ( isset( $post_type['public'] ) ) ? disp_boolean( $post_type['public'] ) : 'true';
 
 
 
 
 
471
  $show_in_nav_menus = ( ! empty( $post_type['show_in_nav_menus'] ) && false !== get_disp_boolean( $post_type['show_in_nav_menus'] ) ) ? 'true' : 'false';
472
  if ( empty( $post_type['show_in_nav_menus'] ) ) {
473
  $show_in_nav_menus = $public;
@@ -481,13 +491,13 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
481
  if ( count( $caps ) > 2 ) {
482
  $caps = array_slice( $caps, 0, 2 );
483
  }
484
- $capability_type = 'array( "' . $caps[0] . '", "' . $caps[1] . '" )';
485
  }
486
  }
487
 
488
  $post_type['description'] = addslashes( $post_type['description'] );
489
 
490
- $my_theme = wp_get_theme();
491
  $textdomain = $my_theme->get( 'TextDomain' );
492
  if ( empty( $textdomain ) ) {
493
  $textdomain = 'custom-post-type-ui';
@@ -498,13 +508,13 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
498
  * Post Type: <?php echo $post_type['label']; ?>.
499
  */
500
 
501
- $labels = array(
502
  "name" => __( "<?php echo $post_type['label']; ?>", "<?php echo $textdomain; ?>" ),
503
  "singular_name" => __( "<?php echo $post_type['singular_label']; ?>", "<?php echo $textdomain; ?>" ),
504
  <?php
505
  foreach ( $post_type['labels'] as $key => $label ) {
506
  if ( ! empty( $label ) ) {
507
- if ( 'parent' === $key ) {
508
  // Fix for incorrect label key. See #439.
509
  echo "\t\t" . '"' . 'parent_item_colon' . '" => __( "' . $label . '", "' . $textdomain . '" ),' . "\n";
510
  } else {
@@ -513,9 +523,9 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
513
  }
514
  }
515
  ?>
516
- );
517
 
518
- $args = array(
519
  "label" => __( "<?php echo $post_type['label']; ?>", "<?php echo $textdomain; ?>" ),
520
  "labels" => $labels,
521
  "description" => "<?php echo $post_type['description']; ?>",
@@ -529,6 +539,7 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
529
  "has_archive" => <?php echo $has_archive; ?>,
530
  "show_in_menu" => <?php echo $show_in_menu; ?>,
531
  "show_in_nav_menus" => <?php echo $show_in_nav_menus; ?>,
 
532
  "exclude_from_search" => <?php echo disp_boolean( $post_type['exclude_from_search'] ); ?>,
533
  "capability_type" => <?php echo $capability_type; ?>,
534
  "map_meta_cap" => <?php echo disp_boolean( $post_type['map_meta_cap'] ); ?>,
@@ -550,7 +561,7 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
550
  <?php if ( true === $yarpp ) { ?>
551
  "yarpp_support" => <?php echo disp_boolean( $yarpp ); ?>,
552
  <?php } ?>
553
- );
554
 
555
  register_post_type( "<?php echo $post_type['name']; ?>", $args );
556
  <?php
@@ -566,12 +577,12 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
566
  * @param array $postdata $_POST data as json. Optional.
567
  * @return mixed false on nothing to do, otherwise void.
568
  */
569
- function cptui_import_types_taxes_settings( $postdata = array() ) {
570
  if ( ! isset( $postdata['cptui_post_import'] ) && ! isset( $postdata['cptui_tax_import'] ) ) {
571
  return false;
572
  }
573
 
574
- $status = 'import_fail';
575
  $success = false;
576
 
577
  /**
@@ -610,7 +621,7 @@ function cptui_import_types_taxes_settings( $postdata = array() ) {
610
 
611
  // Add support to delete settings outright, without accessing database.
612
  // Doing double check to protect.
613
- if ( is_null( $settings ) && '{""}' === $cpt_data ) {
614
 
615
  /**
616
  * Filters whether or not 3rd party options were deleted successfully within post type import.
@@ -657,7 +668,7 @@ function cptui_import_types_taxes_settings( $postdata = array() ) {
657
 
658
  // Add support to delete settings outright, without accessing database.
659
  // Doing double check to protect.
660
- if ( is_null( $settings ) && '{""}' === $tax_data ) {
661
 
662
  /**
663
  * Filters whether or not 3rd party options were deleted successfully within taxonomy import.
@@ -761,7 +772,7 @@ function cptui_render_posttypes_taxonomies_section() {
761
  </p>
762
  </td>
763
  </tr>
764
- <?php } elseif ( ! empty( $_GET ) && 'taxonomies' == $_GET['action'] ) { ?>
765
  <tr>
766
  <td class="outer">
767
  <h2><label for="cptui_tax_import"><?php esc_html_e( 'Import Taxonomies', 'custom-post-type-ui' ); ?></label></h2>
@@ -820,36 +831,46 @@ function cptui_render_getcode_section() {
820
  <p><?php esc_html_e( 'All of the selectable code snippets below are useful if you wish to migrate away from Custom Post Type UI and retain your existing registered post types or taxonomies.', 'custom-post-type-ui' ); ?></p>
821
 
822
  <?php $cptui_post_types = cptui_get_post_type_data(); ?>
823
- <label for="cptui_post_type_get_code"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
824
- <textarea name="cptui_post_type_get_code" id="cptui_post_type_get_code" class="cptui_post_type_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_post_type_code( $cptui_post_types ); ?></textarea>
825
 
826
  <?php
827
  if ( ! empty( $cptui_post_types ) ) {
828
- foreach ( $cptui_post_types as $post_type ) { ?>
829
- <h2 id="<?php echo esc_attr( $post_type['name'] ); ?>"><?php
830
- $type = ( ! empty( $post_type['label'] ) ) ? $post_type['label'] : $post_type['name'];
 
 
831
  printf( esc_html__( '%s Post Type', 'custom-post-type-ui' ), esc_html( $type ) ); ?></h2>
832
- <label for="cptui_post_type_get_code_<?php echo esc_attr( $post_type['name'] ); ?>"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
833
- <textarea name="cptui_post_type_get_code_<?php echo esc_attr( $post_type['name'] ); ?>" id="cptui_post_type_get_code_<?php echo esc_attr( $post_type['name'] ); ?>" class="cptui_post_type_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_post_type_code( array( $post_type ), true ); ?></textarea>
834
- <?php }
835
- } ?>
 
 
836
 
837
  <h2><?php esc_html_e( 'All Custom Post Type UI Taxonomies', 'custom-post-type-ui' ); ?></h2>
838
 
839
  <?php $cptui_taxonomies = cptui_get_taxonomy_data(); ?>
840
- <label for="cptui_tax_get_code"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
841
- <textarea name="cptui_tax_get_code" id="cptui_tax_get_code" class="cptui_tax_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_taxonomy_code( $cptui_taxonomies ); ?></textarea>
842
 
843
  <?php
844
  if ( ! empty( $cptui_taxonomies ) ) {
845
- foreach ( $cptui_taxonomies as $taxonomy ) { ?>
846
- <h2 id="<?php echo esc_attr( $taxonomy['name'] ); ?>"><?php
847
- $tax = ( ! empty( $taxonomy['label'] ) ) ? $taxonomy['label'] : $taxonomy['name'];
848
- printf( esc_html__( '%s Taxonomy', 'custom-post-type-ui' ), esc_html( $tax ) ); ?></h2>
849
- <label for="cptui_tax_get_code_<?php echo esc_attr( $taxonomy['name'] ); ?>"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
850
- <textarea name="cptui_tax_get_code_<?php echo esc_attr( $taxonomy['name'] ); ?>" id="cptui_tax_get_code_<?php echo esc_attr( $taxonomy['name'] ); ?>" class="cptui_tax_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_taxonomy_code( array( $taxonomy ), true ); ?></textarea>
851
- <?php }
852
- } ?>
 
 
 
 
 
 
853
  <?php
854
  }
855
 
@@ -872,7 +893,7 @@ function cptui_render_debuginfo_section() {
872
  if ( ! empty( $_POST ) && isset( $_POST['cptui_debug_info_email'] ) && isset( $_POST['cptui_debuginfo_nonce_field'] ) ) {
873
  wp_verify_nonce( 'cptui_debuginfo_nonce_field', 'cptui_debuginfo_nonce_action' );
874
 
875
- $email_args = array();
876
  $email_args['email'] = sanitize_text_field( $_POST['cptui_debug_info_email'] );
877
  $debuginfo->send_email( $email_args );
878
  }
@@ -908,15 +929,15 @@ function cptui_render_debuginfo_section() {
908
  */
909
  function cptui_render_tools( $tab ) {
910
  if ( isset( $tab ) ) {
911
- if ( 'post_types' == $tab || 'taxonomies' == $tab ) {
912
  cptui_render_posttypes_taxonomies_section();
913
  }
914
 
915
- if ( 'get_code' == $tab ) {
916
  cptui_render_getcode_section();
917
  }
918
 
919
- if ( 'debuginfo' == $tab ) {
920
  cptui_render_debuginfo_section();
921
  }
922
  }
9
  * @license GPL-2.0+
10
  */
11
 
12
+ // phpcs:disable WebDevStudios.All.RequireAuthor
13
+
14
  // Exit if accessed directly.
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
20
  * Enqueue our Custom Post Type UI assets.
21
  *
22
  * @since 1.6.0
23
+ *
24
+ * @return void
25
  */
26
  function cptui_tools_assets() {
27
  $current_screen = get_current_screen();
50
  * @param string $current_page Current page being shown. Optional. Default empty string.
51
  * @return array Amended array of tabs to show.
52
  */
53
+ function cptui_tools_tabs( $tabs = [], $current_page = '' ) {
54
 
55
  if ( 'tools' === $current_page ) {
56
+ $classes = [ 'nav-tab' ];
57
 
58
+ $tabs['page_title'] = get_admin_page_title();
59
+ $tabs['tabs'] = [];
60
+ $tabs['tabs']['post_types'] = [
61
  'text' => __( 'Post Types', 'custom-post-type-ui' ),
62
  'classes' => $classes,
63
  'url' => cptui_admin_url( 'admin.php?page=cptui_' . $current_page ),
64
  'aria-selected' => 'false',
65
+ ];
66
 
67
+ $tabs['tabs']['taxonomies'] = [
68
  'text' => __( 'Taxonomies', 'custom-post-type-ui' ),
69
  'classes' => $classes,
70
+ 'url' => esc_url( add_query_arg( [ 'action' => 'taxonomies' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
71
  'aria-selected' => 'false',
72
+ ];
73
 
74
+ $tabs['tabs']['get_code'] = [
75
  'text' => __( 'Get Code', 'custom-post-type-ui' ),
76
  'classes' => $classes,
77
+ 'url' => esc_url( add_query_arg( [ 'action' => 'get_code' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
78
  'aria-selected' => 'false',
79
+ ];
80
 
81
+ $tabs['tabs']['debuginfo'] = [
82
  'text' => __( 'Debug Info', 'custom-post-type-ui' ),
83
  'classes' => $classes,
84
+ 'url' => esc_url( add_query_arg( [ 'action' => 'debuginfo' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
85
  'aria-selected' => 'false',
86
+ ];
87
 
88
  $active_class = 'nav-tab-active';
89
+ $action = cptui_get_current_action();
90
  if ( ! empty( $action ) ) {
91
  if ( 'taxonomies' === $action ) {
92
+ $tabs['tabs']['taxonomies']['classes'][] = $active_class;
93
  $tabs['tabs']['taxonomies']['aria-selected'] = 'true';
94
  } elseif ( 'get_code' === $action ) {
95
+ $tabs['tabs']['get_code']['classes'][] = $active_class;
96
  $tabs['tabs']['get_code']['aria-selected'] = 'true';
97
  } elseif ( 'debuginfo' === $action ) {
98
+ $tabs['tabs']['debuginfo']['classes'][] = $active_class;
99
  $tabs['tabs']['debuginfo']['aria-selected'] = 'true';
100
  }
101
  } else {
102
+ $tabs['tabs']['post_types']['classes'][] = $active_class;
103
  $tabs['tabs']['post_types']['aria-selected'] = 'true';
104
  }
105
 
150
  *
151
  * @deprecated 1.5.0
152
  */
153
+ do_action_deprecated( 'cptui_inside_importexport_wrap', [], '1.5.0', 'cptui_inside_tools_wrap' );
154
 
155
  /**
156
  * Fires right inside the wrap div for the tools pages.
173
  *
174
  * @param string $tab Current tab being displayed.
175
  */
176
+ do_action_deprecated( 'cptui_import_export_sections', [ $tab ], '1.5.0', 'cptui_tools_sections' );
177
 
178
  /**
179
  * Fires inside the markup for the tools section.
199
  * @param array $cptui_taxonomies Array of taxonomies to render. Optional.
200
  * @param bool $single Whether or not we are rendering a single taxonomy. Optional. Default false.
201
  */
202
+ function cptui_get_taxonomy_code( $cptui_taxonomies = [], $single = false ) {
203
  if ( ! empty( $cptui_taxonomies ) ) {
204
  $callback = 'cptui_register_my_taxes';
205
  if ( $single ) {
227
  *
228
  * @param array $taxonomy Taxonomy data to output. Optional.
229
  */
230
+ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
231
 
232
  $post_types = "''";
233
  if ( is_array( $taxonomy['object_types'] ) ) {
234
+ $post_types = '[ "' . implode( '", "', $taxonomy['object_types'] ) . '" ]';
235
  }
236
 
237
  if ( false !== get_disp_boolean( $taxonomy['rewrite'] ) ) {
243
  }
244
 
245
  $rewrite_withfront = '';
246
+ $withfront = disp_boolean( $taxonomy['rewrite_withfront'] );
247
  if ( ! empty( $withfront ) ) {
248
  $rewrite_withfront = ' \'with_front\' => ' . $withfront . ', ';
249
  }
250
 
251
+ $hierarchical = ! empty( $taxonomy['rewrite_hierarchical'] ) ? disp_boolean( $taxonomy['rewrite_hierarchical'] ) : '';
252
  $rewrite_hierarchcial = '';
253
  if ( ! empty( $hierarchical ) ) {
254
  $rewrite_hierarchcial = ' \'hierarchical\' => ' . $hierarchical . ', ';
255
  }
256
 
257
  if ( ! empty( $taxonomy['rewrite_slug'] ) || false !== disp_boolean( $taxonomy['rewrite_withfront'] ) ) {
258
+ $rewrite_start = '[';
259
+ $rewrite_end = ']';
260
 
261
  $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_hierarchcial . $rewrite_end;
262
  }
263
  } else {
264
  $rewrite = disp_boolean( $taxonomy['rewrite'] );
265
  }
266
+ $public = isset( $taxonomy['public'] ) ? disp_boolean( $taxonomy['public'] ) : 'true';
267
+ $publicly_queryable = isset( $taxonomy['publicly_queryable'] ) ? disp_boolean( $taxonomy['publicly_queryable'] ) : disp_boolean( $taxonomy['public'] );
268
+ $show_in_quick_edit = isset( $taxonomy['show_in_quick_edit'] ) ? disp_boolean( $taxonomy['show_in_quick_edit'] ) : disp_boolean( $taxonomy['show_ui'] );
269
 
270
  $show_in_menu = ( ! empty( $taxonomy['show_in_menu'] ) && false !== get_disp_boolean( $taxonomy['show_in_menu'] ) ) ? 'true' : 'false';
271
  if ( empty( $taxonomy['show_in_menu'] ) ) {
278
  }
279
 
280
  $show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? 'true' : 'false';
281
+ $rest_base = ! empty( $taxonomy['rest_base'] ) ? $taxonomy['rest_base'] : $taxonomy['name'];
282
+ $rest_controller_class = ! empty( $taxonomy['rest_controller_class'] ) ? $taxonomy['rest_controller_class'] : 'WP_REST_Terms_Controller';
283
 
284
  if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
285
  $meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? '"' . $taxonomy['meta_box_cb'] . '"' : 'false';
296
  * Taxonomy: <?php echo esc_html( $taxonomy['label'] ); ?>.
297
  */
298
 
299
+ $labels = [
300
  "name" => __( "<?php echo esc_html( $taxonomy['label'] ); ?>", "<?php echo esc_html( $textdomain ); ?>" ),
301
  "singular_name" => __( "<?php echo esc_html( $taxonomy['singular_label'] ); ?>", "<?php echo esc_html( $textdomain ); ?>" ),
302
  <?php
306
  }
307
  }
308
  ?>
309
+ ];
310
 
311
+ $args = [
312
  "label" => __( "<?php echo $taxonomy['label']; ?>", "<?php echo $textdomain; ?>" ),
313
  "labels" => $labels,
314
  "public" => <?php echo $public; ?>,
327
  <?php if ( ! empty( $meta_box_cb ) ) { ?>
328
  "meta_box_cb" => <?php echo $meta_box_cb; ?>,
329
  <?php } ?>
330
+ ];
331
  register_taxonomy( "<?php echo $taxonomy['name']; ?>", <?php echo $post_types; ?>, $args );
332
  <?php
333
  }
342
  * @param array $cptui_post_types Array of post types to render. Optional.
343
  * @param bool $single Whether or not we are rendering a single post type. Optional. Default false.
344
  */
345
+ function cptui_get_post_type_code( $cptui_post_types = [], $single = false ) {
346
  // Whitespace very much matters here, thus why it's all flush against the left side.
347
  if ( ! empty( $cptui_post_types ) ) {
348
  $callback = 'cptui_register_my_cpts';
349
  if ( $single ) {
350
+ $key = key( $cptui_post_types );
351
  $callback = 'cptui_register_my_cpts_' . str_replace( '-', '_', $cptui_post_types[ $key ]['name'] );
352
  }
353
  ?>
354
 
355
  function <?php echo $callback; ?>() {
356
+ <?php
357
+ // Space before this line reflects in textarea.
358
  foreach ( $cptui_post_types as $type ) {
359
  echo cptui_get_single_post_type_registery( $type );
360
  }
375
  *
376
  * @param array $post_type Post type data to output. Optional.
377
  */
378
+ function cptui_get_single_post_type_registery( $post_type = [] ) {
379
 
380
+ /* This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
381
  $post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', 'true', $post_type['name'], $post_type );
382
 
383
+ /* This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
384
+ $user_supports_params = apply_filters( 'cptui_user_supports_params', [], $post_type['name'], $post_type );
385
  if ( is_array( $user_supports_params ) ) {
386
  $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
387
  }
391
  $custom = explode( ',', $post_type['custom_supports'] );
392
  foreach ( $custom as $part ) {
393
  // We'll handle YARPP separately.
394
+ if ( in_array( $part, [ 'YARPP', 'yarpp' ], true ) ) {
395
  $yarpp = true;
396
  continue;
397
  }
400
  }
401
 
402
  $rewrite_withfront = '';
403
+ $rewrite = get_disp_boolean( $post_type['rewrite'] );
404
  if ( false !== $rewrite ) {
405
  $rewrite = disp_boolean( $post_type['rewrite'] );
406
 
415
  }
416
 
417
  if ( ! empty( $post_type['rewrite_slug'] ) || ! empty( $post_type['rewrite_withfront'] ) ) {
418
+ $rewrite_start = '[';
419
+ $rewrite_end = ']';
420
 
421
  $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_end;
422
  }
436
  $supports = '';
437
  // Do a little bit of php work to get these into strings.
438
  if ( ! empty( $post_type['supports'] ) && is_array( $post_type['supports'] ) ) {
439
+ $supports = '[ "' . implode( '", "', $post_type['supports'] ) . '" ]';
440
  }
441
 
442
+ if ( in_array( 'none', $post_type['supports'], true ) ) {
443
  $supports = 'false';
444
  }
445
 
446
  $taxonomies = '';
447
  if ( ! empty( $post_type['taxonomies'] ) && is_array( $post_type['taxonomies'] ) ) {
448
+ $taxonomies = '[ "' . implode( '", "', $post_type['taxonomies'] ) . '" ]';
449
  }
450
 
451
+ if ( in_array( $post_type['query_var'], [ 'true', 'false', '0', '1' ], true ) ) {
452
  $post_type['query_var'] = disp_boolean( $post_type['query_var'] );
453
  }
454
  if ( ! empty( $post_type['query_var_slug'] ) ) {
458
  if ( empty( $post_type['show_in_rest'] ) ) {
459
  $post_type['show_in_rest'] = 'false';
460
  }
461
+ $rest_controller_class = ! empty( $post_type['rest_controller_class'] ) ? $post_type['rest_controller_class'] : 'WP_REST_Posts_Controller';
462
 
463
  $delete_with_user = ( ! empty( $post_type['delete_with_user'] ) && false !== get_disp_boolean( $post_type['delete_with_user'] ) ) ? 'true' : 'false';
464
 
472
  $show_in_menu = disp_boolean( $post_type['show_in_menu'] );
473
  }
474
 
475
+ $delete_with_user = 'false';
476
+ if ( isset( $post_type['delete_with_user'] ) ) {
477
+ $delete_with_user = disp_boolean( $post_type['delete_with_user'] );
478
+ }
479
+
480
+ $public = isset( $post_type['public'] ) ? disp_boolean( $post_type['public'] ) : 'true';
481
  $show_in_nav_menus = ( ! empty( $post_type['show_in_nav_menus'] ) && false !== get_disp_boolean( $post_type['show_in_nav_menus'] ) ) ? 'true' : 'false';
482
  if ( empty( $post_type['show_in_nav_menus'] ) ) {
483
  $show_in_nav_menus = $public;
491
  if ( count( $caps ) > 2 ) {
492
  $caps = array_slice( $caps, 0, 2 );
493
  }
494
+ $capability_type = '[ "' . $caps[0] . '", "' . $caps[1] . '" ]';
495
  }
496
  }
497
 
498
  $post_type['description'] = addslashes( $post_type['description'] );
499
 
500
+ $my_theme = wp_get_theme();
501
  $textdomain = $my_theme->get( 'TextDomain' );
502
  if ( empty( $textdomain ) ) {
503
  $textdomain = 'custom-post-type-ui';
508
  * Post Type: <?php echo $post_type['label']; ?>.
509
  */
510
 
511
+ $labels = [
512
  "name" => __( "<?php echo $post_type['label']; ?>", "<?php echo $textdomain; ?>" ),
513
  "singular_name" => __( "<?php echo $post_type['singular_label']; ?>", "<?php echo $textdomain; ?>" ),
514
  <?php
515
  foreach ( $post_type['labels'] as $key => $label ) {
516
  if ( ! empty( $label ) ) {
517
+ if ( 'parent' === $key && ! array_key_exists( 'parent_item_colon', $post_type['labels'] ) ) {
518
  // Fix for incorrect label key. See #439.
519
  echo "\t\t" . '"' . 'parent_item_colon' . '" => __( "' . $label . '", "' . $textdomain . '" ),' . "\n";
520
  } else {
523
  }
524
  }
525
  ?>
526
+ ];
527
 
528
+ $args = [
529
  "label" => __( "<?php echo $post_type['label']; ?>", "<?php echo $textdomain; ?>" ),
530
  "labels" => $labels,
531
  "description" => "<?php echo $post_type['description']; ?>",
539
  "has_archive" => <?php echo $has_archive; ?>,
540
  "show_in_menu" => <?php echo $show_in_menu; ?>,
541
  "show_in_nav_menus" => <?php echo $show_in_nav_menus; ?>,
542
+ "delete_with_user" => <?php echo $delete_with_user; ?>,
543
  "exclude_from_search" => <?php echo disp_boolean( $post_type['exclude_from_search'] ); ?>,
544
  "capability_type" => <?php echo $capability_type; ?>,
545
  "map_meta_cap" => <?php echo disp_boolean( $post_type['map_meta_cap'] ); ?>,
561
  <?php if ( true === $yarpp ) { ?>
562
  "yarpp_support" => <?php echo disp_boolean( $yarpp ); ?>,
563
  <?php } ?>
564
+ ];
565
 
566
  register_post_type( "<?php echo $post_type['name']; ?>", $args );
567
  <?php
577
  * @param array $postdata $_POST data as json. Optional.
578
  * @return mixed false on nothing to do, otherwise void.
579
  */
580
+ function cptui_import_types_taxes_settings( $postdata = [] ) {
581
  if ( ! isset( $postdata['cptui_post_import'] ) && ! isset( $postdata['cptui_tax_import'] ) ) {
582
  return false;
583
  }
584
 
585
+ $status = 'import_fail';
586
  $success = false;
587
 
588
  /**
621
 
622
  // Add support to delete settings outright, without accessing database.
623
  // Doing double check to protect.
624
+ if ( null === $settings && '{""}' === $cpt_data ) {
625
 
626
  /**
627
  * Filters whether or not 3rd party options were deleted successfully within post type import.
668
 
669
  // Add support to delete settings outright, without accessing database.
670
  // Doing double check to protect.
671
+ if ( null === $settings && '{""}' === $tax_data ) {
672
 
673
  /**
674
  * Filters whether or not 3rd party options were deleted successfully within taxonomy import.
772
  </p>
773
  </td>
774
  </tr>
775
+ <?php } elseif ( ! empty( $_GET ) && 'taxonomies' === $_GET['action'] ) { ?>
776
  <tr>
777
  <td class="outer">
778
  <h2><label for="cptui_tax_import"><?php esc_html_e( 'Import Taxonomies', 'custom-post-type-ui' ); ?></label></h2>
831
  <p><?php esc_html_e( 'All of the selectable code snippets below are useful if you wish to migrate away from Custom Post Type UI and retain your existing registered post types or taxonomies.', 'custom-post-type-ui' ); ?></p>
832
 
833
  <?php $cptui_post_types = cptui_get_post_type_data(); ?>
834
+ <p><label for="cptui_post_type_get_code"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label></p>
835
+ <textarea name="cptui_post_type_get_code" id="cptui_post_type_get_code" class="large-text cptui_post_type_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_post_type_code( $cptui_post_types ); ?></textarea>
836
 
837
  <?php
838
  if ( ! empty( $cptui_post_types ) ) {
839
+ foreach ( $cptui_post_types as $post_type ) {
840
+ ?>
841
+ <h2 id="<?php echo esc_attr( $post_type['name'] ); ?>">
842
+ <?php
843
+ $type = ! empty( $post_type['label'] ) ? $post_type['label'] : $post_type['name'];
844
  printf( esc_html__( '%s Post Type', 'custom-post-type-ui' ), esc_html( $type ) ); ?></h2>
845
+ <p><label for="cptui_post_type_get_code_<?php echo esc_attr( $post_type['name'] ); ?>"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label></p>
846
+ <textarea name="cptui_post_type_get_code_<?php echo esc_attr( $post_type['name'] ); ?>" id="cptui_post_type_get_code_<?php echo esc_attr( $post_type['name'] ); ?>" class="large-text cptui_post_type_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_post_type_code( [ $post_type ], true ); ?></textarea>
847
+ <?php
848
+ }
849
+ }
850
+ ?>
851
 
852
  <h2><?php esc_html_e( 'All Custom Post Type UI Taxonomies', 'custom-post-type-ui' ); ?></h2>
853
 
854
  <?php $cptui_taxonomies = cptui_get_taxonomy_data(); ?>
855
+ <p><label for="cptui_tax_get_code"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label></p>
856
+ <textarea name="cptui_tax_get_code" id="cptui_tax_get_code" class="large-text cptui_tax_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_taxonomy_code( $cptui_taxonomies ); ?></textarea>
857
 
858
  <?php
859
  if ( ! empty( $cptui_taxonomies ) ) {
860
+ foreach ( $cptui_taxonomies as $taxonomy ) {
861
+ ?>
862
+ <h2 id="<?php echo esc_attr( $taxonomy['name'] ); ?>">
863
+ <?php
864
+ $tax = ! empty( $taxonomy['label'] ) ? $taxonomy['label'] : $taxonomy['name'];
865
+ printf( esc_html__( '%s Taxonomy', 'custom-post-type-ui' ), esc_html( $tax ) );
866
+ ?>
867
+ </h2>
868
+ <p><label for="cptui_tax_get_code_<?php echo esc_attr( $taxonomy['name'] ); ?>"><?php esc_html_e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label></p>
869
+ <textarea name="cptui_tax_get_code_<?php echo esc_attr( $taxonomy['name'] ); ?>" id="cptui_tax_get_code_<?php echo esc_attr( $taxonomy['name'] ); ?>" class="large-text cptui_tax_get_code" onclick="this.focus();this.select()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true"><?php cptui_get_taxonomy_code( [ $taxonomy ], true ); ?></textarea>
870
+ <?php
871
+ }
872
+ }
873
+ ?>
874
  <?php
875
  }
876
 
893
  if ( ! empty( $_POST ) && isset( $_POST['cptui_debug_info_email'] ) && isset( $_POST['cptui_debuginfo_nonce_field'] ) ) {
894
  wp_verify_nonce( 'cptui_debuginfo_nonce_field', 'cptui_debuginfo_nonce_action' );
895
 
896
+ $email_args = [];
897
  $email_args['email'] = sanitize_text_field( $_POST['cptui_debug_info_email'] );
898
  $debuginfo->send_email( $email_args );
899
  }
929
  */
930
  function cptui_render_tools( $tab ) {
931
  if ( isset( $tab ) ) {
932
+ if ( 'post_types' === $tab || 'taxonomies' === $tab ) {
933
  cptui_render_posttypes_taxonomies_section();
934
  }
935
 
936
+ if ( 'get_code' === $tab ) {
937
  cptui_render_getcode_section();
938
  }
939
 
940
+ if ( 'debuginfo' === $tab ) {
941
  cptui_render_debuginfo_section();
942
  }
943
  }
inc/utility.php CHANGED
@@ -9,6 +9,8 @@
9
  * @license GPL-2.0+
10
  */
11
 
 
 
12
  // Exit if accessed directly.
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
@@ -32,12 +34,12 @@ function cptui_edit_plugin_list_links( $links ) {
32
  }
33
 
34
  // Add our custom links to the returned array value.
35
- return array_merge( array(
36
  '<a href="' . admin_url( 'admin.php?page=cptui_main_menu' ) . '">' . __( 'About', 'custom-post-type-ui' ) . '</a>',
37
  '<a href="' . admin_url( 'admin.php?page=cptui_support' ) . '">' . __( 'Help', 'custom-post-type-ui' ) . '</a>',
38
- ), $links );
39
  }
40
- add_filter( 'plugin_action_links_' . plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/custom-post-type-ui.php', 'cptui_edit_plugin_list_links' );
41
 
42
  /**
43
  * Returns SVG icon for custom menu icon
@@ -187,7 +189,7 @@ function cptui_get_post_type_slugs() {
187
  if ( ! empty( $post_types ) ) {
188
  return array_keys( $post_types );
189
  }
190
- return array();
191
  }
192
 
193
  /**
@@ -202,7 +204,7 @@ function cptui_get_taxonomy_slugs() {
202
  if ( ! empty( $taxonomies ) ) {
203
  return array_keys( $taxonomies );
204
  }
205
- return array();
206
  }
207
 
208
  /**
@@ -257,7 +259,7 @@ function cptui_post_form_action( $ui ) {
257
  * @return mixed
258
  */
259
  function cptui_get_post_type_data() {
260
- return apply_filters( 'cptui_get_post_type_data', get_option( 'cptui_post_types', array() ), get_current_blog_id() );
261
  }
262
 
263
  /**
@@ -268,7 +270,7 @@ function cptui_get_post_type_data() {
268
  * @return mixed
269
  */
270
  function cptui_get_taxonomy_data() {
271
- return apply_filters( 'cptui_get_taxonomy_data', get_option( 'cptui_taxonomies', array() ), get_current_blog_id() );
272
  }
273
 
274
  /**
@@ -280,7 +282,7 @@ function cptui_get_taxonomy_data() {
280
  * @param array|string $data Post type data being utilized. Optional.
281
  * @return mixed
282
  */
283
- function cptui_get_post_type_exists( $slug = '', $data = array() ) {
284
 
285
  /**
286
  * Filters the boolean value for if a post type exists for 3rd parties.
@@ -303,7 +305,7 @@ function cptui_get_post_type_exists( $slug = '', $data = array() ) {
303
  *
304
  * @return mixed
305
  */
306
- function cptui_get_taxonomy_exists( $slug = '', $data = array() ) {
307
 
308
  /**
309
  * Filters the boolean value for if a taxonomy exists for 3rd parties.
@@ -392,6 +394,11 @@ function cptui_newsletter_form() {
392
  <?php
393
  }
394
 
 
 
 
 
 
395
  function cptui_mailchimp_scripts_styles() {
396
  $current_screen = get_current_screen();
397
 
@@ -399,11 +406,11 @@ function cptui_mailchimp_scripts_styles() {
399
  return;
400
  }
401
 
402
- $screens = array(
403
  'toplevel_page_cptui_main_menu',
404
  'cpt-ui_page_cptui_manage_post_types',
405
  'cpt-ui_page_cptui_manage_taxonomies',
406
- );
407
 
408
  if ( ! in_array( $current_screen->base, $screens, true ) ) {
409
  return;
@@ -414,7 +421,7 @@ function cptui_mailchimp_scripts_styles() {
414
  }
415
 
416
  wp_enqueue_style( 'cptui-mailchimp', '//cdn-images.mailchimp.com/embedcode/classic-10_7.css' );
417
- wp_enqueue_script( 'cptui-mailchimp-js', '//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js', array(), '', true );
418
  wp_add_inline_script( 'cptui-mailchimp-js', '(function ($) {window.fnames = new Array();window.ftypes = new Array();fnames[0] = "EMAIL";ftypes[0] = "email";}(jQuery));var $mcj = jQuery.noConflict(true);' );
419
 
420
  }
@@ -440,8 +447,7 @@ function cptui_get_ads() {
440
  *
441
  * @param array $value Array of ads to iterate over. Default empty.
442
  */
443
- $ads = (array) apply_filters( 'cptui_ads', array() );
444
- return $ads;
445
  }
446
 
447
  /**
@@ -454,30 +460,30 @@ function cptui_get_ads() {
454
  * @param array $ads Array of ads set so far. Optional.
455
  * @return array $ads Array of newly constructed ads.
456
  */
457
- function cptui_default_ads( $ads = array() ) {
458
- $ads[] = array(
459
  'url' => 'https://pluginize.com/plugins/custom-post-type-ui-extended/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=cptui',
460
- 'image' => plugin_dir_url( dirname( __FILE__ ) ) . 'images/wds_ads/cptui-extended.png',
461
  'text' => 'Custom Post Type UI Extended product ad',
462
- );
463
 
464
- $ads[] = array(
465
  'url' => 'https://pluginize.com/plugins/instago/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=instago',
466
- 'image' => plugin_dir_url( dirname( __FILE__ ) ) . 'images/wds_ads/instago.png',
467
  'text' => 'InstaGo product ad',
468
- );
469
 
470
- $ads[] = array(
471
  'url' => 'https://pluginize.com/plugins/buddypages/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=buddypages',
472
- 'image' => plugin_dir_url( dirname( __FILE__ ) ) . 'images/wds_ads/buddypages.png',
473
  'text' => 'BuddyPages product ad',
474
- );
475
 
476
- $ads[] = array(
477
  'url' => 'https://maintainn.com/?utm_source=Pluginize-v2&utm_medium=Plugin-Sidebar&utm_campaign=CPTUI',
478
- 'image' => plugin_dir_url( dirname( __FILE__ ) ) . 'images/wds_ads/maintainn.png',
479
  'text' => 'Maintainn product ad',
480
- );
481
 
482
  return $ads;
483
  }
@@ -492,8 +498,8 @@ add_filter( 'cptui_ads', 'cptui_default_ads' );
492
  * @param array $ads Array of ads to show.
493
  * @return array
494
  */
495
- function cptui_randomize_ads( $ads = array() ) {
496
- $new_order = array();
497
  foreach ( $ads as $key => $ad ) {
498
  if ( false !== strpos( $ad['url'], 'custom-post-type-ui-extended' ) ) {
499
  $new_order[] = $ad;
@@ -519,9 +525,9 @@ add_filter( 'cptui_ads', 'cptui_randomize_ads', 11 );
519
  */
520
  function cptui_admin_notices_helper( $message = '', $success = true ) {
521
 
522
- $class = array();
523
- $class[] = ( $success ) ? 'updated' : 'error';
524
- $class[] = 'notice is-dismissible';
525
 
526
  $messagewrapstart = '<div id="message" class="' . implode( ' ', $class ) . '"><p>';
527
 
@@ -574,8 +580,7 @@ function cptui_add_success_admin_notice() {
574
  sprintf(
575
  esc_html__( '%s has been successfully added', 'custom-post-type-ui' ),
576
  cptui_get_object_from_post_global()
577
- ),
578
- true
579
  );
580
  }
581
 
@@ -604,8 +609,7 @@ function cptui_update_success_admin_notice() {
604
  sprintf(
605
  esc_html__( '%s has been successfully updated', 'custom-post-type-ui' ),
606
  cptui_get_object_from_post_global()
607
- ),
608
- true
609
  );
610
  }
611
 
@@ -634,8 +638,7 @@ function cptui_delete_success_admin_notice() {
634
  sprintf(
635
  esc_html__( '%s has been successfully deleted', 'custom-post-type-ui' ),
636
  cptui_get_object_from_post_global()
637
- ),
638
- true
639
  );
640
  }
641
 
@@ -766,7 +769,7 @@ function cptui_error_admin_notice() {
766
  */
767
  function cptui_not_new_install( $wp_upgrader, $extras ) {
768
 
769
- if ( ! is_a( $wp_upgrader, 'Plugin_Upgrader' ) ) {
770
  return;
771
  }
772
 
@@ -798,7 +801,7 @@ add_action( 'upgrader_process_complete', 'cptui_not_new_install', 10, 2 );
798
  */
799
  function cptui_is_new_install() {
800
  $new_or_not = true;
801
- $saved = get_option( 'cptui_new_install', '' );
802
 
803
  if ( 'false' === $saved ) {
804
  $new_or_not = false;
@@ -813,7 +816,7 @@ function cptui_is_new_install() {
813
  *
814
  * @param bool $new_or_not Whether or not site is a new install.
815
  */
816
- return (bool) apply_filters( 'cptui_is_new_install', $new_or_not );
817
  }
818
 
819
  /**
@@ -902,3 +905,19 @@ function cptui_published_post_format_fix( $post_types ) {
902
  }
903
  }
904
  add_action( 'cptui_post_register_post_types', 'cptui_published_post_format_fix' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * @license GPL-2.0+
10
  */
11
 
12
+ // phpcs:disable WebDevStudios.All.RequireAuthor
13
+
14
  // Exit if accessed directly.
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
34
  }
35
 
36
  // Add our custom links to the returned array value.
37
+ return array_merge( [
38
  '<a href="' . admin_url( 'admin.php?page=cptui_main_menu' ) . '">' . __( 'About', 'custom-post-type-ui' ) . '</a>',
39
  '<a href="' . admin_url( 'admin.php?page=cptui_support' ) . '">' . __( 'Help', 'custom-post-type-ui' ) . '</a>',
40
+ ], $links );
41
  }
42
+ add_filter( 'plugin_action_links_' . plugin_basename( dirname( __DIR__ ) ) . '/custom-post-type-ui.php', 'cptui_edit_plugin_list_links' );
43
 
44
  /**
45
  * Returns SVG icon for custom menu icon
189
  if ( ! empty( $post_types ) ) {
190
  return array_keys( $post_types );
191
  }
192
+ return [];
193
  }
194
 
195
  /**
204
  if ( ! empty( $taxonomies ) ) {
205
  return array_keys( $taxonomies );
206
  }
207
+ return [];
208
  }
209
 
210
  /**
259
  * @return mixed
260
  */
261
  function cptui_get_post_type_data() {
262
+ return apply_filters( 'cptui_get_post_type_data', get_option( 'cptui_post_types', [] ), get_current_blog_id() );
263
  }
264
 
265
  /**
270
  * @return mixed
271
  */
272
  function cptui_get_taxonomy_data() {
273
+ return apply_filters( 'cptui_get_taxonomy_data', get_option( 'cptui_taxonomies', [] ), get_current_blog_id() );
274
  }
275
 
276
  /**
282
  * @param array|string $data Post type data being utilized. Optional.
283
  * @return mixed
284
  */
285
+ function cptui_get_post_type_exists( $slug = '', $data = [] ) {
286
 
287
  /**
288
  * Filters the boolean value for if a post type exists for 3rd parties.
305
  *
306
  * @return mixed
307
  */
308
+ function cptui_get_taxonomy_exists( $slug = '', $data = [] ) {
309
 
310
  /**
311
  * Filters the boolean value for if a taxonomy exists for 3rd parties.
394
  <?php
395
  }
396
 
397
+ /**
398
+ * Add our mailchimp scripts and stylesheet.
399
+ *
400
+ * @since unsure
401
+ */
402
  function cptui_mailchimp_scripts_styles() {
403
  $current_screen = get_current_screen();
404
 
406
  return;
407
  }
408
 
409
+ $screens = [
410
  'toplevel_page_cptui_main_menu',
411
  'cpt-ui_page_cptui_manage_post_types',
412
  'cpt-ui_page_cptui_manage_taxonomies',
413
+ ];
414
 
415
  if ( ! in_array( $current_screen->base, $screens, true ) ) {
416
  return;
421
  }
422
 
423
  wp_enqueue_style( 'cptui-mailchimp', '//cdn-images.mailchimp.com/embedcode/classic-10_7.css' );
424
+ wp_enqueue_script( 'cptui-mailchimp-js', '//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js', [], '', true );
425
  wp_add_inline_script( 'cptui-mailchimp-js', '(function ($) {window.fnames = new Array();window.ftypes = new Array();fnames[0] = "EMAIL";ftypes[0] = "email";}(jQuery));var $mcj = jQuery.noConflict(true);' );
426
 
427
  }
447
  *
448
  * @param array $value Array of ads to iterate over. Default empty.
449
  */
450
+ return (array) apply_filters( 'cptui_ads', [] );
 
451
  }
452
 
453
  /**
460
  * @param array $ads Array of ads set so far. Optional.
461
  * @return array $ads Array of newly constructed ads.
462
  */
463
+ function cptui_default_ads( $ads = [] ) {
464
+ $ads[] = [
465
  'url' => 'https://pluginize.com/plugins/custom-post-type-ui-extended/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=cptui',
466
+ 'image' => plugin_dir_url( __DIR__ ) . 'images/wds_ads/cptui-extended.png',
467
  'text' => 'Custom Post Type UI Extended product ad',
468
+ ];
469
 
470
+ $ads[] = [
471
  'url' => 'https://pluginize.com/plugins/instago/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=instago',
472
+ 'image' => plugin_dir_url( __DIR__ ) . 'images/wds_ads/instago.png',
473
  'text' => 'InstaGo product ad',
474
+ ];
475
 
476
+ $ads[] = [
477
  'url' => 'https://pluginize.com/plugins/buddypages/?utm_source=cptui-sidebar&utm_medium=text&utm_campaign=buddypages',
478
+ 'image' => plugin_dir_url( __DIR__ ) . 'images/wds_ads/buddypages.png',
479
  'text' => 'BuddyPages product ad',
480
+ ];
481
 
482
+ $ads[] = [
483
  'url' => 'https://maintainn.com/?utm_source=Pluginize-v2&utm_medium=Plugin-Sidebar&utm_campaign=CPTUI',
484
+ 'image' => plugin_dir_url( __DIR__ ) . 'images/wds_ads/maintainn.png',
485
  'text' => 'Maintainn product ad',
486
+ ];
487
 
488
  return $ads;
489
  }
498
  * @param array $ads Array of ads to show.
499
  * @return array
500
  */
501
+ function cptui_randomize_ads( $ads = [] ) {
502
+ $new_order = [];
503
  foreach ( $ads as $key => $ad ) {
504
  if ( false !== strpos( $ad['url'], 'custom-post-type-ui-extended' ) ) {
505
  $new_order[] = $ad;
525
  */
526
  function cptui_admin_notices_helper( $message = '', $success = true ) {
527
 
528
+ $class = [];
529
+ $class[] = $success ? 'updated' : 'error';
530
+ $class[] = 'notice is-dismissible';
531
 
532
  $messagewrapstart = '<div id="message" class="' . implode( ' ', $class ) . '"><p>';
533
 
580
  sprintf(
581
  esc_html__( '%s has been successfully added', 'custom-post-type-ui' ),
582
  cptui_get_object_from_post_global()
583
+ )
 
584
  );
585
  }
586
 
609
  sprintf(
610
  esc_html__( '%s has been successfully updated', 'custom-post-type-ui' ),
611
  cptui_get_object_from_post_global()
612
+ )
 
613
  );
614
  }
615
 
638
  sprintf(
639
  esc_html__( '%s has been successfully deleted', 'custom-post-type-ui' ),
640
  cptui_get_object_from_post_global()
641
+ )
 
642
  );
643
  }
644
 
769
  */
770
  function cptui_not_new_install( $wp_upgrader, $extras ) {
771
 
772
+ if ( $wp_upgrader instanceof \Plugin_Upgrader ) {
773
  return;
774
  }
775
 
801
  */
802
  function cptui_is_new_install() {
803
  $new_or_not = true;
804
+ $saved = get_option( 'cptui_new_install', '' );
805
 
806
  if ( 'false' === $saved ) {
807
  $new_or_not = false;
816
  *
817
  * @param bool $new_or_not Whether or not site is a new install.
818
  */
819
+ return (bool) apply_filters( 'cptui_is_new_install', $new_or_not );
820
  }
821
 
822
  /**
905
  }
906
  }
907
  add_action( 'cptui_post_register_post_types', 'cptui_published_post_format_fix' );
908
+
909
+ /**
910
+ * Return a ready-to-use admin url for adding a new content type.
911
+ *
912
+ * @since 1.7.0
913
+ *
914
+ * @param string $content_type Content type to link to.
915
+ * @return string
916
+ */
917
+ function cptui_get_add_new_link( $content_type = '' ) {
918
+ if ( ! in_array( $content_type, [ 'post_types', 'taxonomies' ] ) ) {
919
+ return cptui_admin_url( 'admin.php?page=cptui_manage_post_types' );
920
+ }
921
+
922
+ return cptui_admin_url( 'admin.php?page=cptui_manage_' . $content_type );
923
+ }
inc/wp-cli.php CHANGED
@@ -1,5 +1,17 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  /**
4
  * Imports and exports Custom Post Type UI setting data.
5
  */
@@ -11,7 +23,7 @@ class CPTUI_Import_JSON extends WP_CLI_Command {
11
 
12
  public $type;
13
 
14
- public $data = array();
15
 
16
  /**
17
  * Imports and parses JSON into CPTUI settings.
1
  <?php
2
 
3
+ /**
4
+ * Custom Post Type UI WP-CLI.
5
+ *
6
+ * @package CPTUI
7
+ * @subpackage WP-CLI
8
+ * @author WebDevStudios
9
+ * @since 1.6.0
10
+ * @license GPL-2.0+
11
+ */
12
+
13
+ // phpcs:disable WebDevStudios.All.RequireAuthor
14
+
15
  /**
16
  * Imports and exports Custom Post Type UI setting data.
17
  */
23
 
24
  public $type;
25
 
26
+ public $data = [];
27
 
28
  /**
29
  * Imports and parses JSON into CPTUI settings.
js/cptui.js CHANGED
@@ -26,11 +26,22 @@ postboxes.add_postbox_toggles(pagenow);
26
  });
27
 
28
  // Confirm our deletions
29
- $('#cpt_submit_delete').on('click',function() {
30
- if ( confirm( cptui_type_data.confirm ) ) {
31
- return true;
32
- }
33
- return false;
 
 
 
 
 
 
 
 
 
 
 
34
  });
35
 
36
  // Toggles help/support accordions.
@@ -186,7 +197,52 @@ postboxes.add_postbox_toggles(pagenow);
186
  $('.cptui-taxonomy-submit').on('click',function(e){
187
  if ( $('.cptui-table :checkbox:checked').length == 0 ) {
188
  e.preventDefault();
189
- alert( cptui_tax_data.no_associated_type );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  });
 
192
  })(jQuery);
26
  });
27
 
28
  // Confirm our deletions
29
+ $('#cpt_submit_delete').on('click',function(e) {
30
+ e.preventDefault();
31
+ var submit_delete_warning = $('<div class="cptui-submit-delete-dialog">' + cptui_type_data.confirm + '</div>').appendTo('#poststuff').dialog({
32
+ 'dialogClass' : 'wp-dialog',
33
+ 'modal' : true,
34
+ 'autoOpen' : true,
35
+ 'buttons' : {
36
+ "OK": function() {
37
+ var form = $(e.target).closest('form');
38
+ $(e.target).unbind('click').click();
39
+ },
40
+ "Cancel": function() {
41
+ $(this).dialog('close');
42
+ }
43
+ }
44
+ });
45
  });
46
 
47
  // Toggles help/support accordions.
197
  $('.cptui-taxonomy-submit').on('click',function(e){
198
  if ( $('.cptui-table :checkbox:checked').length == 0 ) {
199
  e.preventDefault();
200
+ var no_associated_type_warning = $('<div class="cptui-taxonomy-empty-types-dialog">' + cptui_tax_data.no_associated_type + '</div>').appendTo('#poststuff').dialog({
201
+ 'dialogClass' : 'wp-dialog',
202
+ 'modal' : true,
203
+ 'autoOpen' : true,
204
+ 'buttons' : {
205
+ "OK": function() {
206
+ $(this).dialog('close');
207
+ }
208
+ }
209
+ });
210
+ }
211
+ });
212
+
213
+ $('#auto-populate').on( 'click tap', function(e){
214
+ e.preventDefault();
215
+
216
+ var slug = $('#name').val();
217
+ var plural = $('#label').val();
218
+ var singular = $('#singular_label').val();
219
+ var fields = $('.cptui-labels input[type="text"]');
220
+
221
+ if ( '' === slug ) {
222
+ return;
223
+ }
224
+ if ( '' === plural ) {
225
+ plural = slug;
226
  }
227
+ if ( '' === singular ) {
228
+ singular = slug;
229
+ }
230
+
231
+ $(fields).each( function( i, el ) {
232
+ var newval = $( el ).data( 'label' );
233
+ var plurality = $( el ).data( 'plurality' );
234
+ if ( undefined !== newval ) {
235
+ // "slug" is our placeholder from the labels.
236
+ if ( 'plural' === plurality ) {
237
+ newval = newval.replace(/item/gi, plural);
238
+ } else {
239
+ newval = newval.replace(/item/gi, singular);
240
+ }
241
+ if ( $( el ).val() === '' ) {
242
+ $(el).val(newval);
243
+ }
244
+ }
245
+ } );
246
  });
247
+
248
  })(jQuery);
js/cptui.min.js CHANGED
@@ -1 +1 @@
1
- postboxes.add_postbox_toggles(pagenow),function($){if($("#cptui_select_post_type_submit").hide(),$("#cptui_select_taxonomy_submit").hide(),"edit"===function(name,url){url||(url=window.location.href),name=name.replace(/[\[\]]/g,"\\$&");var results=new RegExp("[?&]"+name+"(=([^&#]*)|&|#|$)").exec(url);return results?results[2]?decodeURIComponent(results[2].replace(/\+/g," ")):"":null}("action"))var original_slug=$("#name").val();$("#post_type").on("change",function(){$("#cptui_select_post_type").submit()}),$("#taxonomy").on("change",function(){$("#cptui_select_taxonomy").submit()}),$("#cpt_submit_delete").on("click",function(){return!!confirm(cptui_type_data.confirm)}),$("#support .question").each(function(){var tis=$(this),state=!1,answer=tis.next("div").slideUp();tis.on("click keydown",function(e){"keydown"===e.type&&32!==e.keyCode&&13!==e.keyCode||(e.preventDefault(),state=!state,answer.slideToggle(state),tis.toggleClass("active",state),tis.attr("aria-expanded",state.toString()),tis.focus())})}),$("#name").on("keyup",function(e){var value,original_value;if(value=original_value=$(this).val(),9!==e.keyCode&&37!==e.keyCode&&38!==e.keyCode&&39!==e.keyCode&&40!==e.keyCode&&(value=function(s){return s=s.replace(/[^a-z0-9\s]/gi,"_")}(value=function(word){return word.split("").map(function(char){return cyrillic[char]||char}).join("")}(value=function(s){for(var diacritics=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g],chars=["A","a","E","e","I","i","O","o","U","u","N","n","C","c"],i=0;i<diacritics.length;i++)s=s.replace(diacritics[i],chars[i]);return s}(value=(value=value.replace(/ /g,"_")).toLowerCase()))))!==original_value&&$(this).attr("value",value),void 0!=original_slug){var $slugchanged=$("#slugchanged");value!=original_slug?$slugchanged.removeClass("hidemessage"):$slugchanged.addClass("hidemessage")}var $slugexists=$("#slugexists");"undefined"!=typeof cptui_type_data&&(cptui_type_data.existing_post_types.hasOwnProperty(value)&&value!==original_slug?$slugexists.removeClass("hidemessage"):$slugexists.addClass("hidemessage")),"undefined"!=typeof cptui_tax_data&&(cptui_tax_data.existing_taxonomies.hasOwnProperty(value)&&value!==original_slug?$slugexists.removeClass("hidemessage"):$slugexists.addClass("hidemessage"))});var cyrillic={"Ё":"YO","Й":"I","Ц":"TS","У":"U","К":"K","Е":"E","Н":"N","Г":"G","Ш":"SH","Щ":"SCH","З":"Z","Х":"H","Ъ":"'","ё":"yo","й":"i","ц":"ts","у":"u","к":"k","е":"e","н":"n","г":"g","ш":"sh","щ":"sch","з":"z","х":"h","ъ":"'","Ф":"F","Ы":"I","В":"V","А":"a","П":"P","Р":"R","О":"O","Л":"L","Д":"D","Ж":"ZH","Э":"E","ф":"f","ы":"i","в":"v","а":"a","п":"p","р":"r","о":"o","л":"l","д":"d","ж":"zh","э":"e","Я":"Ya","Ч":"CH","С":"S","М":"M","И":"I","Т":"T","Ь":"'","Б":"B","Ю":"YU","я":"ya","ч":"ch","с":"s","м":"m","и":"i","т":"t","ь":"'","б":"b","ю":"yu"};if(void 0!=wp.media)var _custom_media=!0,_orig_send_attachment=wp.media.editor.send.attachment;$("#cptui_choose_icon").on("click",function(e){e.preventDefault();var button=$(this),id=jQuery("#menu_icon").attr("id");return _custom_media=!0,wp.media.editor.send.attachment=function(props,attachment){if(!_custom_media)return _orig_send_attachment.apply(this,[props,attachment]);$("#"+id).val(attachment.url)},wp.media.editor.open(button),!1}),$("#togglelabels").on("click",function(e){e.preventDefault(),$("#labels_expand").toggleClass("toggledclosed")}),$("#togglesettings").on("click",function(e){e.preventDefault(),$("#settings_expand").toggleClass("toggledclosed")}),$("#labels_expand,#settings_expand").on("focus",function(e){$(this).hasClass("toggledclosed")&&$(this).toggleClass("toggledclosed")}),$("#labels_expand legend,#settings_expand legend").on("click",function(e){$(this).parent().toggleClass("toggledclosed")}),$(".cptui-help").on("click",function(e){e.preventDefault()}),$(".cptui-taxonomy-submit").on("click",function(e){0==$(".cptui-table :checkbox:checked").length&&(e.preventDefault(),alert(cptui_tax_data.no_associated_type))})}(jQuery);
1
+ postboxes.add_postbox_toggles(pagenow),function($){if($("#cptui_select_post_type_submit").hide(),$("#cptui_select_taxonomy_submit").hide(),"edit"===function(name,url){url=url||window.location.href;name=name.replace(/[\[\]]/g,"\\$&");var results=new RegExp("[?&]"+name+"(=([^&#]*)|&|#|$)").exec(url);return results?results[2]?decodeURIComponent(results[2].replace(/\+/g," ")):"":null}("action"))var original_slug=$("#name").val();$("#post_type").on("change",function(){$("#cptui_select_post_type").submit()}),$("#taxonomy").on("change",function(){$("#cptui_select_taxonomy").submit()}),$("#cpt_submit_delete").on("click",function(e){e.preventDefault();$('<div class="cptui-submit-delete-dialog">'+cptui_type_data.confirm+"</div>").appendTo("#poststuff").dialog({dialogClass:"wp-dialog",modal:!0,autoOpen:!0,buttons:{OK:function(){$(e.target).closest("form");$(e.target).unbind("click").click()},Cancel:function(){$(this).dialog("close")}}})}),$("#support .question").each(function(){var tis=$(this),state=!1,answer=tis.next("div").slideUp();tis.on("click keydown",function(e){"keydown"===e.type&&32!==e.keyCode&&13!==e.keyCode||(e.preventDefault(),state=!state,answer.slideToggle(state),tis.toggleClass("active",state),tis.attr("aria-expanded",state.toString()),tis.focus())})}),$("#name").on("keyup",function(e){var value,original_value;if(value=original_value=$(this).val(),9!==e.keyCode&&37!==e.keyCode&&38!==e.keyCode&&39!==e.keyCode&&40!==e.keyCode&&(value=function(s){return s=s.replace(/[^a-z0-9\s]/gi,"_")}(value=function(word){return word.split("").map(function(char){return cyrillic[char]||char}).join("")}(value=function(s){for(var diacritics=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g],chars=["A","a","E","e","I","i","O","o","U","u","N","n","C","c"],i=0;i<diacritics.length;i++)s=s.replace(diacritics[i],chars[i]);return s}(value=(value=value.replace(/ /g,"_")).toLowerCase()))))!==original_value&&$(this).attr("value",value),null!=original_slug){var $slugchanged=$("#slugchanged");value!=original_slug?$slugchanged.removeClass("hidemessage"):$slugchanged.addClass("hidemessage")}var $slugexists=$("#slugexists");"undefined"!=typeof cptui_type_data&&(cptui_type_data.existing_post_types.hasOwnProperty(value)&&value!==original_slug?$slugexists.removeClass("hidemessage"):$slugexists.addClass("hidemessage")),"undefined"!=typeof cptui_tax_data&&(cptui_tax_data.existing_taxonomies.hasOwnProperty(value)&&value!==original_slug?$slugexists.removeClass("hidemessage"):$slugexists.addClass("hidemessage"))});var cyrillic={"Ё":"YO","Й":"I","Ц":"TS","У":"U","К":"K","Е":"E","Н":"N","Г":"G","Ш":"SH","Щ":"SCH","З":"Z","Х":"H","Ъ":"'","ё":"yo","й":"i","ц":"ts","у":"u","к":"k","е":"e","н":"n","г":"g","ш":"sh","щ":"sch","з":"z","х":"h","ъ":"'","Ф":"F","Ы":"I","В":"V","А":"a","П":"P","Р":"R","О":"O","Л":"L","Д":"D","Ж":"ZH","Э":"E","ф":"f","ы":"i","в":"v","а":"a","п":"p","р":"r","о":"o","л":"l","д":"d","ж":"zh","э":"e","Я":"Ya","Ч":"CH","С":"S","М":"M","И":"I","Т":"T","Ь":"'","Б":"B","Ю":"YU","я":"ya","ч":"ch","с":"s","м":"m","и":"i","т":"t","ь":"'","б":"b","ю":"yu"};if(null!=wp.media)var _custom_media=!0,_orig_send_attachment=wp.media.editor.send.attachment;$("#cptui_choose_icon").on("click",function(e){e.preventDefault();var button=$(this),id=jQuery("#menu_icon").attr("id");return _custom_media=!0,wp.media.editor.send.attachment=function(props,attachment){if(!_custom_media)return _orig_send_attachment.apply(this,[props,attachment]);$("#"+id).val(attachment.url)},wp.media.editor.open(button),!1}),$("#togglelabels").on("click",function(e){e.preventDefault(),$("#labels_expand").toggleClass("toggledclosed")}),$("#togglesettings").on("click",function(e){e.preventDefault(),$("#settings_expand").toggleClass("toggledclosed")}),$("#labels_expand,#settings_expand").on("focus",function(e){$(this).hasClass("toggledclosed")&&$(this).toggleClass("toggledclosed")}),$("#labels_expand legend,#settings_expand legend").on("click",function(e){$(this).parent().toggleClass("toggledclosed")}),$(".cptui-help").on("click",function(e){e.preventDefault()}),$(".cptui-taxonomy-submit").on("click",function(e){if(0==$(".cptui-table :checkbox:checked").length){e.preventDefault();$('<div class="cptui-taxonomy-empty-types-dialog">'+cptui_tax_data.no_associated_type+"</div>").appendTo("#poststuff").dialog({dialogClass:"wp-dialog",modal:!0,autoOpen:!0,buttons:{OK:function(){$(this).dialog("close")}}})}}),$("#auto-populate").on("click tap",function(e){e.preventDefault();var slug=$("#name").val(),plural=$("#label").val(),singular=$("#singular_label").val(),fields=$('.cptui-labels input[type="text"]');""!==slug&&(""===plural&&(plural=slug),""===singular&&(singular=slug),$(fields).each(function(i,el){var newval=$(el).data("label"),plurality=$(el).data("plurality");void 0!==newval&&(newval="plural"===plurality?newval.replace(/item/gi,plural):newval.replace(/item/gi,singular),""===$(el).val()&&$(el).val(newval))}))})}(jQuery);
readme.txt CHANGED
@@ -2,11 +2,11 @@
2
  Contributors: webdevstudios, pluginize, tw2113, vegasgeek, modemlooper, williamsba1
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3084056
4
  Tags: custom post types, CPT, CMS, post, types, post type, taxonomy, tax, custom, content types, post types
5
- Requires at least: 4.7
6
- Tested up to: 5.2
7
- Stable tag: 1.6.2
8
  License: GPL-2.0+
9
- Requires PHP: 5.2
10
 
11
  Admin UI for creating custom post types and custom taxonomies for WordPress
12
 
@@ -31,6 +31,18 @@ Official development of Custom Post Type UI is on GitHub, with official stable r
31
 
32
  == Changelog ==
33
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  = 1.6.2 - 2019-05-20 =
35
  * Added: "themes" is now a reserved post type slug due to conflicts with WordPress internally.
36
  * Fixed: Updated wording around "Supports" section of post type settings screen.
@@ -132,6 +144,18 @@ Official development of Custom Post Type UI is on GitHub, with official stable r
132
 
133
  == Upgrade Notice ==
134
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  = 1.6.2 - 2019-05-20 =
136
  * Added: "themes" is now a reserved post type slug due to conflicts with WordPress internally.
137
  * Fixed: Updated wording around "Supports" section of post type settings screen.
2
  Contributors: webdevstudios, pluginize, tw2113, vegasgeek, modemlooper, williamsba1
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3084056
4
  Tags: custom post types, CPT, CMS, post, types, post type, taxonomy, tax, custom, content types, post types
5
+ Requires at least: 5.2
6
+ Tested up to: 5.3
7
+ Stable tag: 1.7.0
8
  License: GPL-2.0+
9
+ Requires PHP: 5.6
10
 
11
  Admin UI for creating custom post types and custom taxonomies for WordPress
12
 
31
 
32
  == Changelog ==
33
 
34
+ = 1.7.0 - 2019-11-06 =
35
+ * Actually added this time: Delete with user support for post types. Managed to miss the code with 1.6.0 which was a long time ago.
36
+ * Added: Ability to disable registration of post types or taxonomies, via code filter, without deleting them completely from settings.
37
+ * Added: New post type labels introduced in WordPress 5.0.0.
38
+ * Added: Link to Dashicon documentation for when editing menu icon. Props @juliekuehl
39
+ * Added: Ability to automatically fill in additional labels based on chosen plural and singular label text.
40
+ * Updated: Added post type templates documentation to help section.
41
+ * Updated: Redirect user to the "add" tab if deleting the last post type or taxonomy created.
42
+ * Updated: Touched up tab markup to match semantic improvements provided by WordPress 5.2.0.
43
+ * Fixed: potential duplicate output of "parent_item_colon" with "Get Code" output.
44
+ * Misc: Added code of conduct file to github repo. Props GaryJones.
45
+
46
  = 1.6.2 - 2019-05-20 =
47
  * Added: "themes" is now a reserved post type slug due to conflicts with WordPress internally.
48
  * Fixed: Updated wording around "Supports" section of post type settings screen.
144
 
145
  == Upgrade Notice ==
146
 
147
+ = 1.7.0 - 2019-11-06 =
148
+ * Actually added this time: Delete with user support for post types. Managed to miss the code with 1.6.0 which was a long time ago.
149
+ * Added: Ability to disable registration of post types or taxonomies, via code filter, without deleting them completely from settings.
150
+ * Added: New post type labels introduced in WordPress 5.0.0.
151
+ * Added: Link to Dashicon documentation for when editing menu icon. Props @juliekuehl
152
+ * Added: Ability to automatically fill in additional labels based on chosen plural and singular label text.
153
+ * Updated: Added post type templates documentation to help section.
154
+ * Updated: Redirect user to the "add" tab if deleting the last post type or taxonomy created.
155
+ * Updated: Touched up tab markup to match semantic improvements provided by WordPress 5.2.0.
156
+ * Fixed: potential duplicate output of "parent_item_colon" with "Get Code" output.
157
+ * Misc: Added code of conduct file to github repo. Props GaryJones.
158
+
159
  = 1.6.2 - 2019-05-20 =
160
  * Added: "themes" is now a reserved post type slug due to conflicts with WordPress internally.
161
  * Fixed: Updated wording around "Supports" section of post type settings screen.