HEX
Server: Apache/2.4.66 (Debian)
System: Linux 6dfabc3b2241 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64
User: (1000)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/wpgraphql-acf/src/assets/admin/js/taxonomy-settings.js
$j = jQuery.noConflict();

$j(document).ready(function () {
	new acf.Model({
		id: 'graphqlPostTypeSettings',
		events: {
			'blur .acf_singular_label': 'onChangeSingularLabel',
			'blur .acf_plural_label': 'onChangePluralLabel',
		},
		// when the singular label of thetaxonomy is changed
		// update the graphql_single_name field, if it doesn't have a value
		onChangeSingularLabel(e, $el) {
			const label = $el.val();
			const sanitized = acf.strCamelCase(acf.strSanitize(label));
			this.updateValue('#acf_taxonomy-graphql_single_name', sanitized);
		},
		// when the plural label of the taxonomy is changed
		// update the graphql_plural_name field, if it doesn't have a value
		onChangePluralLabel(e, $el) {
			const label = $el.val();
			const sanitized = acf.strCamelCase(acf.strSanitize(label));
			this.updateValue('#acf_taxonomy-graphql_plural_name', sanitized);
		},
		updateValue(fieldId, value) {
			const currentValue = $j(fieldId).val();

			// if there's already a value, do nothing
			if ('' !== currentValue) {
				return;
			}

			// set the value
			$j(fieldId).val(value);
		},
	});
});