<?php 

function tawkto_footers() {
	if(get_option("enable_tawkto")) {
		echo removeslashes(get_option('tawkto_property_code'));
	}
}

function tawkto_settings_fields() {
	label("Tawk.to Settings");
	textarea(['label' => 'Property Code', 'id' => 'property_code', 'value' => removeslashes(get_option('tawkto_property_code'))]);
	checkbox(['label' => 'Enable Tawk.to', 'id' => 'enable_tawkto'], get_option('enable_tawkto'));
	?>
	<p>Don't have a Tawk.to account? <a href="https://tawk.to" target="_blank">Click here</a> to create a new account</p>
	<?php
}

function save_tawkto_settings($args) {
	$enable_tawkto = ($args['enable_tawkto'] == 1) ? 1 : 0;
	update_option('enable_tawkto', $enable_tawkto);
	update_option('tawkto_property_code', sanitize($args['property_code']));
}