Skip to content

Commit 24f9970

Browse files
committed
merge in a small but still good 1.8.0
1 parent eadfe04 commit 24f9970

File tree

9 files changed

+256
-241
lines changed

9 files changed

+256
-241
lines changed

CHANGELOG.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,57 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
- Not documented.
1111

12+
## [1.6.2] - 2019-05-20
13+
### Added
14+
- "themes" is now a reserved post type slug due to conflicts with WordPress internally.
15+
16+
### Fixed
17+
- Updated wording around "Supports" section of post type settings screen.
18+
19+
## [1.6.1] - 2018-12-03
20+
### Fixed
21+
- Missed quote for "publicly_queryable" in taxonomy "get code" output.
22+
- 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.
23+
24+
### Updated
25+
- Added note about ability to pass "false" for the "metabox callback" setting to disable the metabox.
26+
- Fall back to "custom-post-type-ui" textdomain in "get code" output if theme does not have their own.
27+
- 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.
28+
29+
## [1.6.0] - 2018-10-22
30+
### Added
31+
- Support for `meta_box_cb` parameter for `register_taxonomy` and taxonomies.
32+
- Dynamically warn about existing slugs.
33+
- "delete_with_user" support for post types.
34+
- Filters for post type and taxonomy data right before saving of final data.
35+
- `cptui_get_taxonomy_exists` function to check if a provided taxonomy is registered.
36+
- Required PHP version to readme.txt
37+
- Filter on taxonomies to be listed as available for association with a post type.
38+
- Warning indicators to our "Slug changed" and "Slug exists" warnings for post types and taxonomies.
39+
- Support for "publicly_queryable" parameter for taxonomies.
40+
- Support for "rest_controller_class" parameters for both post types and taxonomies.
41+
- Some initial WP-CLI support for importing and exporting CPTUI settings.
42+
- `name_admin_bar` support in post type labels.
43+
- Handling of array versions for "capability_type" field.
44+
45+
### Updated
46+
- Bump minimum WordPress version to 4.7.
47+
- Pass the object_type array to `cptui_pre_register_taxonomy` filter as extra parameter.
48+
- Adjusted preserved label handling to aid with plugin performance. Props alex-solovyev
49+
- Utilize `wp_doing_ajax()` function for our AJAX checks.
50+
- Clarify what is exported with the Post Types and Taxonomies spots for the Tools section.
51+
- Clarify that the listed post types to associate to a CPTUI taxonomy are public post types by default.
52+
- Make "Show In Rest" setting default to true for sake of easier Gutenberg integration in the future.
53+
54+
### Fixed
55+
- Only register archive slug if has_archive is set to true.
56+
- Error occurred when attempting to unset post types while editing a taxonomy.
57+
- Prevent errors from non-existant callback functions during post type or taxonomy processing.
58+
- Incorrect use of reserved taxonomy slugs function in a check for reserved post types.
59+
- Make sure "No post type selected" alert trigger from both buttons on the taxonomy settings edit screen.
60+
- Add our stylesheet only on our CPTUI pages. Fixes responsive bug on post editor screen.
61+
- Removed duplicate "label" in taxonomy "get code" section.
62+
1263
## [1.5.8] - 2018-04-16
1364
### Fixed
1465
- Corrected issue with `Get Code` area regarding post types and `show in menu` field values.
@@ -386,7 +437,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
386437

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

389-
[Unreleased]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.8...HEAD
440+
[Unreleased]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.6.2...HEAD
441+
[1.6.2]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.6.1...1.6.2
442+
[1.6.1]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.6.0...1.6.1
443+
[1.6.0]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.8...1.6.0
390444
[1.5.8]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.7...1.5.8
391445
[1.5.7]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.6...1.5.7
392446
[1.5.6]: https://github.com/WebDevStudios/custom-post-type-ui/compare/1.5.5...1.5.6

css/cptui.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210

211211
.about-wrap .cptui-about-text {
212212
margin-bottom: 1em !important;
213-
margin-right: 0px;
213+
margin-right: 0;
214214
max-width: calc(100% - 173px);
215215
}
216216

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

3737
/**
@@ -677,6 +677,19 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
677677
if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
678678
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? $taxonomy['meta_box_cb'] : false;
679679
}
680+
$default_term = null;
681+
if ( ! empty( $taxonomy['default_term'] ) ) {
682+
$term_parts = explode(',', $taxonomy['default_term'] );
683+
if ( ! empty( $term_parts[0] ) ) {
684+
$default_term['name'] = trim( $term_parts[0] );
685+
}
686+
if ( ! empty( $term_parts[1] ) ) {
687+
$default_term['slug'] = trim( $term_parts[1] );
688+
}
689+
if ( ! empty( $term_parts[2] ) ) {
690+
$default_term['description'] = trim( $term_parts[2] );
691+
}
692+
}
680693

681694
$args = [
682695
'labels' => $labels,
@@ -696,6 +709,7 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
696709
'rest_controller_class' => $rest_controller_class,
697710
'show_in_quick_edit' => $show_in_quick_edit,
698711
'meta_box_cb' => $meta_box_cb,
712+
'default_term' => $default_term,
699713
];
700714

701715
$object_type = ! empty( $taxonomy['object_types'] ) ? $taxonomy['object_types'] : '';

inc/about.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,12 @@ 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( '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>
88+
<h2><?php esc_html_e( 'Ability to set a default term for a custom taxonomy.', 'custom-post-type-ui' ); ?></h2>
89+
<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>
9490
</div>
9591
<div class="col last-feature">
96-
<h2></h2>
97-
<p></p>
92+
<h2><?php esc_html_e( 'Removed forced underscores for post type slugs.', 'custom-post-type-ui' ); ?></h2>
93+
<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>
9894
</div>
9995
</div>
10096
</div>

inc/taxonomies.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,14 @@ function cptui_manage_taxonomies() {
10551055
'labeltext' => esc_html__( 'Metabox callback', 'custom-post-type-ui' ),
10561056
'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' ),
10571057
] );
1058+
1059+
echo $ui->get_text_input( [
1060+
'namearray' => 'cpt_custom_tax',
1061+
'name' => 'default_term',
1062+
'textvalue' => isset( $current['default_term'] ) ? esc_attr( $current['default_term'] ) : '',
1063+
'labeltext' => esc_html__( 'Default Term', 'custom-post-type-ui' ),
1064+
'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' ),
1065+
] );
10581066
?>
10591067
</table>
10601068
</div>
@@ -1278,6 +1286,7 @@ function cptui_delete_taxonomy( $data = [] ) {
12781286
$success = update_option( 'cptui_taxonomies', $taxonomies );
12791287
}
12801288
}
1289+
delete_option( "default_term_{$data['cpt_custom_tax']['name']}" );
12811290

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

1335+
// Maybe a little harsh, but we shouldn't be saving THAT frequently.
1336+
delete_option( "default_term_{$data['cpt_custom_tax']['name']}" );
1337+
13261338
if ( empty( $data['cpt_post_types'] ) ) {
13271339
add_filter( 'cptui_custom_error_message', 'cptui_empty_cpt_on_taxonomy' );
13281340
return 'error';
@@ -1397,6 +1409,7 @@ function cptui_update_taxonomy( $data = [] ) {
13971409
$rest_base = trim( $data['cpt_custom_tax']['rest_base'] );
13981410
$rest_controller_class = trim( $data['cpt_custom_tax']['rest_controller_class'] );
13991411
$show_quickpanel_bulk = ! empty( $data['cpt_custom_tax']['show_in_quick_edit'] ) ? disp_boolean( $data['cpt_custom_tax']['show_in_quick_edit'] ) : '';
1412+
$default_term = trim( $data['cpt_custom_tax']['default_term'] );
14001413

14011414
$meta_box_cb = trim( $data['cpt_custom_tax']['meta_box_cb'] );
14021415
// We may or may not need to force a boolean false keyword.
@@ -1429,6 +1442,7 @@ function cptui_update_taxonomy( $data = [] ) {
14291442
'rest_controller_class' => $rest_controller_class,
14301443
'labels' => $data['cpt_tax_labels'],
14311444
'meta_box_cb' => $meta_box_cb,
1445+
'default_term' => $default_term,
14321446
];
14331447

14341448
$taxonomies[ $data['cpt_custom_tax']['name'] ]['object_types'] = $data['cpt_post_types'];

inc/tools.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,24 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
285285
$meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? '"' . $taxonomy['meta_box_cb'] . '"' : 'false';
286286
}
287287

288+
$default_term = '';
289+
if ( ! empty( $taxonomy['default_term'] ) ) {
290+
$term_parts = explode( ',', $taxonomy['default_term'] );
291+
$default_term_start = '[';
292+
$default_term_end = ']';
293+
if ( ! empty( $term_parts[0] ) ) {
294+
$default_term .= "'name' => '" . trim( $term_parts[0] ) . "'";
295+
}
296+
if ( ! empty( $term_parts[1] ) ) {
297+
$default_term .= ", 'slug' => '" . trim( $term_parts[1] ) . "'";
298+
}
299+
if ( ! empty( $term_parts[2] ) ) {
300+
$default_term .= ", 'description' => '" . trim( $term_parts[2] ) . "'";
301+
}
302+
303+
$default_term = $default_term_start . $default_term . $default_term_end;
304+
}
305+
288306
$my_theme = wp_get_theme();
289307
$textdomain = $my_theme->get( 'TextDomain' );
290308
if ( empty( $textdomain ) ) {
@@ -327,6 +345,9 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
327345
<?php if ( ! empty( $meta_box_cb ) ) { ?>
328346
"meta_box_cb" => <?php echo $meta_box_cb; ?>,
329347
<?php } ?>
348+
<?php if ( ! empty( $default_term ) ) { ?>
349+
"default_term" => <?php echo $default_term; ?>,
350+
<?php } ?>
330351
];
331352
register_taxonomy( "<?php echo esc_html( $taxonomy['name'] ); ?>", <?php echo $post_types; ?>, $args );
332353
<?php

js/cptui.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ postboxes.add_postbox_toggles(pagenow);
7878
value = transliterate(value);
7979
value = replaceSpecialCharacters(value);
8080
if ( value !== original_value ) {
81-
$(this).attr('value', value);
81+
$(this).prop('value', value);
8282
}
8383
}
8484

@@ -131,8 +131,11 @@ postboxes.add_postbox_toggles(pagenow);
131131
}
132132

133133
function replaceSpecialCharacters(s) {
134-
135-
s = s.replace(/[^a-z0-9\s]/gi, '_');
134+
if ( 'cpt-ui_page_cptui_manage_post_types' === window.pagenow ) {
135+
s = s.replace(/[^a-z0-9\s-]/gi, '_');
136+
} else {
137+
s = s.replace(/[^a-z0-9\s]/gi, '_');
138+
}
136139

137140
return s;
138141
}
@@ -180,22 +183,6 @@ postboxes.add_postbox_toggles(pagenow);
180183
return false;
181184
});
182185

183-
$('#togglelabels').on('click',function(e){
184-
e.preventDefault();
185-
$('#labels_expand').toggleClass('toggledclosed');
186-
});
187-
$('#togglesettings').on('click',function(e) {
188-
e.preventDefault();
189-
$('#settings_expand').toggleClass('toggledclosed');
190-
});
191-
$('#labels_expand,#settings_expand').on('focus',function(e) {
192-
if ( $(this).hasClass('toggledclosed') ) {
193-
$(this).toggleClass('toggledclosed');
194-
}
195-
});
196-
$('#labels_expand legend,#settings_expand legend').on('click',function(e){
197-
$(this).parent().toggleClass('toggledclosed');
198-
});
199186
$('.cptui-help').on('click',function(e){
200187
e.preventDefault();
201188
});

0 commit comments

Comments
 (0)