Changeset 3417744
- Timestamp:
- 12/11/2025 09:08:02 PM (4 months ago)
- Location:
- simple-menu-order-column/trunk
- Files:
-
- 13 edited
-
assets/js/simple-menu-order-column.js (modified) (1 diff)
-
assets/js/simple-menu-order-column.min.js (modified) (1 diff)
-
changelog.txt (modified) (1 diff)
-
i18n/languages/simple-menu-order-column-ca-3fe84e529a0f3cc0a871b18c31074e39.json (modified) (1 diff)
-
i18n/languages/simple-menu-order-column-ca.mo (modified) (previous)
-
i18n/languages/simple-menu-order-column-ca.po (modified) (6 diffs)
-
i18n/languages/simple-menu-order-column-es_ES-3fe84e529a0f3cc0a871b18c31074e39.json (modified) (1 diff)
-
i18n/languages/simple-menu-order-column-es_ES.mo (modified) (previous)
-
i18n/languages/simple-menu-order-column-es_ES.po (modified) (6 diffs)
-
i18n/languages/simple-menu-order-column.pot (modified) (5 diffs)
-
includes/class-simplemenuordercolumn.php (modified) (4 diffs)
-
readme.txt (modified) (4 diffs)
-
simple-menu-order-column.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-menu-order-column/trunk/assets/js/simple-menu-order-column.js
r3407262 r3417744 9 9 */ 10 10 (function () { 11 12 const { __ } = wp.i18n; 13 14 function smocInit() { 15 document.removeEventListener("DOMContentLoaded", smocInit); 16 window.removeEventListener("load", smocInit); 17 18 const smocInputs = document.querySelectorAll('input[id^=smoc]'); 19 20 smocInputs.forEach(smocInput => { 21 smocInput.addEventListener('focus', () => { 22 smocInput.currentValue = smocInput.value; 23 smocInput.title = parseInt(smocInput.value); 24 25 const { postId } = smocInput.dataset; 26 if (!postId) { return; }; 27 28 const hideElement = id => { 29 const smocElement = document.getElementById(id); 30 if (smocElement) { smocElement.style.display = 'none'; } 31 }; 32 33 const smocBaseId = `smoc-${postId}`; 34 35 hideElement(`${smocBaseId}-loader-container`); 36 hideElement(`${smocBaseId}-success`); 37 hideElement(`${smocBaseId}-error`); 38 }); 39 40 smocInput.addEventListener('focusout', () => { 41 if (smocInput.disabled) { return; }; 42 43 if (smocInput.currentValue !== smocInput.value) { 44 if (window.confirm(__('Should the menu order value be updated?', 'simple-menu-order-column'))) { 45 smocDoReorder(smocInput); 46 } else { 47 smocInput.value = smocInput.defaultValue; 48 } 49 } 50 }); 51 52 smocInput.addEventListener('keydown', (smocKeydownEvent) => { 53 const allowedKeys = [ 54 'Backspace', 'Tab', 'ArrowLeft', 'ArrowRight', 55 'ArrowUp', 'ArrowDown', 'Delete', 'Home', 'End', 'Enter', 'Subtract', '-' 56 ]; 57 58 // Allow: Ctrl/Cmd + A/C/V/X 59 if ((smocKeydownEvent.ctrlKey || smocKeydownEvent.metaKey) && ['a', 'c', 'v', 'x'].includes(smocKeydownEvent.key.toLowerCase())) { return; } 60 61 // Allow navigation/edit keys 62 if (allowedKeys.includes(smocKeydownEvent.key)) { return; } 63 64 // Block any key that is not a digit (0-9) 65 if (!/^\d$/.test(smocKeydownEvent.key)) { 66 smocKeydownEvent.preventDefault(); 67 } 68 }); 69 70 smocInput.addEventListener('paste', (smocPasteEvent) => { 71 const pasted = smocPasteEvent.clipboardData.getData('text'); 72 if (!/^\d+$/.test(pasted)) { 73 smocPasteEvent.preventDefault(); 74 } 75 }); 76 77 smocInput.addEventListener('keypress', smocKeypressEvent => { 78 if (smocKeypressEvent.key === 'Enter') { 79 smocKeypressEvent.preventDefault(); 80 smocDoReorder(smocInput); 81 } 82 }); 83 }); 84 } 85 86 function smocDoReorder(smocInput) { 87 if (!smocInput || smocInput.disabled) { return; } 88 89 const smocContainer = smocInput.closest('.smoc-container'), postId = parseInt(smocInput.dataset.postId); 90 91 if (!postId || isNaN(postId)) { 92 disableInput(null, __('The post_id is invalid.', 'simple-menu-order-column'), true, smocInput); 93 return; 94 } 95 96 const loaderId = `smoc-${postId}`, menuOrder = parseInt(smocInput.value); 97 98 if (isNaN(menuOrder)) { 99 const errorEl = document.getElementById(`${loaderId}-error`); 100 disableInput(errorEl, __('The menu order value is invalid.', 'simple-menu-order-column'), false, smocInput); 101 return; 102 } 103 104 const nonce = smocInput.dataset.wpnonce; 105 if (!nonce) { 106 const errorEl = document.getElementById(`${loaderId}-error`); 107 disableInput(errorEl, __('The postNonce is invalid.', 'simple-menu-order-column'), true, smocInput); 108 return; 109 } 110 111 if (typeof ajaxurl === 'undefined' || typeof typenow === 'undefined') { 112 const errorEl = document.getElementById(`${loaderId}-error`); 113 disableInput(errorEl, __('Invalid WP installation, variables typenow or ajaxurl are not initialized.', 'simple-menu-order-column'), true, smocInput); 114 return; 115 } 116 117 smocInput.disabled = true; 118 119 const showLoader = () => { 120 let smocLoaderContainer = document.getElementById(`${loaderId}-loader-container`); 121 if (!smocLoaderContainer) { 122 const smocLoader = document.createElement('span'); 123 smocLoader.id = `${loaderId}-loader`; 124 smocLoader.className = 'smoc-loader dashicons dashicons-update'; 125 smocLoader.setAttribute('role', 'img'); 126 smocLoader.setAttribute('aria-label', __('Updating menu order...', 'simple-menu-order-column')); 127 smocLoader.style.cssText = 'color: #2ea2cc; animation: iconrotation 2s infinite linear; display: inline-block;'; 128 129 smocLoaderContainer = document.createElement('div'); 130 smocLoaderContainer.id = `${loaderId}-loader-container`; 131 smocLoaderContainer.style.cssText = 'padding-top: 5px; display: inline-block;'; 132 smocLoaderContainer.appendChild(smocLoader); 133 smocContainer.appendChild(smocLoaderContainer); 134 } else { 135 smocLoaderContainer.style.display = 'inline-block'; 136 } 137 }; 138 139 const showSuccess = () => { 140 let smocSuccess = document.getElementById(`${loaderId}-success`); 141 if (!smocSuccess) { 142 smocSuccess = document.createElement('span'); 143 smocSuccess.id = `${loaderId}-success`; 144 smocSuccess.className = 'smoc-success dashicons dashicons-yes-alt'; 145 smocSuccess.setAttribute('role', 'img'); 146 smocSuccess.setAttribute('aria-label', __('The menu order has been updated successfully.', 'simple-menu-order-column')); 147 smocSuccess.style.cssText = 'padding-top: 5px; color: #7ad03a; display: inline-block;'; 148 smocContainer.appendChild(smocSuccess); 149 } else { 150 smocSuccess.style.display = 'inline-block'; 151 } 152 }; 153 154 const showError = () => { 155 let smocError = document.getElementById(`${loaderId}-error`); 156 if (!smocError) { 157 smocError = document.createElement('span'); 158 smocError.id = `${loaderId}-error`; 159 smocError.className = 'smoc-error dashicons dashicons-dismiss'; 160 smocError.setAttribute('role', 'img'); 161 smocError.setAttribute('aria-label', __('An error ocurred while updating menu order.', 'simple-menu-order-column')); 162 smocError.style.cssText = 'padding-top: 5px; color: #a00; display: inline-block;'; 163 smocContainer.appendChild(smocError); 164 } else { 165 smocError.style.display = 'inline-block'; 166 } 167 }; 168 169 const hideLoader = () => { 170 const smocLoaderContainer = document.getElementById(`${loaderId}-loader-container`); 171 if (smocLoaderContainer) { smocLoaderContainer.style.display = 'none'; } 172 }; 173 174 showLoader(); 175 176 fetch(`${ajaxurl}?action=smoc_reorder&_wpnonce=${encodeURIComponent(nonce)}`, { 177 method: 'POST', 178 headers: { 179 'Content-Type': 'application/x-www-form-urlencoded', 180 }, 181 body: new URLSearchParams({ 182 post_type: typenow, 183 post_id: postId, 184 post_menu_order: menuOrder, 185 }), 186 }) 187 .then(res => res.json()) 188 .then(response => { 189 if (response.success) { 190 showSuccess(); 191 smocInput.title = menuOrder; 192 smocInput.currentValue = menuOrder; 193 smocInput.defaultValue = menuOrder; 194 195 const inputs = Array.from(document.querySelectorAll('input[id^=smoc]')), pos = inputs.indexOf(smocInput) + 1; 196 if (inputs[pos]) { inputs[pos].select(); } 197 } else { 198 smocInput.value = smocInput.defaultValue; 199 showError(); 200 } 201 }) 202 .catch(() => { 203 smocInput.value = smocInput.defaultValue; 204 hideLoader(); 205 showError(); 206 }) 207 .finally(() => { 208 hideLoader(); 209 smocInput.disabled = false; 210 }); 211 } 212 213 function disableInput(errorContainer, message, disable, input) { 214 input.value = input.defaultValue; 215 if (errorContainer) { errorContainer.style.display = 'inline-block'; } 216 input.disabled = disable; 217 input.title = message; 218 console.warn(`[Simple Menu Order Column] ${message}`); 219 } 220 221 /** 222 * Initilize Script 223 */ 224 if (document.readyState === "loading") { 225 document.addEventListener('DOMContentLoaded', smocInit); 226 window.addEventListener("load", smocInit); 227 } else { 228 window.setTimeout(smocInit); 229 } 11 const { __ } = wp.i18n; 12 let smocInputs = null; 13 14 /* global smoc_ui */ 15 // Ensure smoc_ui exists, fallback to default 16 const smocConfig = window.smoc_ui ?? {}; 17 18 // Provide defaults for missing keys 19 const config = { 20 enableConfirm: smocConfig.enable_confirm ?? true, 21 tabToNext: smocConfig.tab_to_next ?? true 22 }; 23 24 function smocInit() { 25 document.removeEventListener("DOMContentLoaded", smocInit); 26 window.removeEventListener("load", smocInit); 27 28 smocInputs = document.querySelectorAll('input[id^=smoc]'); 29 30 smocInputs.forEach(smocInput => { 31 smocInput.addEventListener('focus', () => { 32 smocInput.currentValue = smocInput.value; 33 smocInput.title = parseInt(smocInput.value); 34 35 const { postId } = smocInput.dataset; 36 if (!postId) { return; }; 37 38 const hideElement = id => { 39 const smocElement = document.getElementById(id); 40 if (smocElement) { smocElement.style.display = 'none'; } 41 }; 42 43 const smocBaseId = `smoc-${postId}`; 44 45 hideElement(`${smocBaseId}-loader-container`); 46 hideElement(`${smocBaseId}-success`); 47 hideElement(`${smocBaseId}-error`); 48 }); 49 50 smocInput.addEventListener('focusout', () => { 51 if (smocInput.disabled) { return; }; 52 53 if (smocInput.currentValue !== smocInput.value) { 54 if (!config.enableConfirm || window.confirm(__('Should the menu order value be updated?', 'simple-menu-order-column'))) { 55 smocDoReorder(smocInput); 56 } else { 57 smocInput.value = smocInput.defaultValue; 58 } 59 } 60 }); 61 62 smocInput.addEventListener('keydown', (smocKeydownEvent) => { 63 const allowedKeys = [ 64 'Backspace', 'Tab', 'ArrowLeft', 'ArrowRight', 65 'ArrowUp', 'ArrowDown', 'Delete', 'Home', 'End', 'Enter', 'Subtract', '-' 66 ]; 67 68 // Allow: Ctrl/Cmd + A/C/V/X 69 if ((smocKeydownEvent.ctrlKey || smocKeydownEvent.metaKey) && ['a', 'c', 'v', 'x'].includes(smocKeydownEvent.key.toLowerCase())) { return; } 70 71 // Allow navigation/edit keys 72 if (allowedKeys.includes(smocKeydownEvent.key)) { return; } 73 74 // Block any key that is not a digit (0-9) 75 if (!/^\d$/.test(smocKeydownEvent.key)) { 76 smocKeydownEvent.preventDefault(); 77 } 78 }); 79 80 smocInput.addEventListener('paste', (smocPasteEvent) => { 81 const pasted = smocPasteEvent.clipboardData.getData('text'); 82 if (!/^\d+$/.test(pasted)) { 83 smocPasteEvent.preventDefault(); 84 } 85 }); 86 87 smocInput.addEventListener('keypress', smocKeypressEvent => { 88 if (smocKeypressEvent.key === 'Enter') { 89 smocKeypressEvent.preventDefault(); 90 smocDoReorder(smocInput); 91 } 92 }); 93 }); 94 } 95 96 function smocDoReorder(smocInput) { 97 if (!smocInput || smocInput.disabled) { return; } 98 99 const smocContainer = smocInput.closest('.smoc-container'), postId = parseInt(smocInput.dataset.postId); 100 101 if (!postId || isNaN(postId)) { 102 disableInput(null, __('The post_id is invalid.', 'simple-menu-order-column'), true, smocInput); 103 return; 104 } 105 106 const loaderId = `smoc-${postId}`, menuOrder = parseInt(smocInput.value); 107 108 if (isNaN(menuOrder)) { 109 const errorEl = document.getElementById(`${loaderId}-error`); 110 disableInput(errorEl, __('The menu order value is invalid.', 'simple-menu-order-column'), false, smocInput); 111 return; 112 } 113 114 const nonce = smocInput.dataset.wpnonce; 115 if (!nonce) { 116 const errorEl = document.getElementById(`${loaderId}-error`); 117 disableInput(errorEl, __('The postNonce is invalid.', 'simple-menu-order-column'), true, smocInput); 118 return; 119 } 120 121 if (typeof ajaxurl === 'undefined' || typeof typenow === 'undefined') { 122 const errorEl = document.getElementById(`${loaderId}-error`); 123 disableInput(errorEl, __('Invalid WP installation, variables typenow or ajaxurl are not initialized.', 'simple-menu-order-column'), true, smocInput); 124 return; 125 } 126 127 smocInput.disabled = true; 128 129 const showLoader = () => { 130 let smocLoaderContainer = document.getElementById(`${loaderId}-loader-container`); 131 if (!smocLoaderContainer) { 132 const smocLoader = document.createElement('span'); 133 smocLoader.id = `${loaderId}-loader`; 134 smocLoader.className = 'smoc-loader dashicons dashicons-update'; 135 smocLoader.setAttribute('role', 'img'); 136 smocLoader.setAttribute('aria-label', __('Updating menu order...', 'simple-menu-order-column')); 137 smocLoader.style.cssText = 'color: #2ea2cc; animation: iconrotation 2s infinite linear; display: inline-block;'; 138 139 smocLoaderContainer = document.createElement('div'); 140 smocLoaderContainer.id = `${loaderId}-loader-container`; 141 smocLoaderContainer.style.cssText = 'padding-top: 5px; display: inline-block;'; 142 smocLoaderContainer.appendChild(smocLoader); 143 smocContainer.appendChild(smocLoaderContainer); 144 } else { 145 smocLoaderContainer.style.display = 'inline-block'; 146 } 147 }; 148 149 const showSuccess = () => { 150 let smocSuccess = document.getElementById(`${loaderId}-success`); 151 if (!smocSuccess) { 152 smocSuccess = document.createElement('span'); 153 smocSuccess.id = `${loaderId}-success`; 154 smocSuccess.className = 'smoc-success dashicons dashicons-yes-alt'; 155 smocSuccess.setAttribute('role', 'img'); 156 smocSuccess.setAttribute('aria-label', __('The menu order has been updated successfully.', 'simple-menu-order-column')); 157 smocSuccess.style.cssText = 'padding-top: 5px; color: #7ad03a; display: inline-block;'; 158 smocContainer.appendChild(smocSuccess); 159 } else { 160 smocSuccess.style.display = 'inline-block'; 161 } 162 }; 163 164 const showError = () => { 165 let smocError = document.getElementById(`${loaderId}-error`); 166 if (!smocError) { 167 smocError = document.createElement('span'); 168 smocError.id = `${loaderId}-error`; 169 smocError.className = 'smoc-error dashicons dashicons-dismiss'; 170 smocError.setAttribute('role', 'img'); 171 smocError.setAttribute('aria-label', __('An error ocurred while updating menu order.', 'simple-menu-order-column')); 172 smocError.style.cssText = 'padding-top: 5px; color: #a00; display: inline-block;'; 173 smocContainer.appendChild(smocError); 174 } else { 175 smocError.style.display = 'inline-block'; 176 } 177 }; 178 179 const hideLoader = () => { 180 const smocLoaderContainer = document.getElementById(`${loaderId}-loader-container`); 181 if (smocLoaderContainer) { smocLoaderContainer.style.display = 'none'; } 182 }; 183 184 showLoader(); 185 186 fetch(`${ajaxurl}?action=smoc_reorder&_wpnonce=${encodeURIComponent(nonce)}`, { 187 method: 'POST', 188 headers: { 189 'Content-Type': 'application/x-www-form-urlencoded', 190 }, 191 body: new URLSearchParams({ 192 post_type: typenow, 193 post_id: postId, 194 post_menu_order: menuOrder, 195 }), 196 }) 197 .then(res => res.json()) 198 .then(response => { 199 if (response.success) { 200 showSuccess(); 201 smocInput.title = menuOrder; 202 smocInput.currentValue = menuOrder; 203 smocInput.defaultValue = menuOrder; 204 if (smocConfig.tab_to_next) { 205 tabToNextInput(smocInput); 206 } 207 } else { 208 smocInput.value = smocInput.defaultValue; 209 showError(); 210 } 211 }) 212 .catch(() => { 213 smocInput.value = smocInput.defaultValue; 214 hideLoader(); 215 showError(); 216 }) 217 .finally(() => { 218 hideLoader(); 219 smocInput.disabled = false; 220 }); 221 } 222 223 function disableInput(errorContainer, message, disable, input) { 224 input.value = input.defaultValue; 225 if (errorContainer) { errorContainer.style.display = 'inline-block'; } 226 input.disabled = disable; 227 input.title = message; 228 // eslint-disable-next-line no-console 229 console.warn(`[Simple Menu Order Column] ${message}`); 230 } 231 232 function tabToNextInput(smocInput) { 233 const inputs = Array.from(smocInputs); 234 const pos = inputs.indexOf(smocInput) + 1; 235 if (inputs[pos]) { inputs[pos].select(); } 236 } 237 238 /** 239 * Initilize Script 240 */ 241 if (document.readyState === "loading") { 242 document.addEventListener('DOMContentLoaded', smocInit); 243 window.addEventListener("load", smocInit); 244 } else { 245 window.setTimeout(smocInit); 246 } 230 247 })(); -
simple-menu-order-column/trunk/assets/js/simple-menu-order-column.min.js
r3407262 r3417744 8 8 * @license Released under the General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.html 9 9 */ 10 !function(){const{__:e}=wp.i18n; function t(){document.removeEventListener("DOMContentLoaded",t),window.removeEventListener("load",t);document.querySelectorAll("input[id^=smoc]").forEach(t=>{t.addEventListener("focus",()=>{t.currentValue=t.value,t.title=parseInt(t.value);const{postId:e}=t.dataset;if(!e)return;const n=e=>{const t=document.getElementById(e);t&&(t.style.display="none")},o=`smoc-${e}`;n(`${o}-loader-container`),n(`${o}-success`),n(`${o}-error`)}),t.addEventListener("focusout",()=>{t.disabled||t.currentValue!==t.value&&(window.confirm(e("Should the menu order value be updated?","simple-menu-order-column"))?n(t):t.value=t.defaultValue)}),t.addEventListener("keydown",e=>{(e.ctrlKey||e.metaKey)&&["a","c","v","x"].includes(e.key.toLowerCase())||["Backspace","Tab","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Delete","Home","End","Enter","Subtract","-"].includes(e.key)||/^\d$/.test(e.key)||e.preventDefault()}),t.addEventListener("paste",e=>{const t=e.clipboardData.getData("text");/^\d+$/.test(t)||e.preventDefault()}),t.addEventListener("keypress",e=>{"Enter"===e.key&&(e.preventDefault(),n(t))})})}function n(t){if(!t||t.disabled)return;const n=t.closest(".smoc-container"),d=parseInt(t.dataset.postId);if(!d||isNaN(d))return void o(null,e("The post_id is invalid.","simple-menu-order-column"),!0,t);const l=`smoc-${d}`,a=parseInt(t.value);if(isNaN(a)){return void o(document.getElementById(`${l}-error`),e("The menu order value is invalid.","simple-menu-order-column"),!1,t)}const r=t.dataset.wpnonce;if(!r){return void o(document.getElementById(`${l}-error`),e("The postNonce is invalid.","simple-menu-order-column"),!0,t)}if("undefined"==typeof ajaxurl||"undefined"==typeof typenow){return void o(document.getElementById(`${l}-error`),e("Invalid WP installation, variables typenow or ajaxurl are not initialized.","simple-menu-order-column"),!0,t)}t.disabled=!0;const s=()=>{let t=document.getElementById(`${l}-error`);t?t.style.display="inline-block":(t=document.createElement("span"),t.id=`${l}-error`,t.className="smoc-error dashicons dashicons-dismiss",t.setAttribute("role","img"),t.setAttribute("aria-label",e("An error ocurred while updating menu order.","simple-menu-order-column")),t.style.cssText="padding-top: 5px; color: #a00; display: inline-block;",n.appendChild(t))},i=()=>{const e=document.getElementById(`${l}-loader-container`);e&&(e.style.display="none")};(()=>{let t=document.getElementById(`${l}-loader-container`);if(t)t.style.display="inline-block";else{const o=document.createElement("span");o.id=`${l}-loader`,o.className="smoc-loader dashicons dashicons-update",o.setAttribute("role","img"),o.setAttribute("aria-label",e("Updating menu order...","simple-menu-order-column")),o.style.cssText="color: #2ea2cc; animation: iconrotation 2s infinite linear; display: inline-block;",t=document.createElement("div"),t.id=`${l}-loader-container`,t.style.cssText="padding-top: 5px; display: inline-block;",t.appendChild(o),n.appendChild(t)}})(),fetch(`${ajaxurl}?action=smoc_reorder&_wpnonce=${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({post_type:typenow,post_id:d,post_menu_order:a})}).then(e=>e.json()).then(o=>{if(o.success){(()=>{let t=document.getElementById(`${l}-success`);t?t.style.display="inline-block":(t=document.createElement("span"),t.id=`${l}-success`,t.className="smoc-success dashicons dashicons-yes-alt",t.setAttribute("role","img"),t.setAttribute("aria-label",e("The menu order has been updated successfully.","simple-menu-order-column")),t.style.cssText="padding-top: 5px; color: #7ad03a; display: inline-block;",n.appendChild(t))})(),t.title=a,t.currentValue=a,t.defaultValue=a;const o=Array.from(document.querySelectorAll("input[id^=smoc]")),d=o.indexOf(t)+1;o[d]&&o[d].select()}else t.value=t.defaultValue,s()}).catch(()=>{t.value=t.defaultValue,i(),s()}).finally(()=>{i(),t.disabled=!1})}function o(e,t,n,o){o.value=o.defaultValue,e&&(e.style.display="inline-block"),o.disabled=n,o.title=t,console.warn(`[Simple Menu Order Column] ${t}`)}"loading"===document.readyState?(document.addEventListener("DOMContentLoaded",t),window.addEventListener("load",t)):window.setTimeout(t)}();10 !function(){const{__:e}=wp.i18n;let t=null;const n=window.smoc_ui??{},o=n.enable_confirm??!0;n.tab_to_next;function a(){document.removeEventListener("DOMContentLoaded",a),window.removeEventListener("load",a),t=document.querySelectorAll("input[id^=smoc]"),t.forEach(t=>{t.addEventListener("focus",()=>{t.currentValue=t.value,t.title=parseInt(t.value);const{postId:e}=t.dataset;if(!e)return;const n=e=>{const t=document.getElementById(e);t&&(t.style.display="none")},o=`smoc-${e}`;n(`${o}-loader-container`),n(`${o}-success`),n(`${o}-error`)}),t.addEventListener("focusout",()=>{t.disabled||t.currentValue!==t.value&&(!o||window.confirm(e("Should the menu order value be updated?","simple-menu-order-column"))?l(t):t.value=t.defaultValue)}),t.addEventListener("keydown",e=>{(e.ctrlKey||e.metaKey)&&["a","c","v","x"].includes(e.key.toLowerCase())||["Backspace","Tab","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Delete","Home","End","Enter","Subtract","-"].includes(e.key)||/^\d$/.test(e.key)||e.preventDefault()}),t.addEventListener("paste",e=>{const t=e.clipboardData.getData("text");/^\d+$/.test(t)||e.preventDefault()}),t.addEventListener("keypress",e=>{"Enter"===e.key&&(e.preventDefault(),l(t))})})}function l(o){if(!o||o.disabled)return;const a=o.closest(".smoc-container"),l=parseInt(o.dataset.postId);if(!l||isNaN(l))return void d(null,e("The post_id is invalid.","simple-menu-order-column"),!0,o);const s=`smoc-${l}`,r=parseInt(o.value);if(isNaN(r)){return void d(document.getElementById(`${s}-error`),e("The menu order value is invalid.","simple-menu-order-column"),!1,o)}const i=o.dataset.wpnonce;if(!i){return void d(document.getElementById(`${s}-error`),e("The postNonce is invalid.","simple-menu-order-column"),!0,o)}if("undefined"==typeof ajaxurl||"undefined"==typeof typenow){return void d(document.getElementById(`${s}-error`),e("Invalid WP installation, variables typenow or ajaxurl are not initialized.","simple-menu-order-column"),!0,o)}o.disabled=!0;const c=()=>{let t=document.getElementById(`${s}-error`);t?t.style.display="inline-block":(t=document.createElement("span"),t.id=`${s}-error`,t.className="smoc-error dashicons dashicons-dismiss",t.setAttribute("role","img"),t.setAttribute("aria-label",e("An error ocurred while updating menu order.","simple-menu-order-column")),t.style.cssText="padding-top: 5px; color: #a00; display: inline-block;",a.appendChild(t))},u=()=>{const e=document.getElementById(`${s}-loader-container`);e&&(e.style.display="none")};(()=>{let t=document.getElementById(`${s}-loader-container`);if(t)t.style.display="inline-block";else{const n=document.createElement("span");n.id=`${s}-loader`,n.className="smoc-loader dashicons dashicons-update",n.setAttribute("role","img"),n.setAttribute("aria-label",e("Updating menu order...","simple-menu-order-column")),n.style.cssText="color: #2ea2cc; animation: iconrotation 2s infinite linear; display: inline-block;",t=document.createElement("div"),t.id=`${s}-loader-container`,t.style.cssText="padding-top: 5px; display: inline-block;",t.appendChild(n),a.appendChild(t)}})(),fetch(`${ajaxurl}?action=smoc_reorder&_wpnonce=${encodeURIComponent(i)}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({post_type:typenow,post_id:l,post_menu_order:r})}).then(e=>e.json()).then(l=>{l.success?((()=>{let t=document.getElementById(`${s}-success`);t?t.style.display="inline-block":(t=document.createElement("span"),t.id=`${s}-success`,t.className="smoc-success dashicons dashicons-yes-alt",t.setAttribute("role","img"),t.setAttribute("aria-label",e("The menu order has been updated successfully.","simple-menu-order-column")),t.style.cssText="padding-top: 5px; color: #7ad03a; display: inline-block;",a.appendChild(t))})(),o.title=r,o.currentValue=r,o.defaultValue=r,n.tab_to_next&&function(e){const n=Array.from(t),o=n.indexOf(e)+1;n[o]&&n[o].select()}(o)):(o.value=o.defaultValue,c())}).catch(()=>{o.value=o.defaultValue,u(),c()}).finally(()=>{u(),o.disabled=!1})}function d(e,t,n,o){o.value=o.defaultValue,e&&(e.style.display="inline-block"),o.disabled=n,o.title=t,console.warn(`[Simple Menu Order Column] ${t}`)}"loading"===document.readyState?(document.addEventListener("DOMContentLoaded",a),window.addEventListener("load",a)):window.setTimeout(a)}(); -
simple-menu-order-column/trunk/changelog.txt
r3407281 r3417744 1 1 == Changelog == 2 3 = 2.1.0 2025-12-10 = 4 5 * Allow to disable confirm window 6 * Allow to disable tab to next input field when data is updated 7 * Minor code changes 2 8 3 9 = 2.0.1 2025-12-01 = -
simple-menu-order-column/trunk/i18n/languages/simple-menu-order-column-ca-3fe84e529a0f3cc0a871b18c31074e39.json
r3259857 r3417744 1 {"translation-revision-date":"202 4-12-15 23:46+0000","generator":"Loco https:\/\/localise.biz\/","source":"assets\/js\/simple-menu-order-column.min.js","domain":"simple-menu-order-column","locale_data":{"simple-menu-order-column":{"":{"domain":"","lang":"ca","plural-forms":"nplurals=2; plural=n != 1;"},"An error ocurred while updating menu order.":["S'ha produ\u00eft un error en actualitzar l'ordre del men\u00fa."],"Invalid WP installation, variables typenow or ajaxurl are not initialized.":["La instal\u00b7laci\u00f3 de WP no \u00e9s v\u00e0lida, les variables typenow o ajaxurl no estan inicialitzades."],"Should the menu order value be updated?":["S'ha d'actualitzar el valor de la comanda del men\u00fa?"],"The menu order has been updated successfully.":["L'ordre del men\u00fa s'ha actualitzat correctament."],"The menu order value is invalid.":["El valor de l'ordre del men\u00fa no \u00e9s v\u00e0lid."],"The post_id is invalid.":["El post_id no \u00e9s v\u00e0lid."],"The postNonce is invalid.":["El postNonce no \u00e9s v\u00e0lid."],"Updating menu order...":["Actualitzant l'ordre de men\u00fa..."]}}}1 {"translation-revision-date":"2025-12-11 00:45+0000","generator":"Loco https:\/\/localise.biz\/","source":"assets\/js\/simple-menu-order-column.min.js","domain":"simple-menu-order-column","locale_data":{"simple-menu-order-column":{"":{"domain":"","lang":"ca","plural-forms":"nplurals=2; plural=n != 1;"},"An error ocurred while updating menu order.":["S'ha produ\u00eft un error en actualitzar l'ordre del men\u00fa."],"Invalid WP installation, variables typenow or ajaxurl are not initialized.":["La instal\u00b7laci\u00f3 de WP no \u00e9s v\u00e0lida, les variables typenow o ajaxurl no estan inicialitzades."],"Should the menu order value be updated?":["S'ha d'actualitzar el valor de la comanda del men\u00fa?"],"The menu order has been updated successfully.":["L'ordre del men\u00fa s'ha actualitzat correctament."],"The menu order value is invalid.":["El valor de l'ordre del men\u00fa no \u00e9s v\u00e0lid."],"The post_id is invalid.":["El post_id no \u00e9s v\u00e0lid."],"The postNonce is invalid.":["El postNonce no \u00e9s v\u00e0lid."],"Updating menu order...":["Actualitzant l'ordre de men\u00fa..."]}}} -
simple-menu-order-column/trunk/i18n/languages/simple-menu-order-column-ca.po
r3259831 r3417744 4 4 "Report-Msgid-Bugs-To: \n" 5 5 "POT-Creation-Date: 2024-03-08 01:56+0000\n" 6 "PO-Revision-Date: 202 4-12-15 23:46+0000\n"6 "PO-Revision-Date: 2025-12-11 00:45+0000\n" 7 7 "Last-Translator: \n" 8 8 "Language-Team: Catalan\n" … … 21 21 msgstr "Afegiu una columna d'ordre de menú als vostres llistats." 22 22 23 #: assets/js/simple-menu-order-column.js:1 3023 #: assets/js/simple-menu-order-column.js:171 24 24 msgid "An error ocurred while updating menu order." 25 25 msgstr "S'ha produït un error en actualitzar l'ordre del menú." … … 28 28 msgid "Chillcode" 29 29 msgstr "Chillcode" 30 31 #: includes/class-simplemenuordercolumn.php:164 32 msgid "Controls how the plugin handles UI confirmations." 33 msgstr "Controla com el connector gestiona les confirmacions." 34 35 #: includes/class-simplemenuordercolumn.php:135 36 msgid "Go to next field on update" 37 msgstr "Anar al camp següent en actualitzar" 30 38 31 39 #. Author URI of the plugin … … 37 45 msgstr "https://github.com/chillcode/simple-menu-order-column" 38 46 39 #: assets/js/simple-menu-order-column.js:147 47 #: includes/class-simplemenuordercolumn.php:141 48 msgid "" 49 "If disabled, the cursor will remain in the input field after menu order is " 50 "updated." 51 msgstr "" 52 "Si està desactivat, el cursor romandrà al camp d'entrada després que " 53 "s'actualitzi l'ordre del menú." 54 55 #: includes/class-simplemenuordercolumn.php:119 56 msgid "If disabled, the value will be updated automatically without prompting." 57 msgstr "" 58 "Si està desactivat, el valor s'actualitzarà automàticament sense demanar " 59 "confirmació." 60 61 #: assets/js/simple-menu-order-column.js:123 40 62 msgid "" 41 63 "Invalid WP installation, variables typenow or ajaxurl are not initialized." … … 44 66 "inicialitzades." 45 67 46 #: includes/class-simplemenuordercolumn.php: 22568 #: includes/class-simplemenuordercolumn.php:387 47 69 msgid "Order" 48 70 msgstr "Ordre" 49 71 50 #: assets/js/simple-menu-order-column.js: 25272 #: assets/js/simple-menu-order-column.js:54 51 73 msgid "Should the menu order value be updated?" 52 74 msgstr "S'ha d'actualitzar el valor de la comanda del menú?" 75 76 #: includes/class-simplemenuordercolumn.php:113 77 msgid "Show confirmation prompt" 78 msgstr "Mostra missatge de confirmació" 53 79 54 80 #. Name of the plugin … … 56 82 msgstr "Simple Menu Order Column" 57 83 58 #: assets/js/simple-menu-order-column.js:1 0584 #: assets/js/simple-menu-order-column.js:156 59 85 msgid "The menu order has been updated successfully." 60 86 msgstr "L'ordre del menú s'ha actualitzat correctament." 61 87 62 #: assets/js/simple-menu-order-column.js:1 5988 #: assets/js/simple-menu-order-column.js:110 63 89 msgid "The menu order value is invalid." 64 90 msgstr "El valor de l'ordre del menú no és vàlid." 65 91 66 #: assets/js/simple-menu-order-column.js: 3992 #: assets/js/simple-menu-order-column.js:102 67 93 msgid "The post_id is invalid." 68 94 msgstr "El post_id no és vàlid." 69 95 70 #: assets/js/simple-menu-order-column.js:1 7196 #: assets/js/simple-menu-order-column.js:117 71 97 msgid "The postNonce is invalid." 72 98 msgstr "El postNonce no és vàlid." 73 99 74 #: assets/js/simple-menu-order-column.js: 63100 #: assets/js/simple-menu-order-column.js:136 75 101 #| msgid "Updating Menu Order" 76 102 msgid "Updating menu order..." -
simple-menu-order-column/trunk/i18n/languages/simple-menu-order-column-es_ES-3fe84e529a0f3cc0a871b18c31074e39.json
r3259857 r3417744 1 {"translation-revision-date":"202 4-12-15 23:35+0000","generator":"Loco https:\/\/localise.biz\/","source":"assets\/js\/simple-menu-order-column.min.js","domain":"simple-menu-order-column","locale_data":{"simple-menu-order-column":{"":{"domain":"","lang":"es_ES","plural-forms":"nplurals=2; plural=n != 1;"},"An error ocurred while updating menu order.":["Se produjo un error al actualizar el orden de men\u00fa."],"Invalid WP installation, variables typenow or ajaxurl are not initialized.":["Instalaci\u00f3n de WordPress no v\u00e1lida, las variables typenow o ajaxurl no est\u00e1n inicializadas."],"Should the menu order value be updated?":["\u00bfSe debe actualizar el valor del orden de men\u00fa?"],"The menu order has been updated successfully.":["El orden de men\u00fa se actualiz\u00f3 correctamente."],"The menu order value is invalid.":["El valor de orden de men\u00fa no es v\u00e1lido."],"The post_id is invalid.":["El identificador de publicaci\u00f3n no es v\u00e1lido."],"The postNonce is invalid.":["El identificador \u00fanico no es v\u00f1aido"],"Updating menu order...":["Actualizando el orden de men\u00fa..."]}}}1 {"translation-revision-date":"2025-12-11 00:48+0000","generator":"Loco https:\/\/localise.biz\/","source":"assets\/js\/simple-menu-order-column.min.js","domain":"simple-menu-order-column","locale_data":{"simple-menu-order-column":{"":{"domain":"","lang":"es_ES","plural-forms":"nplurals=2; plural=n != 1;"},"An error ocurred while updating menu order.":["Se produjo un error al actualizar el orden de men\u00fa."],"Invalid WP installation, variables typenow or ajaxurl are not initialized.":["Instalaci\u00f3n de WordPress no v\u00e1lida, las variables typenow o ajaxurl no est\u00e1n inicializadas."],"Should the menu order value be updated?":["\u00bfSe debe actualizar el valor del orden de men\u00fa?"],"The menu order has been updated successfully.":["El orden de men\u00fa se actualiz\u00f3 correctamente."],"The menu order value is invalid.":["El valor de orden de men\u00fa no es v\u00e1lido."],"The post_id is invalid.":["El identificador de publicaci\u00f3n no es v\u00e1lido."],"The postNonce is invalid.":["El identificador \u00fanico no es v\u00f1aido"],"Updating menu order...":["Actualizando el orden de men\u00fa..."]}}} -
simple-menu-order-column/trunk/i18n/languages/simple-menu-order-column-es_ES.po
r3259831 r3417744 4 4 "Report-Msgid-Bugs-To: \n" 5 5 "POT-Creation-Date: 2024-03-08 01:56+0000\n" 6 "PO-Revision-Date: 202 4-12-15 23:35+0000\n"6 "PO-Revision-Date: 2025-12-11 00:48+0000\n" 7 7 "Last-Translator: \n" 8 "Language-Team: Español\n"8 "Language-Team: Spanish (Spain)\n" 9 9 "Language: es_ES\n" 10 10 "Plural-Forms: nplurals=2; plural=n != 1;\n" … … 21 21 msgstr "Añade una columna de orden de menú a sus listados." 22 22 23 #: assets/js/simple-menu-order-column.js:1 3023 #: assets/js/simple-menu-order-column.js:171 24 24 msgid "An error ocurred while updating menu order." 25 25 msgstr "Se produjo un error al actualizar el orden de menú." … … 28 28 msgid "Chillcode" 29 29 msgstr "Chillcode" 30 31 #: includes/class-simplemenuordercolumn.php:164 32 msgid "Controls how the plugin handles UI confirmations." 33 msgstr "Controla cómo la extensión maneja las confirmaciones." 34 35 #: includes/class-simplemenuordercolumn.php:135 36 msgid "Go to next field on update" 37 msgstr "Ir al siguiente campo después de actualizar" 30 38 31 39 #. Author URI of the plugin … … 37 45 msgstr "https://github.com/chillcode/simple-menu-order-column" 38 46 39 #: assets/js/simple-menu-order-column.js:147 47 #: includes/class-simplemenuordercolumn.php:141 48 msgid "" 49 "If disabled, the cursor will remain in the input field after menu order is " 50 "updated." 51 msgstr "" 52 "Si está deshabilitado, el cursor permanecerá en el campo de entrada después " 53 "de que se actualice el orden del menú." 54 55 #: includes/class-simplemenuordercolumn.php:119 56 msgid "If disabled, the value will be updated automatically without prompting." 57 msgstr "" 58 "Si está deshabilitado, el valor se actualizará automáticamente sin preguntar." 59 60 #: assets/js/simple-menu-order-column.js:123 40 61 msgid "" 41 62 "Invalid WP installation, variables typenow or ajaxurl are not initialized." … … 44 65 "inicializadas." 45 66 46 #: includes/class-simplemenuordercolumn.php: 22567 #: includes/class-simplemenuordercolumn.php:387 47 68 msgid "Order" 48 69 msgstr "Orden" 49 70 50 #: assets/js/simple-menu-order-column.js: 25271 #: assets/js/simple-menu-order-column.js:54 51 72 msgid "Should the menu order value be updated?" 52 73 msgstr "¿Se debe actualizar el valor del orden de menú?" 74 75 #: includes/class-simplemenuordercolumn.php:113 76 msgid "Show confirmation prompt" 77 msgstr "Mostrar mensaje de confirmación" 53 78 54 79 #. Name of the plugin … … 56 81 msgstr "Simple Menu Order Column" 57 82 58 #: assets/js/simple-menu-order-column.js:1 0583 #: assets/js/simple-menu-order-column.js:156 59 84 msgid "The menu order has been updated successfully." 60 85 msgstr "El orden de menú se actualizó correctamente." 61 86 62 #: assets/js/simple-menu-order-column.js:1 5987 #: assets/js/simple-menu-order-column.js:110 63 88 msgid "The menu order value is invalid." 64 89 msgstr "El valor de orden de menú no es válido." 65 90 66 #: assets/js/simple-menu-order-column.js: 3991 #: assets/js/simple-menu-order-column.js:102 67 92 msgid "The post_id is invalid." 68 93 msgstr "El identificador de publicación no es válido." 69 94 70 #: assets/js/simple-menu-order-column.js:1 7195 #: assets/js/simple-menu-order-column.js:117 71 96 msgid "The postNonce is invalid." 72 97 msgstr "El identificador único no es vñaido" 73 98 74 #: assets/js/simple-menu-order-column.js: 6399 #: assets/js/simple-menu-order-column.js:136 75 100 msgid "Updating menu order..." 76 101 msgstr "Actualizando el orden de menú..." -
simple-menu-order-column/trunk/i18n/languages/simple-menu-order-column.pot
r3259831 r3417744 4 4 "Project-Id-Version: Simple Menu Order Column\n" 5 5 "Report-Msgid-Bugs-To: \n" 6 "POT-Creation-Date: 202 4-12-15 21:37+0000\n"6 "POT-Creation-Date: 2025-12-11 00:40+0000\n" 7 7 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 8 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 21 21 msgstr "" 22 22 23 #: assets/js/simple-menu-order-column.js:1 3023 #: assets/js/simple-menu-order-column.js:171 24 24 msgid "An error ocurred while updating menu order." 25 25 msgstr "" … … 27 27 #. Author of the plugin 28 28 msgid "Chillcode" 29 msgstr "" 30 31 #: includes/class-simplemenuordercolumn.php:164 32 msgid "Controls how the plugin handles UI confirmations." 33 msgstr "" 34 35 #: includes/class-simplemenuordercolumn.php:135 36 msgid "Go to next field on update" 29 37 msgstr "" 30 38 … … 37 45 msgstr "" 38 46 39 #: assets/js/simple-menu-order-column.js:147 47 #: includes/class-simplemenuordercolumn.php:141 48 msgid "" 49 "If disabled, the cursor will remain in the input field after menu order is " 50 "updated." 51 msgstr "" 52 53 #: includes/class-simplemenuordercolumn.php:119 54 msgid "If disabled, the value will be updated automatically without prompting." 55 msgstr "" 56 57 #: assets/js/simple-menu-order-column.js:123 40 58 msgid "" 41 59 "Invalid WP installation, variables typenow or ajaxurl are not initialized." 42 60 msgstr "" 43 61 44 #: includes/class-simplemenuordercolumn.php: 22562 #: includes/class-simplemenuordercolumn.php:387 45 63 msgid "Order" 46 64 msgstr "" 47 65 48 #: assets/js/simple-menu-order-column.js: 25266 #: assets/js/simple-menu-order-column.js:54 49 67 msgid "Should the menu order value be updated?" 68 msgstr "" 69 70 #: includes/class-simplemenuordercolumn.php:113 71 msgid "Show confirmation prompt" 50 72 msgstr "" 51 73 … … 54 76 msgstr "" 55 77 56 #: assets/js/simple-menu-order-column.js:1 0578 #: assets/js/simple-menu-order-column.js:156 57 79 msgid "The menu order has been updated successfully." 58 80 msgstr "" 59 81 60 #: assets/js/simple-menu-order-column.js:1 5982 #: assets/js/simple-menu-order-column.js:110 61 83 msgid "The menu order value is invalid." 62 84 msgstr "" 63 85 64 #: assets/js/simple-menu-order-column.js: 3986 #: assets/js/simple-menu-order-column.js:102 65 87 msgid "The post_id is invalid." 66 88 msgstr "" 67 89 68 #: assets/js/simple-menu-order-column.js:1 7190 #: assets/js/simple-menu-order-column.js:117 69 91 msgid "The postNonce is invalid." 70 92 msgstr "" 71 93 72 #: assets/js/simple-menu-order-column.js: 6394 #: assets/js/simple-menu-order-column.js:136 73 95 msgid "Updating menu order..." 74 96 msgstr "" -
simple-menu-order-column/trunk/includes/class-simplemenuordercolumn.php
r3407262 r3417744 35 35 private static $smoc_allowed_types = array( 'post', 'page', 'product', 'attachment' ); 36 36 37 public const SMOC_OPTION_UI_CONFIRM = 'smoc_ui_confirmation'; 38 public const SMOC_OPTION_UI_TAB_TO_NEXT = 'smoc_ui_tab_to_next'; 39 37 40 /** 38 41 * Construtor. … … 78 81 load_plugin_textdomain( 'simple-menu-order-column', false, dirname( plugin_basename( SMOC_PLUGIN_FILE ) ) . '/i18n/languages/' ); 79 82 } 83 84 add_action( 'admin_init', array( $this, 'add_setting' ) ); 85 } 86 87 /** 88 * Add setting to wriring dashboard to disable UI confirmation. 89 * 90 * @return void 91 */ 92 public function add_setting() { 93 94 add_settings_section( 95 'smoc_section', 96 'Simple Menu Order Column', 97 array( __CLASS__, 'output_section_description' ), 98 'writing' 99 ); 100 101 register_setting( 102 'writing', 103 self::SMOC_OPTION_UI_CONFIRM, 104 array( 105 'type' => 'boolean', 106 'sanitize_callback' => array( __CLASS__, 'input_sanitize_checkbox' ), 107 'default' => true, 108 ) 109 ); 110 111 add_settings_field( 112 self::SMOC_OPTION_UI_CONFIRM, 113 __( 'Show confirmation prompt', 'simple-menu-order-column' ), 114 array( __CLASS__, 'output_admin_setting' ), 115 'writing', 116 'smoc_section', 117 array( 118 'option_name' => self::SMOC_OPTION_UI_CONFIRM, 119 'option_desc' => esc_attr__( 'If disabled, the value will be updated automatically without prompting.', 'simple-menu-order-column' ), 120 ) 121 ); 122 123 register_setting( 124 'writing', 125 self::SMOC_OPTION_UI_TAB_TO_NEXT, 126 array( 127 'type' => 'boolean', 128 'sanitize_callback' => array( __CLASS__, 'input_sanitize_checkbox' ), 129 'default' => true, 130 ) 131 ); 132 133 add_settings_field( 134 self::SMOC_OPTION_UI_TAB_TO_NEXT, 135 __( 'Go to next field on update', 'simple-menu-order-column' ), 136 array( __CLASS__, 'output_admin_setting' ), 137 'writing', 138 'smoc_section', 139 array( 140 'option_name' => self::SMOC_OPTION_UI_TAB_TO_NEXT, 141 'option_desc' => esc_attr__( 'If disabled, the cursor will remain in the input field after menu order is updated.', 'simple-menu-order-column' ), 142 ) 143 ); 144 } 145 146 /** 147 * Sanitize checkbox value. 148 * 149 * @param mixed $value Value to sanitize. 150 * 151 * @return int 152 */ 153 public static function input_sanitize_checkbox( $value ) { 154 155 return $value ? 1 : 0; 156 } 157 158 /** 159 * Generate html checkbox to disable UI confirmation section 160 * 161 * @return void 162 */ 163 public static function output_section_description() { 164 echo '<p>' . esc_html__( 165 'Controls how the plugin handles UI confirmations.', 166 'simple-menu-order-column' 167 ) . '</p>'; 168 } 169 170 /** 171 * Generate html checkbox to disable UI confirmation. 172 * 173 * @param array $options Option name. 174 * 175 * @return void 176 */ 177 public static function output_admin_setting( array $options ) { 178 $checked = filter_var( get_option( $options['option_name'], true ), FILTER_VALIDATE_BOOLEAN, array( 'default' => true ) ); 179 180 print '<label>'; 181 print '<input name="' . esc_attr( $options['option_name'] ) . '" type="checkbox" ' . checked( $checked, true, false ) . ' class="smoc-input" value="1" />'; 182 print esc_attr( $options['option_desc'] ); 183 print '</label>'; 80 184 } 81 185 … … 121 225 $wp_scripts_get_suffix = wp_scripts_get_suffix(); 122 226 123 wp_enqueue_script( 'simple-menu-order-column', plugins_url( 'assets/js/simple-menu-order-column' . $wp_scripts_get_suffix . '.js', SMOC_PLUGIN_FILE ), array( 'wp-i18n' ), SMOC_PLUGIN_VERSION, true ); 124 wp_enqueue_style( 'simple-menu-order-column', plugins_url( 'assets/css/simple-menu-order-column' . $wp_scripts_get_suffix . '.css', SMOC_PLUGIN_FILE ), array(), SMOC_PLUGIN_VERSION ); 125 126 wp_set_script_translations( 'simple-menu-order-column', 'simple-menu-order-column', plugin_dir_path( SMOC_PLUGIN_FILE ) . '/i18n/languages/' ); 227 wp_enqueue_script( 228 'simple-menu-order-column', 229 plugins_url( 'assets/js/simple-menu-order-column' . $wp_scripts_get_suffix . '.js', SMOC_PLUGIN_FILE ), 230 array( 'wp-i18n' ), 231 SMOC_PLUGIN_VERSION, 232 true 233 ); 234 235 wp_localize_script( 236 'simple-menu-order-column', 237 'smoc_ui', 238 array( 239 'enable_confirm' => filter_var( 240 get_option( 241 self::SMOC_OPTION_UI_CONFIRM, 242 true 243 ), 244 FILTER_VALIDATE_BOOLEAN, 245 array( 'default' => true ) 246 ), 247 'tab_to_next' => filter_var( 248 get_option( 249 self::SMOC_OPTION_UI_TAB_TO_NEXT, 250 true 251 ), 252 FILTER_VALIDATE_BOOLEAN, 253 array( 'default' => true ) 254 ), 255 ) 256 ); 257 258 wp_set_script_translations( 259 'simple-menu-order-column', 260 'simple-menu-order-column', 261 plugin_dir_path( SMOC_PLUGIN_FILE ) . '/i18n/languages/' 262 ); 263 264 wp_enqueue_style( 265 'simple-menu-order-column', 266 plugins_url( 'assets/css/simple-menu-order-column' . $wp_scripts_get_suffix . '.css', SMOC_PLUGIN_FILE ), 267 array(), 268 SMOC_PLUGIN_VERSION 269 ); 127 270 } 128 271 … … 158 301 * Get post_id & post_menu_order. 159 302 */ 160 $post_id = filter_input( INPUT_POST, 'post_id', FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1 ) ) ); 161 $post_menu_order = filter_input( INPUT_POST, 'post_menu_order', FILTER_VALIDATE_INT ); 303 $post_id = filter_input( 304 INPUT_POST, 305 'post_id', 306 FILTER_VALIDATE_INT, 307 array( 'options' => array( 'min_range' => 1 ) ) 308 ); 309 $post_menu_order = filter_input( 310 INPUT_POST, 311 'post_menu_order', 312 FILTER_VALIDATE_INT 313 ); 162 314 163 315 if ( -
simple-menu-order-column/trunk/readme.txt
r3407281 r3417744 3 3 Tags: menu order, pages, media, posts, products 4 4 Requires at least: 6.0 5 Tested up to: 6. 85 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 2. 0.17 Stable tag: 2.1.0 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 57 57 Once installed you will see an input box on every listing item. 58 58 59 To disable confirm prompt after menu order is updated visit **Wordpres Settings->Writing** and untick the option **Enable confirmation on input exit** 60 To disable tab to next on position update visit **Wordpress Settings->Writing** and untick the option Enable **Go to next field on update** 61 59 62 == Usage == 60 63 … … 67 70 == Changelog == 68 71 69 = 2. 0.1 2025-12-01=72 = 2.1.0 2025-12-10 = 70 73 71 * Allow negative values 74 * Allow to disable confirm window 75 * Allow to disable tab to next input field when data is updated 72 76 73 77 == Upgrade Notice == 74 78 75 = 1.0.1 = 76 Fix false positive with Woo HPOS. 79 = 2.1.0 = 80 81 Improve UI functionality 82 83 = 2.0.0 = 84 Vanilla Javascript, no jQuery. 85 Minor PHPDoc fixes. 86 Minor code fixes. 77 87 78 88 = 1.0.2 = … … 80 90 Localize Javascript. 81 91 82 = 2.0.0 = 83 Vanilla Javascript, no jQuery. 84 Minor PHPDoc fixes. 85 Minor code fixes. 92 = 1.0.1 = 93 Fix false positive with Woo HPOS. 86 94 87 95 == Screenshots == -
simple-menu-order-column/trunk/simple-menu-order-column.php
r3407262 r3417744 12 12 * Plugin URI: https://github.com/chillcode/simple-menu-order-column 13 13 * Description: Add a menu order column to your listings. 14 * Version: 2. 0.114 * Version: 2.1.0 15 15 * Requires at least: 6.0 16 16 * Requires PHP: 7.4 … … 27 27 define( 'SMOC_PLUGIN_PATH', __DIR__ ); 28 28 define( 'SMOC_PLUGIN_FILE', __FILE__ ); 29 define( 'SMOC_PLUGIN_VERSION', '2. 0.1' );29 define( 'SMOC_PLUGIN_VERSION', '2.1.0' ); 30 30 31 31 require_once SMOC_PLUGIN_PATH . '/includes/class-simplemenuordercolumn.php';
Note: See TracChangeset
for help on using the changeset viewer.