<?php
namespace AIAutoTool\Features\AutoCreateTags;

if ( ! defined( 'ABSPATH' ) ) exit; // Thoát nếu truy cập trực tiếp

/**
 * AI Auto Tool - Auto Create Tags Feature
 * 
 * @package AIAutoTool\Features\AutoCreateTags
 * @namespace AIAutoTool\Features\AutoCreateTags
 */

// Include the full Auto Create Tags implementation with all features
require_once dirname(__FILE__) . '/aiautotool_autocreatetag.php';

// Create namespace wrapper
if (!class_exists('AIAutoTool\\Features\\AutoCreateTags\\AutoCreateTags')) {
    class AutoCreateTags extends \AIautotool_autocreatetags {
        public $active_option_name = 'AIautotool_autocreatetag_active';
        public $icon = '<i class="fa-solid fa-tags"></i>';
        
        public function __construct() {
            // Ensure correct option name
            $this->active_option_name = 'AIautotool_autocreatetag_active';
            parent::__construct();
        }
        
        /**
         * Render feature for integrations page
         */
        public function render_feature() {
            // Load feature descriptions
            require_once plugin_dir_path(dirname(__FILE__)) . 'lib/feature-descriptions.php';
            
            $description = \AiAutoTool_Feature_Descriptions::get('auto_create_tag');
            if (!$description) {
                $description = __('Automatically create and assign tags to posts using AI', 'ai-auto-tool');
            }
            
            $autoToolBox = new \AutoToolBox(
                esc_html__('Auto Tags By AI', 'ai-auto-tool'),
                $description,
                "https://doc.aiautotool.com/features/auto-tags",
                $this->active_option_name,
                $this->active,
                plugins_url('../../images/logo.svg', __FILE__)
            );
            
            echo $autoToolBox->generateHTML();
        }
        
        /**
         * Render tab setting - Already inherited from parent class AIautotool_autocreatetags
         * But we override to ensure it works correctly
         */
        public function render_tab_setting() {
            if ($this->active == 'true') {
                echo '<button href="#tool-autocreatetag" class="nav-tab sotab"><i class="fa-solid fa-tags"></i> ' . esc_html__('Auto Tags', 'ai-auto-tool') . '</button>';
            }
        }
        
        /**
         * Render settings page - Already inherited from parent class AIautotool_autocreatetags
         * This method is already implemented in parent class, no need to override
         */
    }
}
