| Server IP : 38.190.208.107 / Your IP : 216.73.217.51 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.12/wp-content/themes/blocksy/static/js/backend/woo-attributes/ |
Upload File : |
import { createElement, createRoot } from '@wordpress/element'
import ManageAttributeOption from './ManageAttributeOption'
export const collectAttributes = () => {
return [...document.querySelectorAll('[name*=attribute_values]')]
.filter((el) => {
return el
.closest('.woocommerce_attribute_data')
.querySelector(
'input.woocommerce_attribute_used_for_variations'
).checked
})
.map((el) => {
const values = []
const attributeNameField = el
.closest('tr')
.querySelector('.attribute_name')
let attributeName = ''
let customAttr = false
if (el.tagName === 'SELECT') {
;[...el.querySelectorAll('option')].map((option) => {
values.push({
value: option.value,
label: option.textContent,
selected: option.selected,
})
})
attributeName =
attributeNameField.querySelector('strong').textContent
}
if (el.tagName === 'TEXTAREA') {
el.value
.split('|')
.map((value) => value.trim())
.map((value) => {
values.push({
value,
label: value,
selected: true,
})
})
customAttr = true
attributeName = attributeNameField.querySelector('input').value
}
return {
name: attributeName,
taxonomy:
el.closest('[data-taxonomy]').dataset.taxonomy ||
attributeName,
values,
customAttr,
}
})
}
const initWooVariation = (variationWrapper) => {
if (!variationWrapper) {
return
}
const input = document.querySelector('#ct-woo-attributes-list')
const options = JSON.parse(input.dataset.options)
const initialValue = input.value ? JSON.parse(input.value) : {}
variationWrapper.closest('.options_group').innerHtml = ''
const root = createRoot(variationWrapper.closest('.options_group'))
root.render(
<ManageAttributeOption
options={options}
initialValue={initialValue}
input_id={input.id}
input_name={input.name}
/>
)
}
export const initAllWooAttributesOptions = () => {
initWooVariation(document.querySelector('#ct-woo-attributes-list'))
}