Custom Post Type UI - Version 1.10.0

Version Description

  • 2021-10-04 =
  • Added: Dashicon picker with popup. - Props arshidkv12
  • Added: Tag Cloud widget support for custom taxonomies.
  • Added: Filters that allow developers to override the data fetched from our options, if they choose to.
  • Added: Ability to clear all filled in label values.
  • Fixed: Hardened up various parts of our code to ensure security.
  • Fixed: Incorrectly referenced variable from post types instead of taxonomies, for the rest_controller_class property.
Download this release

Release Info

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

Code changes from version 1.9.2 to 1.10.0

classes/class.cptui_admin_ui.php CHANGED
@@ -534,8 +534,9 @@ class cptui_admin_ui {
534
  * @return string Complete button `<input>`.
535
  */
536
  public function get_button( $args = [] ) {
537
- $value = '';
538
- $value .= '<input id="' . $args['id'] . '" class="button" type="button" value="' . $args['textvalue'] . '" />';
 
539
 
540
  return $value;
541
  }
534
  * @return string Complete button `<input>`.
535
  */
536
  public function get_button( $args = [] ) {
537
+ $value = '';
538
+ $classes = isset( $args['classes'] ) ? $args['classes'] : '';
539
+ $value .= '<input id="' . $args['id'] . '" class="button ' . $classes . '" type="button" value="' . $args['textvalue'] . '" />';
540
 
541
  return $value;
542
  }
css/cptui.css CHANGED
@@ -353,6 +353,69 @@ fieldset .cptui-help {
353
  min-width: 463px;
354
  }
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  @media screen and (min-width: 769px) {
357
  .cptui-badge {
358
  margin-top: -42px;
353
  min-width: 463px;
354
  }
355
 
356
+ .dashicon-picker-container {
357
+ position: absolute;
358
+ width: 220px;
359
+ height: 252px;
360
+ font-size: 14px;
361
+ background-color: #fff;
362
+ box-shadow: -1px 2px 5px 3px rgba(0, 0, 0, 0.41);
363
+ overflow: hidden;
364
+ padding: 5px;
365
+ box-sizing: border-box;
366
+ }
367
+
368
+ .dashicon-picker-container ul {
369
+ margin: 0 0 10px;
370
+ padding: 0;
371
+ }
372
+
373
+ .dashicon-picker-container ul .dashicons {
374
+ width: 20px;
375
+ height: 20px;
376
+ font-size: 20px;
377
+ }
378
+
379
+ .dashicon-picker-container ul li {
380
+ display: inline-block;
381
+ margin: 5px;
382
+ float: left;
383
+ }
384
+
385
+ .dashicon-picker-container ul li a {
386
+ display: block;
387
+ text-decoration: none;
388
+ color: #373737;
389
+ padding: 5px 5px;
390
+ border: 1px solid #dfdfdf;
391
+ }
392
+
393
+ .dashicon-picker-container ul li a:hover {
394
+ border-color: #999;
395
+ background: #efefef;
396
+ }
397
+
398
+ .dashicon-picker-control {
399
+ height: 32px;
400
+ }
401
+
402
+ .dashicon-picker-control a {
403
+ padding: 5px;
404
+ text-decoration: none;
405
+ line-height: 32px;
406
+ width: 25px;
407
+ }
408
+
409
+ .dashicon-picker-control a span {
410
+ display: inline;
411
+ vertical-align: middle;
412
+ }
413
+
414
+ .dashicon-picker-control input {
415
+ font-size: 12px;
416
+ width: 140px;
417
+ }
418
+
419
  @media screen and (min-width: 769px) {
420
  .cptui-badge {
421
  margin-top: -42px;
css/cptui.min.css CHANGED
@@ -1 +1 @@
1
- .posttypesui,.taxonomiesui{width:calc(100% - 300px)}.posttypesui .cptui-section:first-child,.taxonomiesui .cptui-section:first-child{margin-top:30px}.posttypesui .postbox-container,.taxonomiesui .postbox-container{width:100%}.posttypesui .postbox .toggle-indicator:before,.taxonomiesui .postbox .toggle-indicator:before{content:"\f142";display:inline-block;font:normal 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.posttypesui .postbox.closed .handlediv .toggle-indicator:before,.taxonomiesui .postbox.closed .handlediv .toggle-indicator:before{content:"\f140"}.posttypesui .postbox .hndle,.taxonomiesui .postbox .hndle{cursor:pointer}.posttypesui .required,.taxonomiesui .required{color:red}.cptui-table td.outer{vertical-align:top;width:50%}.cptui-table input[type=text]{width:75%}.cptui-table .question:hover{cursor:pointer}.cptui-table th p{font-weight:400;font-size:12px}.cptui-table .cptui-slug-details{margin-top:15px}.cptui-table #slugchanged,.cptui-table #slugexists{color:red;font-weight:700}.cptui-table #slugchanged.hidemessage,.cptui-table #slugexists.hidemessage{display:none}.cptui-support #support .question{font-size:18px;font-weight:700}.cptui-support #support .question:before{content:"\f139";display:inline-block;font:normal 25px/1 dashicons;margin-left:-25px;position:absolute;-webkit-font-smoothing:antialiased}.cptui-support #support .question.active:before{content:"\f140"}.cptui-support #support .answer{margin:10px 0 0 20px}.cptui-support #support ol li{list-style:none}.cptui-support #support li{position:relative}.cptui-field-description{font-style:italic}#cptui_select_post_type,#cptui_select_taxonomy{margin-top:15px}.cptui_post_import,.cptui_tax_import{height:200px;margin-bottom:10px;resize:vertical;width:100%}.cptui_post_type_get_code,.cptui_tax_get_code{height:300px;resize:vertical}.about-wrap .cptui-feature{overflow:visible!important;*zoom:1}.about-wrap .cptui-feature:after,.about-wrap .cptui-feature:before{content:" ";display:table}.about-wrap .cptui-feature:after{clear:both}.about-wrap h3+.cptui-feature{margin-top:0}.about-wrap .changelog h2{text-align:center}.about-wrap .feature-rest div{width:50%!important;padding-right:100px;box-sizing:border-box;margin:0!important}.about-wrap .feature-rest div.last-feature{padding-left:100px;padding-right:0}.about-wrap .feature-rest div.icon{width:0!important;padding:0;margin:0}.about-wrap .feature-rest div.icon:before{font-weight:400;width:100%;font-size:170px;line-height:125px;color:#9c5d90;display:inline-block;position:relative;text-align:center;speak:none;margin:0 0 0 -100px;content:"\e01d";-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.about-wrap .about-integrations{background:#fff;margin:20px 0;padding:1px 20px 10px}.about-wrap .changelog h4{line-height:1.4}.about-wrap .cptui-about-text{margin-bottom:1em!important;margin-right:0;max-width:calc(100% - 173px)}.email-octopus-form-row input:-ms-input-placeholder{color:#ccc}.email-octopus-form-row input::placeholder{color:#ccc}.email-octopus-form-row-hp{visibility:hidden}.cptui-intro-devblock{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}.cptui-help{color:#424242;margin-left:4px;opacity:.5;text-decoration:none;width:16px}fieldset .cptui-help{position:relative;top:4px}.cptui-help:hover{color:#0074a2;opacity:1}.cptui-help:focus{box-shadow:none}#menu_icon_preview{float:right;padding-left:8px}#menu_icon_preview img{display:block;height:20px;width:20px}.visuallyhidden{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}.cptui-spacer{display:block;margin-top:25px}.email-octopus-form-wrapper{background:#fff;margin-bottom:10px;padding:20px}.email-octopus-form-wrapper label{margin-bottom:10px}.wdsoctosignup h2{text-align:left}.wdspromos{float:right;margin-left:20px;margin-top:10px;width:275px}.wdspromos-about{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-line-pack:stretch;align-content:stretch;-ms-flex-align:start;align-items:flex-start;margin:20px 0}.wdspromos-about a:first-child,.wdspromos-about a:nth-child(2),.wdspromos-about a:nth-child(3){-ms-flex-order:0;order:0;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-item-align:auto;-ms-grid-row-align:auto;align-self:auto}.wdspromos-about p{padding:0 5px}.wdspromos-about p:first-child{padding-left:0}.wdspromos-about p:nth-child(4){padding-right:0}.no-js #cptui_choose_icon{display:none}.cptui-listings th{font-weight:700}.cptui-listings .post-type-listing th{width:16.66667%}.cptui-listings .taxonomy-listing th{width:20%}#poststuff{min-width:463px}@media screen and (min-width:769px){.cptui-badge{margin-top:-42px;height:173px;width:173px;color:#fafafa;font-weight:700;font-size:14px;text-align:center;margin-bottom:10px;background:url(../images/cptui-icon-173x173.png) no-repeat}}@media screen and (max-width:768px){.cptui-table #description{width:100%}.wdspromos-about{-ms-flex-wrap:wrap;flex-wrap:wrap}.wdspromos-about p{margin:5px auto}.wdspromos-about p:first-child{padding-left:5px}.wdspromos-about p:nth-child(4){padding-right:5px}#cptui_debug_info_email,.cptui-table td.outer{width:100%}}
1
+ .posttypesui,.taxonomiesui{width:calc(100% - 300px)}.posttypesui .cptui-section:first-child,.taxonomiesui .cptui-section:first-child{margin-top:30px}.posttypesui .postbox-container,.taxonomiesui .postbox-container{width:100%}.posttypesui .postbox .toggle-indicator:before,.taxonomiesui .postbox .toggle-indicator:before{content:"\f142";display:inline-block;font:normal 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.posttypesui .postbox.closed .handlediv .toggle-indicator:before,.taxonomiesui .postbox.closed .handlediv .toggle-indicator:before{content:"\f140"}.posttypesui .postbox .hndle,.taxonomiesui .postbox .hndle{cursor:pointer}.posttypesui .required,.taxonomiesui .required{color:red}.cptui-table td.outer{vertical-align:top;width:50%}.cptui-table input[type=text]{width:75%}.cptui-table .question:hover{cursor:pointer}.cptui-table th p{font-weight:400;font-size:12px}.cptui-table .cptui-slug-details{margin-top:15px}.cptui-table #slugchanged,.cptui-table #slugexists{color:red;font-weight:700}.cptui-table #slugchanged.hidemessage,.cptui-table #slugexists.hidemessage{display:none}.cptui-support #support .question{font-size:18px;font-weight:700}.cptui-support #support .question:before{content:"\f139";display:inline-block;font:normal 25px/1 dashicons;margin-left:-25px;position:absolute;-webkit-font-smoothing:antialiased}.cptui-support #support .question.active:before{content:"\f140"}.cptui-support #support .answer{margin:10px 0 0 20px}.cptui-support #support ol li{list-style:none}.cptui-support #support li{position:relative}.cptui-field-description{font-style:italic}#cptui_select_post_type,#cptui_select_taxonomy{margin-top:15px}.cptui_post_import,.cptui_tax_import{height:200px;margin-bottom:10px;resize:vertical;width:100%}.cptui_post_type_get_code,.cptui_tax_get_code{height:300px;resize:vertical}.about-wrap .cptui-feature{overflow:visible!important;*zoom:1}.about-wrap .cptui-feature:after,.about-wrap .cptui-feature:before{content:" ";display:table}.about-wrap .cptui-feature:after{clear:both}.about-wrap h3+.cptui-feature{margin-top:0}.about-wrap .changelog h2{text-align:center}.about-wrap .feature-rest div{width:50%!important;padding-right:100px;box-sizing:border-box;margin:0!important}.about-wrap .feature-rest div.last-feature{padding-left:100px;padding-right:0}.about-wrap .feature-rest div.icon{width:0!important;padding:0;margin:0}.about-wrap .feature-rest div.icon:before{font-weight:400;width:100%;font-size:170px;line-height:125px;color:#9c5d90;display:inline-block;position:relative;text-align:center;speak:none;margin:0 0 0 -100px;content:"\e01d";-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.about-wrap .about-integrations{background:#fff;margin:20px 0;padding:1px 20px 10px}.about-wrap .changelog h4{line-height:1.4}.about-wrap .cptui-about-text{margin-bottom:1em!important;margin-right:0;max-width:calc(100% - 173px)}.email-octopus-form-row input:-ms-input-placeholder{color:#ccc}.email-octopus-form-row input::placeholder{color:#ccc}.email-octopus-form-row-hp{visibility:hidden}.cptui-intro-devblock{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}.cptui-help{color:#424242;margin-left:4px;opacity:.5;text-decoration:none;width:16px}fieldset .cptui-help{position:relative;top:4px}.cptui-help:hover{color:#0074a2;opacity:1}.cptui-help:focus{box-shadow:none}#menu_icon_preview{float:right;padding-left:8px}#menu_icon_preview img{display:block;height:20px;width:20px}.visuallyhidden{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}.cptui-spacer{display:block;margin-top:25px}.email-octopus-form-wrapper{background:#fff;margin-bottom:10px;padding:20px}.email-octopus-form-wrapper label{margin-bottom:10px}.wdsoctosignup h2{text-align:left}.wdspromos{float:right;margin-left:20px;margin-top:10px;width:275px}.wdspromos-about{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-line-pack:stretch;align-content:stretch;-ms-flex-align:start;align-items:flex-start;margin:20px 0}.wdspromos-about a:first-child,.wdspromos-about a:nth-child(2),.wdspromos-about a:nth-child(3){-ms-flex-order:0;order:0;-ms-flex:0 1 auto;flex:0 1 auto;-ms-flex-item-align:auto;-ms-grid-row-align:auto;align-self:auto}.wdspromos-about p{padding:0 5px}.wdspromos-about p:first-child{padding-left:0}.wdspromos-about p:nth-child(4){padding-right:0}.no-js #cptui_choose_icon{display:none}.cptui-listings th{font-weight:700}.cptui-listings .post-type-listing th{width:16.66667%}.cptui-listings .taxonomy-listing th{width:20%}#poststuff{min-width:463px}.dashicon-picker-container{position:absolute;width:220px;height:252px;font-size:14px;background-color:#fff;box-shadow:-1px 2px 5px 3px rgba(0,0,0,.41);overflow:hidden;padding:5px;box-sizing:border-box}.dashicon-picker-container ul{margin:0 0 10px;padding:0}.dashicon-picker-container ul .dashicons{width:20px;height:20px;font-size:20px}.dashicon-picker-container ul li{display:inline-block;margin:5px;float:left}.dashicon-picker-container ul li a{display:block;text-decoration:none;color:#373737;padding:5px;border:1px solid #dfdfdf}.dashicon-picker-container ul li a:hover{border-color:#999;background:#efefef}.dashicon-picker-control{height:32px}.dashicon-picker-control a{padding:5px;text-decoration:none;line-height:32px;width:25px}.dashicon-picker-control a span{display:inline;vertical-align:middle}.dashicon-picker-control input{font-size:12px;width:140px}@media screen and (min-width:769px){.cptui-badge{margin-top:-42px;height:173px;width:173px;color:#fafafa;font-weight:700;font-size:14px;text-align:center;margin-bottom:10px;background:url(../images/cptui-icon-173x173.png) no-repeat}}@media screen and (max-width:768px){.cptui-table #description{width:100%}.wdspromos-about{-ms-flex-wrap:wrap;flex-wrap:wrap}.wdspromos-about p{margin:5px auto}.wdspromos-about p:first-child{padding-left:5px}.wdspromos-about p:nth-child(4){padding-right:5px}#cptui_debug_info_email,.cptui-table td.outer{width:100%}}
css/cptui.scss CHANGED
@@ -332,6 +332,69 @@ $max-tablet: "screen and (max-width: 768px)";
332
  min-width: 463px;
333
  }
334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  @media #{$min-tablet} {
336
  .cptui-badge {
337
  margin-top: -42px;
332
  min-width: 463px;
333
  }
334
 
335
+ .dashicon-picker-container {
336
+ position: absolute;
337
+ width: 220px;
338
+ height: 252px;
339
+ font-size: 14px;
340
+ background-color: #fff;
341
+ box-shadow: -1px 2px 5px 3px rgba(0, 0, 0, 0.41);
342
+ overflow: hidden;
343
+ padding: 5px;
344
+ box-sizing: border-box;
345
+
346
+ ul {
347
+ margin: 0 0 10px;
348
+ padding: 0;
349
+
350
+ .dashicons {
351
+ width: 20px;
352
+ height: 20px;
353
+ font-size: 20px;
354
+ }
355
+
356
+ li {
357
+ display: inline-block;
358
+ margin: 5px;
359
+ float: left;
360
+
361
+ a {
362
+ display: block;
363
+ text-decoration: none;
364
+ color: #373737;
365
+ padding: 5px 5px;
366
+ border: 1px solid #dfdfdf;
367
+
368
+ &:hover {
369
+ border-color: #999;
370
+ background: #efefef;
371
+ }
372
+ }
373
+ }
374
+ }
375
+ }
376
+
377
+ .dashicon-picker-control {
378
+ height: 32px;
379
+
380
+ a {
381
+ padding: 5px;
382
+ text-decoration: none;
383
+ line-height: 32px;
384
+ width: 25px;
385
+
386
+ span {
387
+ display: inline;
388
+ vertical-align: middle;
389
+ }
390
+ }
391
+
392
+ input {
393
+ font-size: 12px;
394
+ width: 140px;
395
+ }
396
+ }
397
+
398
  @media #{$min-tablet} {
399
  .cptui-badge {
400
  margin-top: -42px;
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.9.2
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.9.2' ); // Left for legacy purposes.
34
- define( 'CPTUI_VERSION', '1.9.2' );
35
  define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
36
 
37
  /**
@@ -241,6 +241,7 @@ function cptui_add_styles() {
241
 
242
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
243
  wp_register_script( 'cptui', plugins_url( "js/cptui{$min}.js", __FILE__ ), [ 'jquery', 'jquery-ui-dialog', 'postbox' ], CPTUI_VERSION, true );
 
244
  wp_register_style( 'cptui-css', plugins_url( "css/cptui{$min}.css", __FILE__ ), [ 'wp-jquery-ui-dialog' ], CPTUI_VERSION );
245
  }
246
  add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
@@ -253,12 +254,25 @@ add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
253
  * @internal
254
  */
255
  function cptui_create_custom_post_types() {
256
- $cpts = get_option( 'cptui_post_types' );
 
 
 
 
 
 
 
 
257
 
258
- if ( empty( $cpts ) ) {
259
  return;
260
  }
261
 
 
 
 
 
 
262
  /**
263
  * Fires before the start of the post type registrations.
264
  *
@@ -530,12 +544,25 @@ function cptui_register_single_post_type( $post_type = [] ) {
530
  * @internal
531
  */
532
  function cptui_create_custom_taxonomies() {
533
- $taxes = get_option( 'cptui_taxonomies' );
 
 
 
 
 
 
 
 
534
 
535
- if ( empty( $taxes ) ) {
536
  return;
537
  }
538
 
 
 
 
 
 
539
  /**
540
  * Fires before the start of the taxonomy registrations.
541
  *
@@ -663,6 +690,11 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
663
  $show_in_nav_menus = $public;
664
  }
665
 
 
 
 
 
 
666
  $show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? true : false;
667
 
668
  $show_in_quick_edit = ( ! empty( $taxonomy['show_in_quick_edit'] ) && false !== get_disp_boolean( $taxonomy['show_in_quick_edit'] ) ) ? true : false;
@@ -673,8 +705,8 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
673
  }
674
 
675
  $rest_controller_class = null;
676
- if ( ! empty( $post_type['rest_controller_class'] ) ) {
677
- $rest_controller_class = $post_type['rest_controller_class'];
678
  }
679
 
680
  $meta_box_cb = null;
@@ -705,6 +737,7 @@ function cptui_register_single_taxonomy( $taxonomy = [] ) {
705
  'show_ui' => get_disp_boolean( $taxonomy['show_ui'] ),
706
  'show_in_menu' => $show_in_menu,
707
  'show_in_nav_menus' => $show_in_nav_menus,
 
708
  'query_var' => $taxonomy['query_var'],
709
  'rewrite' => $rewrite,
710
  'show_admin_column' => $show_admin_column,
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.10.0
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.10.0' ); // Left for legacy purposes.
34
+ define( 'CPTUI_VERSION', '1.10.0' );
35
  define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
36
 
37
  /**
241
 
242
  $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
243
  wp_register_script( 'cptui', plugins_url( "js/cptui{$min}.js", __FILE__ ), [ 'jquery', 'jquery-ui-dialog', 'postbox' ], CPTUI_VERSION, true );
244
+ wp_register_script( 'dashicons-picker', plugins_url( "js/dashicons-picker{$min}.js", __FILE__ ), [ 'jquery'], '1.0.0', true );
245
  wp_register_style( 'cptui-css', plugins_url( "css/cptui{$min}.css", __FILE__ ), [ 'wp-jquery-ui-dialog' ], CPTUI_VERSION );
246
  }
247
  add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
254
  * @internal
255
  */
256
  function cptui_create_custom_post_types() {
257
+ $cpts = get_option( 'cptui_post_types', [] );
258
+ /**
259
+ * Filters an override array of post type data to be registered instead of our saved option.
260
+ *
261
+ * @since 1.10.0
262
+ *
263
+ * @param array $value Default override value.
264
+ */
265
+ $cpts_override = apply_filters( 'cptui_post_types_override', [] );
266
 
267
+ if ( empty( $cpts ) && empty( $cpts_override ) ) {
268
  return;
269
  }
270
 
271
+ // Assume good intent, and we're also not wrecking the option so things are always reversable.
272
+ if ( is_array( $cpts_override ) && ! empty( $cpts_override ) ) {
273
+ $cpts = $cpts_override;
274
+ }
275
+
276
  /**
277
  * Fires before the start of the post type registrations.
278
  *
544
  * @internal
545
  */
546
  function cptui_create_custom_taxonomies() {
547
+ $taxes = get_option( 'cptui_taxonomies', [] );
548
+ /**
549
+ * Filters an override array of taxonomy data to be registered instead of our saved option.
550
+ *
551
+ * @since 1.10.0
552
+ *
553
+ * @param array $value Default override value.
554
+ */
555
+ $taxes_override = apply_filters( 'cptui_taxonomies_override', [] );
556
 
557
+ if ( empty( $taxes ) && empty( $taxes_override ) ) {
558
  return;
559
  }
560
 
561
+ // Assume good intent, and we're also not wrecking the option so things are always reversable.
562
+ if ( is_array( $taxes_override ) && ! empty( $taxes_override ) ) {
563
+ $taxes = $taxes_override;
564
+ }
565
+
566
  /**
567
  * Fires before the start of the taxonomy registrations.
568
  *
690
  $show_in_nav_menus = $public;
691
  }
692
 
693
+ $show_tagcloud = ( ! empty( $taxonomy['show_tagcloud'] ) && false !== get_disp_boolean( $taxonomy['show_tagcloud'] ) ) ? true : false;
694
+ if ( empty( $taxonomy['show_tagcloud'] ) ) {
695
+ $show_tagcloud = get_disp_boolean( $taxonomy['show_ui'] );
696
+ }
697
+
698
  $show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? true : false;
699
 
700
  $show_in_quick_edit = ( ! empty( $taxonomy['show_in_quick_edit'] ) && false !== get_disp_boolean( $taxonomy['show_in_quick_edit'] ) ) ? true : false;
705
  }
706
 
707
  $rest_controller_class = null;
708
+ if ( ! empty( $taxonomy['rest_controller_class'] ) ) {
709
+ $rest_controller_class = $taxonomy['rest_controller_class'];
710
  }
711
 
712
  $meta_box_cb = null;
737
  'show_ui' => get_disp_boolean( $taxonomy['show_ui'] ),
738
  'show_in_menu' => $show_in_menu,
739
  'show_in_nav_menus' => $show_in_nav_menus,
740
+ 'show_tagcloud' => $show_tagcloud,
741
  'query_var' => $taxonomy['query_var'],
742
  'rewrite' => $rewrite,
743
  'show_admin_column' => $show_admin_column,
inc/about.php CHANGED
@@ -85,13 +85,8 @@ function cptui_settings() {
85
  <div class="changelog about-integrations">
86
  <div class="cptui-feature feature-section col three-col">
87
  <div class="col">
88
- <h2><?php esc_html_e( 'Built-in WPGraphQL support options.', 'custom-post-type-ui' ); ?></h2>
89
- <p><?php esc_html_e( 'If you have the WPGraphQL plugin installed and active, you will no longer need their Custom Post Type UI extension to register GraphQL support with your post types and taxonomies.', 'custom-post-type-ui' ); ?></p>
90
- <p><?php printf(
91
- esc_html__( 'Visit the %1$sWPGraphQL plugin page%2$s to acquire your own copy.', 'custom-post-type-ui' ),
92
- sprintf( '<a href="%s">', esc_url( 'https://wordpress.org/plugins/wp-graphql/' ) ),
93
- '</a>'
94
- ); ?></p>
95
  </div>
96
  </div>
97
  </div>
85
  <div class="changelog about-integrations">
86
  <div class="cptui-feature feature-section col three-col">
87
  <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>
 
 
 
 
 
90
  </div>
91
  </div>
92
  </div>
inc/post-types.php CHANGED
@@ -37,6 +37,7 @@ function cptui_post_type_enqueue_scripts() {
37
 
38
  wp_enqueue_media();
39
  wp_enqueue_script( 'cptui' );
 
40
  wp_enqueue_style( 'cptui-css' );
41
 
42
  $core = get_post_types( [ '_builtin' => true ] );
@@ -290,13 +291,14 @@ function cptui_manage_post_types() {
290
  ] );
291
 
292
  $link_text = ( 'new' === $tab ) ?
293
- esc_html__( 'Populate additional labels based on chosen labels.', 'custom-post-type-ui' ) :
294
- esc_html__( 'Populate missing labels based on chosen labels.', 'custom-post-type-ui' );
295
  echo $ui->get_tr_end();
296
  echo $ui->get_th_start() . esc_html__( 'Auto-populate labels', 'custom-post-type-ui' ) . $ui->get_th_end();
297
  echo $ui->get_td_start();
298
  ?>
299
- <a href="#" id="auto-populate"><?php echo esc_html( $link_text ); ?></a>
 
300
  <?php
301
  echo $ui->get_td_end() . $ui->get_tr_end();
302
 
@@ -1069,7 +1071,7 @@ function cptui_manage_post_types() {
1069
  'custom-post-type-ui'
1070
  ),
1071
  sprintf(
1072
- '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#menu_position" target="_blank">%s</a>',
1073
  esc_html__( 'Available options', 'custom-post-type-ui' )
1074
  )
1075
  )
@@ -1131,7 +1133,7 @@ function cptui_manage_post_types() {
1131
  'aftertext' => esc_attr__( '(Full URL for icon or Dashicon class)', 'custom-post-type-ui' ),
1132
  'helptext' => sprintf(
1133
  esc_html__( 'Image URL or %sDashicon class name%s to use for icon. Custom image should be 20px by 20px.', 'custom-post-type-ui' ),
1134
- '<a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">',
1135
  '</a>'
1136
  ),
1137
  'wrap' => false,
@@ -1139,6 +1141,14 @@ function cptui_manage_post_types() {
1139
 
1140
  echo '<div class="cptui-spacer">';
1141
 
 
 
 
 
 
 
 
 
1142
  echo $ui->get_button( [
1143
  'id' => 'cptui_choose_icon',
1144
  'textvalue' => esc_attr__( 'Choose image icon', 'custom-post-type-ui' ),
@@ -1304,7 +1314,7 @@ function cptui_manage_post_types() {
1304
  echo $ui->get_fieldset_end() . $ui->get_td_end() . $ui->get_tr_end();
1305
 
1306
  echo $ui->get_tr_start() . $ui->get_th_start() . '<label for="custom_supports">' . esc_html__( 'Custom "Supports"', 'custom-post-type-ui' ) . '</label>';
1307
- echo $ui->get_p( sprintf( esc_html__( 'Use this input to register custom "supports" values, separated by commas. Learn about this at %s', 'custom-post-type-ui' ), '<a href="http://docs.pluginize.com/article/28-third-party-support-upon-registration" target="_blank">' . esc_html__( 'Custom "Supports"', 'custom-post-type-ui' ) . '</a>' ) );
1308
  echo $ui->get_th_end() . $ui->get_td_start();
1309
  echo $ui->get_text_input( [
1310
  'namearray' => 'cpt_custom_post_type',
@@ -1529,14 +1539,12 @@ function cptui_delete_post_type( $data = [] ) {
1529
 
1530
  // Pass double data into last function despite matching values.
1531
  if ( is_string( $data ) && cptui_get_post_type_exists( $data, $data ) ) {
1532
- $data = [
1533
- 'cpt_custom_post_type' => [
1534
- 'name' => $data,
1535
- ],
1536
- ];
1537
  }
1538
 
1539
- if ( empty( $data['cpt_custom_post_type']['name'] ) ) {
1540
  return cptui_admin_notices( 'error', '', false, __( 'Please provide a post type to delete', 'custom-post-type-ui' ) );
1541
  }
1542
 
@@ -1551,9 +1559,9 @@ function cptui_delete_post_type( $data = [] ) {
1551
 
1552
  $post_types = cptui_get_post_type_data();
1553
 
1554
- if ( array_key_exists( strtolower( $data['cpt_custom_post_type']['name'] ), $post_types ) ) {
1555
 
1556
- unset( $post_types[ $data['cpt_custom_post_type']['name'] ] );
1557
 
1558
  /**
1559
  * Filters whether or not 3rd party options were saved successfully within post type deletion.
@@ -1948,10 +1956,13 @@ function cptui_process_post_type() {
1948
  $result = '';
1949
  if ( isset( $_POST['cpt_submit'] ) ) {
1950
  check_admin_referer( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
1951
- $result = cptui_update_post_type( $_POST );
 
1952
  } elseif ( isset( $_POST['cpt_delete'] ) ) {
1953
  check_admin_referer( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
1954
- $result = cptui_delete_post_type( $_POST );
 
 
1955
  add_filter( 'cptui_post_type_deleted', '__return_true' );
1956
  }
1957
 
@@ -1991,7 +2002,15 @@ function cptui_do_convert_post_type_posts() {
1991
  if ( apply_filters( 'cptui_convert_post_type_posts', false ) ) {
1992
  check_admin_referer( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
1993
 
1994
- cptui_convert_post_type_posts( sanitize_text_field( $_POST['cpt_original'] ), sanitize_text_field( $_POST['cpt_custom_post_type']['name'] ) );
 
 
 
 
 
 
 
 
1995
  }
1996
  }
1997
  add_action( 'init', 'cptui_do_convert_post_type_posts' );
@@ -2018,3 +2037,45 @@ function cptui_updated_post_type_slug_exists( $slug_exists, $post_type_slug = ''
2018
  return $slug_exists;
2019
  }
2020
  add_filter( 'cptui_post_type_slug_exists', 'cptui_updated_post_type_slug_exists', 11, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  wp_enqueue_media();
39
  wp_enqueue_script( 'cptui' );
40
+ wp_enqueue_script( 'dashicons-picker' );
41
  wp_enqueue_style( 'cptui-css' );
42
 
43
  $core = get_post_types( [ '_builtin' => true ] );
291
  ] );
292
 
293
  $link_text = ( 'new' === $tab ) ?
294
+ esc_html__( 'Populate additional labels based on chosen labels', 'custom-post-type-ui' ) :
295
+ esc_html__( 'Populate missing labels based on chosen labels', 'custom-post-type-ui' );
296
  echo $ui->get_tr_end();
297
  echo $ui->get_th_start() . esc_html__( 'Auto-populate labels', 'custom-post-type-ui' ) . $ui->get_th_end();
298
  echo $ui->get_td_start();
299
  ?>
300
+ <a href="#" id="auto-populate"><?php echo esc_html( $link_text ); ?></a> |
301
+ <a href="#" id="auto-clear"><?php esc_html_e( 'Clear labels', 'custom-post-type-ui' ); ?></a>
302
  <?php
303
  echo $ui->get_td_end() . $ui->get_tr_end();
304
 
1071
  'custom-post-type-ui'
1072
  ),
1073
  sprintf(
1074
+ '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#menu_position" target="_blank" rel="noopener">%s</a>',
1075
  esc_html__( 'Available options', 'custom-post-type-ui' )
1076
  )
1077
  )
1133
  'aftertext' => esc_attr__( '(Full URL for icon or Dashicon class)', 'custom-post-type-ui' ),
1134
  'helptext' => sprintf(
1135
  esc_html__( 'Image URL or %sDashicon class name%s to use for icon. Custom image should be 20px by 20px.', 'custom-post-type-ui' ),
1136
+ '<a href="https://developer.wordpress.org/resource/dashicons/" target="_blank" rel="noopener">',
1137
  '</a>'
1138
  ),
1139
  'wrap' => false,
1141
 
1142
  echo '<div class="cptui-spacer">';
1143
 
1144
+ echo $ui->get_button( [
1145
+ 'id' => 'cptui_choose_dashicon',
1146
+ 'classes' => 'dashicons-picker',
1147
+ 'textvalue' => esc_attr__( 'Choose dashicon', 'custom-post-type-ui' ),
1148
+ ] );
1149
+
1150
+ echo '<div class="cptui-spacer">';
1151
+
1152
  echo $ui->get_button( [
1153
  'id' => 'cptui_choose_icon',
1154
  'textvalue' => esc_attr__( 'Choose image icon', 'custom-post-type-ui' ),
1314
  echo $ui->get_fieldset_end() . $ui->get_td_end() . $ui->get_tr_end();
1315
 
1316
  echo $ui->get_tr_start() . $ui->get_th_start() . '<label for="custom_supports">' . esc_html__( 'Custom "Supports"', 'custom-post-type-ui' ) . '</label>';
1317
+ echo $ui->get_p( sprintf( esc_html__( 'Use this input to register custom "supports" values, separated by commas. Learn about this at %s', 'custom-post-type-ui' ), '<a href="http://docs.pluginize.com/article/28-third-party-support-upon-registration" target="_blank" rel="noopener">' . esc_html__( 'Custom "Supports"', 'custom-post-type-ui' ) . '</a>' ) );
1318
  echo $ui->get_th_end() . $ui->get_td_start();
1319
  echo $ui->get_text_input( [
1320
  'namearray' => 'cpt_custom_post_type',
1539
 
1540
  // Pass double data into last function despite matching values.
1541
  if ( is_string( $data ) && cptui_get_post_type_exists( $data, $data ) ) {
1542
+ $slug = $data;
1543
+ $data = [];
1544
+ $data['name'] = $slug;
 
 
1545
  }
1546
 
1547
+ if ( empty( $data['name'] ) ) {
1548
  return cptui_admin_notices( 'error', '', false, __( 'Please provide a post type to delete', 'custom-post-type-ui' ) );
1549
  }
1550
 
1559
 
1560
  $post_types = cptui_get_post_type_data();
1561
 
1562
+ if ( array_key_exists( strtolower( $data['name'] ), $post_types ) ) {
1563
 
1564
+ unset( $post_types[ $data['name'] ] );
1565
 
1566
  /**
1567
  * Filters whether or not 3rd party options were saved successfully within post type deletion.
1956
  $result = '';
1957
  if ( isset( $_POST['cpt_submit'] ) ) {
1958
  check_admin_referer( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
1959
+ $data = cptui_filtered_post_type_post_global();
1960
+ $result = cptui_update_post_type( $data );
1961
  } elseif ( isset( $_POST['cpt_delete'] ) ) {
1962
  check_admin_referer( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
1963
+
1964
+ $filtered_data = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
1965
+ $result = cptui_delete_post_type( $filtered_data );
1966
  add_filter( 'cptui_post_type_deleted', '__return_true' );
1967
  }
1968
 
2002
  if ( apply_filters( 'cptui_convert_post_type_posts', false ) ) {
2003
  check_admin_referer( 'cptui_addedit_post_type_nonce_action', 'cptui_addedit_post_type_nonce_field' );
2004
 
2005
+ $original = filter_input( INPUT_POST, 'cpt_original', FILTER_SANITIZE_STRING );
2006
+ $new = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
2007
+
2008
+ // Return early if either fails to successfully validate.
2009
+ if ( ! $original || ! $new ) {
2010
+ return;
2011
+ }
2012
+
2013
+ cptui_convert_post_type_posts( sanitize_text_field( $original ), sanitize_text_field( $new['name'] ) );
2014
  }
2015
  }
2016
  add_action( 'init', 'cptui_do_convert_post_type_posts' );
2037
  return $slug_exists;
2038
  }
2039
  add_filter( 'cptui_post_type_slug_exists', 'cptui_updated_post_type_slug_exists', 11, 3 );
2040
+
2041
+ /**
2042
+ * Sanitize and filter the $_POST global and return a reconstructed array of the parts we need.
2043
+ *
2044
+ * Used for when managing post types.
2045
+ *
2046
+ * @since 1.10.0
2047
+ * @return array
2048
+ */
2049
+ function cptui_filtered_post_type_post_global() {
2050
+ $filtered_data = [];
2051
+
2052
+ foreach(
2053
+ [
2054
+ 'cpt_custom_post_type',
2055
+ 'cpt_labels',
2056
+ 'cpt_supports',
2057
+ 'cpt_addon_taxes',
2058
+ 'update_post_types',
2059
+ ] as $item
2060
+ ) {
2061
+ $first_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
2062
+
2063
+ if ( $first_result ) {
2064
+ $filtered_data[ $item ] = $first_result;
2065
+ }
2066
+ }
2067
+
2068
+ foreach (
2069
+ [
2070
+ 'cpt_original',
2071
+ 'cpt_type_status',
2072
+ ] as $item
2073
+ ) {
2074
+ $second_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_STRING );
2075
+ if ( $second_result ) {
2076
+ $filtered_data[ $item ] = $second_result;
2077
+ }
2078
+ }
2079
+
2080
+ return $filtered_data;
2081
+ }
inc/support.php CHANGED
@@ -130,35 +130,35 @@ function cptui_support() {
130
  <li>
131
  <span tabindex="0" class="question" aria-controls="q9" aria-expanded="false"><?php esc_html_e( 'I changed my custom post type name and now I can not get to my posts. How do I get them back?', 'custom-post-type-ui' ); ?></span>
132
  <div class="answer" id="q9"><?php esc_html_e( 'You can either change the custom post type name back to the original name or try the Post Type Switcher plugin', 'custom-post-type-ui' ); ?>
133
- <a href="https://wordpress.org/plugins/post-type-switcher/" target="_blank">https://wordpress.org/extend/plugins/post-type-switcher/</a>
134
  </div>
135
  </li>
136
  <li>
137
  <span tabindex="0" class="question" aria-controls="q10" aria-expanded="false"><?php esc_html_e( 'I changed my custom post type or taxonomy slug and now I have duplicates shown. How do I remove the duplicate?', 'custom-post-type-ui' ); ?></span>
138
- <div class="answer" id="q10"><?php esc_html_e( 'Renaming the slug for a post type or taxonomy creates a new entry in our saved option which gets registered as its own post type or taxonomy. Since the settings will be mirrored from the previous slug, you will just need to delete the previous version\'s entry.', 'custom-post-type-ui' ); ?> <a href="https://wordpress.org/plugins/post-type-switcher/" target="_blank">https://wordpress.org/extend/plugins/post-type-switcher/</a></div>
139
  </li>
140
  <li>
141
  <span tabindex="0" class="question" aria-controls="q11" aria-expanded="false"><?php esc_html_e( 'I have added post thumbnail and/or post format support to my post type, but those do not appear when adding a post type post.', 'custom-post-type-ui' ); ?></span>
142
- <div class="answer" id="q11"><?php esc_html_e( 'Make sure your theme has post "post-thumbnails" theme support enabled.', 'custom-post-type-ui' ); ?> <a href="https://codex.wordpress.org/Function_Reference/add_theme_support" target="_blank">https://codex.wordpress.org/Function_Reference/add_theme_support</a></div>
143
  </li>
144
  <li>
145
  <span tabindex="0" class="question" aria-controls="q12" aria-expanded="false"><?php esc_html_e( 'Do you have any recommendations for an alternative to Visual Composer?', 'custom-post-type-ui' ); ?></span>
146
  <div class="answer" id="q12"><?php esc_html_e( 'We recommend using VelocityPage.', 'custom-post-type-ui' ); ?>
147
- <a href="https://velocitypage.com" target="_blank">https://velocitypage.com</a>
148
  </div>
149
  </li>
150
  <li>
151
  <span tabindex="0" class="question" aria-controls="q13" aria-expanded="false"><?php esc_html_e( 'Is there any way to get Custom Post Type UI-registered post types working with Visual Composer Media Grid?', 'custom-post-type-ui' ); ?></span>
152
 
153
  <div class="answer" id="q13"><?php esc_html_e( 'Please see the solution from the following forum support thread.', 'custom-post-type-ui' ); ?>
154
- <a href="https://wordpress.org/support/topic/custom-post-type-and-visual-composer-grid-block?replies=11#post-7111458" target="_blank">https://wordpress.org/support/topic/custom-post-type-and-visual-composer-grid-block?replies=11#post-7111458</a>
155
  </div>
156
  </li>
157
  <li>
158
  <span tabindex="0" class="question" aria-controls="q14" aria-expanded="false"><?php esc_html_e( 'Why can I not use dashes in post type or taxonomy slugs?', 'custom-post-type-ui' ); ?></span>
159
 
160
  <div class="answer" id="q14"><?php esc_html_e( 'Custom Post Type UI tries to make smart choices for our users, and forcing underscores is one of them. Please see the tutorial at the following URL for how to get dashes in your permalink urls while continuing to use underscores for the actual slug.', 'custom-post-type-ui' ); ?>
161
- <a href="http://docs.pluginize.com/article/135-dashes-in-post-type-taxonomy-slugs-for-url-seo" target="_blank">http://docs.pluginize.com/article/135-dashes-in-post-type-taxonomy-slugs-for-url-seo</a>
162
  </div>
163
  </li>
164
  </ol>
@@ -174,7 +174,7 @@ function cptui_support() {
174
  <?php
175
  printf(
176
  esc_html__( 'Please visit the %sTemplate Hierarchy%s page on the WordPress codex for details about available templates.', 'custom-post-type-ui' ),
177
- '<a href="https://codex.wordpress.org/Template_Hierarchy" target="_blank">',
178
  '</a>'
179
  ); ?>
180
  </div>
@@ -189,7 +189,7 @@ function cptui_support() {
189
  'https://pluginize.com/plugins/custom-post-type-ui-extended/?utm_source=faq&utm_medium=text&utm_campaign=cptui',
190
  'Custom Post Type UI Extended'
191
  ),
192
- '<a href="https://codex.wordpress.org/Class_Reference/WP_Query" target="_blank">WP_Query</a>'
193
  ); ?>
194
  </div>
195
  </li>
@@ -199,7 +199,7 @@ function cptui_support() {
199
  <?php
200
  printf(
201
  esc_html__( 'You will need to add your newly created post type to the types that the category and tag archives query for. You can see a tutorial on how to do that at %s', 'custom-post-type-ui' ),
202
- '<a href="http://docs.pluginize.com/article/17-post-types-in-category-tag-archives" target="_blank">http://docs.pluginize.com/article/17-post-types-in-category-tag-archives</a>'
203
  ); ?> </div>
204
  </li>
205
  <li>
@@ -208,7 +208,7 @@ function cptui_support() {
208
  <?php
209
  printf(
210
  esc_html__( 'Please visit the %sPost Type Templates in 4.7%s post on the Make WordPress Core blog for details about setting templates for multiple post types.', 'custom-post-type-ui' ),
211
- '<a href="https://make.wordpress.org/core/2016/11/03/post-type-templates-in-4-7/" target="_blank">',
212
  '</a>'
213
  ); ?>
214
  </div>
@@ -223,8 +223,8 @@ function cptui_support() {
223
  <div class="answer" id="q19">
224
  <?php
225
  printf(
226
- esc_html__( 'We recommend checking out %s, the latest iteration of "Custom Metaboxes and Fields for WordPress". Both are maintained by WebDevStudios.', 'custom-post-type-ui' ),
227
- '<a href="https://wordpress.org/plugins/cmb2/" target="_blank">CMB2</a>'
228
  ); ?>
229
  </div>
230
  </li>
@@ -234,7 +234,7 @@ function cptui_support() {
234
  <?php
235
  printf(
236
  esc_html__( 'Check out the %s function for documentation and usage examples.', 'custom-post-type-ui' ),
237
- '<a href="https://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type" target="_blank">register_taxonomy_for_object_type()</a>'
238
  ); ?>
239
  </div>
240
  </li>
@@ -245,16 +245,16 @@ function cptui_support() {
245
  printf(
246
  esc_html__( '%s has an excellent %spost%s introducing users to the %sPosts 2 Posts%s plugin that should be a good start.', 'custom-post-type-ui' ),
247
  'Pippin Williamson',
248
- '<a href="https://pippinsplugins.com/introduction-posts-2-posts-plugin/" target="_blank">',
249
  '</a>',
250
- '<a href="https://wordpress.org/plugins/posts-to-posts/" target="_blank">',
251
  '</a>'
252
  ); ?></div>
253
  </li>
254
  <li>
255
  <span tabindex="0" class="question" aria-controls="q22" aria-expanded="false"><?php esc_html_e( 'Is there any function reference list?', 'custom-post-type-ui' ); ?></span>
256
  <div class="answer" id="q22"><?php printf( esc_html__( '%s has compiled a nice list of functions used by our plugin. Note not all will be useful as they are attached to hooks.', 'custom-post-type-ui' ),
257
- '<a href="http://hookr.io/plugins/custom-post-type-ui/" target="_blank">Hookr.io</a>' ); ?></div>
258
  </li>
259
  <li>
260
  <span tabindex="0" class="question" aria-controls="q23" aria-expanded="false"><?php esc_html_e( 'How do I filter the "enter title here" text in the post editor screen?', 'custom-post-type-ui' ); ?></span>
@@ -272,7 +272,7 @@ add_filter( 'enter_title_here', 'my_custom_title_text' );
272
  <span tabindex="0" class="question" aria-controls="q24" aria-expanded="false"><?php esc_html_e( 'Any help with customizing capabilities?', 'custom-post-type-ui' ); ?></span>
273
  <div class="answer" id="q24">
274
  <p><?php printf( esc_html__( 'We recommend %s for some extended customization and addition of extra fields regarding roles and capabilities.', 'custom-post-type-ui' ),
275
- '<a href="https://github.com/tw2113/custom-post-type-ui-capabilities" target="_blank">Custom Post Type UI Capabilities on GitHub</a>' ); ?></p>
276
  </div>
277
  </li>
278
  </ol>
130
  <li>
131
  <span tabindex="0" class="question" aria-controls="q9" aria-expanded="false"><?php esc_html_e( 'I changed my custom post type name and now I can not get to my posts. How do I get them back?', 'custom-post-type-ui' ); ?></span>
132
  <div class="answer" id="q9"><?php esc_html_e( 'You can either change the custom post type name back to the original name or try the Post Type Switcher plugin', 'custom-post-type-ui' ); ?>
133
+ <a href="https://wordpress.org/plugins/post-type-switcher/" target="_blank" rel="noopener">https://wordpress.org/extend/plugins/post-type-switcher/</a>
134
  </div>
135
  </li>
136
  <li>
137
  <span tabindex="0" class="question" aria-controls="q10" aria-expanded="false"><?php esc_html_e( 'I changed my custom post type or taxonomy slug and now I have duplicates shown. How do I remove the duplicate?', 'custom-post-type-ui' ); ?></span>
138
+ <div class="answer" id="q10"><?php esc_html_e( 'Renaming the slug for a post type or taxonomy creates a new entry in our saved option which gets registered as its own post type or taxonomy. Since the settings will be mirrored from the previous slug, you will just need to delete the previous version\'s entry.', 'custom-post-type-ui' ); ?> <a href="https://wordpress.org/plugins/post-type-switcher/" target="_blank" rel="noopener">https://wordpress.org/extend/plugins/post-type-switcher/</a></div>
139
  </li>
140
  <li>
141
  <span tabindex="0" class="question" aria-controls="q11" aria-expanded="false"><?php esc_html_e( 'I have added post thumbnail and/or post format support to my post type, but those do not appear when adding a post type post.', 'custom-post-type-ui' ); ?></span>
142
+ <div class="answer" id="q11"><?php esc_html_e( 'Make sure your theme has post "post-thumbnails" theme support enabled.', 'custom-post-type-ui' ); ?> <a href="https://codex.wordpress.org/Function_Reference/add_theme_support" target="_blank" rel="noopener">https://codex.wordpress.org/Function_Reference/add_theme_support</a></div>
143
  </li>
144
  <li>
145
  <span tabindex="0" class="question" aria-controls="q12" aria-expanded="false"><?php esc_html_e( 'Do you have any recommendations for an alternative to Visual Composer?', 'custom-post-type-ui' ); ?></span>
146
  <div class="answer" id="q12"><?php esc_html_e( 'We recommend using VelocityPage.', 'custom-post-type-ui' ); ?>
147
+ <a href="https://velocitypage.com" target="_blank" rel="noopener">https://velocitypage.com</a>
148
  </div>
149
  </li>
150
  <li>
151
  <span tabindex="0" class="question" aria-controls="q13" aria-expanded="false"><?php esc_html_e( 'Is there any way to get Custom Post Type UI-registered post types working with Visual Composer Media Grid?', 'custom-post-type-ui' ); ?></span>
152
 
153
  <div class="answer" id="q13"><?php esc_html_e( 'Please see the solution from the following forum support thread.', 'custom-post-type-ui' ); ?>
154
+ <a href="https://wordpress.org/support/topic/custom-post-type-and-visual-composer-grid-block?replies=11#post-7111458" target="_blank" rel="noopener">https://wordpress.org/support/topic/custom-post-type-and-visual-composer-grid-block?replies=11#post-7111458</a>
155
  </div>
156
  </li>
157
  <li>
158
  <span tabindex="0" class="question" aria-controls="q14" aria-expanded="false"><?php esc_html_e( 'Why can I not use dashes in post type or taxonomy slugs?', 'custom-post-type-ui' ); ?></span>
159
 
160
  <div class="answer" id="q14"><?php esc_html_e( 'Custom Post Type UI tries to make smart choices for our users, and forcing underscores is one of them. Please see the tutorial at the following URL for how to get dashes in your permalink urls while continuing to use underscores for the actual slug.', 'custom-post-type-ui' ); ?>
161
+ <a href="http://docs.pluginize.com/article/135-dashes-in-post-type-taxonomy-slugs-for-url-seo" target="_blank" rel="noopener">http://docs.pluginize.com/article/135-dashes-in-post-type-taxonomy-slugs-for-url-seo</a>
162
  </div>
163
  </li>
164
  </ol>
174
  <?php
175
  printf(
176
  esc_html__( 'Please visit the %sTemplate Hierarchy%s page on the WordPress codex for details about available templates.', 'custom-post-type-ui' ),
177
+ '<a href="https://codex.wordpress.org/Template_Hierarchy" target="_blank" rel="noopener">',
178
  '</a>'
179
  ); ?>
180
  </div>
189
  'https://pluginize.com/plugins/custom-post-type-ui-extended/?utm_source=faq&utm_medium=text&utm_campaign=cptui',
190
  'Custom Post Type UI Extended'
191
  ),
192
+ '<a href="https://codex.wordpress.org/Class_Reference/WP_Query" target="_blank" rel="noopener">WP_Query</a>'
193
  ); ?>
194
  </div>
195
  </li>
199
  <?php
200
  printf(
201
  esc_html__( 'You will need to add your newly created post type to the types that the category and tag archives query for. You can see a tutorial on how to do that at %s', 'custom-post-type-ui' ),
202
+ '<a href="http://docs.pluginize.com/article/17-post-types-in-category-tag-archives" target="_blank" rel="noopener">http://docs.pluginize.com/article/17-post-types-in-category-tag-archives</a>'
203
  ); ?> </div>
204
  </li>
205
  <li>
208
  <?php
209
  printf(
210
  esc_html__( 'Please visit the %sPost Type Templates in 4.7%s post on the Make WordPress Core blog for details about setting templates for multiple post types.', 'custom-post-type-ui' ),
211
+ '<a href="https://make.wordpress.org/core/2016/11/03/post-type-templates-in-4-7/" target="_blank" rel="noopener">',
212
  '</a>'
213
  ); ?>
214
  </div>
223
  <div class="answer" id="q19">
224
  <?php
225
  printf(
226
+ esc_html__( 'We recommend checking out %s, the latest iteration of "CMB2". Both are supported by WebDevStudios.', 'custom-post-type-ui' ),
227
+ '<a href="https://wordpress.org/plugins/cmb2/" target="_blank" rel="noopener">CMB2</a>'
228
  ); ?>
229
  </div>
230
  </li>
234
  <?php
235
  printf(
236
  esc_html__( 'Check out the %s function for documentation and usage examples.', 'custom-post-type-ui' ),
237
+ '<a href="https://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type" target="_blank" rel="noopener">register_taxonomy_for_object_type()</a>'
238
  ); ?>
239
  </div>
240
  </li>
245
  printf(
246
  esc_html__( '%s has an excellent %spost%s introducing users to the %sPosts 2 Posts%s plugin that should be a good start.', 'custom-post-type-ui' ),
247
  'Pippin Williamson',
248
+ '<a href="https://pippinsplugins.com/introduction-posts-2-posts-plugin/" target="_blank" rel="noopener">',
249
  '</a>',
250
+ '<a href="https://wordpress.org/plugins/posts-to-posts/" target="_blank" rel="noopener">',
251
  '</a>'
252
  ); ?></div>
253
  </li>
254
  <li>
255
  <span tabindex="0" class="question" aria-controls="q22" aria-expanded="false"><?php esc_html_e( 'Is there any function reference list?', 'custom-post-type-ui' ); ?></span>
256
  <div class="answer" id="q22"><?php printf( esc_html__( '%s has compiled a nice list of functions used by our plugin. Note not all will be useful as they are attached to hooks.', 'custom-post-type-ui' ),
257
+ '<a href="http://hookr.io/plugins/custom-post-type-ui/" target="_blank" rel="noopener">Hookr.io</a>' ); ?></div>
258
  </li>
259
  <li>
260
  <span tabindex="0" class="question" aria-controls="q23" aria-expanded="false"><?php esc_html_e( 'How do I filter the "enter title here" text in the post editor screen?', 'custom-post-type-ui' ); ?></span>
272
  <span tabindex="0" class="question" aria-controls="q24" aria-expanded="false"><?php esc_html_e( 'Any help with customizing capabilities?', 'custom-post-type-ui' ); ?></span>
273
  <div class="answer" id="q24">
274
  <p><?php printf( esc_html__( 'We recommend %s for some extended customization and addition of extra fields regarding roles and capabilities.', 'custom-post-type-ui' ),
275
+ '<a href="https://github.com/tw2113/custom-post-type-ui-capabilities" target="_blank" rel="noopener">Custom Post Type UI Capabilities on GitHub</a>' ); ?></p>
276
  </div>
277
  </li>
278
  </ol>
inc/taxonomies.php CHANGED
@@ -298,14 +298,15 @@ function cptui_manage_taxonomies() {
298
 
299
 
300
  $link_text = ( 'new' === $tab ) ?
301
- esc_html__( 'Populate additional labels based on chosen labels.', 'custom-post-type-ui' ) :
302
- esc_html__( 'Populate missing labels based on chosen labels.', 'custom-post-type-ui' );
303
  echo $ui->get_tr_end();
304
  echo $ui->get_th_start() . esc_html__( 'Auto-populate labels', 'custom-post-type-ui' ) . $ui->get_th_end();
305
  echo $ui->get_td_start();
306
 
307
  ?>
308
- <a href="#" id="auto-populate"><?php echo esc_html( $link_text ); ?></a>
 
309
  <?php
310
 
311
  echo $ui->get_td_end() . $ui->get_tr_end();
@@ -1039,6 +1040,29 @@ function cptui_manage_taxonomies() {
1039
  'textvalue' => isset( $current['rest_controller_class'] ) ? esc_attr( $current['rest_controller_class'] ) : '',
1040
  ] );
1041
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1042
  $select = [
1043
  'options' => [
1044
  [
@@ -1260,15 +1284,13 @@ function cptui_get_current_taxonomy( $taxonomy_deleted = false ) {
1260
  function cptui_delete_taxonomy( $data = [] ) {
1261
 
1262
  if ( is_string( $data ) && taxonomy_exists( $data ) ) {
1263
- $data = [
1264
- 'cpt_custom_tax' => [
1265
- 'name' => $data,
1266
- ],
1267
- ];
1268
  }
1269
 
1270
  // Check if they selected one to delete.
1271
- if ( empty( $data['cpt_custom_tax']['name'] ) ) {
1272
  return cptui_admin_notices( 'error', '', false, esc_html__( 'Please provide a taxonomy to delete', 'custom-post-type-ui' ) );
1273
  }
1274
 
@@ -1283,9 +1305,9 @@ function cptui_delete_taxonomy( $data = [] ) {
1283
 
1284
  $taxonomies = cptui_get_taxonomy_data();
1285
 
1286
- if ( array_key_exists( strtolower( $data['cpt_custom_tax']['name'] ), $taxonomies ) ) {
1287
 
1288
- unset( $taxonomies[ $data['cpt_custom_tax']['name'] ] );
1289
 
1290
  /**
1291
  * Filters whether or not 3rd party options were saved successfully within taxonomy deletion.
@@ -1300,7 +1322,7 @@ function cptui_delete_taxonomy( $data = [] ) {
1300
  $success = update_option( 'cptui_taxonomies', $taxonomies );
1301
  }
1302
  }
1303
- delete_option( "default_term_{$data['cpt_custom_tax']['name']}" );
1304
 
1305
  /**
1306
  * Fires after a taxonomy is deleted from our saved options.
@@ -1451,6 +1473,7 @@ function cptui_update_taxonomy( $data = [] ) {
1451
  'rewrite_hierarchical' => $data['cpt_custom_tax']['rewrite_hierarchical'],
1452
  'show_admin_column' => disp_boolean( $data['cpt_custom_tax']['show_admin_column'] ),
1453
  'show_in_rest' => disp_boolean( $data['cpt_custom_tax']['show_in_rest'] ),
 
1454
  'show_in_quick_edit' => $show_quickpanel_bulk,
1455
  'rest_base' => $rest_base,
1456
  'rest_controller_class' => $rest_controller_class,
@@ -1721,10 +1744,13 @@ function cptui_process_taxonomy() {
1721
  $result = '';
1722
  if ( isset( $_POST['cpt_submit'] ) ) {
1723
  check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
1724
- $result = cptui_update_taxonomy( $_POST );
 
1725
  } elseif ( isset( $_POST['cpt_delete'] ) ) {
1726
  check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
1727
- $result = cptui_delete_taxonomy( $_POST );
 
 
1728
  add_filter( 'cptui_taxonomy_deleted', '__return_true' );
1729
  }
1730
 
@@ -1763,7 +1789,15 @@ function cptui_do_convert_taxonomy_terms() {
1763
  if ( apply_filters( 'cptui_convert_taxonomy_terms', false ) ) {
1764
  check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
1765
 
1766
- cptui_convert_taxonomy_terms( sanitize_text_field( $_POST['tax_original'] ), sanitize_text_field( $_POST['cpt_custom_tax']['name'] ) );
 
 
 
 
 
 
 
 
1767
  }
1768
  }
1769
  add_action( 'init', 'cptui_do_convert_taxonomy_terms' );
@@ -1789,3 +1823,44 @@ function cptui_updated_taxonomy_slug_exists( $slug_exists, $taxonomy_slug = '',
1789
  return $slug_exists;
1790
  }
1791
  add_filter( 'cptui_taxonomy_slug_exists', 'cptui_updated_taxonomy_slug_exists', 11, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
 
299
 
300
  $link_text = ( 'new' === $tab ) ?
301
+ esc_html__( 'Populate additional labels based on chosen labels', 'custom-post-type-ui' ) :
302
+ esc_html__( 'Populate missing labels based on chosen labels', 'custom-post-type-ui' );
303
  echo $ui->get_tr_end();
304
  echo $ui->get_th_start() . esc_html__( 'Auto-populate labels', 'custom-post-type-ui' ) . $ui->get_th_end();
305
  echo $ui->get_td_start();
306
 
307
  ?>
308
+ <a href="#" id="auto-populate"><?php echo esc_html( $link_text ); ?></a> |
309
+ <a href="#" id="auto-clear"><?php esc_html_e( 'Clear labels', 'custom-post-type-ui' ); ?></a>
310
  <?php
311
 
312
  echo $ui->get_td_end() . $ui->get_tr_end();
1040
  'textvalue' => isset( $current['rest_controller_class'] ) ? esc_attr( $current['rest_controller_class'] ) : '',
1041
  ] );
1042
 
1043
+ $select = [
1044
+ 'options' => [
1045
+ [
1046
+ 'attr' => '0',
1047
+ 'text' => esc_attr__( 'False', 'custom-post-type-ui' ),
1048
+ 'default' => 'false',
1049
+ ],
1050
+ [
1051
+ 'attr' => '1',
1052
+ 'text' => esc_attr__( 'True', 'custom-post-type-ui' ),
1053
+ ],
1054
+ ],
1055
+ ];
1056
+ $selected = ( isset( $current ) && ! empty( $current['show_tagcloud'] ) ) ? disp_boolean( $current['show_tagcloud'] ) : '';
1057
+ $select['selected'] = ! empty( $selected ) ? $current['show_tagcloud'] : '';
1058
+ echo $ui->get_select_input( [
1059
+ 'namearray' => 'cpt_custom_tax',
1060
+ 'name' => 'show_tagcloud',
1061
+ 'labeltext' => esc_html__( 'Show in tag cloud.', 'custom-post-type-ui' ),
1062
+ 'aftertext' => esc_html__( '(default: inherited from "show_ui") Whether to list the taxonomy in the Tag Cloud Widget controls.', 'custom-post-type-ui' ),
1063
+ 'selections' => $select,
1064
+ ] );
1065
+
1066
  $select = [
1067
  'options' => [
1068
  [
1284
  function cptui_delete_taxonomy( $data = [] ) {
1285
 
1286
  if ( is_string( $data ) && taxonomy_exists( $data ) ) {
1287
+ $slug = $data;
1288
+ $data = [];
1289
+ $data['name'] = $slug;
 
 
1290
  }
1291
 
1292
  // Check if they selected one to delete.
1293
+ if ( empty( $data['name'] ) ) {
1294
  return cptui_admin_notices( 'error', '', false, esc_html__( 'Please provide a taxonomy to delete', 'custom-post-type-ui' ) );
1295
  }
1296
 
1305
 
1306
  $taxonomies = cptui_get_taxonomy_data();
1307
 
1308
+ if ( array_key_exists( strtolower( $data['name'] ), $taxonomies ) ) {
1309
 
1310
+ unset( $taxonomies[ $data['name'] ] );
1311
 
1312
  /**
1313
  * Filters whether or not 3rd party options were saved successfully within taxonomy deletion.
1322
  $success = update_option( 'cptui_taxonomies', $taxonomies );
1323
  }
1324
  }
1325
+ delete_option( "default_term_{$data['name']}" );
1326
 
1327
  /**
1328
  * Fires after a taxonomy is deleted from our saved options.
1473
  'rewrite_hierarchical' => $data['cpt_custom_tax']['rewrite_hierarchical'],
1474
  'show_admin_column' => disp_boolean( $data['cpt_custom_tax']['show_admin_column'] ),
1475
  'show_in_rest' => disp_boolean( $data['cpt_custom_tax']['show_in_rest'] ),
1476
+ 'show_tagcloud' => disp_boolean( $data['cpt_custom_tax']['show_tagcloud'] ),
1477
  'show_in_quick_edit' => $show_quickpanel_bulk,
1478
  'rest_base' => $rest_base,
1479
  'rest_controller_class' => $rest_controller_class,
1744
  $result = '';
1745
  if ( isset( $_POST['cpt_submit'] ) ) {
1746
  check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
1747
+ $data = cptui_filtered_taxonomy_post_global();
1748
+ $result = cptui_update_taxonomy( $data );
1749
  } elseif ( isset( $_POST['cpt_delete'] ) ) {
1750
  check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
1751
+
1752
+ $filtered_data = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
1753
+ $result = cptui_delete_taxonomy( $filtered_data );
1754
  add_filter( 'cptui_taxonomy_deleted', '__return_true' );
1755
  }
1756
 
1789
  if ( apply_filters( 'cptui_convert_taxonomy_terms', false ) ) {
1790
  check_admin_referer( 'cptui_addedit_taxonomy_nonce_action', 'cptui_addedit_taxonomy_nonce_field' );
1791
 
1792
+ $original = filter_input( INPUT_POST, 'tax_original', FILTER_SANITIZE_STRING );
1793
+ $new = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
1794
+
1795
+ // Return early if either fails to successfully validate.
1796
+ if ( ! $original || ! $new ) {
1797
+ return;
1798
+ }
1799
+
1800
+ cptui_convert_taxonomy_terms( sanitize_text_field( $original ), sanitize_text_field( $new['name'] ) );
1801
  }
1802
  }
1803
  add_action( 'init', 'cptui_do_convert_taxonomy_terms' );
1823
  return $slug_exists;
1824
  }
1825
  add_filter( 'cptui_taxonomy_slug_exists', 'cptui_updated_taxonomy_slug_exists', 11, 3 );
1826
+
1827
+ /**
1828
+ * Sanitize and filter the $_POST global and return a reconstructed array of the parts we need.
1829
+ *
1830
+ * Used for when managing taxonomies.
1831
+ *
1832
+ * @since 1.10.0
1833
+ * @return array
1834
+ */
1835
+ function cptui_filtered_taxonomy_post_global() {
1836
+ $filtered_data = [];
1837
+
1838
+ foreach (
1839
+ [
1840
+ 'cpt_custom_tax',
1841
+ 'cpt_tax_labels',
1842
+ 'cpt_post_types',
1843
+ 'update_taxonomy',
1844
+ ] as $item
1845
+ ) {
1846
+ $first_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
1847
+
1848
+ if ( $first_result ) {
1849
+ $filtered_data[ $item ] = $first_result;
1850
+ }
1851
+ }
1852
+
1853
+ foreach (
1854
+ [
1855
+ 'tax_original',
1856
+ 'cpt_tax_status',
1857
+ ] as $item
1858
+ ) {
1859
+ $second_result = filter_input( INPUT_POST, $item, FILTER_SANITIZE_STRING );
1860
+ if ( $second_result ) {
1861
+ $filtered_data[ $item ] = $second_result;
1862
+ }
1863
+ }
1864
+
1865
+ return $filtered_data;
1866
+ }
inc/tools.php CHANGED
@@ -128,7 +128,7 @@ add_filter( 'cptui_get_tabs', 'cptui_tools_tabs', 10, 2 );
128
  */
129
  function cptui_tools() {
130
 
131
- $tab = '';
132
  if ( ! empty( $_GET ) ) {
133
  if ( ! empty( $_GET['action'] ) && 'taxonomies' === $_GET['action'] ) {
134
  $tab = 'taxonomies';
@@ -136,8 +136,6 @@ function cptui_tools() {
136
  $tab = 'get_code';
137
  } elseif ( ! empty( $_GET['action'] ) && 'debuginfo' === $_GET['action'] ) {
138
  $tab = 'debuginfo';
139
- } else {
140
- $tab = 'post_types';
141
  }
142
  }
143
 
@@ -266,6 +264,7 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) {
266
  $public = isset( $taxonomy['public'] ) ? disp_boolean( $taxonomy['public'] ) : 'true';
267
  $publicly_queryable = isset( $taxonomy['publicly_queryable'] ) ? disp_boolean( $taxonomy['publicly_queryable'] ) : disp_boolean( $taxonomy['public'] );
268
  $show_in_quick_edit = isset( $taxonomy['show_in_quick_edit'] ) ? disp_boolean( $taxonomy['show_in_quick_edit'] ) : disp_boolean( $taxonomy['show_ui'] );
 
269
 
270
  $show_in_menu = ( ! empty( $taxonomy['show_in_menu'] ) && false !== get_disp_boolean( $taxonomy['show_in_menu'] ) ) ? 'true' : 'false';
271
  if ( empty( $taxonomy['show_in_menu'] ) ) {
@@ -343,6 +342,7 @@ foreach ( $taxonomy['labels'] as $key => $label ) {
343
  "rewrite" => <?php echo $rewrite; ?>,
344
  "show_admin_column" => <?php echo $taxonomy['show_admin_column']; ?>,
345
  "show_in_rest" => <?php echo $show_in_rest; ?>,
 
346
  "rest_base" => "<?php echo $rest_base; ?>",
347
  "rest_controller_class" => "<?php echo $rest_controller_class; ?>",
348
  "show_in_quick_edit" => <?php echo $show_in_quick_edit; ?>,
@@ -617,7 +617,7 @@ function cptui_get_single_post_type_registery( $post_type = [] ) {
617
  * @return mixed false on nothing to do, otherwise void.
618
  */
619
  function cptui_import_types_taxes_settings( $postdata = [] ) {
620
- if ( ! isset( $postdata['cptui_post_import'] ) && ! isset( $postdata['cptui_tax_import'] ) ) {
621
  return false;
622
  }
623
 
@@ -659,13 +659,15 @@ function cptui_import_types_taxes_settings( $postdata = [] ) {
659
  $postdata['cptui_tax_import'] = $third_party_taxonomy_data;
660
  }
661
 
662
- if ( ! empty( $postdata['cptui_post_import'] ) ) {
663
- $cpt_data = stripslashes_deep( trim( $postdata['cptui_post_import'] ) );
664
- $settings = json_decode( $cpt_data, true );
 
 
665
 
666
  // Add support to delete settings outright, without accessing database.
667
  // Doing double check to protect.
668
- if ( null === $settings && '{""}' === $cpt_data ) {
669
 
670
  /**
671
  * Filters whether or not 3rd party options were deleted successfully within post type import.
@@ -706,13 +708,15 @@ function cptui_import_types_taxes_settings( $postdata = [] ) {
706
  if ( $success ) {
707
  $status = 'import_success';
708
  }
709
- } elseif ( ! empty( $postdata['cptui_tax_import'] ) ) {
710
- $tax_data = stripslashes_deep( trim( $postdata['cptui_tax_import'] ) );
711
- $settings = json_decode( $tax_data, true );
712
 
 
 
 
713
  // Add support to delete settings outright, without accessing database.
714
  // Doing double check to protect.
715
- if ( null === $settings && '{""}' === $tax_data ) {
716
 
717
  /**
718
  * Filters whether or not 3rd party options were deleted successfully within taxonomy import.
@@ -974,18 +978,16 @@ function cptui_render_debuginfo_section() {
974
  * @param string $tab Current tab to display.
975
  */
976
  function cptui_render_tools( $tab ) {
977
- if ( isset( $tab ) ) {
978
- if ( 'post_types' === $tab || 'taxonomies' === $tab ) {
979
- cptui_render_posttypes_taxonomies_section();
980
- }
981
 
982
- if ( 'get_code' === $tab ) {
983
- cptui_render_getcode_section();
984
- }
985
 
986
- if ( 'debuginfo' === $tab ) {
987
- cptui_render_debuginfo_section();
988
- }
989
  }
990
  }
991
  add_action( 'cptui_tools_sections', 'cptui_render_tools' );
@@ -1001,7 +1003,42 @@ function cptui_do_import_types_taxes() {
1001
  ( ! empty( $_POST['cptui_post_import'] ) && isset( $_POST['cptui_post_import'] ) ) ||
1002
  ( ! empty( $_POST['cptui_tax_import'] ) && isset( $_POST['cptui_tax_import'] ) )
1003
  ) {
1004
- $success = cptui_import_types_taxes_settings( $_POST );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1005
  add_action( 'admin_notices', "cptui_{$success}_admin_notice" );
1006
  }
1007
  }
128
  */
129
  function cptui_tools() {
130
 
131
+ $tab = 'post_types';
132
  if ( ! empty( $_GET ) ) {
133
  if ( ! empty( $_GET['action'] ) && 'taxonomies' === $_GET['action'] ) {
134
  $tab = 'taxonomies';
136
  $tab = 'get_code';
137
  } elseif ( ! empty( $_GET['action'] ) && 'debuginfo' === $_GET['action'] ) {
138
  $tab = 'debuginfo';
 
 
139
  }
140
  }
141
 
264
  $public = isset( $taxonomy['public'] ) ? disp_boolean( $taxonomy['public'] ) : 'true';
265
  $publicly_queryable = isset( $taxonomy['publicly_queryable'] ) ? disp_boolean( $taxonomy['publicly_queryable'] ) : disp_boolean( $taxonomy['public'] );
266
  $show_in_quick_edit = isset( $taxonomy['show_in_quick_edit'] ) ? disp_boolean( $taxonomy['show_in_quick_edit'] ) : disp_boolean( $taxonomy['show_ui'] );
267
+ $show_tagcloud = isset( $taxonomy['show_tagcloud'] ) ? disp_boolean( $taxonomy['show_tagcloud'] ) : disp_boolean( $taxonomy['show_ui'] );
268
 
269
  $show_in_menu = ( ! empty( $taxonomy['show_in_menu'] ) && false !== get_disp_boolean( $taxonomy['show_in_menu'] ) ) ? 'true' : 'false';
270
  if ( empty( $taxonomy['show_in_menu'] ) ) {
342
  "rewrite" => <?php echo $rewrite; ?>,
343
  "show_admin_column" => <?php echo $taxonomy['show_admin_column']; ?>,
344
  "show_in_rest" => <?php echo $show_in_rest; ?>,
345
+ "show_tagcloud" => <?php echo $show_tagcloud; ?>,
346
  "rest_base" => "<?php echo $rest_base; ?>",
347
  "rest_controller_class" => "<?php echo $rest_controller_class; ?>",
348
  "show_in_quick_edit" => <?php echo $show_in_quick_edit; ?>,
617
  * @return mixed false on nothing to do, otherwise void.
618
  */
619
  function cptui_import_types_taxes_settings( $postdata = [] ) {
620
+ if ( ! isset( $postdata['cptui_post_import'] ) && ! isset( $postdata['cptui_tax_import'] ) && ! array_key_exists( 'delete', $postdata ) ) {
621
  return false;
622
  }
623
 
659
  $postdata['cptui_tax_import'] = $third_party_taxonomy_data;
660
  }
661
 
662
+ if ( ! empty( $postdata['cptui_post_import'] ) || ( isset( $postdata['delete'] ) && 'type_true' === $postdata['delete'] ) ) {
663
+ $settings = null;
664
+ if ( ! empty( $postdata['cptui_post_import'] ) ) {
665
+ $settings = $postdata['cptui_post_import'];
666
+ }
667
 
668
  // Add support to delete settings outright, without accessing database.
669
  // Doing double check to protect.
670
+ if ( null === $settings && ( isset( $postdata['delete'] ) && 'type_true' === $postdata['delete'] ) ) {
671
 
672
  /**
673
  * Filters whether or not 3rd party options were deleted successfully within post type import.
708
  if ( $success ) {
709
  $status = 'import_success';
710
  }
711
+ } elseif ( ! empty( $postdata['cptui_tax_import'] ) || ( isset( $postdata['delete'] ) && 'tax_true' === $postdata['delete'] ) ) {
712
+ $settings = null;
 
713
 
714
+ if ( ! empty( $postdata['cptui_tax_import'] ) ) {
715
+ $settings = $postdata['cptui_tax_import'];
716
+ }
717
  // Add support to delete settings outright, without accessing database.
718
  // Doing double check to protect.
719
+ if ( null === $settings && ( isset( $postdata['delete'] ) && 'tax_true' === $postdata['delete'] ) ) {
720
 
721
  /**
722
  * Filters whether or not 3rd party options were deleted successfully within taxonomy import.
978
  * @param string $tab Current tab to display.
979
  */
980
  function cptui_render_tools( $tab ) {
981
+ if ( 'post_types' === $tab || 'taxonomies' === $tab ) {
982
+ cptui_render_posttypes_taxonomies_section();
983
+ }
 
984
 
985
+ if ( 'get_code' === $tab ) {
986
+ cptui_render_getcode_section();
987
+ }
988
 
989
+ if ( 'debuginfo' === $tab ) {
990
+ cptui_render_debuginfo_section();
 
991
  }
992
  }
993
  add_action( 'cptui_tools_sections', 'cptui_render_tools' );
1003
  ( ! empty( $_POST['cptui_post_import'] ) && isset( $_POST['cptui_post_import'] ) ) ||
1004
  ( ! empty( $_POST['cptui_tax_import'] ) && isset( $_POST['cptui_tax_import'] ) )
1005
  ) {
1006
+ $data = [];
1007
+ $decoded_post_data = null;
1008
+ $decoded_tax_data = null;
1009
+ if ( ! empty( $_POST['cptui_post_import'] ) ) {
1010
+ $decoded_post_data = json_decode( stripslashes_deep( trim( $_POST['cptui_post_import'] ) ), true );
1011
+ }
1012
+
1013
+ if ( ! empty( $_POST['cptui_tax_import'] ) ) {
1014
+ $decoded_tax_data = json_decode( stripslashes_deep( trim( $_POST['cptui_tax_import'] ) ), true );
1015
+ }
1016
+
1017
+ if (
1018
+ empty( $decoded_post_data ) &&
1019
+ empty( $decoded_tax_data ) &&
1020
+ (
1021
+ ! empty( $_POST['cptui_post_import'] ) && '{""}' !== stripslashes_deep( trim( $_POST['cptui_post_import'] ) )
1022
+ ) &&
1023
+ (
1024
+ ! empty( $_POST['cptui_tax_import'] ) && '{""}' !== stripslashes_deep( trim( $_POST['cptui_tax_import'] ) )
1025
+ )
1026
+ ) {
1027
+ return;
1028
+ }
1029
+ if ( null !== $decoded_post_data ) {
1030
+ $data['cptui_post_import'] = $decoded_post_data;
1031
+ }
1032
+ if ( null !== $decoded_tax_data ) {
1033
+ $data['cptui_tax_import'] = $decoded_tax_data;
1034
+ }
1035
+ if ( ! empty( $_POST['cptui_post_import'] ) && '{""}' === stripslashes_deep( trim( $_POST['cptui_post_import'] ) ) ) {
1036
+ $data['delete'] = 'type_true';
1037
+ }
1038
+ if ( ! empty( $_POST['cptui_tax_import'] ) && '{""}' === stripslashes_deep( trim( $_POST['cptui_tax_import'] ) ) ) {
1039
+ $data['delete'] = 'tax_true';
1040
+ }
1041
+ $success = cptui_import_types_taxes_settings( $data );
1042
  add_action( 'admin_notices', "cptui_{$success}_admin_notice" );
1043
  }
1044
  }
inc/utility.php CHANGED
@@ -108,14 +108,14 @@ function cptui_footer( $original = '' ) {
108
  __( '%s version %s by %s', 'custom-post-type-ui' ),
109
  __( 'Custom Post Type UI', 'custom-post-type-ui' ),
110
  CPTUI_VERSION,
111
- '<a href="https://webdevstudios.com" target="_blank">WebDevStudios</a>'
112
  ) . ' - ' .
113
  sprintf(
114
- '<a href="http://wordpress.org/support/plugin/custom-post-type-ui" target="_blank">%s</a>',
115
  __( 'Support forums', 'custom-post-type-ui' )
116
  ) . ' - ' .
117
  sprintf(
118
- '<a href="https://wordpress.org/plugins/custom-post-type-ui/reviews/" target="_blank">%s</a>',
119
  sprintf(
120
  // translators: Placeholder will hold `<abbr>` tag for CPTUI.
121
  __( 'Review %s', 'custom-post-type-ui' ),
@@ -129,7 +129,7 @@ function cptui_footer( $original = '' ) {
129
  __( 'Follow on Twitter:', 'custom-post-type-ui' ) .
130
  sprintf(
131
  ' %s',
132
- '<a href="https://twitter.com/webdevstudios" target="_blank">WebDevStudios</a>'
133
  );
134
  }
135
  add_filter( 'admin_footer_text', 'cptui_footer' );
@@ -571,11 +571,17 @@ function cptui_admin_notices_helper( $message = '', $success = true ) {
571
  */
572
  function cptui_get_object_from_post_global() {
573
  if ( isset( $_POST['cpt_custom_post_type']['name'] ) ) {
574
- return sanitize_text_field( $_POST['cpt_custom_post_type']['name'] );
 
 
 
575
  }
576
 
577
  if ( isset( $_POST['cpt_custom_tax']['name'] ) ) {
578
- return sanitize_text_field( $_POST['cpt_custom_tax']['name'] );
 
 
 
579
  }
580
 
581
  return esc_html__( 'Object', 'custom-post-type-ui' );
@@ -872,7 +878,7 @@ function cptui_get_cptui_post_type_object( $post_type = '' ) {
872
  if ( array_key_exists( $post_type, $post_types ) ) {
873
  return $post_types[ $post_type ];
874
  }
875
- return '';
876
  }
877
 
878
  /**
@@ -889,7 +895,7 @@ function cptui_get_cptui_taxonomy_object( $taxonomy = '' ) {
889
  if ( array_key_exists( $taxonomy, $taxonomies ) ) {
890
  return $taxonomies[ $taxonomy ];
891
  }
892
- return '';
893
  }
894
 
895
  /**
108
  __( '%s version %s by %s', 'custom-post-type-ui' ),
109
  __( 'Custom Post Type UI', 'custom-post-type-ui' ),
110
  CPTUI_VERSION,
111
+ '<a href="https://webdevstudios.com" target="_blank" rel="noopener">WebDevStudios</a>'
112
  ) . ' - ' .
113
  sprintf(
114
+ '<a href="http://wordpress.org/support/plugin/custom-post-type-ui" target="_blank" rel="noopener">%s</a>',
115
  __( 'Support forums', 'custom-post-type-ui' )
116
  ) . ' - ' .
117
  sprintf(
118
+ '<a href="https://wordpress.org/plugins/custom-post-type-ui/reviews/" target="_blank" rel="noopener">%s</a>',
119
  sprintf(
120
  // translators: Placeholder will hold `<abbr>` tag for CPTUI.
121
  __( 'Review %s', 'custom-post-type-ui' ),
129
  __( 'Follow on Twitter:', 'custom-post-type-ui' ) .
130
  sprintf(
131
  ' %s',
132
+ '<a href="https://twitter.com/webdevstudios" target="_blank" rel="noopener">WebDevStudios</a>'
133
  );
134
  }
135
  add_filter( 'admin_footer_text', 'cptui_footer' );
571
  */
572
  function cptui_get_object_from_post_global() {
573
  if ( isset( $_POST['cpt_custom_post_type']['name'] ) ) {
574
+ $type_item = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
575
+ if ( $type_item ) {
576
+ return sanitize_text_field( $type_item['name'] );
577
+ }
578
  }
579
 
580
  if ( isset( $_POST['cpt_custom_tax']['name'] ) ) {
581
+ $tax_item = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
582
+ if ( $tax_item ) {
583
+ return sanitize_text_field( $tax_item['name'] );
584
+ }
585
  }
586
 
587
  return esc_html__( 'Object', 'custom-post-type-ui' );
878
  if ( array_key_exists( $post_type, $post_types ) ) {
879
  return $post_types[ $post_type ];
880
  }
881
+ return [];
882
  }
883
 
884
  /**
895
  if ( array_key_exists( $taxonomy, $taxonomies ) ) {
896
  return $taxonomies[ $taxonomy ];
897
  }
898
+ return [];
899
  }
900
 
901
  /**
js/cptui.js CHANGED
@@ -41,7 +41,7 @@ postboxes.add_postbox_toggles(pagenow);
41
  'buttons' : {
42
  "OK": function() {
43
  var form = $(e.target).closest('form');
44
- $(e.target).unbind('click').click();
45
  },
46
  "Cancel": function() {
47
  $(this).dialog('close');
@@ -141,15 +141,28 @@ postboxes.add_postbox_toggles(pagenow);
141
  }
142
 
143
  function composePreviewContent(value) {
 
 
 
 
144
  if (!value) {
145
  return '';
146
  } else if (0 === value.indexOf('dashicons-')) {
147
- return $('<div class="dashicons-before"><br></div>').addClass(value);
148
- } else {
149
- return $('<img />').attr('src', value);
 
 
 
150
  }
151
  }
152
 
 
 
 
 
 
 
153
  var cyrillic = {
154
  "Ё": "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"
155
  };
@@ -194,7 +207,8 @@ postboxes.add_postbox_toggles(pagenow);
194
  });
195
 
196
  $('#menu_icon').on('change', function () {
197
- var value = $(this).val().trim();
 
198
  $('#menu_icon_preview').html(composePreviewContent(value));
199
  });
200
 
@@ -253,4 +267,14 @@ postboxes.add_postbox_toggles(pagenow);
253
  } );
254
  });
255
 
 
 
 
 
 
 
 
 
 
 
256
  })(jQuery);
41
  'buttons' : {
42
  "OK": function() {
43
  var form = $(e.target).closest('form');
44
+ $(e.target).off('click').click();
45
  },
46
  "Cancel": function() {
47
  $(this).dialog('close');
141
  }
142
 
143
  function composePreviewContent(value) {
144
+
145
+ var re = /(http|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/;
146
+ var is_url = re.test(value);
147
+
148
  if (!value) {
149
  return '';
150
  } else if (0 === value.indexOf('dashicons-')) {
151
+ return $('<div class="dashicons-before"><br></div>').addClass(htmlEncode(value));
152
+ } else if ( is_url ) {
153
+ var imgsrc = encodeURI(value);
154
+ var theimg = document.createElement('IMG');
155
+ theimg.src = imgsrc;
156
+ return theimg;
157
  }
158
  }
159
 
160
+ function htmlEncode(str) {
161
+ return String(str).replace(/[^-\w. ]/gi, function (c) {
162
+ return '&#' + c.charCodeAt(0) + ';';
163
+ });
164
+ }
165
+
166
  var cyrillic = {
167
  "Ё": "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"
168
  };
207
  });
208
 
209
  $('#menu_icon').on('change', function () {
210
+ var value = $(this).val();
211
+ value = value.trim();
212
  $('#menu_icon_preview').html(composePreviewContent(value));
213
  });
214
 
267
  } );
268
  });
269
 
270
+ $('#auto-clear').on( 'click tap', function(e) {
271
+ e.preventDefault();
272
+
273
+ var fields = $('.cptui-labels input[type="text"]');
274
+
275
+ $(fields).each( function( i, el ) {
276
+ $(el).val('');
277
+ });
278
+ });
279
+
280
  })(jQuery);
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()}),$(".cptui-delete-top, .cptui-delete-bottom").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){s="cpt-ui_page_cptui_manage_post_types"===window.pagenow?s.replace(/[^a-z0-9\s-]/gi,"_"):s.replace(/[^a-z0-9\s]/gi,"_");return s}(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).prop("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).change()},wp.media.editor.open(button),!1}),$("#menu_icon").on("change",function(){var value=$(this).val().trim();$("#menu_icon_preview").html(function(value){return value?0===value.indexOf("dashicons-")?$('<div class="dashicons-before"><br></div>').addClass(value):$("<img />").attr("src",value):""}(value))}),$(".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);
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();function composePreviewContent(value){var is_url=/(http|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/.test(value);if(!value)return"";if(0===value.indexOf("dashicons-"))return $('<div class="dashicons-before"><br></div>').addClass(function(str){return String(str).replace(/[^-\w. ]/gi,function(c){return"&#"+c.charCodeAt(0)+";"})}(value));if(is_url){var imgsrc=encodeURI(value),theimg=document.createElement("IMG");return theimg.src=imgsrc,theimg}}$("#post_type").on("change",function(){$("#cptui_select_post_type").submit()}),$("#taxonomy").on("change",function(){$("#cptui_select_taxonomy").submit()}),$(".cptui-delete-top, .cptui-delete-bottom").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).off("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){s="cpt-ui_page_cptui_manage_post_types"===window.pagenow?s.replace(/[^a-z0-9\s-]/gi,"_"):s.replace(/[^a-z0-9\s]/gi,"_");return s}(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).prop("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).change()},wp.media.editor.open(button),!1}),$("#menu_icon").on("change",function(){var value=$(this).val();value=value.trim(),$("#menu_icon_preview").html(composePreviewContent(value))}),$(".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))}))}),$("#auto-clear").on("click tap",function(e){e.preventDefault();var fields=$('.cptui-labels input[type="text"]');$(fields).each(function(i,el){$(el).val("")})})}(jQuery);
js/dashicons-picker.js ADDED
@@ -0,0 +1,419 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Dashicons Picker
3
+ *
4
+ * Based on: https://github.com/bradvin/dashicons-picker/
5
+ */
6
+
7
+ ( function ( $ ) {
8
+ 'use strict';
9
+ /**
10
+ *
11
+ * @returns {void}
12
+ */
13
+ $.fn.dashiconsPicker = function () {
14
+
15
+ /**
16
+ * Dashicons, in CSS order
17
+ *
18
+ * @type Array
19
+ */
20
+ var icons = [
21
+ 'menu',
22
+ 'admin-site',
23
+ 'dashboard',
24
+ 'admin-media',
25
+ 'admin-page',
26
+ 'admin-comments',
27
+ 'admin-appearance',
28
+ 'admin-plugins',
29
+ 'admin-users',
30
+ 'admin-tools',
31
+ 'admin-settings',
32
+ 'admin-network',
33
+ 'admin-generic',
34
+ 'admin-home',
35
+ 'admin-collapse',
36
+ 'filter',
37
+ 'admin-customizer',
38
+ 'admin-multisite',
39
+ 'admin-links',
40
+ 'format-links',
41
+ 'admin-post',
42
+ 'format-standard',
43
+ 'format-image',
44
+ 'format-gallery',
45
+ 'format-audio',
46
+ 'format-video',
47
+ 'format-chat',
48
+ 'format-status',
49
+ 'format-aside',
50
+ 'format-quote',
51
+ 'welcome-write-blog',
52
+ 'welcome-edit-page',
53
+ 'welcome-add-page',
54
+ 'welcome-view-site',
55
+ 'welcome-widgets-menus',
56
+ 'welcome-comments',
57
+ 'welcome-learn-more',
58
+ 'image-crop',
59
+ 'image-rotate',
60
+ 'image-rotate-left',
61
+ 'image-rotate-right',
62
+ 'image-flip-vertical',
63
+ 'image-flip-horizontal',
64
+ 'image-filter',
65
+ 'undo',
66
+ 'redo',
67
+ 'editor-bold',
68
+ 'editor-italic',
69
+ 'editor-ul',
70
+ 'editor-ol',
71
+ 'editor-quote',
72
+ 'editor-alignleft',
73
+ 'editor-aligncenter',
74
+ 'editor-alignright',
75
+ 'editor-insertmore',
76
+ 'editor-spellcheck',
77
+ 'editor-distractionfree',
78
+ 'editor-expand',
79
+ 'editor-contract',
80
+ 'editor-kitchensink',
81
+ 'editor-underline',
82
+ 'editor-justify',
83
+ 'editor-textcolor',
84
+ 'editor-paste-word',
85
+ 'editor-paste-text',
86
+ 'editor-removeformatting',
87
+ 'editor-video',
88
+ 'editor-customchar',
89
+ 'editor-outdent',
90
+ 'editor-indent',
91
+ 'editor-help',
92
+ 'editor-strikethrough',
93
+ 'editor-unlink',
94
+ 'editor-rtl',
95
+ 'editor-break',
96
+ 'editor-code',
97
+ 'editor-paragraph',
98
+ 'editor-table',
99
+ 'align-left',
100
+ 'align-right',
101
+ 'align-center',
102
+ 'align-none',
103
+ 'lock',
104
+ 'unlock',
105
+ 'calendar',
106
+ 'calendar-alt',
107
+ 'visibility',
108
+ 'hidden',
109
+ 'post-status',
110
+ 'edit',
111
+ 'post-trash',
112
+ 'trash',
113
+ 'sticky',
114
+ 'external',
115
+ 'arrow-up',
116
+ 'arrow-down',
117
+ 'arrow-left',
118
+ 'arrow-right',
119
+ 'arrow-up-alt',
120
+ 'arrow-down-alt',
121
+ 'arrow-left-alt',
122
+ 'arrow-right-alt',
123
+ 'arrow-up-alt2',
124
+ 'arrow-down-alt2',
125
+ 'arrow-left-alt2',
126
+ 'arrow-right-alt2',
127
+ 'leftright',
128
+ 'sort',
129
+ 'randomize',
130
+ 'list-view',
131
+ 'excerpt-view',
132
+ 'grid-view',
133
+ 'hammer',
134
+ 'art',
135
+ 'migrate',
136
+ 'performance',
137
+ 'universal-access',
138
+ 'universal-access-alt',
139
+ 'tickets',
140
+ 'nametag',
141
+ 'clipboard',
142
+ 'heart',
143
+ 'megaphone',
144
+ 'schedule',
145
+ 'wordpress',
146
+ 'wordpress-alt',
147
+ 'pressthis',
148
+ 'update',
149
+ 'screenoptions',
150
+ 'cart',
151
+ 'feedback',
152
+ 'cloud',
153
+ 'translation',
154
+ 'tag',
155
+ 'category',
156
+ 'archive',
157
+ 'tagcloud',
158
+ 'text',
159
+ 'media-archive',
160
+ 'media-audio',
161
+ 'media-code',
162
+ 'media-default',
163
+ 'media-document',
164
+ 'media-interactive',
165
+ 'media-spreadsheet',
166
+ 'media-text',
167
+ 'media-video',
168
+ 'playlist-audio',
169
+ 'playlist-video',
170
+ 'controls-play',
171
+ 'controls-pause',
172
+ 'controls-forward',
173
+ 'controls-skipforward',
174
+ 'controls-back',
175
+ 'controls-skipback',
176
+ 'controls-repeat',
177
+ 'controls-volumeon',
178
+ 'controls-volumeoff',
179
+ 'yes',
180
+ 'no',
181
+ 'no-alt',
182
+ 'plus',
183
+ 'plus-alt',
184
+ 'plus-alt2',
185
+ 'minus',
186
+ 'dismiss',
187
+ 'marker',
188
+ 'star-filled',
189
+ 'star-half',
190
+ 'star-empty',
191
+ 'flag',
192
+ 'info',
193
+ 'warning',
194
+ 'share',
195
+ 'share1',
196
+ 'share-alt',
197
+ 'share-alt2',
198
+ 'twitter',
199
+ 'rss',
200
+ 'email',
201
+ 'email-alt',
202
+ 'facebook',
203
+ 'facebook-alt',
204
+ 'networking',
205
+ 'googleplus',
206
+ 'location',
207
+ 'location-alt',
208
+ 'camera',
209
+ 'images-alt',
210
+ 'images-alt2',
211
+ 'video-alt',
212
+ 'video-alt2',
213
+ 'video-alt3',
214
+ 'vault',
215
+ 'shield',
216
+ 'shield-alt',
217
+ 'sos',
218
+ 'search',
219
+ 'slides',
220
+ 'analytics',
221
+ 'chart-pie',
222
+ 'chart-bar',
223
+ 'chart-line',
224
+ 'chart-area',
225
+ 'groups',
226
+ 'businessman',
227
+ 'id',
228
+ 'id-alt',
229
+ 'products',
230
+ 'awards',
231
+ 'forms',
232
+ 'testimonial',
233
+ 'portfolio',
234
+ 'book',
235
+ 'book-alt',
236
+ 'download',
237
+ 'upload',
238
+ 'backup',
239
+ 'clock',
240
+ 'lightbulb',
241
+ 'microphone',
242
+ 'desktop',
243
+ 'tablet',
244
+ 'smartphone',
245
+ 'phone',
246
+ 'smiley',
247
+ 'index-card',
248
+ 'carrot',
249
+ 'building',
250
+ 'store',
251
+ 'album',
252
+ 'palmtree',
253
+ 'tickets-alt',
254
+ 'money',
255
+ 'thumbs-up',
256
+ 'thumbs-down',
257
+ 'layout',
258
+ 'align-pull-left',
259
+ 'align-pull-right',
260
+ 'block-default',
261
+ 'cloud-saved',
262
+ 'cloud-upload',
263
+ 'columns',
264
+ 'cover-image',
265
+ 'embed-audio',
266
+ 'embed-generic',
267
+ 'embed-photo',
268
+ 'embed-post',
269
+ 'embed-video',
270
+ 'exit',
271
+ 'html',
272
+ 'info-outline',
273
+ 'insert-after',
274
+ 'insert-before',
275
+ 'insert',
276
+ 'remove',
277
+ 'shortcode',
278
+ 'table-col-after',
279
+ 'table-col-before',
280
+ 'table-col-delete',
281
+ 'table-row-after',
282
+ 'table-row-before',
283
+ 'table-row-delete',
284
+ 'saved',
285
+ 'amazon',
286
+ 'google',
287
+ 'linkedin',
288
+ 'pinterest',
289
+ 'podio',
290
+ 'reddit',
291
+ 'spotify',
292
+ 'twitch',
293
+ 'whatsapp',
294
+ 'xing',
295
+ 'youtube',
296
+ 'database-add',
297
+ 'database-export',
298
+ 'database-import',
299
+ 'database-remove',
300
+ 'database-view',
301
+ 'database',
302
+ 'bell',
303
+ 'airplane',
304
+ 'car',
305
+ 'calculator',
306
+ 'ames',
307
+ 'printer',
308
+ 'beer',
309
+ 'coffee',
310
+ 'drumstick',
311
+ 'food',
312
+ 'bank',
313
+ 'hourglass',
314
+ 'money-alt',
315
+ 'open-folder',
316
+ 'pdf',
317
+ 'pets',
318
+ 'privacy',
319
+ 'superhero',
320
+ 'superhero-alt',
321
+ 'edit-page',
322
+ 'fullscreen-alt',
323
+ 'fullscreen-exit-alt'
324
+ ];
325
+
326
+ return this.each( function () {
327
+
328
+ var button = $( this ),
329
+ offsetTop,
330
+ offsetLeft;
331
+
332
+ button.on( 'click.dashiconsPicker', function ( e ) {
333
+ offsetTop = $( e.currentTarget ).offset().top;
334
+ offsetLeft = $( e.currentTarget ).offset().left;
335
+ createPopup( button );
336
+ } );
337
+
338
+ function createPopup( button ) {
339
+
340
+ var target = $( '#menu_icon' ),
341
+ preview = $( button.data( 'preview' ) ),
342
+ popup = $( '<div class="dashicon-picker-container">' +
343
+ '<div class="dashicon-picker-control"></div>' +
344
+ '<ul class="dashicon-picker-list"></ul>' +
345
+ '</div>' ).css( {
346
+ 'top': offsetTop,
347
+ 'left': offsetLeft
348
+ } ),
349
+ list = popup.find( '.dashicon-picker-list' );
350
+
351
+ for ( var i in icons ) {
352
+ if ( icons.hasOwnProperty(i) ) {
353
+ list.append('<li data-icon="' + icons[i] + '"><a href="#" title="' + icons[i] + '"><span class="dashicons dashicons-' + icons[i] + '"></span></a></li>');
354
+ }
355
+ }
356
+
357
+ $( 'a', list ).on( 'click', function ( e ) {
358
+ e.preventDefault();
359
+ var title = $( this ).attr( 'title' );
360
+ target.val( 'dashicons-' + title ).change();
361
+ preview
362
+ .prop('class', 'dashicons')
363
+ .addClass( 'dashicons-' + title );
364
+ removePopup();
365
+ } );
366
+
367
+ var control = popup.find( '.dashicon-picker-control' );
368
+
369
+ control.html( '<a data-direction="back" href="#">' +
370
+ '<span class="dashicons dashicons-arrow-left-alt2"></span></a>' +
371
+ '<input type="text" class="" placeholder="Search" />' +
372
+ '<a data-direction="forward" href="#"><span class="dashicons dashicons-arrow-right-alt2"></span></a>'
373
+ );
374
+
375
+ $( 'a', control ).on( 'click', function ( e ) {
376
+ e.preventDefault();
377
+ if ( $( this ).data( 'direction' ) === 'back' ) {
378
+ $( 'li:gt(' + ( icons.length - 26 ) + ')', list ).prependTo( list );
379
+ } else {
380
+ $( 'li:lt(25)', list ).appendTo( list );
381
+ }
382
+ } );
383
+
384
+ popup.appendTo( 'body' ).show();
385
+
386
+ $( 'input', control ).on( 'keyup', function ( e ) {
387
+ var search = $( this ).val();
388
+ if ( search === '' ) {
389
+ $( 'li:lt(25)', list ).show();
390
+ } else {
391
+ $( 'li', list ).each( function () {
392
+ if ( $( this ).data( 'icon' ).toLowerCase().indexOf( search.toLowerCase() ) !== -1 ) {
393
+ $( this ).show();
394
+ } else {
395
+ $( this ).hide();
396
+ }
397
+ } );
398
+ }
399
+ } );
400
+
401
+ $( document ).on( 'mouseup.dashicons-picker', function ( e ) {
402
+ if ( ! popup.is( e.target ) && popup.has( e.target ).length === 0 ) {
403
+ removePopup();
404
+ }
405
+ } );
406
+ }
407
+
408
+ function removePopup() {
409
+ $( '.dashicon-picker-container' ).remove();
410
+ $( document ).off( '.dashicons-picker' );
411
+ }
412
+ } );
413
+ };
414
+
415
+ $( function () {
416
+ $( '.dashicons-picker' ).dashiconsPicker();
417
+ } );
418
+
419
+ }( jQuery ) );