PluginProbe ʕ •ᴥ•ʔ
Custom Post Type UI / 1.19.2
Custom Post Type UI v1.19.2
1.19.2 1.19.1 1.19.0 trunk 0.7.0.0 0.7.1.0 0.7.2.0 0.8.0.0 0.8.1 0.8.2 0.8.3 0.8.4 0.8.5 0.9.0 0.9.5 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.10.1 1.10.2 1.11.0 1.11.1 1.11.2 1.12.0 1.12.1 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.13.5 1.13.6 1.13.7 1.14.0 1.15.0 1.15.1 1.16.0 1.17.0 1.17.1 1.17.2 1.17.3 1.18.0 1.18.1 1.18.2 1.18.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.8.0 1.8.1 1.8.2 1.9.0 1.9.1 1.9.2
custom-post-type-ui / build / cptui.js
custom-post-type-ui / build Last commit date
vanilla-icon-picker 3 weeks ago cptui-editor.asset.php 3 weeks ago cptui-editor.js 3 weeks ago cptui-editor.js.map 3 weeks ago cptui-styles.css 3 weeks ago cptui-styles.css.map 3 weeks ago cptui-styles.min.css 3 weeks ago cptui-styles.min.css.map 3 weeks ago cptui.asset.php 3 weeks ago cptui.js 3 weeks ago cptui.js.map 3 weeks ago cptui.min.js 3 weeks ago cptui.min.js.map 3 weeks ago dashicons.json 3 weeks ago
cptui.js
767 lines
1 /******/ (() => { // webpackBootstrap
2 /******/ "use strict";
3 /******/ var __webpack_modules__ = ({
4
5 /***/ 194:
6 /***/ (() => {
7
8
9
10 /*
11 * This file handles accordian behavior on the Supports page with the various question/answer panels.
12 *
13 * The functionality includes keyboard and accessibility functionality to help those who need it.
14 */
15 (() => {
16 // Toggles help/support accordions.
17 const supportQuestions = document.querySelectorAll('#support .question');
18 Array.from(supportQuestions).forEach(function (question, index) {
19 let next = function (elem, selector) {
20 let nextElem = elem.nextElementSibling;
21 if (!selector) {
22 return nextElem;
23 }
24 if (nextElem && nextElem.matches(selector)) {
25 return nextElem;
26 }
27 return null;
28 };
29 let state = false;
30 let answer = next(question, 'div');
31 answer.style.display = 'none';
32 ['click', 'keydown'].forEach(theEvent => {
33 question.addEventListener(theEvent, e => {
34 // Helps with accessibility and keyboard navigation.
35 let keys = ['Space', 'Enter'];
36 if (e.type === 'keydown' && !keys.includes(e.code)) {
37 return;
38 }
39 e.preventDefault();
40 state = !state;
41 answer.style.display = state ? 'block' : 'none';
42 e.currentTarget.classList.toggle('active');
43 e.currentTarget.setAttribute('aria-expanded', state.toString());
44 e.currentTarget.focus();
45 });
46 });
47 });
48 })();
49
50 /***/ }),
51
52 /***/ 213:
53 /***/ (() => {
54
55
56
57 /*
58 * This file handles storing the panel state for the post type and taxonomy edit screens.
59 *
60 * The open/closed state gets stored into localstorage and is remembered on future page refreshes.
61 */
62 postboxes.add_postbox_toggles(pagenow);
63 (() => {
64 // Toggle Panels State.
65 // @todo. Localize the list of panel selectors so that we can filter in the CPTUI-Extended panel without hardcoding here.
66 const all_panels = ["#cptui_panel_pt_basic_settings", "#cptui_panel_pt_additional_labels", "#cptui_panel_pt_advanced_settings", "#cptui_panel_tax_basic_settings", "#cptui_panel_tax_additional_labels", "#cptui_panel_tax_advanced_settings"];
67 all_panels.forEach((element, index) => {
68 const panel_id_item = document.querySelector(element);
69 if (panel_id_item) {
70 const panel_id = panel_id_item.getAttribute('id');
71 const panel = document.querySelector('#' + panel_id);
72
73 // check default state on page load
74 if (!localStorage.getItem(panel_id) || localStorage.getItem(panel_id) === null) {
75 panel.classList.remove('closed');
76 } else {
77 panel.classList.add('closed');
78 }
79 const postbox = panel_id_item.querySelectorAll('.postbox-header');
80 Array.from(postbox).forEach((el, i) => {
81 el.addEventListener('click', e => {
82 if (!localStorage.getItem(panel_id)) {
83 localStorage.setItem(panel_id, '1');
84 } else {
85 localStorage.removeItem(panel_id);
86 }
87 });
88 });
89 }
90 });
91 })();
92
93 /***/ }),
94
95 /***/ 285:
96 /***/ (() => {
97
98
99
100 /*
101 * This file handles confirming the deletion of a content type before continuing.
102 *
103 * @todo Finish converting away from jQuery.
104 */
105 ($ => {
106 // NOT DONE
107 /*['.cptui-delete-top', '.cptui-delete-bottom'].forEach( (element,index) => {
108 let theDialog = document.querySelector('#cptui-content-type-delete');
109 let theelement = document.querySelector(element);
110 theelement.addEventListener('click', async (e) => {
111 e.preventDefault();
112 const doPerformAction = await confirm();
113 if ( doPerformAction ) {
114 let thing = document.querySelector('#cpt_submit_delete');
115 console.log(thing);
116 thing.click();
117 thing.submit();
118 theDialog.close();
119 } else {
120 theDialog.close();
121 }
122 });
123 });
124 let closeBtnConfirm = document.querySelector('.cptui-confirm-deny-delete button');
125 let closeBtnDeny = document.querySelector('#cptui-content-type-deny-delete');
126 function confirm() {
127 return new Promise((resolve, reject) => {
128 document.querySelector('#cptui-content-type-delete').showModal();
129 closeBtnConfirm.focus();
130 closeBtnConfirm.addEventListener("click", () => {
131 resolve(true);
132 document.querySelector('#cptui-content-type-delete').close()
133 });
134 closeBtnDeny.addEventListener("click", () => {
135 resolve(false);
136 document.querySelector('#cptui-content-type-delete').close()
137 });
138 });
139 }*/
140
141 // Confirm our deletions
142 $('.cptui-delete-top, .cptui-delete-bottom').on('click', function (e) {
143 e.preventDefault();
144 let msg = '';
145 if (typeof cptui_type_data !== 'undefined') {
146 msg = cptui_type_data.confirm;
147 } else if (typeof cptui_tax_data !== 'undefined') {
148 msg = cptui_tax_data.confirm;
149 }
150 let submit_delete_warning = $('<div class="cptui-submit-delete-dialog">' + msg + '</div>').appendTo('#poststuff').dialog({
151 'dialogClass': 'wp-dialog',
152 'modal': true,
153 'autoOpen': true,
154 'buttons': {
155 "OK": function () {
156 $(this).dialog('close');
157 $(e.target).off('click').click();
158 },
159 "Cancel": function () {
160 $(this).dialog('close');
161 }
162 }
163 });
164 });
165 })(jQuery);
166
167 /***/ }),
168
169 /***/ 376:
170 /***/ (() => {
171
172
173
174 /*
175 * This file provides a dialog box to alert the user that at least one post type must be chosen
176 * before they can save a taxonomy.
177 *
178 * This was added because taxonomies need to have a post type, meanwhile post types do NOT need
179 * to have a taxonomy.
180 */
181 (() => {
182 // Handles checking if a post type has been chosen or not when adding/saving a taxonomy.
183 // Post type associations are a required attribute.
184 const taxSubmit = document.querySelectorAll('.cptui-taxonomy-submit');
185 const taxSubmitSelectCPTDialog = document.querySelector('#cptui-select-post-type-confirm');
186 Array.from(taxSubmit).forEach((element, i) => {
187 element.addEventListener('click', e => {
188 // putting inside event listener to check every time clicked. Defining outside lost re-checking.
189 let taxCPTChecked = document.querySelectorAll('#cptui_panel_tax_basic_settings input[type="checkbox"]:checked');
190 if (taxCPTChecked.length === 0) {
191 e.preventDefault();
192 taxSubmitSelectCPTDialog.showModal();
193 }
194 });
195 });
196 let taxSubmitSelectCPTConfirmCloseBtn = document.querySelector('#cptui-select-post-type-confirm-close');
197 if (taxSubmitSelectCPTConfirmCloseBtn) {
198 taxSubmitSelectCPTConfirmCloseBtn.addEventListener('click', e => {
199 e.preventDefault();
200 taxSubmitSelectCPTDialog.close();
201 });
202 }
203 })();
204
205 /***/ }),
206
207 /***/ 464:
208 /***/ (() => {
209
210
211
212 /*
213 * This file handles the automatic population as well as the automatic clearing of the label
214 * fields, based on the provided singular and plural label values.
215 */
216 (() => {
217 let nameField = document.querySelector('#name');
218 let autoPopulate = document.querySelector('#auto-populate');
219 const autoLabels = document.querySelector('#autolabels');
220 if (autoLabels) {
221 autoLabels.style.display = 'table-row';
222 }
223 if (autoPopulate) {
224 ['click', 'tap'].forEach((eventName, index) => {
225 autoPopulate.addEventListener(eventName, e => {
226 e.preventDefault();
227 let slug = nameField.value;
228 let plural = document.querySelector('#label').value;
229 let singular = document.querySelector('#singular_label').value;
230 let fields = document.querySelectorAll('.cptui-labels input[type="text"]');
231 if ('' === slug) {
232 return;
233 }
234 if ('' === plural) {
235 plural = slug;
236 }
237 if ('' === singular) {
238 singular = slug;
239 }
240 Array.from(fields).forEach(field => {
241 let newval = field.getAttribute('data-label');
242 let plurality = field.getAttribute('data-plurality');
243 if (typeof newval !== 'undefined') {
244 // "slug" is our placeholder from the labels.
245 if ('plural' === plurality) {
246 newval = newval.replace(/item/gi, plural);
247 } else {
248 // using an else statement because we do not
249 // want to mutate the original string by default.
250 newval = newval.replace(/item/gi, singular);
251 }
252 if (field.value === '') {
253 field.value = newval;
254 }
255 }
256 });
257 });
258 });
259 }
260 let autoClear = document.querySelector('#auto-clear');
261 if (autoClear) {
262 ['click', 'tap'].forEach((eventName, index) => {
263 autoClear.addEventListener(eventName, e => {
264 e.preventDefault();
265 const fields = document.querySelectorAll('.cptui-labels input[type="text"]');
266 Array.from(fields).forEach(field => {
267 field.value = '';
268 });
269 });
270 });
271 }
272 })();
273
274 /***/ }),
275
276 /***/ 643:
277 /***/ (() => {
278
279
280
281 /*
282 * This file handles automatically toggling the "Page attributes" option in the "Supports" section
283 * when a user chooses to have their post type be hierarchical.
284 *
285 * The purpose is to help ensure that the "parent" and "template" metabox option shows up by default,
286 * but we do not force that to remain checked. The user can still toggle it off after the fact.
287 */
288 (() => {
289 // Automatically toggle the "page attributes" checkbox if
290 // setting a hierarchical post type.
291 const hierarchicalSetting = document.querySelector('#hierarchical');
292 if (hierarchicalSetting) {
293 hierarchicalSetting.addEventListener('change', e => {
294 let pageAttributesCheck = document.querySelector('#page-attributes');
295 if (e.currentTarget && e.currentTarget.value === '1') {
296 pageAttributesCheck.checked = true;
297 } else {
298 pageAttributesCheck.checked = false;
299 }
300 });
301 }
302 })();
303
304 /***/ }),
305
306 /***/ 698:
307 /***/ (() => {
308
309
310
311 /*
312 * This file handles setting the menu icon preview for a given post type.
313 */
314 (() => {
315 let _custom_media;
316 let _orig_send_attachment;
317 if (undefined !== wp.media) {
318 _custom_media = true;
319 _orig_send_attachment = wp.media.editor.send.attachment;
320 }
321 const maybeHasPicker = document.querySelector('#cptui_choose_dashicon');
322 if (!maybeHasPicker) {
323 return;
324 }
325
326 // Trigger the modal and load our icons.
327 const icons = cptuiIconPicker.iconsJSON;
328 const iconPicker = new IconPicker('#cptui_choose_dashicon', {
329 theme: 'default',
330 iconSource: [{
331 key: 'dashicons',
332 prefix: 'dashicons-',
333 url: icons
334 }],
335 closeOnSelect: true,
336 i18n: {
337 'input:placeholder': cptuiIconPicker.iconsPlaceholder,
338 'text:title': cptuiIconPicker.iconsTitle,
339 'text:empty': cptuiIconPicker.iconsEmpty,
340 'text:loading': cptuiIconPicker.iconsLoading,
341 'btn:save': cptuiIconPicker.iconsSave
342 }
343 });
344 const menuIconField = document.querySelector('#menu_icon');
345 const menuIconPreview = document.querySelector('#menu_icon_preview');
346 const regIcon = document.querySelector('#cptui_choose_icon');
347 const dashIcon = document.querySelector('#cptui_choose_dashicon');
348 const origText = dashIcon.value;
349 iconPicker.on('select', icon => {
350 menuIconField.value = icon.value;
351 menuIconPreview.innerHTML = '';
352 let div = document.createElement('div');
353 div.classList.add('dashicons', icon.value);
354 menuIconPreview.insertAdjacentElement('afterbegin', div);
355 });
356 iconPicker.on('hide', () => {
357 dashIcon.value = origText;
358 });
359 if (regIcon) {
360 regIcon.addEventListener('click', e => {
361 e.preventDefault();
362 let button = e.currentTarget;
363 _custom_media = true;
364 wp.media.editor.send.attachment = function (props, attachment) {
365 if (_custom_media) {
366 menuIconField.value = attachment.url;
367 menuIconPreview.innerHTML = '';
368 let img = document.createElement('img');
369 img.src = attachment.url;
370 menuIconPreview.insertAdjacentElement('afterbegin', img);
371 } else {
372 return _orig_send_attachment.apply(this, [props, attachment]);
373 }
374 };
375 wp.media.editor.open(button);
376 return false;
377 });
378 }
379 })();
380
381 /***/ }),
382
383 /***/ 706:
384 /***/ (() => {
385
386
387
388 /*
389 * This file handles automatically switching to a chosen content type when selecting from the
390 * dropdown listing.
391 */
392 (() => {
393 // Switch to newly selected post type or taxonomy automatically.
394 const postTypeDropdown = document.querySelector('#post_type');
395 const taxonomyDropdown = document.querySelector('#taxonomy');
396 if (postTypeDropdown) {
397 postTypeDropdown.addEventListener('change', () => {
398 const postTypeSelectPostType = document.querySelector('#cptui_select_post_type');
399 if (postTypeSelectPostType) {
400 postTypeSelectPostType.submit();
401 }
402 });
403 }
404 if (taxonomyDropdown) {
405 taxonomyDropdown.addEventListener('change', () => {
406 const taxonomySelectPostType = document.querySelector('#cptui_select_taxonomy');
407 if (taxonomySelectPostType) {
408 taxonomySelectPostType.submit();
409 }
410 });
411 }
412 })();
413
414 /***/ }),
415
416 /***/ 710:
417 /***/ (() => {
418
419
420
421 /*
422 * This file visually removes the submit button to change content type being edited.
423 *
424 * If by chance javascript is disabled or somehow breaking, the button would show by default,
425 * preventing issues with switching content types.
426 */
427 (() => {
428 const cptSelectSubmit = document.querySelector('#cptui_select_post_type_submit');
429 if (cptSelectSubmit) {
430 cptSelectSubmit.style.display = 'none';
431 }
432 const taxSelectSubmit = document.querySelector('#cptui_select_taxonomy_submit');
433 if (taxSelectSubmit) {
434 taxSelectSubmit.style.display = 'none';
435 }
436 })();
437
438 /***/ }),
439
440 /***/ 864:
441 /***/ (() => {
442
443
444
445 /*
446 * This file handles the back to top functionality as the user scrolls, for quick return to top.
447 *
448 * This includes some debouncing to prevent excessive scroll event listening.
449 */
450 (() => {
451 const back_to_top_btn = document.querySelector('.cptui-back-to-top');
452 if (back_to_top_btn) {
453 document.addEventListener('scroll', () => {
454 cptuiDebounce(backToTop, 500);
455 });
456 back_to_top_btn.addEventListener('click', e => {
457 e.preventDefault();
458 window.scrollTo({
459 top: 0,
460 behavior: "smooth"
461 });
462 });
463 }
464 function backToTop() {
465 if (window.scrollY > 300) {
466 back_to_top_btn.classList.add('show');
467 } else {
468 back_to_top_btn.classList.remove('show');
469 }
470 }
471 function cptuiDebounce(method, delay) {
472 clearTimeout(method._tId);
473 method._tId = setTimeout(function () {
474 method();
475 }, delay);
476 }
477 })();
478
479 /***/ })
480
481 /******/ });
482 /************************************************************************/
483 /******/ // The module cache
484 /******/ var __webpack_module_cache__ = {};
485 /******/
486 /******/ // The require function
487 /******/ function __webpack_require__(moduleId) {
488 /******/ // Check if module is in cache
489 /******/ var cachedModule = __webpack_module_cache__[moduleId];
490 /******/ if (cachedModule !== undefined) {
491 /******/ return cachedModule.exports;
492 /******/ }
493 /******/ // Create a new module (and put it into the cache)
494 /******/ var module = __webpack_module_cache__[moduleId] = {
495 /******/ // no module.id needed
496 /******/ // no module.loaded needed
497 /******/ exports: {}
498 /******/ };
499 /******/
500 /******/ // Execute the module function
501 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
502 /******/
503 /******/ // Return the exports of the module
504 /******/ return module.exports;
505 /******/ }
506 /******/
507 /************************************************************************/
508
509 ;// ./src/js/partials/utils.js
510
511
512 // Retrieve URL parameters by requested parameter name.
513 function getParameterByName(name, url) {
514 if (!url) url = window.location.href;
515 name = name.replace(/[\[\]]/g, "\\$&");
516 const regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
517 results = regex.exec(url);
518 if (!results) return null;
519 if (!results[2]) return '';
520 return decodeURIComponent(results[2].replace(/\+/g, " "));
521 }
522
523 // Split, translate cyrillic characters, and then re-join the final result.
524 function transliterate(word) {
525 return word.split('').map(function (char) {
526 return cyrillic[char] || char;
527 }).join("");
528 }
529
530 //Character encode special characters.
531 function htmlEncode(str) {
532 return String(str).replace(/[^-\w. ]/gi, function (c) {
533 return '&#' + c.charCodeAt(0) + ';';
534 });
535 }
536
537 // Constructs miniture versions of uploaded media for admnin menu icon usage,
538 // or displays the rendered dashicon.
539 function composePreviewContent(value) {
540 const re = /(http|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/;
541 const isURL = re.test(value);
542 if (!value) {
543 return '';
544 } else if (0 === value.indexOf('dashicons-')) {
545 const dashDiv = document.createElement('div');
546 dashDiv.classList.add('dashicons-before');
547 dashDiv.innerHTML = '<br/>';
548 dashDiv.classList.add(htmlEncode(value));
549 return dashDiv;
550 } else if (isURL) {
551 const imgsrc = encodeURI(value);
552 const theimg = document.createElement('IMG');
553 theimg.src = imgsrc;
554 return theimg;
555 }
556 }
557
558 // Replace diacritic characters with latin characters.
559 function replaceDiacritics(s) {
560 const diacritics = [/[\300-\306]/g, /[\340-\346]/g,
561 // A, a
562 /[\310-\313]/g, /[\350-\353]/g,
563 // E, e
564 /[\314-\317]/g, /[\354-\357]/g,
565 // I, i
566 /[\322-\330]/g, /[\362-\370]/g,
567 // O, o
568 /[\331-\334]/g, /[\371-\374]/g,
569 // U, u
570 /[\321]/g, /[\361]/g,
571 // N, n
572 /[\307]/g, /[\347]/g // C, c
573 ];
574 let chars = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u', 'N', 'n', 'C', 'c'];
575 for (let i = 0; i < diacritics.length; i++) {
576 s = s.replace(diacritics[i], chars[i]);
577 }
578 return s;
579 }
580
581 // Converts non-alphanumeric or space characters to an underscore. Should ignore dashes, to allow
582 // using dashes in slugs.
583 function replaceSpecialCharacters(s) {
584 s = s.replace(/[^a-z0-9\s-]/gi, '_');
585 return s;
586 }
587
588 // List of available cyrillic characters and the value to translate to.
589 const cyrillic = {
590 "Ё": "YO",
591 "Й": "I",
592 "Ц": "TS",
593 "У": "U",
594 "К": "K",
595 "Е": "E",
596 "Н": "N",
597 "Г": "G",
598 "Ш": "SH",
599 "Щ": "SCH",
600 "З": "Z",
601 "Х": "H",
602 "Ъ": "'",
603 "ё": "yo",
604 "й": "i",
605 "ц": "ts",
606 "у": "u",
607 "к": "k",
608 "е": "e",
609 "н": "n",
610 "г": "g",
611 "ш": "sh",
612 "щ": "sch",
613 "з": "z",
614 "�
615 ": "h",
616 "ъ": "'",
617 "Ф": "F",
618 "Ы": "I",
619 "В": "V",
620 "А": "a",
621 "П": "P",
622 "Р": "R",
623 "О": "O",
624 "Л": "L",
625 "Д": "D",
626 "Ж": "ZH",
627 "Э": "E",
628 "ф": "f",
629 "ы": "i",
630 "в": "v",
631 "а": "a",
632 "п": "p",
633 "р": "r",
634 "о": "o",
635 "л": "l",
636 "д": "d",
637 "ж": "zh",
638 "э": "e",
639 "Я": "Ya",
640 "Ч": "CH",
641 "С": "S",
642 "М": "M",
643 "И": "I",
644 "Т": "T",
645 "Ь": "'",
646 "Б": "B",
647 "Ю": "YU",
648 "я": "ya",
649 "ч": "ch",
650 "с": "s",
651 "м": "m",
652 "и": "i",
653 "т": "t",
654 "ь": "'",
655 "б": "b",
656 "ю": "yu"
657 };
658 // EXTERNAL MODULE: ./src/js/partials/hide-submit.js
659 var hide_submit = __webpack_require__(710);
660 // EXTERNAL MODULE: ./src/js/partials/toggle-hierarchical.js
661 var toggle_hierarchical = __webpack_require__(643);
662 // EXTERNAL MODULE: ./src/js/partials/autoswitch.js
663 var autoswitch = __webpack_require__(706);
664 // EXTERNAL MODULE: ./src/js/partials/confirm-delete.js
665 var confirm_delete = __webpack_require__(285);
666 // EXTERNAL MODULE: ./src/js/partials/support-toggles.js
667 var support_toggles = __webpack_require__(194);
668 ;// ./src/js/partials/namefield.js
669
670
671
672
673 /*
674 * This file handles all of the normalization of the name/slug field for a post type
675 * or taxonomy being registered.
676 *
677 * That way we are only allowing latin characters and dashes/underscores.
678 *
679 * It also shows a hidden alert if the slug has been changed in some way when editing an existing
680 * content type.
681 *
682 * Lastly it will also show a warning if the attempted slug has already been registered elsewhere,
683 * to help avoid clashes. The only exception is if the checkbox is checked indicating that the user
684 * is trying to convert TO using CPTUI, and the conflicting slug elsewhere will be removed soon.
685 */
686
687 (() => {
688 let nameField = document.querySelector('#name');
689 let original_slug;
690 if ('edit' === getParameterByName('action')) {
691 if (nameField) {
692 // Store our original slug on page load for edit checking.
693 original_slug = nameField.value;
694 }
695 }
696 if (nameField) {
697 // Use the `input` event so we catch paste, autofill, drag-drop, and
698 // any programmatic value change — not just keystrokes. The previous
699 // `keyup` listener missed paste/autofill, which is how invalid
700 // uppercase slugs ("People") could slip past client-side normalization.
701 nameField.addEventListener('input', e => {
702 let value, original_value;
703 value = original_value = e.currentTarget.value;
704 value = value.replace(/ /g, "_");
705 value = value.toLowerCase();
706 value = replaceDiacritics(value);
707 value = transliterate(value);
708 value = replaceSpecialCharacters(value);
709 if (value !== original_value) {
710 e.currentTarget.value = value;
711 }
712
713 //Displays a message if slug changes.
714 if (typeof original_slug !== 'undefined') {
715 let slugchanged = document.querySelector('#slugchanged');
716 if (value !== original_slug) {
717 slugchanged.classList.remove('hidemessage');
718 } else {
719 slugchanged.classList.add('hidemessage');
720 }
721 }
722 let slugexists = document.querySelector('#slugexists');
723 let override = document.querySelector('#override_validation');
724 let override_validation = override ? override.checked : false;
725 if (typeof cptui_type_data != 'undefined') {
726 if (cptui_type_data.existing_post_types.hasOwnProperty(value) && value !== original_slug && override_validation === false) {
727 slugexists.classList.remove('hidemessage');
728 } else {
729 slugexists.classList.add('hidemessage');
730 }
731 }
732 if (typeof cptui_tax_data != 'undefined') {
733 if (cptui_tax_data.existing_taxonomies.hasOwnProperty(value) && value !== original_slug) {
734 slugexists.classList.remove('hidemessage');
735 } else {
736 slugexists.classList.add('hidemessage');
737 }
738 }
739 });
740 }
741 })();
742 // EXTERNAL MODULE: ./src/js/partials/menu-icon.js
743 var menu_icon = __webpack_require__(698);
744 // EXTERNAL MODULE: ./src/js/partials/tax-required-post-type.js
745 var tax_required_post_type = __webpack_require__(376);
746 // EXTERNAL MODULE: ./src/js/partials/autopopulate.js
747 var autopopulate = __webpack_require__(464);
748 // EXTERNAL MODULE: ./src/js/partials/back-to-top.js
749 var back_to_top = __webpack_require__(864);
750 // EXTERNAL MODULE: ./src/js/partials/toggle-panels.js
751 var toggle_panels = __webpack_require__(213);
752 ;// ./src/js/cptui.js
753
754
755
756
757
758
759
760
761
762
763
764
765 /******/ })()
766 ;
767 //# sourceMappingURL=cptui.js.map