<?php

/**
 * HappyFenceNG Total Enterprise Security Plugin
 * HAPPYWPRESS is a RazorVue Trademark. 
 * @package     HappyFenceNG
 * @developer   Simonluca Scillitani
 * @copyright   2025 RazorVue di Scillitani Simonluca
 * @link        https://razorvue.it
 * @author      RazorVue di Scillitani Simonluca
 * @brand       HappyWPress
 * @uri         https://happywpress.com
 * @set all
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
if ( defined( 'WP_CLI' ) && WP_CLI ) {
    require_once HAPPYFENCENG_PATH . 'includes/tools/cli/class-happyfencengwpclilogin.php';
    require_once HAPPYFENCENG_PATH . 'includes/tools/cli/class-happyfencenglistfilters.php';
    require_once HAPPYFENCENG_PATH . 'includes/tools/cli/class-happyfencenglisthffilters.php';
    require_once HAPPYFENCENG_PATH . 'includes/tools/cli/class-happyfencengclidashboard.php';
    require_once HAPPYFENCENG_PATH . 'includes/tools/cli/premium/class-happyfencengclicfguard.php';
}
/**PHPCS -> code compliance: we put useful comments where needed.. */
function happyfenceng_enqueue_admin_styles(  $hook  ) {
    wp_enqueue_style(
        'happyfenceng-admin-style',
        plugin_dir_url( __FILE__ ) . 'assets/happyfenceng.css',
        array(),
        '1.0.0'
    );
}

add_action( 'admin_enqueue_scripts', 'happyfenceng_enqueue_admin_styles' );
function happyfenceng_enqueue_styles() {
    wp_enqueue_style(
        'happyfenceng-main',
        plugin_dir_url( __FILE__ ) . 'assets/happyfenceng.css',
        array(),
        false,
        'all'
    );
    wp_enqueue_style(
        'happyfenceng-privacy',
        plugin_dir_url( __FILE__ ) . 'assets/happyfenceng-privacy.css',
        array(),
        false,
        'all'
    );
    wp_enqueue_script(
        'happyfenceng-js',
        plugin_dir_url( __FILE__ ) . 'assets/happyfenceng-privacy.js',
        array(),
        false,
        true
    );
}

add_action( 'wp_enqueue_scripts', 'happyfenceng_enqueue_styles', 20 );
call_user_func( function () {
    if ( !did_action( 'plugins_loaded' ) ) {
        add_action( 'init', 'happyfenceng_init', 1 );
    }
} );
/**PHPCS -> code compliance: we put useful comments where needed.. */
function happyfenceng_init() {
    HappyFenceNGSControl::get_instance()->init();
    HappyFenceNGEControl::get_instance()->init();
}

/**PHPCS -> code compliance: we put useful comments where needed.. */
add_action( 'admin_menu', 'happyfenceng_admin_menu' );
/**PHPCS -> code compliance: we put useful comments where needed.. */
function happyfenceng_admin_menu() {
    HappyFenceNGAdmin::get_instance()->init();
}

/**PHPCS -> code compliance: we put useful comments where needed.. */
add_action( 'admin_notices', 'happyfenceng_admin_notices' );
/**PHPCS -> code compliance: we put useful comments where needed.. */
function happyfenceng_admin_notices() {
    if ( $msg = get_transient( 'happyfenceng_last_error' ) ) {
        echo '<div class="notice notice-error"><p>' . esc_html( $msg ) . '</p></div>';
        delete_transient( 'happyfenceng_last_error' );
    }
}
