js_vars

Use output and set transport to auto instead.

Using js_vars is almost never needed. This argument should only be used in special cases as it will be internally calculated from the output argument if you set transport to auto.

See the transport and output arguments for more details.

If you set transport to postMessage you can write your own scripts, or you can use the js_vars argument and let Kirki automatically create these for you.

It is defined as an array of arrays so you can specify multiple elements.

Kirki::add_field( 'my_config', [
	'type'      => 'color',
	'settings'  => 'my_setting',
	'label'     => esc_html__( 'Text Color', 'translation_domain' ),
	'section'   => 'my_section',
	'default'   => 1,
	'priority'  => 1,
	'transport' => 'postMessage',
	'js_vars'   => [
		[
			'element'  => 'body',
			'function' => 'css',
			'property' => 'color',
		],
		[
			'element'  => 'h1, h2, h3, h4',
			'function' => 'css',
			'property' => 'color',
		],
	]
] );

Available arguments you can use on each item inside each array:

Can't find what you're looking for? Check the github issues or edit this page to add what's missing.