<?php

namespace WKO\Helpers;


use WKO\Controllers\Emails;
use WKO\Controllers\Woocommerce;
use WKO\Controllers\Actions\SyncOrder;

/**
 * Name: Hooks
 * Call the actions and filter
 * @package Helpers
 * @since 1.0.0
 */

add_action('init', [
    'WKO\Helpers\Functions',
    'initialize'
], 0);

add_action('admin_menu', [
    'WKO\Helpers\Functions',
    'initialize_menus'
]);

add_action('wp_enqueue_scripts', [
    'WKO\Helpers\Functions',
    'enqueue_theme_scripts'
]);

add_action('admin_enqueue_scripts', [
    'WKO\Helpers\Functions',
    'enqueue_admin_scripts'
]);


add_action('init', [
    'WKO\Helpers\Functions',
    'woo_init'
]);

add_filter('plugin_action_links', [
    'WKO\Helpers\Functions',
    'settings_link'
], 10, 2);


add_action('plugins_loaded', [
    'WKO\Helpers\Functions',
    'init_database'
]);

add_action('rest_api_init', [
    new Functions,
    'registerRestAPI'
]);

add_filter('script_loader_tag', [
    new Functions,
    'add_script_attributes'
], 10, 1);


add_filter('woocommerce_payment_gateways', [
    new Woocommerce,
    'registerPaymentGateways'
], 10, 1);

add_action('woocommerce_blocks_loaded', [
    new WooCommerce,
    'loadWooCommerceBlocks'
], 10);

add_action('woocommerce_blocks_loaded', [
    new WooCommerce,
    'registerGatewayUpdateTotal'
]);

add_filter('woocommerce_email_classes', [
    'WKO\Controllers\Emails',
    'register_email_classes'
], 10, 1);

add_action('init', function () {
    new Emails();
}, 20);

add_action('wp_ajax_koin_sync_order', function () {
    new SyncOrder();
});
