<?php
/**
 * Taslak Ekranını Oluşturan Klastır
 *
 * Loads and defines the internationalization files for this plugin
 * so that it is ready for translation.
 *
 * @link       http://yemlihakorkmaz.com
 * @since      1.0.0
 *
 * @package    Korkmaz_contract-taslak-ekrani
 * @subpackage Korkmaz_contract-taslak-ekrani/includes
 */

/**
 * Define the internationalization functionality.
 *
 * Loads and defines the internationalization files for this plugin
 * so that it is ready for translation.
 *
 * @since      1.0.0
 * @package    Korkmaz_contract-taslak-ekrani
 * @subpackage Korkmaz_contract-taslak-ekrani/includes
 * @author     Yemliha KORKMAZ <yemlihakorkmaz@hotmail.com>
 */
class SCWC_Draft_Screen
{
	/**
	 * taslak ekrani burada bulunur
	 *
	 * @since    1.0.0
	 */
	public function taslak_ekrani($editor_adi)
	{
		if (!current_user_can('manage_options')) {
			wp_die(esc_html__('You do not have permission to edit contract templates.', 'wc-korkmaz-contract'));
		}

		if (isset($_POST['submit'])) {
			check_admin_referer('korkmaz_contract_save_template_' . $editor_adi);

			$raw = isset($_POST[$editor_adi]) ? wp_unslash($_POST[$editor_adi]) : '';
			$gelenmetin = wp_kses_post($raw);
			update_option($editor_adi, $gelenmetin);
		}
		?>
        <form method="POST">
			<?php wp_nonce_field('korkmaz_contract_save_template_' . $editor_adi); ?>
			<?php $settings = [
				'wpautop'       => false,
				'textarea_name' => $editor_adi
			];
			wp_editor((stripslashes(get_option($editor_adi))), $editor_adi, $settings);
			submit_button();
			?>
        </form>
		<?php
	}
}
