jQuery(document).ready(function ($) { $('#update-nav-menu').bind('click', function (e) { if (e.target && e.target.className && -1 != e.target.className.indexOf('item-edit')) { $("input[value='#weglot_switcher'][type=text]").parents('.menu-item-settings').each(function () { const id = $(this).attr('id').substring(19); $(this).children('p:not( .field-move )').remove(); // remove default fields we don't need $(this).append($('').attr({ // phpcs:ignore type: 'hidden', id: 'edit-menu-item-title-' + id, name: 'menu-item-title[' + id + ']', value: weglot_data.title })); $(this).append($("").attr({ // phpcs:ignore type: "hidden", id: "edit-menu-item-url-" + id, name: "menu-item-url[" + id + "]", value: "#weglot_switcher" })); $(this).append($('').attr({ // phpcs:ignore type: 'hidden', id: 'edit-menu-item-weglot-detect-' + id, name: 'menu-item-weglot-detect[' + id + ']', value: 1 })); $.each(weglot_data.list_options, (key, option) => { const paragraph = $("

").attr("class", "description"); const label = $("