Skip to content

Commit

Permalink
release 1.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tw2113 committed May 9, 2022
1 parent 9dd873d commit 1e50c6e
Show file tree
Hide file tree
Showing 20 changed files with 143 additions and 53 deletions.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

- Not documented.
## [1.9.2] - 2021-06-16 =
### Added
- Added: "date" as a reserved taxonomy slug.
### Fixed
- Fixed: duplicate "show_in_graphql" attribute output in "Get Code" output.
### Updated
- Updated: image optimization for smaller file sizes.
- Updated: removed duplicate taxonomy labels.

## [1.9.1] - 2021-04-19 =
### Fixed
- Fixed: missed WPGraphQL settings in our Get Tools/Export functionality.
### Updated
- Updated: note about needing a published item to set parent/child relationships in post types.

## [1.9.0] - 2021-03-30 =
### Added
- Added: WPGraphQL Support when WPGraphQL is installed and active.
### Fixed
- Fixed: Better handling of code in post_format based helper functions.
### Updated
- Updated: Cleaned up unused CSS.
- Updated: Added `types` to disallowed taxonomy slugs.
- Updated: Amended some helper text on the listings page regarding templates. Props @tarecord

## [1.8.2] - 2020-12-29
### Fixed
Expand Down
Binary file modified assets/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/screenshot-10.png
Binary file not shown.
Binary file removed assets/screenshot-11.png
Binary file not shown.
Binary file modified assets/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshot-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/screenshot-6.png
Binary file not shown.
Binary file removed assets/screenshot-7.png
Binary file not shown.
Binary file removed assets/screenshot-8.png
Binary file not shown.
Binary file removed assets/screenshot-9.png
Binary file not shown.
20 changes: 17 additions & 3 deletions custom-post-type-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Plugin URI: https://github.com/WebDevStudios/custom-post-type-ui/
* Description: Admin panel for creating custom post types and custom taxonomies in WordPress
* Author: WebDevStudios
* Version: 1.11.2
* Version: 1.12.0
* Author URI: https://webdevstudios.com/
* Text Domain: custom-post-type-ui
* Domain Path: /languages
Expand All @@ -30,8 +30,8 @@
exit;
}

define( 'CPT_VERSION', '1.11.2' ); // Left for legacy purposes.
define( 'CPTUI_VERSION', '1.11.2' );
define( 'CPT_VERSION', '1.12.0' ); // Left for legacy purposes.
define( 'CPTUI_VERSION', '1.12.0' );
define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );

/**
Expand Down Expand Up @@ -434,6 +434,7 @@ function cptui_register_single_post_type( $post_type = [] ) {
}

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

if ( in_array( $post_type['query_var'], [ 'true', 'false', '0', '1' ], true ) ) {
$post_type['query_var'] = get_disp_boolean( $post_type['query_var'] );
Expand Down Expand Up @@ -492,6 +493,11 @@ function cptui_register_single_post_type( $post_type = [] ) {
$rest_controller_class = $post_type['rest_controller_class'];
}

$rest_namespace = null;
if ( ! empty( $post_type['rest_namespace'] ) ) {
$rest_namespace = $post_type['rest_namespace'];
}

$can_export = null;
if ( ! empty( $post_type['can_export'] ) ) {
$can_export = get_disp_boolean( $post_type['can_export'] );
Expand All @@ -510,6 +516,7 @@ function cptui_register_single_post_type( $post_type = [] ) {
'show_in_rest' => get_disp_boolean( $post_type['show_in_rest'] ),
'rest_base' => $rest_base,
'rest_controller_class' => $rest_controller_class,
'rest_namespace' => $rest_namespace,
'exclude_from_search' => $exclude_from_search,
'capability_type' => $capability_type,
'map_meta_cap' => $post_type['map_meta_cap'],
Expand All @@ -518,6 +525,7 @@ function cptui_register_single_post_type( $post_type = [] ) {
'rewrite' => $rewrite,
'menu_position' => $menu_position,
'menu_icon' => $menu_icon,
'register_meta_box_cb' => $register_meta_box_cb,
'query_var' => $post_type['query_var'],
'supports' => $post_type['supports'],
'taxonomies' => $post_type['taxonomies'],
Expand Down Expand Up @@ -717,6 +725,11 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
$rest_controller_class = $taxonomy['rest_controller_class'];
}

$rest_namespace = null;
if ( ! empty( $taxonomy['rest_namespace'] ) ) {
$rest_namespace = $taxonomy['rest_namespace'];
}

$meta_box_cb = null;
if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? $taxonomy['meta_box_cb'] : false;
Expand Down Expand Up @@ -752,6 +765,7 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
'show_in_rest' => $show_in_rest,
'rest_base' => $rest_base,
'rest_controller_class' => $rest_controller_class,
'rest_namespace' => $rest_namespace,
'show_in_quick_edit' => $show_in_quick_edit,
'sort' => $sort,
'meta_box_cb' => $meta_box_cb,
Expand Down
6 changes: 4 additions & 2 deletions inc/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ function cptui_settings() {
<div class="changelog about-integrations">
<div class="cptui-feature feature-section col three-col">
<div class="col">
<h2><?php esc_html_e( 'Dashicon Picker UI', 'custom-post-type-ui' ); ?></h2>
<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>
<h2><?php esc_html_e( 'Auto-selection of "page attributes" for post types', 'custom-post-type-ui' ); ?></h2>
<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>
<h2><?php esc_html_e( 'More post type and taxonomy settings', 'custom-post-type-ui' ); ?></h2>
<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>
</div>
</div>
</div>
Expand Down
24 changes: 24 additions & 0 deletions inc/post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,14 @@ function cptui_manage_post_types() {
'textvalue' => isset( $current['rest_controller_class'] ) ? esc_attr( $current['rest_controller_class'] ) : '',
] );

echo $ui->get_text_input( [
'namearray' => 'cpt_custom_post_type',
'name' => 'rest_namespace',
'labeltext' => esc_html__( 'REST API namespace', 'custom-post-type-ui' ),
'aftertext' => esc_attr__( '(default: wp/v2) To change the namespace URL of REST API route.', 'custom-post-type-ui' ),
'textvalue' => isset( $current['rest_namespace'] ) ? esc_attr( $current['rest_namespace'] ) : '',
] );

echo $ui->get_tr_start() . $ui->get_th_start();
echo $ui->get_label( 'has_archive', esc_html__( 'Has Archive', 'custom-post-type-ui' ) );
echo $ui->get_p( esc_html__( 'If left blank, the archive slug will default to the post type slug.', 'custom-post-type-ui' ) );
Expand Down Expand Up @@ -1187,6 +1195,14 @@ function cptui_manage_post_types() {

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

echo $ui->get_text_input( [
'namearray' => 'cpt_custom_post_type',
'name' => 'register_meta_box_cb',
'textvalue' => isset( $current['register_meta_box_cb'] ) ? esc_attr( $current['register_meta_box_cb'] ) : '',
'labeltext' => esc_html__( 'Metabox callback', 'custom-post-type-ui' ),
'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' ),
] );

echo $ui->get_tr_start() . $ui->get_th_start() . esc_html__( 'Supports', 'custom-post-type-ui' );

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' ) );
Expand Down Expand Up @@ -1727,6 +1743,11 @@ function cptui_update_post_type( $data = [] ) {
$data['cpt_custom_post_type']['menu_icon'] = null;
}

$register_meta_box_cb = trim( $data['cpt_custom_post_type']['register_meta_box_cb'] );
if ( empty( $register_meta_box_cb ) ) {
$register_meta_box_cb = null;
}

$label = ucwords( str_replace( '_', ' ', $data['cpt_custom_post_type']['name'] ) );
if ( ! empty( $data['cpt_custom_post_type']['label'] ) ) {
$label = str_replace( '"', '', htmlspecialchars_decode( $data['cpt_custom_post_type']['label'] ) );
Expand All @@ -1743,6 +1764,7 @@ function cptui_update_post_type( $data = [] ) {
$description = stripslashes_deep( $data['cpt_custom_post_type']['description'] );
$rest_base = trim( $data['cpt_custom_post_type']['rest_base'] );
$rest_controller_class = trim( $data['cpt_custom_post_type']['rest_controller_class'] );
$rest_namespace = trim( $data['cpt_custom_post_type']['rest_namespace'] );
$has_archive_string = trim( $data['cpt_custom_post_type']['has_archive_string'] );
$capability_type = trim( $data['cpt_custom_post_type']['capability_type'] );
$rewrite_slug = trim( $data['cpt_custom_post_type']['rewrite_slug'] );
Expand All @@ -1766,6 +1788,7 @@ function cptui_update_post_type( $data = [] ) {
'show_in_rest' => disp_boolean( $data['cpt_custom_post_type']['show_in_rest'] ),
'rest_base' => $rest_base,
'rest_controller_class' => $rest_controller_class,
'rest_namespace' => $rest_namespace,
'has_archive' => disp_boolean( $data['cpt_custom_post_type']['has_archive'] ),
'has_archive_string' => $has_archive_string,
'exclude_from_search' => disp_boolean( $data['cpt_custom_post_type']['exclude_from_search'] ),
Expand All @@ -1781,6 +1804,7 @@ function cptui_update_post_type( $data = [] ) {
'show_in_menu' => disp_boolean( $data['cpt_custom_post_type']['show_in_menu'] ),
'show_in_menu_string' => $show_in_menu_string,
'menu_icon' => $menu_icon,
'register_meta_box_cb' => $register_meta_box_cb,
'supports' => $data['cpt_supports'],
'taxonomies' => $data['cpt_addon_taxes'],
'labels' => $data['cpt_labels'],
Expand Down
21 changes: 18 additions & 3 deletions inc/taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,14 @@ function cptui_manage_taxonomies() {
'textvalue' => isset( $current['rest_controller_class'] ) ? esc_attr( $current['rest_controller_class'] ) : '',
] );

echo $ui->get_text_input( [
'namearray' => 'cpt_custom_tax',
'name' => 'rest_namespace',
'labeltext' => esc_html__( 'REST API namespace', 'custom-post-type-ui' ),
'aftertext' => esc_attr__( '(default: wp/v2) To change the namespace URL of REST API route.', 'custom-post-type-ui' ),
'textvalue' => isset( $current['rest_namespace'] ) ? esc_attr( $current['rest_namespace'] ) : '',
] );

$select = [
'options' => [
[
Expand Down Expand Up @@ -1523,6 +1531,7 @@ function cptui_update_taxonomy( $data = [] ) {
$rewrite_slug = trim( $data['cpt_custom_tax']['rewrite_slug'] );
$rest_base = trim( $data['cpt_custom_tax']['rest_base'] );
$rest_controller_class = trim( $data['cpt_custom_tax']['rest_controller_class'] );
$rest_namespace = trim( $data['cpt_custom_tax']['rest_namespace'] );
$show_quickpanel_bulk = ! empty( $data['cpt_custom_tax']['show_in_quick_edit'] ) ? disp_boolean( $data['cpt_custom_tax']['show_in_quick_edit'] ) : '';
$default_term = trim( $data['cpt_custom_tax']['default_term'] );

Expand Down Expand Up @@ -1557,6 +1566,7 @@ function cptui_update_taxonomy( $data = [] ) {
'show_in_quick_edit' => $show_quickpanel_bulk,
'rest_base' => $rest_base,
'rest_controller_class' => $rest_controller_class,
'rest_namespace' => $rest_namespace,
'labels' => $data['cpt_tax_labels'],
'meta_box_cb' => $meta_box_cb,
'default_term' => $default_term,
Expand Down Expand Up @@ -1630,12 +1640,14 @@ function cptui_reserved_taxonomies() {
'category_name',
'comments_per_page',
'comments_popup',
'cpage',
'custom',
'customize_messenger_channel',
'customized',
'cpage',
'day',
'date',
'day',
'debug',
'embed',
'error',
'exact',
'feed',
Expand All @@ -1654,6 +1666,7 @@ function cptui_reserved_taxonomies() {
'offset',
'order',
'orderby',
'output',
'p',
'page',
'page_id',
Expand All @@ -1680,6 +1693,7 @@ function cptui_reserved_taxonomies() {
'sentence',
'showposts',
'static',
'status',
'subpost',
'subpost_id',
'tag',
Expand All @@ -1692,14 +1706,15 @@ function cptui_reserved_taxonomies() {
'taxonomy',
'tb',
'term',
'terms',
'theme',
'title',
'type',
'types',
'w',
'withcomments',
'withoutcomments',
'year',
'output',
];

/**
Expand Down
14 changes: 13 additions & 1 deletion inc/tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
$show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? 'true' : 'false';
$rest_base = ! empty( $taxonomy['rest_base'] ) ? $taxonomy['rest_base'] : $taxonomy['name'];
$rest_controller_class = ! empty( $taxonomy['rest_controller_class'] ) ? $taxonomy['rest_controller_class'] : 'WP_REST_Terms_Controller';
$rest_namespace = ! empty( $taxonomy['rest_namespace'] ) ? $taxonomy['rest_namespace'] : 'wp/v2';

if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? '"' . $taxonomy['meta_box_cb'] . '"' : 'false';
Expand Down Expand Up @@ -345,6 +346,7 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
"show_tagcloud" => <?php echo $show_tagcloud; ?>,
"rest_base" => "<?php echo $rest_base; ?>",
"rest_controller_class" => "<?php echo $rest_controller_class; ?>",
"rest_namespace" => "<?php echo $rest_namespace; ?>",
"show_in_quick_edit" => <?php echo $show_in_quick_edit; ?>,
"sort" => <?php echo disp_boolean( $taxonomy['sort'] ); ?>,
<?php if ( $show_graphql ) : ?>
Expand Down Expand Up @@ -495,6 +497,7 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
$post_type['show_in_rest'] = 'false';
}
$rest_controller_class = ! empty( $post_type['rest_controller_class'] ) ? $post_type['rest_controller_class'] : 'WP_REST_Posts_Controller';
$rest_namespace = ! empty( $post_type['rest_namespace'] ) ? $post_type['rest_namespace'] : 'wp/v2';

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

$can_export = 'true';
if ( isset( $post_type['can_export'] ) ) {
$can_export = disp_boolean( $post_type['can_export'] );
}

$public = isset( $post_type['public'] ) ? disp_boolean( $post_type['public'] ) : 'true';
$show_in_nav_menus = ( ! empty( $post_type['show_in_nav_menus'] ) && false !== get_disp_boolean( $post_type['show_in_nav_menus'] ) ) ? 'true' : 'false';
if ( empty( $post_type['show_in_nav_menus'] ) ) {
Expand Down Expand Up @@ -569,6 +577,7 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
"show_in_rest" => <?php echo disp_boolean( $post_type['show_in_rest'] ); ?>,
"rest_base" => "<?php echo $post_type['rest_base']; ?>",
"rest_controller_class" => "<?php echo $rest_controller_class; ?>",
"rest_namespace" => "<?php echo $rest_namespace; ?>",
"has_archive" => <?php echo $has_archive; ?>,
"show_in_menu" => <?php echo $show_in_menu; ?>,
"show_in_nav_menus" => <?php echo $show_in_nav_menus; ?>,
Expand All @@ -577,7 +586,7 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
"capability_type" => <?php echo $capability_type; ?>,
"map_meta_cap" => <?php echo disp_boolean( $post_type['map_meta_cap'] ); ?>,
"hierarchical" => <?php echo disp_boolean( $post_type['hierarchical'] ); ?>,
"can_export" => <?php echo disp_boolean( $post_type['can_export'] ); ?>,
"can_export" => <?php echo $can_export; ?>,
"rewrite" => <?php echo $rewrite; ?>,
"query_var" => <?php echo $post_type['query_var']; ?>,
<?php if ( ! empty( $post_type['menu_position'] ) ) { ?>
Expand All @@ -586,6 +595,9 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
<?php if ( ! empty( $post_type['menu_icon'] ) ) { ?>
"menu_icon" => "<?php echo $post_type['menu_icon']; ?>",
<?php } ?>
<?php if ( ! empty( $post_type['register_meta_box_cb'] ) ) { ?>
"register_meta_box_cb" => "<?php echo $post_type['register_meta_box_cb']; ?>",
<?php } ?>
<?php if ( ! empty( $supports ) ) { ?>
"supports" => <?php echo $supports; ?>,
<?php } ?>
Expand Down
11 changes: 11 additions & 0 deletions js/cptui.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ postboxes.add_postbox_toggles(pagenow);
var original_slug = $('#name').val();
}

// Automatically toggle the "page attributes" checkbox if
// setting a hierarchical post type.
$('#hierarchical').on('change', function() {
var hierarchical = $(this).val();
if ('1' === hierarchical) {
$('#page-attributes').prop('checked', true);
} else {
$('#page-attributes').prop('checked', false);
}
});

// Switch to newly selected post type or taxonomy automatically.
$('#post_type').on('change',function(){
$('#cptui_select_post_type').submit();
Expand Down
Loading

0 comments on commit 1e50c6e

Please sign in to comment.