Skip to content

Commit

Permalink
merge in a small but still good 1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tw2113 committed Aug 14, 2020
1 parent eadfe04 commit 24f9970
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 241 deletions.
56 changes: 55 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,57 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Not documented.

## [1.6.2] - 2019-05-20
### Added
- "themes" is now a reserved post type slug due to conflicts with WordPress internally.

### Fixed
- Updated wording around "Supports" section of post type settings screen.

## [1.6.1] - 2018-12-03
### Fixed
- Missed quote for "publicly_queryable" in taxonomy "get code" output.
- Adjusted handling of capitalization on the word "false" when being used to disable a taxonomy metabox via the "metabox callback" setting. The word "false" needs to be all lowercase to disable.

### Updated
- Added note about ability to pass "false" for the "metabox callback" setting to disable the metabox.
- Fall back to "custom-post-type-ui" textdomain in "get code" output if theme does not have their own.
- Make "Show In Rest" setting default to true taxonomies for sake of easier Gutenberg integration in the future. 1.6.0 had just post types doing this.

## [1.6.0] - 2018-10-22
### Added
- Support for `meta_box_cb` parameter for `register_taxonomy` and taxonomies.
- Dynamically warn about existing slugs.
- "delete_with_user" support for post types.
- Filters for post type and taxonomy data right before saving of final data.
- `cptui_get_taxonomy_exists` function to check if a provided taxonomy is registered.
- Required PHP version to readme.txt
- Filter on taxonomies to be listed as available for association with a post type.
- Warning indicators to our "Slug changed" and "Slug exists" warnings for post types and taxonomies.
- Support for "publicly_queryable" parameter for taxonomies.
- Support for "rest_controller_class" parameters for both post types and taxonomies.
- Some initial WP-CLI support for importing and exporting CPTUI settings.
- `name_admin_bar` support in post type labels.
- Handling of array versions for "capability_type" field.

### Updated
- Bump minimum WordPress version to 4.7.
- Pass the object_type array to `cptui_pre_register_taxonomy` filter as extra parameter.
- Adjusted preserved label handling to aid with plugin performance. Props alex-solovyev
- Utilize `wp_doing_ajax()` function for our AJAX checks.
- Clarify what is exported with the Post Types and Taxonomies spots for the Tools section.
- Clarify that the listed post types to associate to a CPTUI taxonomy are public post types by default.
- Make "Show In Rest" setting default to true for sake of easier Gutenberg integration in the future.

### Fixed
- Only register archive slug if has_archive is set to true.
- Error occurred when attempting to unset post types while editing a taxonomy.
- Prevent errors from non-existant callback functions during post type or taxonomy processing.
- Incorrect use of reserved taxonomy slugs function in a check for reserved post types.
- Make sure "No post type selected" alert trigger from both buttons on the taxonomy settings edit screen.
- Add our stylesheet only on our CPTUI pages. Fixes responsive bug on post editor screen.
- Removed duplicate "label" in taxonomy "get code" section.

## [1.5.8] - 2018-04-16
### Fixed
- Corrected issue with `Get Code` area regarding post types and `show in menu` field values.
Expand Down Expand Up @@ -386,7 +437,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

[Gary Jones]: https://github.com/GaryJones

[Unreleased]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.8...HEAD
[Unreleased]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.6.2...HEAD
[1.6.2]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.6.1...1.6.2
[1.6.1]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.6.0...1.6.1
[1.6.0]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.8...1.6.0
[1.5.8]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.7...1.5.8
[1.5.7]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.6...1.5.7
[1.5.6]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.5...1.5.6
Expand Down
2 changes: 1 addition & 1 deletion css/cptui.css
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@

.about-wrap .cptui-about-text {
margin-bottom: 1em !important;
margin-right: 0px;
margin-right: 0;
max-width: calc(100% - 173px);
}

Expand Down
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.7.5
* Version: 1.8.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.7.5' ); // Left for legacy purposes.
define( 'CPTUI_VERSION', '1.7.5' );
define( 'CPT_VERSION', '1.8.0' ); // Left for legacy purposes.
define( 'CPTUI_VERSION', '1.8.0' );
define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );

/**
Expand Down Expand Up @@ -677,6 +677,19 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? $taxonomy['meta_box_cb'] : false;
}
$default_term = null;
if ( ! empty( $taxonomy['default_term'] ) ) {
$term_parts = explode(',', $taxonomy['default_term'] );
if ( ! empty( $term_parts[0] ) ) {
$default_term['name'] = trim( $term_parts[0] );
}
if ( ! empty( $term_parts[1] ) ) {
$default_term['slug'] = trim( $term_parts[1] );
}
if ( ! empty( $term_parts[2] ) ) {
$default_term['description'] = trim( $term_parts[2] );
}
}

$args = [
'labels' => $labels,
Expand All @@ -696,6 +709,7 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
'rest_controller_class' => $rest_controller_class,
'show_in_quick_edit' => $show_in_quick_edit,
'meta_box_cb' => $meta_box_cb,
'default_term' => $default_term,
];

$object_type = ! empty( $taxonomy['object_types'] ) ? $taxonomy['object_types'] : '';
Expand Down
12 changes: 4 additions & 8 deletions inc/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,12 @@ 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( 'Ability to temporarily disable content types without deleting them.', 'custom-post-type-ui' ); ?></h2>
<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>
</div>
<div class="col">
<h2><?php esc_html_e( 'New post type labels introduced in WordPress 5.0', 'custom-post-type-ui' ); ?></h2>
<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>
<h2><?php esc_html_e( 'Ability to set a default term for a custom taxonomy.', 'custom-post-type-ui' ); ?></h2>
<p><?php esc_html_e( 'WordPress 5.5 added the ability to set a default term to your custom taxonomy, and now you do not have to worry about extra coding for that with Custom Post Type UI.', 'custom-post-type-ui' ); ?></p>
</div>
<div class="col last-feature">
<h2></h2>
<p></p>
<h2><?php esc_html_e( 'Removed forced underscores for post type slugs.', 'custom-post-type-ui' ); ?></h2>
<p><?php esc_html_e( 'Post types are actually able to have dashes in their slug/name value, so we have removed the forcing of underscores for them. Taxonomies do still need underscores, until told otherwise.', 'custom-post-type-ui' ); ?></p>
</div>
</div>
</div>
Expand Down
14 changes: 14 additions & 0 deletions inc/taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,14 @@ function cptui_manage_taxonomies() {
'labeltext' => esc_html__( 'Metabox callback', 'custom-post-type-ui' ),
'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' ),
] );

echo $ui->get_text_input( [
'namearray' => 'cpt_custom_tax',
'name' => 'default_term',
'textvalue' => isset( $current['default_term'] ) ? esc_attr( $current['default_term'] ) : '',
'labeltext' => esc_html__( 'Default Term', 'custom-post-type-ui' ),
'helptext' => esc_html__( 'Set a default term for the taxonomy. Able to set a name, slug, and description. Only a name is required if setting a default, others are optional. Set values in the following order, separated by comma. Example: name, slug, description', 'custom-post-type-ui' ),
] );
?>
</table>
</div>
Expand Down Expand Up @@ -1278,6 +1286,7 @@ function cptui_delete_taxonomy( $data = [] ) {
$success = update_option( 'cptui_taxonomies', $taxonomies );
}
}
delete_option( "default_term_{$data['cpt_custom_tax']['name']}" );

/**
* Fires after a taxonomy is deleted from our saved options.
Expand Down Expand Up @@ -1323,6 +1332,9 @@ function cptui_update_taxonomy( $data = [] ) {
return cptui_admin_notices( 'error', '', false, esc_html__( 'Please provide a taxonomy name', 'custom-post-type-ui' ) );
}

// Maybe a little harsh, but we shouldn't be saving THAT frequently.
delete_option( "default_term_{$data['cpt_custom_tax']['name']}" );

if ( empty( $data['cpt_post_types'] ) ) {
add_filter( 'cptui_custom_error_message', 'cptui_empty_cpt_on_taxonomy' );
return 'error';
Expand Down Expand Up @@ -1397,6 +1409,7 @@ function cptui_update_taxonomy( $data = [] ) {
$rest_base = trim( $data['cpt_custom_tax']['rest_base'] );
$rest_controller_class = trim( $data['cpt_custom_tax']['rest_controller_class'] );
$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'] );

$meta_box_cb = trim( $data['cpt_custom_tax']['meta_box_cb'] );
// We may or may not need to force a boolean false keyword.
Expand Down Expand Up @@ -1429,6 +1442,7 @@ function cptui_update_taxonomy( $data = [] ) {
'rest_controller_class' => $rest_controller_class,
'labels' => $data['cpt_tax_labels'],
'meta_box_cb' => $meta_box_cb,
'default_term' => $default_term,
];

$taxonomies[ $data['cpt_custom_tax']['name'] ]['object_types'] = $data['cpt_post_types'];
Expand Down
21 changes: 21 additions & 0 deletions inc/tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,24 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? '"' . $taxonomy['meta_box_cb'] . '"' : 'false';
}

$default_term = '';
if ( ! empty( $taxonomy['default_term'] ) ) {
$term_parts = explode( ',', $taxonomy['default_term'] );
$default_term_start = '[';
$default_term_end = ']';
if ( ! empty( $term_parts[0] ) ) {
$default_term .= "'name' => '" . trim( $term_parts[0] ) . "'";
}
if ( ! empty( $term_parts[1] ) ) {
$default_term .= ", 'slug' => '" . trim( $term_parts[1] ) . "'";
}
if ( ! empty( $term_parts[2] ) ) {
$default_term .= ", 'description' => '" . trim( $term_parts[2] ) . "'";
}

$default_term = $default_term_start . $default_term . $default_term_end;
}

$my_theme = wp_get_theme();
$textdomain = $my_theme->get( 'TextDomain' );
if ( empty( $textdomain ) ) {
Expand Down Expand Up @@ -327,6 +345,9 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
<?php if ( ! empty( $meta_box_cb ) ) { ?>
"meta_box_cb" => <?php echo $meta_box_cb; ?>,
<?php } ?>
<?php if ( ! empty( $default_term ) ) { ?>
"default_term" => <?php echo $default_term; ?>,
<?php } ?>
];
register_taxonomy( "<?php echo esc_html( $taxonomy['name'] ); ?>", <?php echo $post_types; ?>, $args );
<?php
Expand Down
25 changes: 6 additions & 19 deletions js/cptui.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ postboxes.add_postbox_toggles(pagenow);
value = transliterate(value);
value = replaceSpecialCharacters(value);
if ( value !== original_value ) {
$(this).attr('value', value);
$(this).prop('value', value);
}
}

Expand Down Expand Up @@ -131,8 +131,11 @@ postboxes.add_postbox_toggles(pagenow);
}

function replaceSpecialCharacters(s) {

s = s.replace(/[^a-z0-9\s]/gi, '_');
if ( 'cpt-ui_page_cptui_manage_post_types' === window.pagenow ) {
s = s.replace(/[^a-z0-9\s-]/gi, '_');
} else {
s = s.replace(/[^a-z0-9\s]/gi, '_');
}

return s;
}
Expand Down Expand Up @@ -180,22 +183,6 @@ postboxes.add_postbox_toggles(pagenow);
return false;
});

$('#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) {
if ( $(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();
});
Expand Down
Loading

0 comments on commit 24f9970

Please sign in to comment.