<?php
/**
 *
 * @link              http://yemlihakorkmaz.com
 * @since             2.4.0
 * @package           Korkmaz_contract
 *
 * @wordpress-plugin
 * Plugin Name:       Order Contracts for WooCommerce
 * Plugin URI:        http://www.yemlihakorkmaz.com/
 * Description:       A WooCommerce plugin that automatically generates contracts shown to customers at checkout, displays them dynamically, and emails them as PDFs.
 * Version:           2.4.10
 * Author:            yemlihakorkmaz
 * Author URI:        http://yemlihakorkmaz.com/contact
 * Requires Plugins:  woocommerce
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       wc-korkmaz-contract
 * Domain Path:       /languages
 */

if (!defined('WPINC')) {
	die;
}

const KORKMAZ_CONTRACT_VERSION = '2.4.10';

if (!defined('korkmaz_contract_dir')) {
	define('korkmaz_contract_dir', plugin_dir_path(__FILE__));
}

if (!defined('korkmaz_contract_url')) {
	define('korkmaz_contract_url', plugins_url('/', dirname(__FILE__)));
}

add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'korkmaz_contract_action_links');

function korkmaz_contract_action_links($links)
{
	$settings_label = did_action('init') ? __('Settings', 'wc-korkmaz-contract') : 'Settings';
	$settings_link = '<a href="' . esc_url(admin_url('admin.php?page=sozlesme_ekrani')) . '">' . esc_html($settings_label) . '</a>';
	array_unshift($links, $settings_link);
	return $links;
}

function scwc_activate_plugin(): void
{
	require_once plugin_dir_path(__FILE__) . 'includes/class-korkmaz_contract-activator.php';
	SCWC_Activator::activate();
}

function scwc_deactivate_plugin(): void
{
	require_once plugin_dir_path(__FILE__) . 'includes/class-korkmaz_contract-deactivator.php';
	Korkmaz_contract_Deactivator::deactivate();
}

add_action(
	'before_woocommerce_init',
	function () {
		if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
			\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
		}
	}
);

register_activation_hook(__FILE__, 'scwc_activate_plugin');
register_deactivation_hook(__FILE__, 'scwc_deactivate_plugin');

require plugin_dir_path(__FILE__) . 'includes/class-korkmaz_contract.php';

function scwc_run_plugin(): void
{
	$plugin = new Korkmaz_contract();
	$plugin->run();
}

scwc_run_plugin();
