code

Using the code control your users can enter custom CSS, JS, HTML (and others) which you can then use however you please in your themes. Internally this control uses the CodeMirror library available in WordPress.

CodeMirror is only available in WordPress 4.9+ so if used in an older WordPress installation we gracefully fallback to a textarea field.

Example

Kirki::add_field( 'theme_config_id', [
	'type'        => 'code',
	'settings'    => 'code_setting',
	'label'       => esc_html__( 'Code Control', 'kirki' ),
	'description' => esc_html__( 'Description', 'kirki' ),
	'section'     => 'section_id',
	'default'     => '',
	'choices'     => [
		'language' => 'css',
	],
] );

Usage

<?php echo get_theme_mod( 'code_setting', '' ); ?>

Last updated on: May 9th, 2020

Scroll to Top

Download

Subscribe & be the first to be informed about
new features & updates!