Skip to content

Commit 1e50c6e

Browse files
committed
release 1.12.0
1 parent 9dd873d commit 1e50c6e

20 files changed

+143
-53
lines changed

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10-
- Not documented.
10+
## [1.9.2] - 2021-06-16 =
11+
### Added
12+
- Added: "date" as a reserved taxonomy slug.
13+
### Fixed
14+
- Fixed: duplicate "show_in_graphql" attribute output in "Get Code" output.
15+
### Updated
16+
- Updated: image optimization for smaller file sizes.
17+
- Updated: removed duplicate taxonomy labels.
18+
19+
## [1.9.1] - 2021-04-19 =
20+
### Fixed
21+
- Fixed: missed WPGraphQL settings in our Get Tools/Export functionality.
22+
### Updated
23+
- Updated: note about needing a published item to set parent/child relationships in post types.
24+
25+
## [1.9.0] - 2021-03-30 =
26+
### Added
27+
- Added: WPGraphQL Support when WPGraphQL is installed and active.
28+
### Fixed
29+
- Fixed: Better handling of code in post_format based helper functions.
30+
### Updated
31+
- Updated: Cleaned up unused CSS.
32+
- Updated: Added `types` to disallowed taxonomy slugs.
33+
- Updated: Amended some helper text on the listings page regarding templates. Props @tarecord
1134

1235
## [1.8.2] - 2020-12-29
1336
### Fixed

assets/screenshot-1.png

949 KB
Loading

assets/screenshot-10.png

-51.1 KB
Binary file not shown.

assets/screenshot-11.png

-99.5 KB
Binary file not shown.

assets/screenshot-2.png

928 KB
Loading

assets/screenshot-3.png

756 KB
Loading

assets/screenshot-4.png

363 KB
Loading

assets/screenshot-5.png

759 KB
Loading

assets/screenshot-6.png

-45.7 KB
Binary file not shown.

assets/screenshot-7.png

-45.8 KB
Binary file not shown.

assets/screenshot-8.png

-65.6 KB
Binary file not shown.

assets/screenshot-9.png

-37.1 KB
Binary file not shown.

custom-post-type-ui.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Plugin URI: https://github.com/WebDevStudios/custom-post-type-ui/
1717
* Description: Admin panel for creating custom post types and custom taxonomies in WordPress
1818
* Author: WebDevStudios
19-
* Version: 1.11.2
19+
* Version: 1.12.0
2020
* Author URI: https://webdevstudios.com/
2121
* Text Domain: custom-post-type-ui
2222
* Domain Path: /languages
@@ -30,8 +30,8 @@
3030
exit;
3131
}
3232

33-
define( 'CPT_VERSION', '1.11.2' ); // Left for legacy purposes.
34-
define( 'CPTUI_VERSION', '1.11.2' );
33+
define( 'CPT_VERSION', '1.12.0' ); // Left for legacy purposes.
34+
define( 'CPTUI_VERSION', '1.12.0' );
3535
define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
3636

3737
/**
@@ -434,6 +434,7 @@ function cptui_register_single_post_type( $post_type = [] ) {
434434
}
435435

436436
$menu_icon = ! empty( $post_type['menu_icon'] ) ? $post_type['menu_icon'] : null;
437+
$register_meta_box_cb = ! empty( $post_type['register_meta_box_cb'] ) ? $post_type['register_meta_box_cb'] : null;
437438

438439
if ( in_array( $post_type['query_var'], [ 'true', 'false', '0', '1' ], true ) ) {
439440
$post_type['query_var'] = get_disp_boolean( $post_type['query_var'] );
@@ -492,6 +493,11 @@ function cptui_register_single_post_type( $post_type = [] ) {
492493
$rest_controller_class = $post_type['rest_controller_class'];
493494
}
494495

496+
$rest_namespace = null;
497+
if ( ! empty( $post_type['rest_namespace'] ) ) {
498+
$rest_namespace = $post_type['rest_namespace'];
499+
}
500+
495501
$can_export = null;
496502
if ( ! empty( $post_type['can_export'] ) ) {
497503
$can_export = get_disp_boolean( $post_type['can_export'] );
@@ -510,6 +516,7 @@ function cptui_register_single_post_type( $post_type = [] ) {
510516
'show_in_rest' => get_disp_boolean( $post_type['show_in_rest'] ),
511517
'rest_base' => $rest_base,
512518
'rest_controller_class' => $rest_controller_class,
519+
'rest_namespace' => $rest_namespace,
513520
'exclude_from_search' => $exclude_from_search,
514521
'capability_type' => $capability_type,
515522
'map_meta_cap' => $post_type['map_meta_cap'],
@@ -518,6 +525,7 @@ function cptui_register_single_post_type( $post_type = [] ) {
518525
'rewrite' => $rewrite,
519526
'menu_position' => $menu_position,
520527
'menu_icon' => $menu_icon,
528+
'register_meta_box_cb' => $register_meta_box_cb,
521529
'query_var' => $post_type['query_var'],
522530
'supports' => $post_type['supports'],
523531
'taxonomies' => $post_type['taxonomies'],
@@ -717,6 +725,11 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
717725
$rest_controller_class = $taxonomy['rest_controller_class'];
718726
}
719727

728+
$rest_namespace = null;
729+
if ( ! empty( $taxonomy['rest_namespace'] ) ) {
730+
$rest_namespace = $taxonomy['rest_namespace'];
731+
}
732+
720733
$meta_box_cb = null;
721734
if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
722735
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? $taxonomy['meta_box_cb'] : false;
@@ -752,6 +765,7 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
752765
'show_in_rest' => $show_in_rest,
753766
'rest_base' => $rest_base,
754767
'rest_controller_class' => $rest_controller_class,
768+
'rest_namespace' => $rest_namespace,
755769
'show_in_quick_edit' => $show_in_quick_edit,
756770
'sort' => $sort,
757771
'meta_box_cb' => $meta_box_cb,

inc/about.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ function cptui_settings() {
8585
<div class="changelog about-integrations">
8686
<div class="cptui-feature feature-section col three-col">
8787
<div class="col">
88-
<h2><?php esc_html_e( 'Dashicon Picker UI', 'custom-post-type-ui' ); ?></h2>
89-
<p><?php esc_html_e( 'You no longer have to know the Dashicon class values ahead of time or look them up in the WordPress Developer Documentation. We now provide a visual picker that shows them all for you. All you have to do is choose one.', 'custom-post-type-ui' ); ?></p>
88+
<h2><?php esc_html_e( 'Auto-selection of "page attributes" for post types', 'custom-post-type-ui' ); ?></h2>
89+
<p><?php esc_html_e( 'When setting a post type to be hierarchical, you also want to make sure you have `page_attributes` selected in the "Supports" section to set hierarchy. We do not force this, if you want to still turn it off, but this helps prevent potentially missing this setting.', 'custom-post-type-ui' ); ?></p>
90+
<h2><?php esc_html_e( 'More post type and taxonomy settings', 'custom-post-type-ui' ); ?></h2>
91+
<p><?php esc_html_e( 'We have updated the available settings to include the `rest_namespace` field as well as `register_meta_box_cb` for post types.', 'custom-post-type-ui' ); ?></p>
9092
</div>
9193
</div>
9294
</div>

inc/post-types.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,14 @@ function cptui_manage_post_types() {
937937
'textvalue' => isset( $current['rest_controller_class'] ) ? esc_attr( $current['rest_controller_class'] ) : '',
938938
] );
939939

940+
echo $ui->get_text_input( [
941+
'namearray' => 'cpt_custom_post_type',
942+
'name' => 'rest_namespace',
943+
'labeltext' => esc_html__( 'REST API namespace', 'custom-post-type-ui' ),
944+
'aftertext' => esc_attr__( '(default: wp/v2) To change the namespace URL of REST API route.', 'custom-post-type-ui' ),
945+
'textvalue' => isset( $current['rest_namespace'] ) ? esc_attr( $current['rest_namespace'] ) : '',
946+
] );
947+
940948
echo $ui->get_tr_start() . $ui->get_th_start();
941949
echo $ui->get_label( 'has_archive', esc_html__( 'Has Archive', 'custom-post-type-ui' ) );
942950
echo $ui->get_p( esc_html__( 'If left blank, the archive slug will default to the post type slug.', 'custom-post-type-ui' ) );
@@ -1187,6 +1195,14 @@ function cptui_manage_post_types() {
11871195

11881196
echo $ui->get_td_end() . $ui->get_tr_end();
11891197

1198+
echo $ui->get_text_input( [
1199+
'namearray' => 'cpt_custom_post_type',
1200+
'name' => 'register_meta_box_cb',
1201+
'textvalue' => isset( $current['register_meta_box_cb'] ) ? esc_attr( $current['register_meta_box_cb'] ) : '',
1202+
'labeltext' => esc_html__( 'Metabox callback', 'custom-post-type-ui' ),
1203+
'helptext' => esc_html__( 'Provide a callback function that sets up the meta boxes for the edit form. Do `remove_meta_box()` and `add_meta_box()` calls in the callback. Default null.', 'custom-post-type-ui' ),
1204+
] );
1205+
11901206
echo $ui->get_tr_start() . $ui->get_th_start() . esc_html__( 'Supports', 'custom-post-type-ui' );
11911207

11921208
echo $ui->get_p( esc_html__( 'Add support for various available post editor features on the right. A checked value means the post type feature is supported.', 'custom-post-type-ui' ) );
@@ -1727,6 +1743,11 @@ function cptui_update_post_type( $data = [] ) {
17271743
$data['cpt_custom_post_type']['menu_icon'] = null;
17281744
}
17291745

1746+
$register_meta_box_cb = trim( $data['cpt_custom_post_type']['register_meta_box_cb'] );
1747+
if ( empty( $register_meta_box_cb ) ) {
1748+
$register_meta_box_cb = null;
1749+
}
1750+
17301751
$label = ucwords( str_replace( '_', ' ', $data['cpt_custom_post_type']['name'] ) );
17311752
if ( ! empty( $data['cpt_custom_post_type']['label'] ) ) {
17321753
$label = str_replace( '"', '', htmlspecialchars_decode( $data['cpt_custom_post_type']['label'] ) );
@@ -1743,6 +1764,7 @@ function cptui_update_post_type( $data = [] ) {
17431764
$description = stripslashes_deep( $data['cpt_custom_post_type']['description'] );
17441765
$rest_base = trim( $data['cpt_custom_post_type']['rest_base'] );
17451766
$rest_controller_class = trim( $data['cpt_custom_post_type']['rest_controller_class'] );
1767+
$rest_namespace = trim( $data['cpt_custom_post_type']['rest_namespace'] );
17461768
$has_archive_string = trim( $data['cpt_custom_post_type']['has_archive_string'] );
17471769
$capability_type = trim( $data['cpt_custom_post_type']['capability_type'] );
17481770
$rewrite_slug = trim( $data['cpt_custom_post_type']['rewrite_slug'] );
@@ -1766,6 +1788,7 @@ function cptui_update_post_type( $data = [] ) {
17661788
'show_in_rest' => disp_boolean( $data['cpt_custom_post_type']['show_in_rest'] ),
17671789
'rest_base' => $rest_base,
17681790
'rest_controller_class' => $rest_controller_class,
1791+
'rest_namespace' => $rest_namespace,
17691792
'has_archive' => disp_boolean( $data['cpt_custom_post_type']['has_archive'] ),
17701793
'has_archive_string' => $has_archive_string,
17711794
'exclude_from_search' => disp_boolean( $data['cpt_custom_post_type']['exclude_from_search'] ),
@@ -1781,6 +1804,7 @@ function cptui_update_post_type( $data = [] ) {
17811804
'show_in_menu' => disp_boolean( $data['cpt_custom_post_type']['show_in_menu'] ),
17821805
'show_in_menu_string' => $show_in_menu_string,
17831806
'menu_icon' => $menu_icon,
1807+
'register_meta_box_cb' => $register_meta_box_cb,
17841808
'supports' => $data['cpt_supports'],
17851809
'taxonomies' => $data['cpt_addon_taxes'],
17861810
'labels' => $data['cpt_labels'],

inc/taxonomies.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,14 @@ function cptui_manage_taxonomies() {
10961096
'textvalue' => isset( $current['rest_controller_class'] ) ? esc_attr( $current['rest_controller_class'] ) : '',
10971097
] );
10981098

1099+
echo $ui->get_text_input( [
1100+
'namearray' => 'cpt_custom_tax',
1101+
'name' => 'rest_namespace',
1102+
'labeltext' => esc_html__( 'REST API namespace', 'custom-post-type-ui' ),
1103+
'aftertext' => esc_attr__( '(default: wp/v2) To change the namespace URL of REST API route.', 'custom-post-type-ui' ),
1104+
'textvalue' => isset( $current['rest_namespace'] ) ? esc_attr( $current['rest_namespace'] ) : '',
1105+
] );
1106+
10991107
$select = [
11001108
'options' => [
11011109
[
@@ -1523,6 +1531,7 @@ function cptui_update_taxonomy( $data = [] ) {
15231531
$rewrite_slug = trim( $data['cpt_custom_tax']['rewrite_slug'] );
15241532
$rest_base = trim( $data['cpt_custom_tax']['rest_base'] );
15251533
$rest_controller_class = trim( $data['cpt_custom_tax']['rest_controller_class'] );
1534+
$rest_namespace = trim( $data['cpt_custom_tax']['rest_namespace'] );
15261535
$show_quickpanel_bulk = ! empty( $data['cpt_custom_tax']['show_in_quick_edit'] ) ? disp_boolean( $data['cpt_custom_tax']['show_in_quick_edit'] ) : '';
15271536
$default_term = trim( $data['cpt_custom_tax']['default_term'] );
15281537

@@ -1557,6 +1566,7 @@ function cptui_update_taxonomy( $data = [] ) {
15571566
'show_in_quick_edit' => $show_quickpanel_bulk,
15581567
'rest_base' => $rest_base,
15591568
'rest_controller_class' => $rest_controller_class,
1569+
'rest_namespace' => $rest_namespace,
15601570
'labels' => $data['cpt_tax_labels'],
15611571
'meta_box_cb' => $meta_box_cb,
15621572
'default_term' => $default_term,
@@ -1630,12 +1640,14 @@ function cptui_reserved_taxonomies() {
16301640
'category_name',
16311641
'comments_per_page',
16321642
'comments_popup',
1643+
'cpage',
1644+
'custom',
16331645
'customize_messenger_channel',
16341646
'customized',
1635-
'cpage',
1636-
'day',
16371647
'date',
1648+
'day',
16381649
'debug',
1650+
'embed',
16391651
'error',
16401652
'exact',
16411653
'feed',
@@ -1654,6 +1666,7 @@ function cptui_reserved_taxonomies() {
16541666
'offset',
16551667
'order',
16561668
'orderby',
1669+
'output',
16571670
'p',
16581671
'page',
16591672
'page_id',
@@ -1680,6 +1693,7 @@ function cptui_reserved_taxonomies() {
16801693
'sentence',
16811694
'showposts',
16821695
'static',
1696+
'status',
16831697
'subpost',
16841698
'subpost_id',
16851699
'tag',
@@ -1692,14 +1706,15 @@ function cptui_reserved_taxonomies() {
16921706
'taxonomy',
16931707
'tb',
16941708
'term',
1709+
'terms',
16951710
'theme',
1711+
'title',
16961712
'type',
16971713
'types',
16981714
'w',
16991715
'withcomments',
17001716
'withoutcomments',
17011717
'year',
1702-
'output',
17031718
];
17041719

17051720
/**

inc/tools.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
279279
$show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? 'true' : 'false';
280280
$rest_base = ! empty( $taxonomy['rest_base'] ) ? $taxonomy['rest_base'] : $taxonomy['name'];
281281
$rest_controller_class = ! empty( $taxonomy['rest_controller_class'] ) ? $taxonomy['rest_controller_class'] : 'WP_REST_Terms_Controller';
282+
$rest_namespace = ! empty( $taxonomy['rest_namespace'] ) ? $taxonomy['rest_namespace'] : 'wp/v2';
282283

283284
if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
284285
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? '"' . $taxonomy['meta_box_cb'] . '"' : 'false';
@@ -345,6 +346,7 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
345346
"show_tagcloud" => <?php echo $show_tagcloud; ?>,
346347
"rest_base" => "<?php echo $rest_base; ?>",
347348
"rest_controller_class" => "<?php echo $rest_controller_class; ?>",
349+
"rest_namespace" => "<?php echo $rest_namespace; ?>",
348350
"show_in_quick_edit" => <?php echo $show_in_quick_edit; ?>,
349351
"sort" => <?php echo disp_boolean( $taxonomy['sort'] ); ?>,
350352
<?php if ( $show_graphql ) : ?>
@@ -495,6 +497,7 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
495497
$post_type['show_in_rest'] = 'false';
496498
}
497499
$rest_controller_class = ! empty( $post_type['rest_controller_class'] ) ? $post_type['rest_controller_class'] : 'WP_REST_Posts_Controller';
500+
$rest_namespace = ! empty( $post_type['rest_namespace'] ) ? $post_type['rest_namespace'] : 'wp/v2';
498501

499502
$show_in_menu = get_disp_boolean( $post_type['show_in_menu'] );
500503
if ( false !== $show_in_menu ) {
@@ -511,6 +514,11 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
511514
$delete_with_user = disp_boolean( $post_type['delete_with_user'] );
512515
}
513516

517+
$can_export = 'true';
518+
if ( isset( $post_type['can_export'] ) ) {
519+
$can_export = disp_boolean( $post_type['can_export'] );
520+
}
521+
514522
$public = isset( $post_type['public'] ) ? disp_boolean( $post_type['public'] ) : 'true';
515523
$show_in_nav_menus = ( ! empty( $post_type['show_in_nav_menus'] ) && false !== get_disp_boolean( $post_type['show_in_nav_menus'] ) ) ? 'true' : 'false';
516524
if ( empty( $post_type['show_in_nav_menus'] ) ) {
@@ -569,6 +577,7 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
569577
"show_in_rest" => <?php echo disp_boolean( $post_type['show_in_rest'] ); ?>,
570578
"rest_base" => "<?php echo $post_type['rest_base']; ?>",
571579
"rest_controller_class" => "<?php echo $rest_controller_class; ?>",
580+
"rest_namespace" => "<?php echo $rest_namespace; ?>",
572581
"has_archive" => <?php echo $has_archive; ?>,
573582
"show_in_menu" => <?php echo $show_in_menu; ?>,
574583
"show_in_nav_menus" => <?php echo $show_in_nav_menus; ?>,
@@ -577,7 +586,7 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
577586
"capability_type" => <?php echo $capability_type; ?>,
578587
"map_meta_cap" => <?php echo disp_boolean( $post_type['map_meta_cap'] ); ?>,
579588
"hierarchical" => <?php echo disp_boolean( $post_type['hierarchical'] ); ?>,
580-
"can_export" => <?php echo disp_boolean( $post_type['can_export'] ); ?>,
589+
"can_export" => <?php echo $can_export; ?>,
581590
"rewrite" => <?php echo $rewrite; ?>,
582591
"query_var" => <?php echo $post_type['query_var']; ?>,
583592
<?php if ( ! empty( $post_type['menu_position'] ) ) { ?>
@@ -586,6 +595,9 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
586595
<?php if ( ! empty( $post_type['menu_icon'] ) ) { ?>
587596
"menu_icon" => "<?php echo $post_type['menu_icon']; ?>",
588597
<?php } ?>
598+
<?php if ( ! empty( $post_type['register_meta_box_cb'] ) ) { ?>
599+
"register_meta_box_cb" => "<?php echo $post_type['register_meta_box_cb']; ?>",
600+
<?php } ?>
589601
<?php if ( ! empty( $supports ) ) { ?>
590602
"supports" => <?php echo $supports; ?>,
591603
<?php } ?>

js/cptui.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ postboxes.add_postbox_toggles(pagenow);
1616
var original_slug = $('#name').val();
1717
}
1818

19+
// Automatically toggle the "page attributes" checkbox if
20+
// setting a hierarchical post type.
21+
$('#hierarchical').on('change', function() {
22+
var hierarchical = $(this).val();
23+
if ('1' === hierarchical) {
24+
$('#page-attributes').prop('checked', true);
25+
} else {
26+
$('#page-attributes').prop('checked', false);
27+
}
28+
});
29+
1930
// Switch to newly selected post type or taxonomy automatically.
2031
$('#post_type').on('change',function(){
2132
$('#cptui_select_post_type').submit();

0 commit comments

Comments
 (0)