Custom Post Type UI - Version 1.7.1

Version Description

  • 2019-11-06 =
  • Fixed: Random-ish redirects to the "Add new" tab for post types or taxonomies
  • Fixed: JavaScript error when trying to delete a taxonomy.
Download this release

Release Info

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

Code changes from version 1.7.0 to 1.7.1

custom-post-type-ui.php CHANGED
@@ -16,7 +16,7 @@
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
@@ -30,8 +30,8 @@ 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
  /**
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.1
20
  * Author URI: https://webdevstudios.com/
21
  * Text Domain: custom-post-type-ui
22
  * Domain Path: /languages
30
  exit;
31
  }
32
 
33
+ define( 'CPT_VERSION', '1.7.1' ); // Left for legacy purposes.
34
+ define( 'CPTUI_VERSION', '1.7.1' );
35
  define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
36
 
37
  /**
inc/post-types.php CHANGED
@@ -1945,7 +1945,7 @@ function cptui_process_post_type() {
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' ],
1945
  add_action( 'admin_notices', "cptui_{$result}_admin_notice" );
1946
  }
1947
  }
1948
+ if ( isset( $_POST['cpt_delete'] ) && empty( cptui_get_post_type_slugs() ) ) {
1949
  wp_safe_redirect(
1950
  add_query_arg(
1951
  [ 'page' => 'cptui_manage_post_types' ],
inc/taxonomies.php CHANGED
@@ -1691,7 +1691,7 @@ function cptui_process_taxonomy() {
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' ],
1691
  add_action( 'admin_notices', "cptui_{$result}_admin_notice" );
1692
  }
1693
 
1694
+ if ( isset( $_POST['cpt_delete'] ) && empty( cptui_get_taxonomy_slugs() ) ) {
1695
  wp_safe_redirect(
1696
  add_query_arg(
1697
  [ 'page' => 'cptui_manage_taxonomies' ],
js/cptui.js CHANGED
@@ -28,7 +28,13 @@ postboxes.add_postbox_toggles(pagenow);
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,
@@ -77,7 +83,7 @@ postboxes.add_postbox_toggles(pagenow);
77
  }
78
 
79
  //Displays a message if slug changes.
80
- if(undefined != original_slug) {
81
  var $slugchanged = $('#slugchanged');
82
  if(value != original_slug) {
83
  $slugchanged.removeClass('hidemessage');
@@ -231,7 +237,7 @@ postboxes.add_postbox_toggles(pagenow);
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);
28
  // Confirm our deletions
29
  $('#cpt_submit_delete').on('click',function(e) {
30
  e.preventDefault();
31
+ var msg = '';
32
+ if (typeof cptui_type_data !== 'undefined') {
33
+ msg = cptui_type_data.confirm;
34
+ } else if (typeof cptui_tax_data !== 'undefined') {
35
+ msg = cptui_tax_data.confirm;
36
+ }
37
+ var submit_delete_warning = $('<div class="cptui-submit-delete-dialog">' + msg + '</div>').appendTo('#poststuff').dialog({
38
  'dialogClass' : 'wp-dialog',
39
  'modal' : true,
40
  'autoOpen' : true,
83
  }
84
 
85
  //Displays a message if slug changes.
86
+ if(typeof original_slug !== 'undefined') {
87
  var $slugchanged = $('#slugchanged');
88
  if(value != original_slug) {
89
  $slugchanged.removeClass('hidemessage');
237
  $(fields).each( function( i, el ) {
238
  var newval = $( el ).data( 'label' );
239
  var plurality = $( el ).data( 'plurality' );
240
+ if ( 'undefined' !== newval ) {
241
  // "slug" is our placeholder from the labels.
242
  if ( 'plural' === plurality ) {
243
  newval = newval.replace(/item/gi, plural);
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(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);
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();var msg="";"undefined"!=typeof cptui_type_data?msg=cptui_type_data.confirm:"undefined"!=typeof cptui_tax_data&&(msg=cptui_tax_data.confirm);$('<div class="cptui-submit-delete-dialog">'+msg+"</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),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(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");"undefined"!==newval&&(newval="plural"===plurality?newval.replace(/item/gi,plural):newval.replace(/item/gi,singular),""===$(el).val()&&$(el).val(newval))}))})}(jQuery);
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
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
 
@@ -31,6 +31,10 @@ Official development of Custom Post Type UI is on GitHub, with official stable r
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.
@@ -144,6 +148,10 @@ Official development of Custom Post Type UI is on GitHub, with official stable r
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.
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.1
8
  License: GPL-2.0+
9
  Requires PHP: 5.6
10
 
31
 
32
  == Changelog ==
33
 
34
+ = 1.7.1 - 2019-11-06 =
35
+ * Fixed: Random-ish redirects to the "Add new" tab for post types or taxonomies
36
+ * Fixed: JavaScript error when trying to delete a taxonomy.
37
+
38
  = 1.7.0 - 2019-11-06 =
39
  * 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.
40
  * Added: Ability to disable registration of post types or taxonomies, via code filter, without deleting them completely from settings.
148
 
149
  == Upgrade Notice ==
150
 
151
+ = 1.7.1 - 2019-11-06 =
152
+ * Fixed: Random-ish redirects to the "Add new" tab for post types or taxonomies
153
+ * Fixed: JavaScript error when trying to delete a taxonomy.
154
+
155
  = 1.7.0 - 2019-11-06 =
156
  * 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.
157
  * Added: Ability to disable registration of post types or taxonomies, via code filter, without deleting them completely from settings.